Mercurial > mm7
annotate Render.cpp @ 1038:39f42990698f
Cleanings
author | Nomad |
---|---|
date | Thu, 23 May 2013 03:29:29 +0200 |
parents | c45d51b3f4f4 |
children | 48168499f52e |
rev | line source |
---|---|
140 | 1 #include <assert.h> |
2 | |
1016 | 3 #include "VideoPlayer.h" |
4 #include "Sprites.h" | |
5 #include "Mouse.h" | |
6 #include "GammaControl.h" | |
7 #include "stru6.h" | |
8 | |
9 #include "DecalBuilder.h" | |
10 #include "ParticleEngine.h" | |
0 | 11 #include "Render.h" |
12 #include "OutdoorCamera.h" | |
13 #include "IndoorCamera.h" | |
14 #include "Outdoor.h" | |
15 #include "Party.h" | |
16 #include "LOD.h" | |
17 #include "Viewport.h" | |
18 #include "Math.h" | |
19 #include "PaletteManager.h" | |
20 #include "Time.h" | |
21 #include "Game.h" | |
22 #include "LightmapBuilder.h" | |
23 #include "stru220.h" | |
24 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
25 #include "SpriteObject.h" |
0 | 26 #include "DecorationList.h" |
27 #include "Allocator.h" | |
28 #include "OSInfo.h" | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
29 #include "Actor.h" |
0 | 30 #include "Log.h" |
179 | 31 #include "TileFrameTable.h" |
189 | 32 #include "texts.h" |
0 | 33 #include "mm7_data.h" |
860 | 34 #include "MM7.h" |
0 | 35 |
36 #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | |
37 #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | |
38 | |
39 struct IDirectDrawClipper *pDDrawClipper; | |
40 struct Render *pRenderer; // idb | |
67 | 41 struct RenderVertexD3D3 pVertices[50]; |
0 | 42 int uNumDecorationsDrawnThisFrame; // weak |
43 RenderBillboard pBillboardRenderList[500]; | |
44 unsigned int uNumBillboardsToDraw; | |
45 int uNumSpritesDrawnThisFrame; // weak | |
46 | |
47 RenderVertexSoft array_507D30[50]; | |
48 RenderVertexSoft array_508690[50]; | |
49 RenderVertexSoft array_508FF0[50]; | |
50 RenderVertexSoft array_509950[50]; | |
51 RenderVertexSoft array_50A2B0[50]; | |
52 RenderVertexSoft array_50AC10[50]; | |
53 | |
54 RenderVertexSoft array_73D150[20]; | |
55 | |
186 | 56 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 57 |
58 RenderVertexSoft *ptr_801A04; | |
59 RenderVertexSoft *ptr_801A08; | |
60 | |
61 RenderVertexSoft pVerticesSR_801A10[384]; | |
62 RenderVertexSoft pVerticesSR_806210[384]; | |
63 | |
64 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
65 | |
66 /* 384 */ | |
67 #pragma pack(push, 1) | |
68 struct PCXHeader_1 | |
69 { | |
70 char manufacturer; | |
71 char version; | |
72 char encoding; | |
73 char bpp; | |
74 __int16 left; | |
75 __int16 up; | |
76 __int16 right; | |
77 __int16 bottom; | |
78 __int16 hdpi; | |
79 __int16 vdpi; | |
80 }; | |
81 #pragma pack(pop) | |
82 | |
83 /* 385 */ | |
84 #pragma pack(push, 1) | |
85 struct PCXHeader_2 | |
86 { | |
87 char reserved; | |
88 char planes; | |
89 __int16 pitch; | |
90 __int16 palette_info; | |
91 }; | |
92 #pragma pack(pop) | |
93 | |
94 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
95 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
96 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
97 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
98 | |
99 //----- (0049E79F) -------------------------------------------------------- | |
100 bool __cdecl CheckTextureStages() | |
101 { | |
102 bool v0; // edi@1 | |
103 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
104 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
105 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
106 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
107 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
108 | |
109 v0 = false; | |
110 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); | |
111 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
112 | |
113 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
186 | 114 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 115 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u)); |
116 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
117 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
118 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
119 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u)); | |
120 | |
121 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
186 | 122 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
0 | 123 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u)); |
124 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u)); | |
125 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u)); | |
126 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u)); | |
127 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u)); | |
128 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u)); | |
129 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u)); | |
130 | |
131 if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
132 v0 = true; | |
133 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); | |
134 pTexture1->Release(); | |
135 pTexture2->Release(); | |
136 pSurface1->Release(); | |
137 pSurface2->Release(); | |
138 return v0; | |
139 } | |
140 | |
141 //----- (00440CB8) -------------------------------------------------------- | |
142 void Render::DrawBillboardList_BLV() | |
143 { | |
144 __int16 v2; // ax@3 | |
145 int v5; // eax@11 | |
146 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
147 | |
148 soft_billboard.uParentBillboardID = -1; | |
149 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; | |
150 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
151 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
152 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
153 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
154 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
155 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
156 | |
617 | 157 pOutdoorCamera->uNumBillboards = ::uNumBillboardsToDraw; |
158 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) | |
0 | 159 { |
160 auto p = pBillboardRenderList + i; | |
161 | |
162 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
163 soft_billboard.uParentBillboardID = i; | |
164 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
165 soft_billboard._screenspace_x_scaler_packedfloat = p->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
166 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 167 soft_billboard.sZValue = p->sZValue; |
168 soft_billboard.uFlags = p->field_1E; | |
169 soft_billboard.uTintColor = p->uTintColor; | |
170 v2 = p->uHwSpriteID; | |
171 if ( v2 != -1 ) | |
172 { | |
173 if ( pRenderer->pRenderD3D ) | |
657 | 174 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 175 else |
176 { | |
657 | 177 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 178 if (p->field_1E & 0x0100) |
179 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
180 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
181 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
182 v5 = p->uHwSpriteID; | |
183 if ( v5 >= 0 ) | |
733 | 184 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 185 } |
186 } | |
187 } | |
188 } | |
189 | |
190 //----- (004A16A5) -------------------------------------------------------- | |
191 bool __cdecl AreRenderSurfacesOk() | |
192 { | |
193 char v0; // zf@4 | |
194 bool result; // eax@8 | |
195 | |
196 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
197 { | |
198 if ( !pRenderer->pBackBuffer4 ) | |
199 goto LABEL_9; | |
200 v0 = pRenderer->pFrontBuffer4 == 0; | |
201 } | |
202 else | |
203 { | |
204 if ( !pRenderer->pBackBuffer2 ) | |
205 goto LABEL_9; | |
206 v0 = pRenderer->pFrontBuffer2 == 0; | |
207 } | |
208 if ( !v0 ) | |
209 { | |
210 LOBYTE(result) = 1; | |
211 return result; | |
212 } | |
213 LABEL_9: | |
214 LOBYTE(result) = 0; | |
215 return result; | |
216 } | |
217 | |
218 //----- (00487389) -------------------------------------------------------- | |
973 | 219 void Render::ExecOutdoorDrawSW() |
0 | 220 { |
221 unsigned __int16 *v0; // ebx@1 | |
222 unsigned int v1; // esi@1 | |
223 stru148 *v2; // eax@1 | |
224 Span *v3; // edi@6 | |
225 stru148 *v4; // esi@9 | |
226 Texture *v5; // ebp@10 | |
227 int v6; // esi@16 | |
228 unsigned int v7; // edx@16 | |
229 char *v8; // ecx@17 | |
230 unsigned int v9; // edi@22 | |
231 int v10; // eax@26 | |
232 int v11; // eax@27 | |
233 unsigned int v12; // ebp@32 | |
234 Span *v13; // esi@33 | |
235 int v14; // ecx@37 | |
236 int v15; // eax@40 | |
237 Texture *v16; // ebp@51 | |
973 | 238 //unsigned int v17; // eax@51 |
0 | 239 int v18; // eax@54 |
240 char v19; // al@56 | |
241 unsigned int v20; // eax@57 | |
242 int v21; // ecx@57 | |
243 unsigned int v22; // eax@57 | |
244 stru149 *v23; // eax@65 | |
245 int v24; // eax@67 | |
246 ODMFace *v25; // eax@78 | |
247 signed int v26; // edx@79 | |
248 signed int v27; // ecx@79 | |
249 unsigned int v28; // eax@106 | |
250 unsigned int v29; // ebp@117 | |
251 Span *v30; // esi@118 | |
252 unsigned int v31; // ST04_4@124 | |
253 int v33; // [sp+18h] [bp-44h]@80 | |
254 signed int v34; // [sp+1Ch] [bp-40h]@3 | |
255 signed int v35; // [sp+20h] [bp-3Ch]@79 | |
256 Span **v36; // [sp+24h] [bp-38h]@4 | |
257 unsigned int v37; // [sp+28h] [bp-34h]@1 | |
258 unsigned __int16 *a1; // [sp+2Ch] [bp-30h]@1 | |
259 int a1a; // [sp+2Ch] [bp-30h]@26 | |
260 unsigned int a1b; // [sp+2Ch] [bp-30h]@116 | |
261 char v41; // [sp+30h] [bp-2Ch]@57 | |
262 | |
263 v0 = pRenderer->pTargetSurface; | |
264 v1 = pOutdoorCamera->numStru148s; | |
265 a1 = pRenderer->pTargetSurface; | |
266 v2 = array_77EC08; | |
267 v37 = pOutdoorCamera->numStru148s; | |
268 if ( !(pParty->uFlags & 2) ) | |
269 { | |
270 v1 = uNumElementsIn80AA28; | |
271 v2 = ptr_80AA28[0]; | |
272 v37 = uNumElementsIn80AA28; | |
273 } | |
274 v34 = 0; | |
275 if ( (signed int)v1 > 0 ) | |
276 { | |
277 v36 = &v2->prolly_head; | |
278 do | |
279 { | |
280 if ( pParty->uFlags & 2 ) | |
281 v3 = *v36; | |
282 else | |
283 v3 = ptr_80AA28[v34]->prolly_head; | |
284 if ( v3 ) | |
285 { | |
286 v4 = v3->pParent; | |
287 if ( v4 ) | |
288 { | |
289 v5 = v4->pTexture; | |
290 if ( v5 ) | |
291 { | |
693 | 292 if ( v3->field_8 >= (signed int)pViewport->uViewportTL_X || v3->field_C != pViewport->uViewportTL_X ) |
0 | 293 { |
294 LOBYTE(v4->field_32) |= 2u; | |
295 v14 = *(int *)&v4->flags; | |
296 if ( v14 & 0x10 && v4->field_59 != 5 ) | |
297 { | |
638 | 298 dword_80AA20 = (v4->terrain_grid_z - 64) << 25; |
0 | 299 dword_80AA1C = dword_80AA20 + 0x1FF0000; |
638 | 300 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 301 dword_80AA18 = dword_80AA14 - 0x1FF0000; |
302 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 303 v4->terrain_grid_z, |
304 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 305 if ( *(int *)&v4->flags & 2 || (v15 = *(int *)&v4->flags, BYTE1(v15) & 1) ) |
306 { | |
307 if ( *(int *)&v4->flags & 2 ) | |
308 { | |
309 while ( 1 ) | |
310 { | |
311 if ( pOutdoorCamera->outdoor_no_wavy_water ) | |
312 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
313 else | |
314 sr_sub_485407_prolly_odm_water_wavy(v3); | |
315 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
316 if ( v4->prolly_tail == v3 ) | |
317 break; | |
318 v3 = v3->pNext; | |
319 } | |
320 } | |
321 else | |
322 { | |
323 while ( 1 ) | |
324 { | |
325 v16 = v4->pTexture; | |
973 | 326 v4->pTexture = pBitmaps_LOD->LoadTexturePtr("wtrtyl"); |
0 | 327 if ( pOutdoorCamera->outdoor_no_wavy_water ) |
328 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
329 else | |
330 sr_sub_485407_prolly_odm_water_wavy(v3); | |
638 | 331 v18 = v4->terrain_grid_z - 64; |
0 | 332 v4->pTexture = v16; |
333 dword_80AA20 = v18 << 25; | |
334 dword_80AA1C = (v18 << 25) + 0x1FF0000; | |
638 | 335 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 336 dword_80AA18 = dword_80AA14 - 0x1FF0000; |
337 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 338 v4->terrain_grid_z, |
339 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 340 sr_sub_484442(v3); |
341 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
342 if ( v4->prolly_tail == v3 ) | |
343 break; | |
344 v3 = v3->pNext; | |
345 } | |
346 } | |
347 } | |
348 else | |
349 { | |
350 while ( sr_sub_48408A_prolly_odm_water_no_waves(v3) ) | |
351 { | |
352 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
353 if ( v4->prolly_tail == v3 ) | |
354 break; | |
355 v3 = v3->pNext; | |
356 } | |
357 } | |
358 } | |
359 else | |
360 { | |
361 v19 = v4->field_59; | |
362 if ( v19 != 5 ) | |
363 { | |
364 if ( v14 & 2 ) | |
365 { | |
366 while ( 1 ) | |
367 { | |
368 v28 = pBitmaps_LOD->LoadTexture("wtrtyla"); | |
369 v4->pTexture = (Texture *)(v28 != -1 ? &pBitmaps_LOD->pTextures[v28] : 0); | |
370 if ( !sr_sub_4847EB(v3) ) | |
371 break; | |
372 v4->pTexture = v5; | |
373 if ( !sr_sub_484442(v3) ) | |
374 break; | |
375 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
376 if ( v4->prolly_tail == v3 ) | |
377 break; | |
378 v3 = v3->pNext; | |
379 v5 = v4->pTexture; | |
380 } | |
381 } | |
382 else | |
383 { | |
384 if ( v19 == 1 ) | |
385 { | |
638 | 386 dword_80AA20 = (v4->terrain_grid_z - 64) << 25; |
0 | 387 dword_80AA1C = dword_80AA20 + 33488896; |
638 | 388 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 389 dword_80AA18 = dword_80AA14 - 33488896; |
390 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 391 v4->terrain_grid_z, |
392 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 393 while ( 1 ) |
394 { | |
395 if ( !sr_sub_4847EB(v3) ) | |
396 sr_sub_48585C_mb_DrawSpan(v3, &pRenderer->pTargetSurface[v3->field_8 + 640 * v3->field_A], 0); | |
397 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
398 if ( v4->prolly_tail == v3 ) | |
399 break; | |
400 v3 = v3->pNext; | |
401 } | |
402 } | |
403 } | |
404 goto LABEL_14; | |
405 } | |
406 v4->ptr_38 = (stru149 *)&v41; | |
407 v4->_479295(); | |
408 v20 = GetTickCount(); | |
409 v21 = *(int *)&v4->flags; | |
410 v22 = v20 >> 3; | |
411 if ( BYTE1(v21) & 4 ) | |
412 { | |
413 v4->sTextureDeltaV -= v22 & v4->pTexture->uHeightMinus1; | |
414 } | |
415 else | |
416 { | |
417 if ( BYTE1(v21) & 8 ) | |
418 v4->sTextureDeltaV += v22 & v4->pTexture->uHeightMinus1; | |
419 } | |
420 if ( BYTE1(v21) & 0x10 ) | |
421 { | |
422 v4->sTextureDeltaU -= v22 & v4->pTexture->uWidthMinus1; | |
423 } | |
424 else | |
425 { | |
426 if ( BYTE1(v21) & 0x20 ) | |
427 v4->sTextureDeltaU += v22 & v4->pTexture->uWidthMinus1; | |
428 } | |
429 v23 = v4->ptr_38; | |
430 v4->field_52 = 32; | |
431 v4->field_5A = 5; | |
432 if ( (double)abs(v23->field_C) > 52428.8 ) | |
433 { | |
434 v4->field_52 = 8; | |
435 v4->field_5A = 3; | |
436 } | |
437 v24 = *(int *)&v4->flags; | |
438 if ( !(v24 & 0x10000) ) | |
439 { | |
440 if ( !(v24 & 2) ) | |
441 { | |
442 v25 = v4->pODMFace; | |
443 if ( v25->uPolygonType == 1 ) | |
444 { | |
445 v26 = v25->pTextureUIDs[0]; | |
446 dword_80AA1C = v26; | |
447 dword_80AA20 = v26; | |
448 v27 = v25->pTextureVIDs[0]; | |
449 dword_80AA14 = v27; | |
450 dword_80AA18 = v27; | |
451 v35 = 1; | |
452 if ( v25->uNumVertices > 1u ) | |
453 { | |
454 v33 = (int)&v25->pTextureVIDs[1]; | |
455 do | |
456 { | |
457 if ( dword_80AA20 > *(short *)(v33 - 40) ) | |
458 dword_80AA20 = *(short *)(v33 - 40); | |
459 if ( v26 < *(short *)(v33 - 40) ) | |
460 { | |
461 v26 = *(short *)(v33 - 40); | |
462 dword_80AA1C = *(short *)(v33 - 40); | |
463 } | |
464 if ( dword_80AA18 > *(short *)v33 ) | |
465 dword_80AA18 = *(short *)v33; | |
466 if ( v27 < *(short *)v33 ) | |
467 { | |
468 v27 = *(short *)v33; | |
469 dword_80AA14 = *(short *)v33; | |
470 } | |
471 ++v35; | |
472 v33 += 2; | |
473 } | |
474 while ( v35 < v25->uNumVertices ); | |
475 v0 = a1; | |
476 } | |
477 dword_80AA20 = (dword_80AA20 + v4->sTextureDeltaU) << 16; | |
478 dword_80AA1C = ((v26 + v4->sTextureDeltaU) << 16) - 65536; | |
479 dword_80AA18 = (dword_80AA18 + v4->sTextureDeltaV) << 16; | |
480 dword_80AA14 = ((v27 + v4->sTextureDeltaV) << 16) - 65536; | |
481 } | |
482 while ( 1 ) | |
483 { | |
484 if ( !sr_sub_482E07(v3, v0) ) | |
485 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
486 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
487 if ( v4->prolly_tail == v3 ) | |
488 break; | |
489 v3 = v3->pNext; | |
490 } | |
491 goto LABEL_14; | |
492 } | |
493 while ( 1 ) | |
494 { | |
495 LABEL_74: | |
496 if ( !sr_sub_4839BD(v3, v0) ) | |
497 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
498 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
499 if ( v4->prolly_tail == v3 ) | |
500 break; | |
501 v3 = v3->pNext; | |
502 } | |
503 goto LABEL_14; | |
504 } | |
505 if ( v24 & 2 ) | |
506 goto LABEL_74; | |
507 while ( 1 ) | |
508 { | |
509 if ( !sr_sub_482A94(v3) ) | |
510 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
511 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
512 if ( v4->prolly_tail == v3 ) | |
513 break; | |
514 v3 = v3->pNext; | |
515 } | |
516 } | |
517 } | |
518 else | |
519 { | |
520 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
521 } | |
522 } | |
523 } | |
524 } | |
525 LABEL_14: | |
526 ++v34; | |
527 LOWORD(v2) = v34; | |
528 v36 += 67; | |
529 } | |
530 while ( v34 < (signed int)v37 ); | |
531 } | |
532 if ( pParty->uFlags & 2 ) | |
533 { | |
534 v6 = pOutdoorCamera->numStru148s; | |
535 v7 = 0; | |
536 uNumElementsIn80AA28 = 0; | |
537 if ( pOutdoorCamera->numStru148s > 0 ) | |
538 { | |
539 v8 = (char *)&array_77EC08[0].flags; | |
540 do | |
541 { | |
542 v2 = *(stru148 **)v8; | |
543 if ( (unsigned int)v2 & 0x20000 ) | |
544 { | |
545 ++v7; | |
546 *(int *)v8 = (unsigned int)v2 & 0xFFFDFFFF; | |
547 LOWORD(v2) = (short)v8 - 48; | |
548 *(&uNumElementsIn80AA28 + v7) = (unsigned int)(v8 - 48); | |
549 } | |
550 v8 += 268; | |
551 --v6; | |
552 } | |
553 while ( v6 ); | |
554 uNumElementsIn80AA28 = v7; | |
555 } | |
556 } | |
557 v9 = pOutdoorCamera->uNumSpans; | |
558 unnamed_6BE060[0] = pOutdoorCamera->uNumSpans; | |
973 | 559 if (pOutdoorCamera->numStru148s >= 1999) |
560 return; | |
561 | |
562 array_77EC08[1999]._48607B(&stru_8019C8); | |
563 array_77EC08[1999].ptr_38->_48694B(); | |
564 | |
565 if (pOutdoor->uMainTile_BitmapID == -1) | |
566 { | |
567 array_77EC08[1999].pTexture = nullptr; | |
568 return; | |
569 } | |
570 else | |
571 array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uMainTile_BitmapID); | |
638 | 572 array_77EC08[1999].dimming_level = 23 - (-20 * pOutdoor->vSunlight.z >> 16); |
573 if ( array_77EC08[1999].dimming_level > 20 ) | |
574 array_77EC08[1999].dimming_level = 20; | |
323 | 575 v10 = stru_5C6E00->Sin(pIndoorCamera->sRotationX); |
0 | 576 array_77EC08[1999].v_18.y = 0; |
577 array_77EC08[1999].v_18.x = v10; | |
323 | 578 array_77EC08[1999].v_18.z = stru_5C6E00->Cos(pIndoorCamera->sRotationX); |
0 | 579 array_77EC08[1999].field_24 = 2048 - (pIndoorCamera->pos.z << 16); |
580 a1a = (signed __int64)((double)(pIndoorCamera->pos.z * pOutdoorCamera->int_fov_rad) | |
581 / ((double)pOutdoorCamera->int_fov_rad + 8192.0) | |
582 + (double)pViewport->uScreenCenterY); | |
583 cos((double)pIndoorCamera->sRotationX * 0.0030664064); | |
584 sin((double)pIndoorCamera->sRotationX * 0.0030664064); | |
585 array_77EC08[1999]._48607B(&stru_8019C8); | |
586 array_77EC08[1999].ptr_38->_48694B(); | |
973 | 587 |
588 if (pOutdoor->uSky_TextureID == -1) | |
589 { | |
590 array_77EC08[1999].pTexture = nullptr; | |
591 return; | |
592 } | |
593 else | |
594 array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uSky_TextureID); | |
638 | 595 array_77EC08[1999].dimming_level = 0; |
323 | 596 v11 = stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16); |
0 | 597 array_77EC08[1999].v_18.y = 0; |
598 array_77EC08[1999].v_18.x = -v11; | |
323 | 599 array_77EC08[1999].v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16); |
0 | 600 LOWORD(v2) = 224 * LOWORD(pMiscTimer->uTotalGameTimeElapsed); |
601 array_77EC08[1999].field_24 = 0x2000000u; | |
602 array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
603 array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
767 | 604 if ( day_attrib & DAY_ATTRIB_FOG |
0 | 605 && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5) |
606 && pParty->uCurrentHour < 0x15 | |
607 || bUnderwater ) | |
608 { | |
609 v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1); | |
610 a1b = (unsigned int)v2; | |
611 if ( (signed int)v9 <= 0 ) | |
973 | 612 return; |
0 | 613 v29 = v9; |
614 while ( 1 ) | |
615 { | |
616 v30 = &pSpans[v29 - 1]; | |
617 v2 = (stru148 *)v30->field_E; | |
618 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
619 { | |
693 | 620 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
621 if ( v30->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 622 goto LABEL_124; |
693 | 623 if ( v30->field_C == pViewport->uViewportTL_X ) |
0 | 624 { |
625 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
626 } | |
627 else | |
628 { | |
693 | 629 v30->field_8 = LOWORD(pViewport->uViewportTL_X); |
630 v30->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 631 if ( v30->field_C >= 0 ) |
632 { | |
633 LABEL_124: | |
634 v31 = v30->field_C; | |
635 v30->pParent = &array_77EC08[1999]; | |
636 fill_pixels_fast( | |
637 a1b, | |
638 &pRenderer->pTargetSurface[v30->field_8 + pRenderer->uTargetSurfacePitch * v30->field_A], | |
639 v31); | |
640 j_memset32(-65536, &pRenderer->pActiveZBuffer[v30->field_8 + 640 * v30->field_A], v30->field_C); | |
641 goto LABEL_125; | |
642 } | |
643 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
644 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
645 } | |
646 } | |
647 LABEL_125: | |
648 --v29; | |
649 --v9; | |
650 if ( !v9 ) | |
973 | 651 return; |
0 | 652 } |
653 } | |
654 if ( (signed int)v9 > 0 ) | |
655 { | |
656 v12 = v9; | |
657 do | |
658 { | |
659 v13 = &pSpans[v12 - 1]; | |
660 v2 = (stru148 *)v13->field_E; | |
661 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
662 { | |
693 | 663 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
664 if ( v13->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 665 goto LABEL_109; |
693 | 666 if ( v13->field_C != pViewport->uViewportTL_X ) |
667 { | |
668 v13->field_8 = LOWORD(pViewport->uViewportTL_X); | |
669 v13->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 670 if ( v13->field_C >= 0 ) |
671 { | |
672 LABEL_109: | |
673 if ( pOutdoorCamera->bNoSky ) | |
674 { | |
675 const_1_0(); | |
676 } | |
677 else | |
678 { | |
679 v13->pParent = &array_77EC08[1999]; | |
680 if ( !Render::DrawSkySW(v13, &array_77EC08[1999], a1a) ) | |
681 j_memset32(-65536, &pRenderer->pActiveZBuffer[v13->field_8 + 640 * v13->field_A], v13->field_C); | |
682 } | |
683 } | |
684 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
685 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
686 goto LABEL_114; | |
687 } | |
688 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
689 } | |
690 LABEL_114: | |
691 --v12; | |
692 --v9; | |
693 } | |
694 while ( v9 ); | |
695 } | |
696 } | |
697 | |
698 //----- (00485044) -------------------------------------------------------- | |
699 int Render::DrawSkySW(Span *a1, stru148 *a2, int a3) | |
700 { | |
701 stru148 *v3; // esi@1 | |
702 Span *v4; // edi@1 | |
703 float v5; // ST2C_4@1 | |
704 signed int result; // eax@2 | |
705 int v7; // ST40_4@3 | |
706 stru149 *v8; // eax@3 | |
707 int v9; // ebx@3 | |
708 int v10; // ecx@3 | |
709 int v11; // edx@3 | |
710 int v12; // eax@3 | |
711 int v13; // ST28_4@5 | |
712 int v14; // eax@5 | |
713 signed __int64 v15; // qtt@11 | |
714 int v16; // ST28_4@11 | |
715 int v17; // eax@11 | |
716 signed int v18; // ecx@11 | |
717 int v19; // ST40_4@11 | |
718 int v20; // ST3C_4@11 | |
719 int v21; // ST30_4@11 | |
720 void *v22; // eax@11 | |
721 Texture *v23; // esi@11 | |
722 int v24; // ecx@11 | |
723 unsigned int v25; // esi@11 | |
724 int v26; // edi@11 | |
725 unsigned __int16 *v27; // eax@11 | |
726 int *v28; // ebx@12 | |
727 int v29; // edx@13 | |
728 unsigned __int16 v30; // cx@13 | |
729 int v31; // edx@14 | |
730 unsigned __int16 v32; // cx@14 | |
731 unsigned __int8 v33; // sf@15 | |
732 unsigned __int8 v34; // of@15 | |
733 double v35; // [sp+14h] [bp-38h]@1 | |
734 int v36; // [sp+18h] [bp-34h]@3 | |
735 signed int v37; // [sp+18h] [bp-34h]@11 | |
736 int v38; // [sp+1Ch] [bp-30h]@3 | |
737 signed int v39; // [sp+1Ch] [bp-30h]@11 | |
738 int v40; // [sp+20h] [bp-2Ch]@3 | |
739 void *v41; // [sp+20h] [bp-2Ch]@11 | |
740 int v42; // [sp+24h] [bp-28h]@3 | |
741 unsigned __int8 *v43; // [sp+24h] [bp-28h]@11 | |
742 int v44; // [sp+28h] [bp-24h]@11 | |
743 int v45; // [sp+2Ch] [bp-20h]@3 | |
744 signed int v46; // [sp+30h] [bp-1Ch]@3 | |
745 __int16 v47; // [sp+30h] [bp-1Ch]@11 | |
746 signed int v48; // [sp+34h] [bp-18h]@3 | |
747 int v49; // [sp+34h] [bp-18h]@11 | |
748 int v50; // [sp+38h] [bp-14h]@3 | |
749 unsigned __int16 *v51; // [sp+38h] [bp-14h]@11 | |
750 int v52; // [sp+3Ch] [bp-10h]@4 | |
751 int a1a; // [sp+40h] [bp-Ch]@3 | |
752 int v54; // [sp+44h] [bp-8h]@3 | |
753 int v55; // [sp+48h] [bp-4h]@3 | |
754 int v56; // [sp+54h] [bp+8h]@11 | |
755 int *v57; // [sp+54h] [bp+8h]@11 | |
756 | |
757 v3 = a2; | |
758 v4 = a1; | |
693 | 759 v5 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5 / tan(0.6457717418670654) + 0.5; |
0 | 760 v35 = v5 + 6.7553994e15; |
761 if ( LODWORD(v35) ) | |
762 { | |
763 v55 = 65536 / SLODWORD(v35); | |
764 v7 = 65536 / SLODWORD(v35) * (a3 - v4->field_A); | |
765 v8 = v3->ptr_38; | |
766 v42 = ((unsigned __int64)(v3->ptr_38->field_14 * (signed __int64)v7) >> 16) + v8->field_C; | |
767 v40 = ((unsigned __int64)(v8->field_20 * (signed __int64)v7) >> 16) + v3->ptr_38->field_18; | |
768 v38 = pOutdoorCamera->camera_rotation_y_int_sine; | |
769 HIDWORD(v35) = pOutdoorCamera->camera_rotation_y_int_cosine; | |
770 v45 = v4->field_C; | |
771 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v7) >> 16) + v3->v_18.x; | |
772 v10 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
773 v48 = 0; | |
774 v50 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
775 v46 = -v3->field_24; | |
776 v11 = v4->field_A - 1; | |
777 v54 = v11; | |
778 v12 = 65536 / SLODWORD(v35) * (a3 - v11); | |
779 a1a = 65536 / SLODWORD(v35) * (a3 - v11); | |
780 while ( 1 ) | |
781 { | |
782 v52 = v9; | |
783 if ( v9 ) | |
784 { | |
785 v13 = abs(v46 >> 14); | |
786 v14 = abs(v9); | |
787 v11 = v54; | |
788 v10 = v50; | |
789 if ( v13 <= v14 ) | |
790 break; | |
791 v12 = a1a; | |
792 } | |
693 | 793 if ( v11 <= (signed int)pViewport->uViewportTL_Y ) |
0 | 794 break; |
795 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x; | |
796 --v54; | |
797 a1a += v55; | |
798 v12 = a1a; | |
799 v11 = v54; | |
800 v48 = 1; | |
801 } | |
802 if ( v48 ) | |
803 v52 = ((unsigned __int64)(v3->v_18.z * (signed __int64)(v55 * (a3 + (signed int)v4->field_A - 2 * v11))) >> 16) | |
804 + v3->v_18.x; | |
805 LODWORD(v15) = v46 << 16; | |
806 HIDWORD(v15) = v46 >> 16; | |
807 v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16); | |
808 v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16); | |
809 v18 = v15 / v52; | |
710 | 810 v43 = v3->pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 811 v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3); |
812 v56 = v15 / v52; | |
813 v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3); | |
814 v21 = (unsigned __int64)(v55 * (signed __int64)v56) >> 16; | |
815 v39 = (signed int)((unsigned __int64)(v21 * (signed __int64)v38) >> 16) >> 3; | |
816 v37 = (signed int)((unsigned __int64)(v21 * (signed __int64)v36) >> 16) >> 3; | |
817 v22 = sr_sub_47C178(v18, v3, 0, 1); | |
818 v23 = v3->pTexture; | |
819 v41 = v22; | |
820 v47 = 16 - v23->uWidthLn2; | |
821 v44 = v23->uTextureWidth - 1; | |
822 v49 = (v23->uTextureHeight << 16) - 65536; | |
823 v24 = v4->field_8; | |
824 v51 = &pRenderer->pTargetSurface[v24 + pRenderer->uTargetSurfacePitch * v4->field_A]; | |
825 v57 = &pRenderer->pActiveZBuffer[v24 + 640 * v4->field_A]; | |
826 v25 = v19; | |
827 v26 = v20; | |
828 v27 = v51; | |
829 if ( !(v45 & 1) ) | |
830 goto LABEL_15; | |
831 --v45; | |
832 v27 = v51 - 1; | |
833 v28 = v57; | |
834 ++v57; | |
835 while ( 1 ) | |
836 { | |
837 *v28 = -65536; | |
838 v31 = v44 & (v25 >> 16); | |
839 v27 += 2; | |
840 v25 += v39; | |
841 v32 = *((short *)v41 + *(&v43[v31] + ((v49 & (unsigned int)v26) >> v47))); | |
842 v26 += v37; | |
843 *(v27 - 1) = v32; | |
844 LABEL_15: | |
845 v34 = __OFSUB__(v45, 2); | |
846 v33 = v45 - 2 < 0; | |
847 v45 -= 2; | |
848 if ( v33 ^ v34 ) | |
849 break; | |
850 v29 = v44 & (v25 >> 16); | |
851 v25 += v39; | |
852 v30 = *((short *)v41 + *(&v43[v29] + ((v49 & (unsigned int)v26) >> v47))); | |
853 v26 += v37; | |
854 v28 = v57; | |
855 *v27 = v30; | |
856 v57 += 2; | |
857 v28[1] = -65536; | |
858 } | |
859 result = 1; | |
860 } | |
861 else | |
862 { | |
863 result = 0; | |
864 } | |
865 return result; | |
866 } | |
867 | |
868 //----- (0047F5C6) -------------------------------------------------------- | |
869 float Render::DrawBezierTerrain() | |
870 { | |
871 //__debugbreak();Ritor1: it's temporarily | |
872 //return 0; | |
873 | |
86 | 874 unsigned int pDirectionIndicator1; // ebx@1 |
875 unsigned int pDirectionIndicator2; // edi@1 | |
0 | 876 unsigned int v2; // eax@1 |
877 int v3; // eax@3 | |
878 int v4; // edi@3 | |
879 int v5; // ebx@3 | |
880 int v6; // esi@3 | |
881 unsigned int v7; // eax@3 | |
882 int v8; // eax@4 | |
883 unsigned int v9; // eax@6 | |
884 int v10; // eax@7 | |
985 | 885 //int v11; // ebx@9 |
886 //int v12; // edi@9 | |
0 | 887 int v13; // eax@21 |
888 int v14; // eax@31 | |
889 int v15; // edi@33 | |
67 | 890 int v16; // eax@34 |
0 | 891 int v17; // edx@34 |
892 int v18; // ebx@34 | |
893 int v19; // eax@36 | |
894 int v20; // eax@39 | |
895 int v21; // ecx@43 | |
985 | 896 //char v22; // zf@44 |
0 | 897 int v23; // ecx@47 |
990 | 898 //int v24; // edi@52 |
67 | 899 int v25; // eax@54 |
0 | 900 int v26; // ecx@54 |
901 int v27; // eax@56 | |
902 int v28; // edx@60 | |
903 int v29; // ecx@61 | |
904 int v30; // ecx@64 | |
905 int v31; // ecx@68 | |
906 int v32; // eax@70 | |
907 int v33; // ecx@71 | |
908 int v34; // eax@73 | |
909 int v35; // ecx@77 | |
910 int v36; // ecx@81 | |
911 int v37; // ecx@86 | |
67 | 912 int v38; // eax@88 |
913 int v39; // ecx@88 | |
0 | 914 int v40; // eax@90 |
915 int v41; // edx@94 | |
916 int v42; // ecx@95 | |
917 int v43; // ecx@98 | |
918 int v44; // ecx@102 | |
919 int v45; // eax@104 | |
920 int v46; // eax@107 | |
921 int v47; // ecx@111 | |
922 int v48; // ecx@115 | |
923 int v49; // edi@120 | |
67 | 924 int v50; // eax@122 |
0 | 925 int v51; // ecx@122 |
926 int v52; // eax@124 | |
927 int v53; // edx@128 | |
928 int v54; // ecx@129 | |
929 int v55; // ecx@132 | |
930 int v56; // eax@139 | |
931 int v57; // ecx@140 | |
932 int v58; // eax@142 | |
933 int v59; // ecx@146 | |
934 int v60; // ecx@147 | |
935 int v61; // ecx@150 | |
936 int v62; // ecx@155 | |
67 | 937 int v63; // eax@157 |
938 int v64; // ecx@157 | |
0 | 939 int v65; // eax@159 |
940 int v66; // edx@163 | |
941 int v67; // ecx@164 | |
942 int v68; // ecx@167 | |
990 | 943 //int v69; // eax@173 |
0 | 944 int v70; // edi@178 |
985 | 945 //int v71; // eax@178 |
946 //int v72; // ecx@178 | |
947 //int x; // ebx@180 | |
948 //int v74; // eax@182 | |
0 | 949 int v75; // eax@184 |
67 | 950 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 |
86 | 951 int uStartZ; // ecx@184 |
0 | 952 int v79; // ebx@185 |
953 int v127; // esi@185 | |
954 int v86; // edi@196 | |
985 | 955 //int v87; // eax@196 |
956 //int v88; // ecx@196 | |
957 //int v89; // eax@198 | |
958 //int v90; // ecx@200 | |
0 | 959 int v92; // ebx@203 |
985 | 960 //int v93; // ST08_4@204 |
0 | 961 int v97; // ST08_4@204 |
962 float result; // eax@212 | |
985 | 963 //struct |
964 //{ | |
965 int v106; // [sp+Ch] [bp-68h]@191 | |
966 int v103; // [sp+10h] [bp-64h]@190 | |
967 int v104; // [sp+12h] [bp-62h]@190 | |
968 //} v102; | |
77 | 969 int v105; // [sp+1Ch] [bp-58h]@1 |
985 | 970 int v107; // [sp+20h] [bp-54h]@3 |
86 | 971 int uEndZ; // [sp+24h] [bp-50h]@3 |
0 | 972 int v108; // [sp+28h] [bp-4Ch]@9 |
973 int v109; // [sp+2Ch] [bp-48h]@9 | |
974 int v110; // [sp+30h] [bp-44h]@9 | |
975 int v111; // [sp+34h] [bp-40h]@3 | |
976 int v112; // [sp+38h] [bp-3Ch]@6 | |
67 | 977 IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 |
0 | 978 int v114; // [sp+40h] [bp-34h]@9 |
979 int v115; // [sp+44h] [bp-30h]@9 | |
980 int v116; // [sp+48h] [bp-2Ch]@9 | |
985 | 981 //int v117; // [sp+4Ch] [bp-28h]@9 |
0 | 982 int v118; // [sp+50h] [bp-24h]@9 |
983 int v119; // [sp+54h] [bp-20h]@1 | |
984 int v120; // [sp+58h] [bp-1Ch]@1 | |
985 int i; // [sp+5Ch] [bp-18h]@1 | |
986 int v122; // [sp+60h] [bp-14h]@1 | |
987 int v123; // [sp+64h] [bp-10h]@1 | |
67 | 988 int v124; // [sp+68h] [bp-Ch]@1 |
0 | 989 int v125; // [sp+6Ch] [bp-8h]@9 |
67 | 990 int v126; // [sp+70h] [bp-4h]@9 |
991 | |
96 | 992 v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 |
86 | 993 pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 |
994 pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 | |
323 | 995 v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16; |
996 v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16; | |
67 | 997 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X |
0 | 998 v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; |
999 v2 = pOutdoorCamera->uCameraFovInDegrees + 15; | |
67 | 1000 i = v124 - pOutdoorCamera->outdoor_grid_band_3; |
0 | 1001 v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; |
67 | 1002 |
1003 if ( v2 > 90 ) | |
0 | 1004 v2 = 90; |
67 | 1005 v3 = (v2 << 11) / 720; |
86 | 1006 v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); |
1007 v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); | |
323 | 1008 v106 = stru_5C6E00->Cos(v4); |
1009 uEndZ = stru_5C6E00->Sin(v4); | |
1010 v111 = stru_5C6E00->Cos(v5); | |
1011 v6 = stru_5C6E00->Sin(v5); | |
0 | 1012 v7 = v4 & stru_5C6E00->uPiMask; |
67 | 1013 |
1014 if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) | |
0 | 1015 v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; |
1016 else | |
1017 v8 = stru_5C6E00->pTanTable[v7]; | |
1018 v112 = abs(v8); | |
1019 v9 = v5 & stru_5C6E00->uPiMask; | |
67 | 1020 if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) |
0 | 1021 v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; |
1022 else | |
1023 v10 = stru_5C6E00->pTanTable[v9]; | |
1024 v108 = abs(v10); | |
985 | 1025 //v11 = v124; |
1026 //v12 = v123; | |
0 | 1027 v114 = 0; |
1028 v115 = 0; | |
67 | 1029 pIndoorCameraD3D_4 = 0; |
0 | 1030 v125 = 0; |
67 | 1031 v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; |
0 | 1032 v126 = v124; |
1033 v118 = v123; | |
86 | 1034 v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; |
1035 uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; | |
0 | 1036 terrain_76E1C8[0] = 65535; |
985 | 1037 uint _i = 1; |
67 | 1038 v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; |
985 | 1039 uint j = 1; |
0 | 1040 terrain_76E3C8[0] = 65535; |
1041 terrain_76DDC8[0] = 65535; | |
1042 terrain_76DFC8[0] = 65535; | |
985 | 1043 for( _i = 1; _i < 128; _i++) |
67 | 1044 { |
1045 if ( v112 >= 0x10000 ) | |
1046 { | |
1047 int v1, v2; | |
1048 /*v111 = 4294967296i64 / v112; | |
0 | 1049 v114 += v111; |
1050 if ( v114 >= 65536 ) | |
1051 { | |
1052 v11 += v110; | |
1053 v114 = (unsigned __int16)v114; | |
1054 } | |
67 | 1055 v12 += v109;*/ |
0 | 1056 } |
1057 else | |
1058 { | |
985 | 1059 v124 += v110; |
0 | 1060 v115 += v112; |
67 | 1061 if ( v112 + v115 >= 65536 ) |
0 | 1062 { |
985 | 1063 v123 += v109; |
0 | 1064 v115 = (unsigned __int16)v115; |
1065 } | |
1066 } | |
985 | 1067 if ( v124 < _i || v124 > v120 || v123 < v122 || v123 > v119 ) |
0 | 1068 break; |
67 | 1069 //v13 = v116++; |
985 | 1070 terrain_76E3C8[_i] = v124; |
1071 terrain_76E1C8[_i] = v123; | |
1072 } | |
1073 | |
1074 for( j = 1; j < 128; j++ ) | |
0 | 1075 { |
1076 if ( v108 >= 65536 ) | |
1077 { | |
1078 v111 = 4294967296i64 / v108; | |
67 | 1079 v114 += v111;// |
1080 if ( v111 + v114 >= 65536 ) | |
1081 { | |
86 | 1082 v126 += uEndZ; |
67 | 1083 v114 = (unsigned __int16)v114;// |
0 | 1084 } |
1085 v118 += v106; | |
1086 } | |
1087 else | |
1088 { | |
1089 v125 += v108; | |
86 | 1090 v126 += uEndZ; |
0 | 1091 if ( v125 >= 65536 ) |
1092 { | |
1093 v118 += v106; | |
1094 v125 = (unsigned __int16)v125; | |
1095 } | |
1096 } | |
67 | 1097 //if ( v117 >= 128 ) |
1098 //break; | |
985 | 1099 if ( v126 < _i ) |
0 | 1100 break; |
67 | 1101 if ( v126 > v120 ) |
0 | 1102 break; |
1103 v14 = v118; | |
1104 if ( v118 < v122 ) | |
1105 break; | |
1106 if ( v118 > v119 ) | |
1107 break; | |
985 | 1108 terrain_76DFC8[j] = v126; |
1109 terrain_76DDC8[j] = v14; | |
67 | 1110 } |
1111 v16 = 0; | |
1112 v126 = 0; | |
985 | 1113 v17 = j - 1; |
1114 v18 = _i - 1; | |
77 | 1115 switch ( v105 ) |
0 | 1116 { |
1117 case 0: | |
1118 case 7: | |
67 | 1119 { |
985 | 1120 //v116 = terrain_76DFC8[v17]; |
1121 if ( v120 > terrain_76DFC8[v17] ) | |
0 | 1122 { |
1123 v125 = v120; | |
985 | 1124 memset32(terrain_76D9C8, v119 + 1, 4 * (v120 - terrain_76DFC8[v17] + 1)); |
0 | 1125 v19 = v120; |
1126 do | |
67 | 1127 terrain_76DBC8[v126++] = v19--; |
985 | 1128 while ( v19 >= terrain_76DFC8[v17] ); |
0 | 1129 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) |
1130 { | |
1131 do | |
67 | 1132 v20 = terrain_76DDC8[v17-- -1]; |
1133 while ( v20 == terrain_76DDC8[v17 -1] ); | |
0 | 1134 } |
1135 v16 = v126; | |
1136 --v17; | |
1137 } | |
1138 if ( v17 < 0 ) | |
1139 v17 = 0; | |
1140 v21 = terrain_76DFC8[v17]; | |
1141 while ( 1 ) | |
1142 { | |
990 | 1143 v125 = terrain_76DFC8[v17]; |
67 | 1144 if ( v21 < v124 ) |
0 | 1145 break; |
67 | 1146 terrain_76DBC8[v16] = v21; |
985 | 1147 //v22 = terrain_76DDC8[v17] == 65535; |
67 | 1148 terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; |
985 | 1149 if ( terrain_76DDC8[v17] == 65535 ) |
0 | 1150 { |
67 | 1151 terrain_76D9C8[v16] = v123 + 1; |
0 | 1152 break; |
1153 } | |
1154 if ( !v17 ) | |
1155 break; | |
67 | 1156 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) |
0 | 1157 { |
1158 do | |
67 | 1159 v23 = terrain_76DDC8[v17-- -1]; |
1160 while ( v23 == terrain_76DDC8[v17 -1] ); | |
0 | 1161 } |
1162 --v17; | |
1163 v21 = v125 - 1; | |
67 | 1164 ++v16; |
1165 } | |
1166 v16 = 0; | |
990 | 1167 //v24 = terrain_76E3C8[v18]; |
67 | 1168 v126 = 0; |
990 | 1169 if ( v120 > terrain_76E3C8[v18] ) |
0 | 1170 { |
1171 v125 = v120; | |
990 | 1172 memset32(terrain_76D5C8, v122, 4 * (v120 - terrain_76E3C8[v18] + 1)); |
0 | 1173 do |
1174 { | |
1175 v25 = v126; | |
1176 v26 = v125--; | |
67 | 1177 ++v126; |
1178 terrain_76D7C8[v25] = v26; | |
0 | 1179 } |
1180 while ( v125 >= terrain_76E3C8[v18] ); | |
67 | 1181 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1182 { |
1183 do | |
67 | 1184 v27 = terrain_76E1C8[v18-- -1]; |
1185 while ( v27 == terrain_76E1C8[v18 -1] ); | |
0 | 1186 } |
1187 v16 = v126; | |
1188 --v18; | |
1189 } | |
1190 if ( v18 < 0 ) | |
1191 v18 = 0; | |
1192 v28 = terrain_76E3C8[v18]; | |
67 | 1193 while ( v28 >= v124 ) |
0 | 1194 { |
1195 v29 = terrain_76E1C8[v18]; | |
67 | 1196 terrain_76D7C8[v16] = v28; |
1197 terrain_76D5C8[v16] = v29; | |
0 | 1198 if ( v29 == 65535 ) |
1199 { | |
1200 v31 = v123; | |
67 | 1201 terrain_76D5C8[v16] = v31; |
1202 break; | |
0 | 1203 } |
1204 if ( !v18 ) | |
1205 break; | |
67 | 1206 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1207 { |
1208 do | |
67 | 1209 v30 = terrain_76E1C8[v18-- -1]; |
1210 while ( v30 == terrain_76E1C8[v18 -1] ); | |
0 | 1211 } |
1212 --v18; | |
1213 --v28; | |
67 | 1214 ++v16; |
0 | 1215 } |
1216 break; | |
67 | 1217 } |
0 | 1218 case 1: |
1219 case 2: | |
67 | 1220 { |
985 | 1221 //v116 = terrain_76DDC8[v17]; |
1222 if ( v122 < terrain_76DDC8[v17] ) | |
0 | 1223 { |
1224 v106 = v122; | |
985 | 1225 memset32(terrain_76DBC8, v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1)); |
0 | 1226 v32 = v122; |
1227 do | |
1228 { | |
67 | 1229 v33 = v126++; |
0 | 1230 terrain_76D9C8[v33] = v32++; |
1231 } | |
985 | 1232 while ( v32 <= terrain_76DDC8[v17] ); |
67 | 1233 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1234 { |
1235 do | |
67 | 1236 v34 = terrain_76DBC8[v17-- -1]; |
1237 while ( v34 == terrain_76DBC8[v17 -1] ); | |
0 | 1238 } |
1239 v16 = v126; | |
1240 --v17; | |
1241 } | |
1242 if ( v17 < 0 ) | |
1243 v17 = 0; | |
1244 v35 = terrain_76DDC8[v17]; | |
1245 v125 = terrain_76DDC8[v17]; | |
1246 while ( v35 <= v123 ) | |
1247 { | |
985 | 1248 //v22 = terrain_76DFC8[v17] == 65535; |
67 | 1249 terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; |
1250 terrain_76D9C8[v16] = v125; | |
985 | 1251 if ( terrain_76DFC8[v17] == 65535 ) |
0 | 1252 { |
67 | 1253 terrain_76DBC8[v16] = v124 + 1; |
0 | 1254 break; |
1255 } | |
1256 if ( !v17 ) | |
1257 break; | |
67 | 1258 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1259 { |
1260 do | |
67 | 1261 v36 = terrain_76DBC8[v17-- -1]; |
1262 while ( v36 == terrain_76DBC8[v17 -1] ); | |
0 | 1263 } |
1264 --v17; | |
1265 ++v125; | |
1266 v35 = v125; | |
67 | 1267 ++v16; |
1268 } | |
1269 v16 = 0; | |
1270 v126 = 0; | |
0 | 1271 v37 = terrain_76E1C8[v18]; |
1272 if ( v122 < v37 ) | |
1273 { | |
67 | 1274 v114 = v122; |
1275 memset32(terrain_76D7C8, i, 4 * (v37 - v122 + 1)); | |
0 | 1276 do |
1277 { | |
1278 v38 = v126; | |
67 | 1279 v39 = v114; |
1280 ++v126; | |
1281 ++v114; | |
1282 terrain_76D5C8[v38] = v39; | |
1283 } | |
1284 while ( v114 <= terrain_76E1C8[v18] ); | |
1285 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1286 { |
1287 do | |
67 | 1288 v40 = terrain_76DFC8[v18-- -1]; |
1289 while ( v40 == terrain_76DFC8[v18 -1] ); | |
0 | 1290 } |
1291 v16 = v126; | |
1292 --v18; | |
1293 } | |
1294 if ( v18 < 0 ) | |
1295 v18 = 0; | |
1296 v41 = terrain_76E1C8[v18]; | |
1297 while ( v41 <= v123 ) | |
1298 { | |
1299 v42 = terrain_76E3C8[v18]; | |
67 | 1300 terrain_76D5C8[v16] = v41; |
1301 terrain_76D7C8[v16] = v42; | |
0 | 1302 if ( v42 == 65535 ) |
1303 { | |
67 | 1304 terrain_76D7C8[v16] = v124; |
1305 break; | |
0 | 1306 } |
1307 if ( !v18 ) | |
1308 break; | |
67 | 1309 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1310 { |
1311 do | |
67 | 1312 v43 = terrain_76DFC8[v18-- -1]; |
1313 while ( v43 == terrain_76DFC8[v18 -1] ); | |
0 | 1314 } |
1315 --v18; | |
1316 ++v41; | |
67 | 1317 ++v16; |
0 | 1318 } |
1319 break; | |
67 | 1320 } |
0 | 1321 case 5: |
1322 case 6: | |
67 | 1323 { |
985 | 1324 //v116 = terrain_76DDC8[v17]; |
1325 if ( v119 > terrain_76DDC8[v17] ) | |
0 | 1326 { |
1327 v106 = v119; | |
985 | 1328 memset32(terrain_76DBC8, i, 4 * (v119 - terrain_76DDC8[v17] + 1)); |
0 | 1329 v45 = v119; |
1330 do | |
67 | 1331 terrain_76D9C8[v126++] = v45--; |
985 | 1332 while ( v45 >= terrain_76DDC8[v17] ); |
67 | 1333 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1334 { |
1335 do | |
67 | 1336 v46 = terrain_76DBC8[v17-- -1]; |
1337 while ( v46 == terrain_76DBC8[v17 -1] ); | |
0 | 1338 } |
1339 v16 = v126; | |
1340 --v17; | |
1341 } | |
1342 if ( v17 < 0 ) | |
1343 v17 = 0; | |
1344 v47 = terrain_76DDC8[v17]; | |
1345 v125 = terrain_76DDC8[v17]; | |
1346 while ( v47 >= v123 ) | |
1347 { | |
985 | 1348 //v22 = terrain_76DFC8[v17] == 65535; |
67 | 1349 terrain_76DBC8[v16] = terrain_76DFC8[v17]; |
1350 terrain_76D9C8[v16] = v125; | |
985 | 1351 if ( terrain_76DFC8[v17] == 65535 ) |
0 | 1352 { |
67 | 1353 terrain_76DBC8[v16] = v124; |
0 | 1354 break; |
1355 } | |
1356 if ( !v17 ) | |
1357 break; | |
67 | 1358 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1359 { |
1360 do | |
67 | 1361 v48 = terrain_76DBC8[v17-- -1]; |
1362 while ( v48 == terrain_76DBC8[v17 -1] ); | |
0 | 1363 } |
1364 --v17; | |
1365 --v125; | |
1366 v47 = v125; | |
67 | 1367 ++v16; |
1368 } | |
1369 v16 = 0; | |
0 | 1370 v49 = terrain_76E1C8[v18]; |
67 | 1371 v126 = 0; |
0 | 1372 if ( v119 > v49 ) |
1373 { | |
1374 v125 = v119; | |
67 | 1375 memset32(terrain_76D7C8, v120 + 1, 4 * (v119 - v49 + 1)); |
0 | 1376 do |
1377 { | |
1378 v50 = v126; | |
1379 v51 = v125--; | |
67 | 1380 ++v126; |
1381 terrain_76D5C8[v50] = v51; | |
0 | 1382 } |
1383 while ( v125 >= terrain_76E1C8[v18] ); | |
67 | 1384 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1385 { |
1386 do | |
67 | 1387 v52 = terrain_76DFC8[v18-- -1]; |
1388 while ( v52 == terrain_76DFC8[v18 -1] ); | |
0 | 1389 } |
1390 v16 = v126; | |
1391 --v18; | |
1392 } | |
1393 if ( v18 < 0 ) | |
1394 v18 = 0; | |
1395 v53 = terrain_76E1C8[v18]; | |
1396 while ( v53 >= v123 ) | |
1397 { | |
1398 v54 = terrain_76E3C8[v18]; | |
67 | 1399 terrain_76D5C8[v16] = v53; |
1400 terrain_76D7C8[v16] = v54 + 1; | |
0 | 1401 if ( v54 == 65535 ) |
1402 { | |
67 | 1403 terrain_76D7C8[v16] = v124 + 1; |
1404 break; | |
0 | 1405 } |
1406 if ( !v18 ) | |
67 | 1407 break; |
1408 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1409 { |
1410 do | |
67 | 1411 v55 = terrain_76DFC8[v18-- -1]; |
1412 while ( v55 == terrain_76DFC8[v18 -1] ); | |
0 | 1413 } |
1414 --v18; | |
1415 --v53; | |
67 | 1416 ++v16; |
0 | 1417 } |
1418 break; | |
67 | 1419 } |
0 | 1420 case 3: |
1421 case 4: | |
67 | 1422 { |
985 | 1423 //v116 = terrain_76DFC8[v17]; |
1424 if ( i < terrain_76DFC8[v17] ) | |
0 | 1425 { |
1426 v106 = i; | |
985 | 1427 memset32(terrain_76D9C8, v122, 4 * (terrain_76DFC8[v17] - i + 1)); |
0 | 1428 v56 = i; |
1429 do | |
1430 { | |
67 | 1431 v57 = v126++; |
0 | 1432 terrain_76DBC8[v57] = v56++; |
1433 } | |
985 | 1434 while ( v56 <= terrain_76DFC8[v17] ); |
67 | 1435 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1436 { |
1437 do | |
67 | 1438 v58 = terrain_76DDC8[v17-- -1]; |
1439 while ( v58 == terrain_76DDC8[v17 -1] ); | |
0 | 1440 } |
1441 v16 = v126; | |
1442 --v17; | |
1443 } | |
1444 if ( v17 < 0 ) | |
1445 v17 = 0; | |
1446 v59 = terrain_76DFC8[v17]; | |
1447 while ( 1 ) | |
1448 { | |
1449 v125 = v59; | |
67 | 1450 if ( v59 > v124 ) |
0 | 1451 break; |
67 | 1452 terrain_76DBC8[v16] = v59; |
0 | 1453 v60 = terrain_76DDC8[v17]; |
67 | 1454 terrain_76D9C8[v16] = v60; |
0 | 1455 if ( v60 == 65535 ) |
1456 { | |
67 | 1457 terrain_76D9C8[v16] = v123; |
0 | 1458 break; |
1459 } | |
1460 if ( !v17 ) | |
1461 break; | |
67 | 1462 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1463 { |
1464 do | |
67 | 1465 v61 = terrain_76DDC8[v17-- -1]; |
1466 while ( v61 == terrain_76DDC8[v17 -1] ); | |
0 | 1467 } |
1468 --v17; | |
1469 v59 = v125 + 1; | |
67 | 1470 ++v16; |
1471 } | |
1472 v16 = 0; | |
1473 v126 = 0; | |
0 | 1474 v62 = terrain_76E3C8[v18]; |
1475 if ( i < v62 ) | |
1476 { | |
67 | 1477 v114 = i; |
1478 memset32(terrain_76D5C8, v119 + 1, 4 * (v62 - i + 1)); | |
0 | 1479 do |
1480 { | |
1481 v63 = v126; | |
67 | 1482 v64 = v114; |
1483 ++v126; | |
1484 ++v114; | |
1485 terrain_76D7C8[v63] = v64; | |
1486 } | |
1487 while ( v114 <= terrain_76E3C8[v18] ); | |
1488 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1489 { |
1490 do | |
67 | 1491 v65 = terrain_76E1C8[v18-- -1]; |
1492 while ( v65 == terrain_76E1C8[v18 -1] ); | |
0 | 1493 } |
1494 v16 = v126; | |
1495 --v18; | |
1496 } | |
1497 if ( v18 < 0 ) | |
1498 v18 = 0; | |
1499 v66 = terrain_76E3C8[v18]; | |
67 | 1500 while ( v66 <= v124 ) |
0 | 1501 { |
1502 v67 = terrain_76E1C8[v18]; | |
67 | 1503 terrain_76D7C8[v16] = v66; |
1504 terrain_76D5C8[v16] = v67 + 1; | |
985 | 1505 if ( terrain_76E1C8[v18] == 65535 ) |
0 | 1506 { |
1507 v31 = v123 + 1; | |
67 | 1508 terrain_76D5C8[v16] = v31; |
1509 break; | |
0 | 1510 } |
1511 if ( !v18 ) | |
67 | 1512 break; |
1513 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1514 { |
1515 do | |
67 | 1516 v68 = terrain_76E1C8[v18-- -1]; |
1517 while ( v68 == terrain_76E1C8[v18 -1] ); | |
0 | 1518 } |
1519 --v18; | |
1520 ++v66; | |
67 | 1521 ++v16; |
0 | 1522 } |
1523 break; | |
67 | 1524 } |
0 | 1525 default: |
1526 break; | |
1527 } | |
990 | 1528 //v69 = v16 - 1; |
0 | 1529 ptr_801A08 = pVerticesSR_806210; |
1530 ptr_801A04 = pVerticesSR_801A10; | |
990 | 1531 //v126 = v69; |
1532 | |
106 | 1533 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//áëîê |
0 | 1534 { |
990 | 1535 for ( i = v16 - 1; i >= 1; --i ) |
0 | 1536 { |
67 | 1537 //v70 = i; |
985 | 1538 //v71 = terrain_76D7C8[i];//88 |
1539 //v72 = terrain_76DBC8[i];//0 | |
1540 if ( terrain_76D7C8[i] < terrain_76DBC8[i] )//swap | |
1541 { | |
1542 terrain_76DBC8[i] = terrain_76D7C8[i]; | |
1543 terrain_76D7C8[i] = terrain_76DBC8[i]; | |
1544 } | |
1545 //x = terrain_76DBC8[i];//0 | |
0 | 1546 v111 = 0; |
985 | 1547 if ( terrain_76DBC8[i] <= 0 ) |
1548 terrain_76DBC8[i] = -terrain_76DBC8[i]; | |
1549 //v74 = terrain_76D7C8[i]; | |
1550 if ( terrain_76D7C8[i] <= 0 ) | |
1551 terrain_76D7C8[i] = -terrain_76D7C8[i]; | |
1552 v75 = terrain_76D7C8[i] + 2; | |
67 | 1553 //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; |
86 | 1554 uEndZ = v75; |
67 | 1555 //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; |
985 | 1556 uStartZ = terrain_76DBC8[i] - 2; |
1557 if ( terrain_76DBC8[i] - 2 < v75 ) | |
0 | 1558 { |
1559 v127 = 0; | |
67 | 1560 //v79 = (v73 - 66) << 9; |
1561 //v116 = v77; | |
1562 //pHeight = v79; | |
86 | 1563 v111 = v75 - uStartZ; |
1564 for (int z = uStartZ; z < uEndZ; ++z) | |
1565 { | |
985 | 1566 ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; |
67 | 1567 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; |
86 | 1568 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); |
985 | 1569 ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512; |
67 | 1570 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; |
86 | 1571 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); |
0 | 1572 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1573 { | |
67 | 1574 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); |
1575 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); | |
1576 pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); | |
1577 pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); | |
0 | 1578 } |
67 | 1579 //v79 += 512; |
1580 v127 ++; | |
1581 //++v116; | |
1582 //pHeight = v79; | |
106 | 1583 } |
67 | 1584 //while ( v116 < v107 ); |
1585 } | |
985 | 1586 v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); |
1587 v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); | |
106 | 1588 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test |
985 | 1589 Render::DrawTerrainD3D(v111, 0, v103, v104);//Render::RenderTerrainD3D(); |
67 | 1590 else |
985 | 1591 Render::DrawTerrainSW(v111, 0, v103, v104); |
1592 } | |
1593 } | |
1594 else | |
0 | 1595 { |
990 | 1596 for ( i = v16 - 1; i >= 1; --i ) |
0 | 1597 { |
985 | 1598 //v86 = i; |
1599 //v87 = terrain_76D5C8[i]; | |
1600 //v88 = terrain_76D9C8[i]; | |
1601 if ( terrain_76D5C8[i] < terrain_76D9C8[i] ) | |
1602 { | |
1603 terrain_76D9C8[i] = terrain_76D5C8[i]; | |
1604 terrain_76D5C8[i] = terrain_76D9C8[i]; | |
1605 } | |
1606 //v89 = terrain_76D9C8[i]; | |
0 | 1607 v111 = 0; |
985 | 1608 if ( terrain_76D9C8[i] <= 0 ) |
1609 terrain_76D9C8[i] = -terrain_76D9C8[i]; | |
1610 //v90 = terrain_76D5C8[i]; | |
1611 if ( terrain_76D5C8[i] <= 0 ) | |
1612 terrain_76D5C8[i] = -terrain_76D5C8[i]; | |
67 | 1613 pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; |
985 | 1614 v107 = terrain_76D5C8[i] + 2; |
1615 if ( terrain_76D9C8[i] - 2 < terrain_76D5C8[i] + 2 ) | |
0 | 1616 { |
1617 v86 = 0; | |
985 | 1618 //v116 = terrain_76D9C8[i] - 2; |
1619 v92 = (66 - terrain_76D9C8[i]) << 9; | |
1620 //pHeight = (66 - terrain_76D9C8[i]) << 9; | |
1621 v111 = terrain_76D5C8[i] + 2 - (terrain_76D9C8[i] - 2); | |
1622 //do | |
1623 for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 ) | |
1624 { | |
1625 //v93 = v116; | |
1626 //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9; | |
1627 ptr_801A08[v86].vWorldPosition.x = terrain_76DBC8[v86] - 64 << 9; | |
1628 //*(float *)&pHeight = (double)pHeight; | |
1629 ptr_801A08[v86].vWorldPosition.y = v92; | |
1630 //v106 = ; | |
1631 //v97 = v116; | |
1632 ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116); | |
1633 //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9; | |
1634 ptr_801A04[v86].vWorldPosition.x = terrain_76DBC8[v86] - 63 << 9; | |
1635 ptr_801A04[v86].vWorldPosition.y = v92; | |
1636 //pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97); | |
1637 ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116); | |
0 | 1638 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1639 { | |
67 | 1640 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); |
1641 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); | |
1642 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); | |
1643 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); | |
0 | 1644 } |
1645 v92 -= 512; | |
1646 v86 += 48; | |
985 | 1647 //++v116; |
1648 //pHeight = v92; | |
1649 } | |
1650 //while ( v116 < v107 ); | |
0 | 1651 } |
1652 v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); | |
1653 v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); | |
67 | 1654 if ( pRenderer->pRenderD3D ) |
985 | 1655 Render::DrawTerrainD3D(v111, 1, v103, v104); |
67 | 1656 else |
985 | 1657 Render::DrawTerrainSW(v111, 1, v103, v104); |
1658 } | |
1659 } | |
0 | 1660 result = v126; |
1661 pOutdoorCamera->field_40 = v126; | |
1662 return result; | |
1663 } | |
1664 // 47FFC4: inconsistent fpu stack | |
1665 // 4D864C: using guessed type char byte_4D864C; | |
1666 | |
988 | 1667 |
88 | 1668 void Render::RenderTerrainD3D() // New function. It's temporary |
86 | 1669 { |
1670 char result; // al@3 | |
1671 //int v1; // eax@3 | |
1672 //int v2; // ebx@4 | |
1673 //struct ODMFace *v4; // esi@6 | |
1674 int v6; // ecx@8 | |
1675 //int v7; // ecx@8 | |
1676 struct stru148 *v8; // ebx@8 | |
179 | 1677 // RenderVertexSoft *v8a; // edi@3 |
86 | 1678 //char v11; // zf@8 |
1679 struct stru148 *v16; | |
1680 unsigned int v18; // edi@22 | |
1681 //int v20; // edi@34 | |
1682 //int v28; // eax@50 | |
1683 //int v29; // ecx@55 | |
1684 //int v30; // eax@57 | |
1685 int v31; // eax@57 | |
1686 int v35; // edi@63 | |
1687 int v37; // eax@73 | |
1688 int v39; // eax@80 | |
1689 char v40; // [sp-18h] [bp-70h]@2 | |
1690 int v41; // [sp-14h] [bp-6Ch]@2 | |
1691 int v42; // [sp-10h] [bp-68h]@2 | |
1692 int v43; // [sp-Ch] [bp-64h]@2 | |
1693 const char *v44; // [sp-8h] [bp-60h]@2 | |
1694 int v45; // [sp-4h] [bp-5Ch]@2 | |
1695 //float v48; // [sp+14h] [bp-44h]@8 | |
1696 //void *v52; // [sp+24h] [bp-34h]@3 | |
1697 bool v54; // [sp+2Ch] [bp-2Ch]@10 | |
1698 int v55; // [sp+30h] [bp-28h]@34 | |
1699 int v56; | |
1700 int v57; // [sp+38h] [bp-20h]@36 | |
1701 int v58; // [sp+3Ch] [bp-1Ch]@8 | |
1702 int v63; // [sp+50h] [bp-8h]@3 | |
1703 int v64; // [sp+57h] [bp-1h]@2 | |
1704 int v62; | |
121 | 1705 //struct IndoorCameraD3D *pIndoorCameraD3D; |
179 | 1706 //RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 |
86 | 1707 |
186 | 1708 |
1709 //warning: the game uses CW culling by default, ccw is incosistent | |
1710 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
1711 | |
1712 | |
86 | 1713 v63 = 0; |
1714 // basic optimizations | |
577 | 1715 unsigned int uStartX, uEndX, uStartZ, uEndZ; |
106 | 1716 if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) |
1717 { | |
1718 uStartX = 0, uEndX = 128; | |
1719 uStartZ = 0, uEndZ = 64 + 16; | |
1720 } | |
1721 else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) | |
1722 { | |
1723 uStartX = 0, uEndX = 64 + 16; | |
1724 uStartZ = 0, uEndZ = 128; | |
1725 } | |
1726 else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) | |
1727 { | |
1728 uStartX = 64 - 16, uEndX = 128; | |
1729 uStartZ = 0, uEndZ = 128; | |
1730 } | |
1731 else | |
1732 { | |
1733 uStartX = 0, uEndX = 128; | |
1734 uStartZ = 64 - 16, uEndZ = 128; | |
1735 } | |
147 | 1736 uStartX = 0, uEndX = 128; |
1737 uStartZ = 0, uEndZ = 128; | |
106 | 1738 static RenderVertexSoft pTerrainVertices[128 * 128]; |
1739 for (unsigned int z = uStartZ; z < uEndZ; ++z) | |
1740 { | |
1741 for (unsigned int x = uStartX; x < uEndX; ++x) | |
1742 { | |
1743 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; | |
1744 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; | |
1745 pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 1746 //pIndoorCameraD3D = pGame->pIndoorCameraD3D; |
1747 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); | |
1748 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 1749 } |
1750 } | |
186 | 1751 |
106 | 1752 for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) |
1753 { | |
1754 for (unsigned int x = uStartX; x < uEndX - 1; ++x) | |
1755 { | |
1756 v8 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
1757 v8->flags = 0; | |
1758 v8->field_32 = 0; | |
1759 //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; | |
179 | 1760 //struct TileDesc *pTile = pTileTable->GetTileById(uTileID); |
106 | 1761 v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); |
179 | 1762 //v6 = v8->uTileBitmapID; |
1763 v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v8->uTileBitmapID]; | |
106 | 1764 if (v8->uTileBitmapID == 0xFFFF) |
1765 continue; | |
186 | 1766 |
179 | 1767 v8->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1768 v8->field_32 = 0; | |
1769 v8->field_59 = 1; | |
1770 //v8->field_5D = (char)WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8a->vWorldPosition.z) / 2 + 0.5f)); | |
1771 //v8->field_5C = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f));; | |
106 | 1772 v8->sTextureDeltaU = 0; |
1773 v8->sTextureDeltaV = 0; | |
1774 memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); | |
1775 array_73D150[0].u = 0; | |
1776 array_73D150[0].v = 0; | |
1777 memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1778 array_73D150[1].u = 1; | |
1779 array_73D150[1].v = 0; | |
1780 memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1781 array_73D150[2].u = 1; | |
1782 array_73D150[2].v = 1; | |
1783 memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); | |
1784 array_73D150[3].u = 0; | |
1785 array_73D150[3].v = 1; | |
86 | 1786 v55 = 0; |
1787 v54 = false; | |
1788 v58 = 0; | |
1789 if (v58 == 4) // if all y == first y; primitive in xz plane | |
1790 v8->field_32 |= 0x0001; | |
1791 v8->pODMFace = nullptr; | |
1792 v8->uNumVertices = 4; | |
1793 v8->field_59 = 5; | |
638 | 1794 |
1795 | |
1796 uint norm_idx = pTerrainNormalIndices[2 * (x + 128 * z) + 1]; | |
1797 assert(norm_idx < uNumTerrainNormals); | |
1798 | |
1799 auto norm = pTerrainNormals + norm_idx; | |
1800 float _f = (norm->x * (float)pOutdoor->vSunlight.x / 65536.0 - | |
1801 norm->y * (float)pOutdoor->vSunlight.y / 65536.0 - | |
1802 norm->z * (float)pOutdoor->vSunlight.z / 65536.0); | |
1803 v8->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); | |
1804 | |
86 | 1805 ++pOutdoorCamera->numStru148s; |
1806 ++pOutdoorCamera->field_44; | |
265 | 1807 assert(pOutdoorCamera->numStru148s < 20000); |
1808 | |
106 | 1809 v8->uBModelID = 0; |
1810 v8->uBModelFaceID = 0; | |
1811 v31 = (8 * (0 | (0 << 6))); | |
1812 v8->field_50 = v31 | 6; | |
265 | 1813 for (unsigned int k = 0; k < v8->uNumVertices; ++k) |
106 | 1814 { |
1815 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 1816 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 1817 } |
140 | 1818 |
186 | 1819 bool transparent = false; |
265 | 1820 if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->hd_water_tile_id) |
179 | 1821 { |
1822 //v80 = false; | |
265 | 1823 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
179 | 1824 } |
1825 else | |
1826 { | |
1827 v6 = v8->uTileBitmapID; | |
186 | 1828 transparent = true; |
179 | 1829 } |
1830 | |
140 | 1831 assert(v6 < 1000); // many random crashes here |
186 | 1832 |
1833 // for all shore tiles - draw a tile water under them since they're half-empty | |
1834 if (!strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX | |
1835 { | |
1836 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE); // no Z writing: the shore tile will be draw in the same place, so taking care about z-fighting | |
265 | 1837 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); |
186 | 1838 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE); |
1839 | |
1840 } | |
1841 | |
1842 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1843 | |
1844 | |
86 | 1845 --pOutdoorCamera->numStru148s; |
1846 --pOutdoorCamera->field_44; | |
106 | 1847 } |
1848 } | |
1849 } | |
0 | 1850 |
1851 //----- (0048034E) -------------------------------------------------------- | |
985 | 1852 void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) |
1853 { | |
1854 //int v3; // esi@1 | |
0 | 1855 int v4; // edi@1 |
1856 int v5; // ebx@2 | |
1857 int v6; // eax@2 | |
1858 int v7; // eax@3 | |
1859 RenderVertexSoft *v8; // edi@3 | |
1860 RenderVertexSoft *v9; // ebx@4 | |
1861 RenderVertexSoft *v10; // ecx@4 | |
1862 float v11; // eax@6 | |
1863 double v12; // ST5C_8@6 | |
1864 double v13; // ST2C_8@6 | |
1865 int v14; // eax@6 | |
1866 double v15; // st7@6 | |
1867 stru148 *v16; // ebx@12 | |
1868 unsigned __int16 v17; // ax@12 | |
1869 int v18; // eax@13 | |
67 | 1870 int v19; // ecx@13 |
1871 int v20; // eax@13 | |
0 | 1872 int v21; // eax@13 |
1873 signed int v22; // eax@13 | |
1874 Vec3_float_ *v23; // eax@15 | |
1875 double v24; // st6@17 | |
1876 double v25; // ST54_8@17 | |
1877 unsigned __int8 v26; // sf@17 | |
1878 unsigned __int8 v27; // of@17 | |
1879 double v28; // st5@19 | |
1880 double v29; // st5@19 | |
1881 double v30; // st5@19 | |
1882 double v31; // st5@19 | |
67 | 1883 struct struct8 *v32; // esi@21 |
1884 double v3a; // st7@32 | |
0 | 1885 int v33; // edi@38 |
1886 unsigned int v34; // ecx@47 | |
1887 char v35; // zf@47 | |
1888 unsigned int v36; // eax@50 | |
1889 int v37; // eax@54 | |
1890 stru148 *v38; // ecx@55 | |
1891 unsigned int v39; // eax@59 | |
1892 stru148 *v40; // ebx@62 | |
86 | 1893 unsigned __int16 pTileBitmapsID; // ax@62 |
0 | 1894 int v42; // eax@63 |
1895 LightmapBuilder *v43; // ecx@63 | |
67 | 1896 int v44; // eax@63 |
0 | 1897 int v45; // eax@63 |
1898 int v46; // eax@63 | |
1899 signed int v47; // eax@63 | |
1900 Vec3_float_ *v48; // eax@65 | |
1901 double v49; // st6@67 | |
1902 double v50; // ST4C_8@67 | |
1903 double v51; // st5@71 | |
1904 double v52; // st5@71 | |
1905 double v53; // st5@71 | |
1906 double v54; // st7@84 | |
1907 unsigned int v55; // ecx@98 | |
1908 unsigned int v56; // eax@101 | |
1909 int v57; // eax@105 | |
1910 unsigned int v58; // eax@109 | |
1911 stru148 *v59; // esi@112 | |
1912 unsigned __int16 v60; // ax@112 | |
67 | 1913 int v61; // eax@113 |
0 | 1914 signed int v62; // eax@113 |
1915 Vec3_float_ *v63; // eax@114 | |
1916 double v64; // st6@116 | |
1917 double v65; // ST3C_8@116 | |
1918 double v66; // st5@120 | |
1919 double v67; // st5@120 | |
1920 double v68; // st5@120 | |
1921 double v69; // st7@133 | |
1922 int v70; // edi@138 | |
86 | 1923 stru148 *v71; // esi@147 |
0 | 1924 unsigned int v72; // ecx@147 |
1925 unsigned int v73; // eax@150 | |
67 | 1926 int v74; // eax@154 |
0 | 1927 unsigned int v75; // eax@158 |
985 | 1928 //unsigned int v76; // [sp-10h] [bp-E0h]@61 |
67 | 1929 int v77; // [sp-Ch] [bp-DCh]@61 |
0 | 1930 IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 |
985 | 1931 //int v79; // [sp-4h] [bp-D4h]@61 |
0 | 1932 int v80; // [sp+0h] [bp-D0h]@59 |
1933 int v81; // [sp+0h] [bp-D0h]@109 | |
1934 int v82; // [sp+54h] [bp-7Ch]@1 | |
1935 int v83; // [sp+60h] [bp-70h]@1 | |
1936 int v84; // [sp+6Ch] [bp-64h]@1 | |
1937 int v85; // [sp+70h] [bp-60h]@63 | |
1938 int a4; // [sp+74h] [bp-5Ch]@73 | |
1939 float v87; // [sp+78h] [bp-58h]@122 | |
1940 int v88; // [sp+7Ch] [bp-54h]@1 | |
1941 int v89; // [sp+80h] [bp-50h]@6 | |
1942 float v90; // [sp+84h] [bp-4Ch]@1 | |
1943 float v91; // [sp+88h] [bp-48h]@1 | |
1944 float v92; // [sp+8Ch] [bp-44h]@1 | |
67 | 1945 int v93; // [sp+90h] [bp-40h]@2 |
0 | 1946 int X; // [sp+94h] [bp-3Ch]@1 |
1947 float v95; // [sp+98h] [bp-38h]@21 | |
1948 LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 | |
67 | 1949 int v97; // [sp+A0h] [bp-30h]@6 |
0 | 1950 int sX; // [sp+A4h] [bp-2Ch]@6 |
1951 unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 | |
1952 int v100; // [sp+ACh] [bp-24h]@122 | |
1953 int sY; // [sp+B0h] [bp-20h]@6 | |
67 | 1954 RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 |
0 | 1955 unsigned int a5; // [sp+B8h] [bp-18h]@21 |
1956 RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 | |
1957 Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 | |
1958 RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 | |
67 | 1959 RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 |
0 | 1960 char v108; // [sp+CFh] [bp-1h]@36 |
1961 float thisd; // [sp+D8h] [bp+8h]@6 | |
1962 float thise; // [sp+D8h] [bp+8h]@6 | |
1963 float thisf; // [sp+D8h] [bp+8h]@17 | |
1964 IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 | |
1965 float thisg; // [sp+D8h] [bp+8h]@67 | |
1966 IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 | |
1967 float thish; // [sp+D8h] [bp+8h]@116 | |
1968 IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 | |
1969 char this_3; // [sp+DBh] [bp+Bh]@30 | |
1970 char this_3a; // [sp+DBh] [bp+Bh]@82 | |
1971 char this_3b; // [sp+DBh] [bp+Bh]@131 | |
1972 | |
67 | 1973 static stru154 static_sub_0048034E_stru_154; |
1974 static stru154 stru_76D5A8; | |
985 | 1975 //v3 = a1; |
67 | 1976 v82 = a2; |
985 | 1977 v83 = a3; |
1978 X = abs(unk4); | |
0 | 1979 v4 = 0; |
1980 v88 = 0; | |
985 | 1981 v84 = a1 - 1; |
638 | 1982 v90 = (float)pOutdoor->vSunlight.x / 65536.0; |
67 | 1983 v91 = (float)pOutdoor->vSunlight.y / 65536.0; |
1984 v92 = (float)pOutdoor->vSunlight.z / 65536.0; | |
985 | 1985 if ( a1 - 1 > 0 ) |
0 | 1986 { |
1987 while ( 1 ) | |
1988 { | |
1989 v5 = abs(X);//v5 = 13108 | |
1990 v6 = abs(v83);//v6 = 13108 | |
1991 --X; | |
985 | 1992 //__debugbreak(); // uncoment & refactor following large if |
67 | 1993 v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; |
1994 /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), | |
0 | 1995 v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), |
1996 ((a8 = v9, | |
1997 pVertices = &pVerticesSR_801A10[1] + v7, | |
1998 v11 = v8->vWorldPosition.x, | |
1999 v101 = v10, | |
2000 v12 = v11 + 6.755399441055744e15, | |
2001 sX = LODWORD(v12), | |
2002 v13 = v8->vWorldPosition.y + 6.755399441055744e15, | |
2003 sY = LODWORD(v13), | |
2004 thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, | |
62 | 2005 v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X |
0 | 2006 v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, |
2007 v89 = v14, | |
2008 thise = v15 * 0.5, | |
62 | 2009 _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z |
0 | 2010 WorldPosToGridCellX(sX), |
2011 WorldPosToGridCellZ(sY), | |
2012 !byte_4D864C) | |
2013 || !(pGame->uFlags & 0x80)) | |
67 | 2014 && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ |
2015 if ( !&stru_76E5C8[(v5 << 7) + v6] ) | |
0 | 2016 goto LABEL_162; |
67 | 2017 v8 = &pVerticesSR_806210[v4]; |
2018 pVertices2 = &pVerticesSR_801A10[v4 + 1]; | |
2019 v102 = v8; | |
2020 if (!v82) | |
2021 { | |
86 | 2022 pVertices = &pVerticesSR_801A10[v4]; |
2023 v101 = &pVerticesSR_806210[v4 + 1]; | |
67 | 2024 } |
2025 else | |
2026 { | |
86 | 2027 pVertices = &pVerticesSR_801A10[v4 + 1]; |
2028 v101 = &pVerticesSR_806210[v4]; | |
2029 } | |
67 | 2030 sX = floorf(v8->vWorldPosition.x + 0.5f); |
2031 sY = floorf(v8->vWorldPosition.z + 0.5f); | |
2032 v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); | |
2033 v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); | |
2034 WorldPosToGridCellX(sX); | |
2035 WorldPosToGridCellZ(sY); | |
2036 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) | |
86 | 2037 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y |
2038 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) | |
67 | 2039 break; |
2040 v16 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2041 v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
86 | 2042 if ( v16->uTileBitmapID != -1 ) |
2043 { | |
2044 v19 = v97; | |
2045 v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2046 v16->field_32 = 0; | |
2047 v20 = v93; | |
2048 v16->field_59 = 1; | |
638 | 2049 v16->terrain_grid_x = (char)v19; |
86 | 2050 v16->field_34 = *(_WORD *)(v20 + 2); |
2051 v21 = v89; | |
638 | 2052 v16->terrain_grid_z = v89; |
86 | 2053 v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; |
2054 if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) | |
2055 v23 = 0; | |
2056 else | |
2057 v23 = &pTerrainNormals[v22]; | |
638 | 2058 v24 = v92 * v23->z; |
86 | 2059 //v99 = v23; |
638 | 2060 thisf = 20.0 - (-v24 - v91 * v23->y - v90 * v23->x) * 20.0; |
86 | 2061 //v25 = thisf + 6.7553994e15; |
2062 //v27 = pOutdoorCamera->numStru148s > 1999; | |
2063 //v26 = pOutdoorCamera->numStru148s - 1999 < 0; | |
638 | 2064 v16->dimming_level = floorf(thisf + 0.5f); |
86 | 2065 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2066 return; | |
2067 ++pOutdoorCamera->numStru148s; | |
96 | 2068 //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary |
4 | 2069 //goto LABEL_126; |
96 | 2070 //{ |
2071 //--pOutdoorCamera->numStru148s; | |
2072 //goto LABEL_162; | |
2073 //} | |
86 | 2074 memcpy(&array_50AC10[0], v102, 0x30u); |
168 | 2075 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2076 array_50AC10[0].u = 0.0; |
2077 array_50AC10[0].v = 0.0; | |
2078 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2079 array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2080 array_50AC10[1].u = 0.0; |
2081 array_50AC10[1].v = 1.0; | |
2082 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2083 array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2084 array_50AC10[2].u = 1.0; |
2085 array_50AC10[2].v = 1.0; | |
2086 memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); | |
168 | 2087 array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2088 array_50AC10[3].u = 1.0; |
2089 array_50AC10[3].v = 0.0; | |
2090 /*if ( !(byte_76D5C0 & 1) ) | |
2091 { | |
2092 byte_76D5C0 |= 1u; | |
2093 stru154(stru_76D5A8); | |
2094 atexit(loc_481199); | |
2095 }*/ | |
2096 v32 = (struct8 *)array_50AC10; | |
2097 v97 = (int)pGame->pLightmapBuilder; | |
2098 pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1); | |
2099 pDecalBuilder->_49BE8A(v16, *(float *)&v23, (int)&v95, array_50AC10, 4, 1); | |
2100 a5 = 4; | |
2101 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2102 { | |
2103 thisa = pGame->pIndoorCameraD3D; | |
2104 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) | |
2105 goto LABEL_162; | |
2106 thisa->ViewTransform(array_50AC10, a5); | |
2107 thisa->Project(array_50AC10, a5, 0); | |
2108 } | |
2109 this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 | |
2110 || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2111 v3a = (double)pOutdoorCamera->shading_dist_mist; | |
2112 v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x | |
2113 || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; | |
2114 v33 = 0; | |
2115 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
2116 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
0 | 2117 { |
86 | 2118 if ( this_3 ) |
2119 v33 = 3; | |
2120 else | |
2121 v33 = v108 != 0 ? 5 : 0; | |
734 | 2122 static_sub_0048034E_stru_154.ClassifyPolygon(v23, v95); |
86 | 2123 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2124 pDecalBuilder->ApplyDecals(31 - v16->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); |
0 | 2125 } |
86 | 2126 if ( stru_F8AD28.uNumLightsApplied > 0 ) |
2127 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); | |
2128 v34 = a5; | |
2129 //v35 = byte_4D864C == 0; | |
2130 v16->uNumVertices = a5; | |
2131 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) | |
0 | 2132 { |
86 | 2133 if ( this_3 ) |
2134 { | |
2135 v36 = sr_424CD7(v34); | |
2136 v16->uNumVertices = v36; | |
2137 OutdoorCamera::Project(v36); | |
2138 } | |
2139 if ( v108 ) | |
2140 { | |
2141 v36 = sr_424EE0_MakeFanFromTriangle(v34); | |
2142 v16->uNumVertices = v36; | |
2143 OutdoorCamera::Project(v36); | |
2144 } | |
0 | 2145 } |
86 | 2146 //v37 = *(int *)&v16->flags; |
2147 if ( ~v16->flags & 1 ) | |
2148 { | |
265 | 2149 if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2150 { |
2151 v80 = false; | |
265 | 2152 v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2153 } |
2154 else | |
2155 { | |
2156 v39 = v16->uTileBitmapID; | |
2157 v80 = true; | |
2158 } | |
2159 //v79 = 0; | |
2160 //v78 = pBitmaps_LOD->pHardwareTextures[v39]; | |
2161 v16->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary | |
2162 v77 = (int)v16; | |
2163 //v76 = v16->uNumVertices; | |
4 | 2164 //LABEL_161: |
186 | 2165 pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80); |
86 | 2166 goto LABEL_162; |
2167 } | |
2168 v38 = v16; | |
0 | 2169 LABEL_56: |
86 | 2170 v38->_4811A3(); |
2171 } | |
0 | 2172 LABEL_162: |
86 | 2173 v4 = v88 + 1; |
2174 if ( ++v88 >= v84 ) | |
2175 return; | |
2176 } | |
2177 v40 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2178 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2179 if ( v40->uTileBitmapID == -1 ) | |
2180 goto LABEL_162; | |
2181 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2182 BYTE1(v42) |= 0x80u; | |
2183 v43 = pGame->pLightmapBuilder; | |
2184 *(int *)&v40->flags = v42; | |
2185 v44 = v93; | |
2186 v40->field_59 = 1; | |
638 | 2187 v40->terrain_grid_x = (char)v43; |
86 | 2188 v40->field_34 = *(_WORD *)(v44 + 2); |
2189 v45 = v89; | |
638 | 2190 v40->terrain_grid_z = v89; |
86 | 2191 v46 = 4 * ((char)v43 + (v45 << 7)); |
2192 v85 = v46; | |
2193 v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; | |
2194 if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) | |
2195 v48 = 0; | |
2196 else | |
2197 v48 = &pTerrainNormals[v47]; | |
2198 v49 = v92 * v48->y; | |
2199 //v99 = v48; | |
2200 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; | |
2201 v50 = thisg + 6.755399441055744e15; | |
638 | 2202 v40->dimming_level = LOBYTE(v50); |
86 | 2203 if ( LOBYTE(v50) < 0 ) |
638 | 2204 v40->dimming_level = 0; |
86 | 2205 if ( pOutdoorCamera->numStru148s >= 1999 ) |
0 | 2206 return; |
86 | 2207 ++pOutdoorCamera->numStru148s; |
2208 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary | |
2209 //goto LABEL_77; | |
2210 { | |
2211 --pOutdoorCamera->numStru148s; | |
2212 goto LABEL_112; | |
2213 }*/ | |
2214 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2215 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2216 array_50AC10[0].u = 0.0; |
2217 array_50AC10[0].v = 0.0; | |
2218 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2219 array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2220 array_50AC10[1].u = 0.0; |
2221 array_50AC10[1].v = 1.0; | |
2222 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2223 array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2224 array_50AC10[2].u = 1.0; |
2225 array_50AC10[2].v = 1.0; | |
2226 static stru154 static_sub_0048034E_stru_76D590; | |
2227 /*static bool __init_flag2 = false; | |
2228 if (!__init_flag2) | |
2229 { | |
2230 __init_flag2 = true; | |
2231 stru154::stru154(&static_sub_0048034E_stru_76D590); | |
2232 }*/ | |
2233 /*if ( !(byte_76D5C0 & 2) ) | |
2234 { | |
2235 byte_76D5C0 |= 2; | |
2236 stru148(stru_76D590); | |
2237 atexit(loc_48118F); | |
2238 }*/ | |
2239 v96 = pGame->pLightmapBuilder; | |
2240 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); | |
2241 pDecalBuilder->_49BE8A(v40, *(float *)&v48, (int)&a4, array_50AC10, 3, 0); | |
2242 uNumVertices = 3; | |
2243 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2244 { | |
2245 thisb = pGame->pIndoorCameraD3D; | |
2246 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) | |
2247 { | |
2248 //LABEL_77: | |
2249 --pOutdoorCamera->numStru148s; | |
2250 goto LABEL_112; | |
2251 } | |
2252 thisb->ViewTransform(array_50AC10, uNumVertices); | |
2253 thisb->Project(array_50AC10, uNumVertices, 0); | |
2254 } | |
2255 this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2256 v54 = (double)pOutdoorCamera->shading_dist_mist; | |
2257 v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; | |
2258 pVertices = 0; | |
2259 v96->std__vector_000004_size = 0; | |
2260 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2261 { | |
2262 if ( this_3a ) | |
2263 pVertices = (RenderVertexSoft *)3; | |
2264 else | |
2265 pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); | |
2266 //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); | |
734 | 2267 static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); |
86 | 2268 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2269 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); |
86 | 2270 } |
2271 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2272 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); | |
2273 v55 = uNumVertices; | |
2274 //v35 = byte_4D864C == 0; | |
2275 v40->uNumVertices = uNumVertices; | |
2276 if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) | |
2277 { | |
2278 if ( this_3a ) | |
2279 { | |
2280 v56 = sr_424CD7(v55); | |
2281 } | |
2282 else | |
2283 { | |
2284 if ( !v108 ) | |
2285 goto LABEL_105; | |
2286 v56 = sr_424EE0_MakeFanFromTriangle(v55); | |
2287 } | |
2288 v40->uNumVertices = v56; | |
2289 OutdoorCamera::Project(v56); | |
2290 } | |
2291 LABEL_105: | |
2292 v57 = *(int *)&v40->flags; | |
2293 if ( BYTE1(v57) & 1 ) | |
2294 { | |
2295 v40->_4811A3(); | |
2296 } | |
2297 else | |
2298 { | |
265 | 2299 if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2300 { |
2301 v81 = 0; | |
265 | 2302 v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2303 } |
2304 else | |
2305 { | |
2306 v58 = v40->uTileBitmapID; | |
2307 v81 = 1; | |
2308 } | |
186 | 2309 pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); |
86 | 2310 } |
2311 LABEL_112: | |
2312 v59 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2313 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; | |
2314 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2315 if ( v59->uTileBitmapID == -1 ) | |
2316 goto LABEL_162; | |
2317 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2318 v61 = v93; | |
2319 v59->field_59 = 1; | |
2320 v59->field_34 = *(_WORD *)(v61 + 2); | |
638 | 2321 v59->terrain_grid_z = v89; |
2322 v59->terrain_grid_x = v97; | |
86 | 2323 v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); |
2324 if ( v62 > (signed int)(uNumTerrainNormals - 1) ) | |
2325 v63 = 0; | |
2326 else | |
2327 v63 = &pTerrainNormals[v62]; | |
2328 v64 = v92 * v63->y; | |
2329 //v99 = v63; | |
2330 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; | |
638 | 2331 v59->dimming_level = floorf(thish + 0.5f); |
2332 if ( v59->dimming_level < 0 ) | |
2333 v59->dimming_level = 0; | |
86 | 2334 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2335 return; | |
2336 ++pOutdoorCamera->numStru148s; | |
2337 if ( !sub_481FC9(v101, v102, pVertices2, v59) ) | |
2338 { | |
2339 //LABEL_126: | |
4 | 2340 --pOutdoorCamera->numStru148s; |
86 | 2341 goto LABEL_162; |
2342 } | |
2343 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2344 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2345 array_50AC10[0].u = 0.0; |
2346 array_50AC10[0].v = 0.0; | |
2347 memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); | |
168 | 2348 array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2349 array_50AC10[1].u = 1.0; |
2350 array_50AC10[1].v = 1.0; | |
2351 memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); | |
168 | 2352 array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2353 array_50AC10[2].u = 1.0; |
2354 array_50AC10[2].v = 0.0; | |
2355 static stru154 static_sub_0048034E_stru_76D578; | |
2356 /*static bool __init_flag1 = false; | |
2357 if (!__init_flag1) | |
2358 { | |
2359 __init_flag1 = true; | |
2360 stru154::stru154(&static_sub_0048034E_stru_76D578); | |
2361 }*/ | |
2362 v96 = pGame->pLightmapBuilder; | |
2363 pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); | |
2364 pDecalBuilder->_49BE8A(v40, *(float *)&v63, (int)&v87, array_50AC10, 3, 1); | |
2365 v100 = 3; | |
2366 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2367 { | |
2368 thisc = pGame->pIndoorCameraD3D; | |
2369 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) | |
2370 //goto LABEL_126; | |
2371 { | |
2372 --pOutdoorCamera->numStru148s; | |
2373 goto LABEL_162; | |
2374 } | |
2375 thisc->ViewTransform(array_50AC10, v100); | |
2376 thisc->Project(array_50AC10, v100, 0); | |
2377 } | |
2378 this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 | |
2379 || v101->vWorldViewPosition.x < 8.0; | |
2380 v69 = (double)pOutdoorCamera->shading_dist_mist; | |
2381 v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; | |
2382 v70 = 0; | |
2383 v96->std__vector_000004_size = 0; | |
2384 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2385 { | |
2386 if ( this_3b ) | |
2387 v70 = 3; | |
2388 else | |
2389 v70 = v108 != 0 ? 5 : 0; | |
734 | 2390 static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); |
86 | 2391 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2392 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); |
86 | 2393 } |
2394 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2395 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); | |
2396 v71 = v59; | |
2397 v72 = v100; | |
2398 //v35 = byte_4D864C == 0; | |
2399 v59->uNumVertices = v100;//??? | |
2400 if ( !byte_4D864C && pGame->uFlags & 0x80 ) | |
2401 goto LABEL_154; | |
2402 if ( this_3b ) | |
2403 { | |
2404 v73 = sr_424CD7(v72); | |
0 | 2405 } |
2406 else | |
2407 { | |
2408 if ( !v108 ) | |
86 | 2409 { |
2410 LABEL_154: | |
2411 v74 = v71->flags; | |
2412 if ( !(BYTE1(v74) & 1) ) | |
2413 { | |
265 | 2414 if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2415 { |
2416 v80 = false; | |
265 | 2417 v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2418 } |
2419 else | |
2420 { | |
2421 v75 = v71->uTileBitmapID; | |
2422 v80 = true; | |
2423 } | |
2424 //v79 = 0; | |
985 | 2425 v78 = pBitmaps_LOD->pHardwareTextures[v75]; |
86 | 2426 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary |
2427 //v77 = (int)v71; | |
2428 //v76 = v71->uNumVertices; | |
2429 //goto LABEL_161; | |
985 | 2430 pRenderer->DrawTerrainPolygon(v71->uNumVertices, (stru148 *)v71, v78, 0, v80); |
86 | 2431 goto LABEL_162; |
2432 } | |
2433 v38 = (stru148 *)v71; | |
2434 goto LABEL_56; | |
2435 } | |
2436 v73 = sr_424EE0_MakeFanFromTriangle(v72); | |
2437 } | |
2438 v71->uNumVertices = v73; | |
2439 OutdoorCamera::Project(v73); | |
0 | 2440 goto LABEL_154; |
86 | 2441 } |
2442 } | |
0 | 2443 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); |
2444 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
2445 // 4D864C: using guessed type char byte_4D864C; | |
2446 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag; | |
2447 | |
2448 //----- (00481212) -------------------------------------------------------- | |
985 | 2449 void Render::DrawTerrainSW(int a1, int a2, int a3, int a4) |
0 | 2450 { |
2451 int v3; // esi@1 | |
2452 int v4; // ecx@1 | |
2453 int v5; // ST10_4@1 | |
2454 int v6; // edi@1 | |
2455 int v7; // ebx@2 | |
2456 int v8; // eax@2 | |
2457 int v9; // eax@3 | |
2458 RenderVertexSoft *v10; // edi@3 | |
2459 RenderVertexSoft *v11; // ebx@4 | |
2460 RenderVertexSoft *v12; // ecx@4 | |
2461 float v13; // eax@6 | |
2462 int v14; // eax@6 | |
2463 double v15; // st7@6 | |
2464 double v16; // st7@6 | |
2465 stru148 *v17; // ebx@12 | |
2466 unsigned __int16 v18; // ax@12 | |
2467 int v19; // eax@13 | |
2468 float v20; // ecx@13 | |
2469 stru220 *v21; // eax@13 | |
2470 int v22; // eax@13 | |
2471 signed int v23; // eax@13 | |
2472 Vec3_float_ *v24; // eax@15 | |
2473 double v25; // st7@18 | |
2474 double v26; // st5@24 | |
2475 double v27; // st5@24 | |
2476 double v28; // st5@24 | |
2477 double v29; // st5@24 | |
2478 Game *v30; // eax@25 | |
2479 RenderVertexSoft *v31; // edi@29 | |
2480 double v32; // st7@31 | |
2481 int v33; // esi@35 | |
2482 RenderVertexSoft *v34; // edx@36 | |
2483 RenderVertexSoft *v35; // ecx@36 | |
2484 signed int v36; // eax@39 | |
2485 signed int v37; // esi@40 | |
2486 stru148 *v38; // ebx@43 | |
2487 unsigned __int16 v39; // ax@43 | |
2488 int v40; // eax@44 | |
2489 float v41; // ecx@44 | |
2490 stru220 *v42; // eax@44 | |
2491 int v43; // eax@44 | |
2492 int v44; // eax@44 | |
2493 signed int v45; // eax@44 | |
2494 Vec3_float_ *v46; // eax@46 | |
2495 double v47; // st7@49 | |
2496 double v48; // st5@57 | |
2497 double v49; // st5@57 | |
2498 double v50; // st5@57 | |
2499 Game *v51; // eax@58 | |
2500 RenderVertexSoft *v52; // edi@62 | |
2501 double v53; // st7@63 | |
2502 int v54; // esi@66 | |
2503 signed int v55; // eax@69 | |
2504 signed int v56; // esi@71 | |
2505 unsigned __int16 v57; // ax@75 | |
2506 stru220 *v58; // eax@76 | |
2507 signed int v59; // eax@76 | |
2508 Vec3_float_ *v60; // eax@77 | |
2509 double v61; // st7@80 | |
2510 double v62; // st5@88 | |
2511 double v63; // st5@88 | |
2512 double v64; // st5@88 | |
2513 Game *v65; // eax@89 | |
2514 double v66; // st7@94 | |
2515 RenderVertexSoft *v67; // [sp-Ch] [bp-C4h]@36 | |
2516 stru148 *v68; // [sp-8h] [bp-C0h]@36 | |
2517 int v69; // [sp-4h] [bp-BCh]@36 | |
2518 float v70; // [sp+Ch] [bp-ACh]@88 | |
2519 double v71; // [sp+10h] [bp-A8h]@6 | |
2520 double v72; // [sp+18h] [bp-A0h]@82 | |
2521 double v73; // [sp+20h] [bp-98h]@6 | |
2522 double v74; // [sp+28h] [bp-90h]@51 | |
2523 double v75; // [sp+30h] [bp-88h]@6 | |
2524 double v76; // [sp+38h] [bp-80h]@20 | |
2525 double v77; // [sp+40h] [bp-78h]@6 | |
2526 float v78; // [sp+48h] [bp-70h]@57 | |
2527 float v79; // [sp+4Ch] [bp-6Ch]@6 | |
2528 float v80; // [sp+50h] [bp-68h]@6 | |
2529 int v81; // [sp+54h] [bp-64h]@1 | |
2530 int v82; // [sp+58h] [bp-60h]@6 | |
2531 int v83; // [sp+5Ch] [bp-5Ch]@82 | |
2532 int v84; // [sp+60h] [bp-58h]@20 | |
2533 int v85; // [sp+64h] [bp-54h]@1 | |
2534 int v86; // [sp+68h] [bp-50h]@1 | |
2535 int v87; // [sp+6Ch] [bp-4Ch]@51 | |
2536 float v88; // [sp+70h] [bp-48h]@51 | |
2537 int v89; // [sp+74h] [bp-44h]@6 | |
2538 int v90; // [sp+78h] [bp-40h]@1 | |
2539 float a3a; // [sp+7Ch] [bp-3Ch]@24 | |
2540 stru220 *v92; // [sp+80h] [bp-38h]@2 | |
2541 float v93; // [sp+84h] [bp-34h]@44 | |
2542 int v94; // [sp+88h] [bp-30h]@6 | |
2543 float v95; // [sp+8Ch] [bp-2Ch]@1 | |
2544 float v96; // [sp+90h] [bp-28h]@1 | |
2545 float v97; // [sp+94h] [bp-24h]@1 | |
2546 int X; // [sp+98h] [bp-20h]@1 | |
2547 float v99; // [sp+9Ch] [bp-1Ch]@6 | |
2548 int v100; // [sp+A0h] [bp-18h]@6 | |
2549 unsigned __int64 v101; // [sp+A4h] [bp-14h]@6 | |
2550 RenderVertexSoft *v102; // [sp+ACh] [bp-Ch]@6 | |
2551 RenderVertexSoft *v103; // [sp+B0h] [bp-8h]@6 | |
2552 RenderVertexSoft *v104; // [sp+B4h] [bp-4h]@3 | |
2553 float pNormalc; // [sp+C0h] [bp+8h]@6 | |
2554 float pNormald; // [sp+C0h] [bp+8h]@6 | |
2555 Vec3_float_ *pNormal; // [sp+C0h] [bp+8h]@17 | |
2556 Vec3_float_ *pNormala; // [sp+C0h] [bp+8h]@48 | |
2557 Vec3_float_ *pNormalb; // [sp+C0h] [bp+8h]@77 | |
2558 | |
2559 v3 = a1; | |
2560 //v4 = *(short *)(a3 + 4); | |
2561 //v5 = *(short *)(a3 + 6); | |
2562 v85 = a2; | |
985 | 2563 v86 = a3; //v4; |
2564 X = abs(a4); //v5 | |
0 | 2565 v6 = 0; |
2566 v90 = 0; | |
2567 v81 = v3 - 1; | |
638 | 2568 v95 = (double)pOutdoor->vSunlight.x / 65536.0; |
2569 v96 = (double)pOutdoor->vSunlight.y / 65536.0; | |
2570 v97 = (double)pOutdoor->vSunlight.z / 65536.0; | |
0 | 2571 if ( v3 - 1 > 0 ) |
2572 { | |
2573 while ( 1 ) | |
2574 { | |
2575 v7 = abs(X); | |
2576 v8 = abs(v86); | |
2577 --X; | |
2578 v92 = &stru_76E5C8[(v7 << 7) + v8]; | |
2579 if ( !v92->field_0 | |
2580 || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9], | |
2581 v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]), | |
2582 ((v103 = &pVerticesSR_801A10[v9 + 1], | |
2583 v13 = v10->vWorldPosition.x, | |
2584 v102 = v12, | |
2585 v80 = v13, | |
2586 v73 = v13 + 6.7553994e15, | |
2587 v101 = __PAIR__((unsigned int)v11, LODWORD(v73)), | |
2588 v79 = v10->vWorldPosition.y, | |
2589 v75 = v79 + 6.7553994e15, | |
2590 v100 = LODWORD(v75), | |
2591 pNormalc = (v12->vWorldPosition.x + v10->vWorldPosition.x) * 0.5, | |
2592 v71 = pNormalc + 6.7553994e15, | |
2593 v89 = LODWORD(v71), | |
2594 v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(pNormalc + 6.7553994e15)), | |
2595 v15 = v11->vWorldPosition.y + v10->vWorldPosition.y, | |
2596 v94 = v14, | |
2597 pNormald = v15 * 0.5, | |
2598 v16 = pNormald + 6.7553994e15, | |
2599 v77 = v16, | |
2600 v82 = LODWORD(v77), | |
2601 LODWORD(v99) = WorldPosToGridCellZ(LODWORD(v16)), | |
2602 WorldPosToGridCellX(v101), | |
2603 WorldPosToGridCellZ(v100), | |
2604 !byte_4D864C) | |
2605 || !(pGame->uFlags & 0x80)) | |
2606 && !sub_481EFA(v10, v11, v102, v103, 1)) ) | |
2607 goto LABEL_105; | |
2608 if ( v10->vWorldPosition.z != v11->vWorldPosition.z | |
2609 || v11->vWorldPosition.z != v103->vWorldPosition.z | |
2610 || v103->vWorldPosition.z != v102->vWorldPosition.z ) | |
2611 break; | |
2612 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2613 v18 = pOutdoor->GetTileTexture(v101, v100); | |
2614 v17->uTileBitmapID = v18; | |
2615 if ( v18 != -1 ) | |
2616 { | |
2617 v19 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2618 LOWORD(v19) = v19 | 0x8010; | |
2619 v20 = v99; | |
2620 *(int *)&v17->flags = v19; | |
2621 v21 = v92; | |
2622 v17->field_59 = 1; | |
638 | 2623 v17->terrain_grid_x = LOBYTE(v20); |
0 | 2624 v17->field_34 = v21->distance; |
2625 v22 = v94; | |
638 | 2626 v17->terrain_grid_z = v94; |
0 | 2627 v23 = pTerrainNormalIndices[2 * (LODWORD(v20) + (v22 << 7)) + 1]; |
2628 if ( v23 < 0 || v23 > (signed int)(uNumTerrainNormals - 1) ) | |
2629 v24 = 0; | |
2630 else | |
2631 v24 = &pTerrainNormals[v23]; | |
2632 pNormal = v24; | |
2633 if ( v24 ) | |
2634 { | |
2635 v25 = -(v97 * v24->z + v96 * v24->y + v95 * v24->x); | |
2636 if ( v25 < 0.0 ) | |
2637 v25 = 0.0; | |
2638 v99 = v25 * 31.0; | |
2639 v76 = v99 + 6.7553994e15; | |
2640 v84 = LODWORD(v76); | |
638 | 2641 v17->dimming_level = 31 - LOBYTE(v76); |
0 | 2642 } |
2643 else | |
2644 { | |
638 | 2645 v17->dimming_level = 0; |
0 | 2646 } |
2647 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
2648 return; | |
2649 ++pOutdoorCamera->numStru148s; | |
2650 if ( !sub_481FC9(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) | |
2651 goto LABEL_104; | |
2652 v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2653 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2654 array_50AC10[0]._rhw = v26; |
0 | 2655 array_50AC10[0].u = 0.0; |
2656 array_50AC10[0].v = 0.0; | |
2657 v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2658 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
168 | 2659 array_50AC10[1]._rhw = 1.0 / v27; |
0 | 2660 array_50AC10[1].u = 0.0; |
2661 array_50AC10[1].v = 1.0; | |
2662 v28 = v103->vWorldViewPosition.x + 0.0000001; | |
2663 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
168 | 2664 array_50AC10[2]._rhw = 1.0 / v28; |
0 | 2665 array_50AC10[2].u = 1.0; |
2666 array_50AC10[2].v = 1.0; | |
2667 v29 = v102->vWorldViewPosition.x + 0.0000001; | |
2668 memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3])); | |
168 | 2669 array_50AC10[3]._rhw = 1.0 / v29; |
0 | 2670 array_50AC10[3].u = 1.0; |
2671 array_50AC10[3].v = 0.0; | |
2672 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1); | |
2673 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2674 { | |
2675 v17->field_108 = 0; | |
2676 } | |
2677 else | |
2678 { | |
2679 v30 = pGame; | |
2680 v17->field_108 = 1; | |
2681 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 4, pNormal); | |
2682 } | |
2683 if ( v104->vWorldViewPosition.x < 8.0 | |
2684 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2685 || (v31 = v102, v102->vWorldViewPosition.x < 8.0) | |
2686 || v103->vWorldViewPosition.x < 8.0 ) | |
2687 { | |
2688 v36 = sr_4250FE(4u); | |
2689 } | |
2690 else | |
2691 { | |
2692 v32 = (double)pOutdoorCamera->shading_dist_mist; | |
2693 if ( v32 >= v104->vWorldViewPosition.x | |
2694 && v32 >= *(float *)(HIDWORD(v101) + 12) | |
2695 && v32 >= v102->vWorldViewPosition.x | |
2696 && v32 >= v103->vWorldViewPosition.x ) | |
2697 { | |
2698 v33 = sr_4254D2(4); | |
2699 v17->uNumVertices = v33; | |
2700 if ( !v33 ) | |
2701 goto LABEL_104; | |
2702 v34 = (RenderVertexSoft *)HIDWORD(v101); | |
2703 v35 = v104; | |
2704 v69 = 0; | |
2705 v68 = v17; | |
2706 v67 = v31; | |
2707 goto LABEL_37; | |
2708 } | |
2709 v36 = sr_4252E8(4u); | |
2710 } | |
2711 v37 = v36; | |
2712 if ( !v36 ) | |
2713 goto LABEL_104; | |
2714 LABEL_41: | |
2715 OutdoorCamera::Project(v37); | |
2716 LABEL_102: | |
2717 v33 = sr_4254D2(v37); | |
2718 v17->uNumVertices = v33; | |
2719 if ( !v33 ) | |
2720 goto LABEL_104; | |
2721 v17->_48276F_sr(); | |
2722 goto LABEL_38; | |
2723 } | |
2724 LABEL_105: | |
2725 v6 = v90++ + 1; | |
2726 if ( v90 >= v81 ) | |
2727 return; | |
2728 } | |
2729 v38 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2730 v39 = pOutdoor->GetTileTexture(v101, v100); | |
2731 v38->uTileBitmapID = v39; | |
2732 if ( v39 == -1 ) | |
2733 goto LABEL_105; | |
2734 v40 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2735 BYTE1(v40) |= 0x80u; | |
2736 v41 = v99; | |
2737 *(int *)&v38->flags = v40; | |
2738 v42 = v92; | |
2739 v38->field_59 = 1; | |
638 | 2740 v38->terrain_grid_x = LOBYTE(v41); |
0 | 2741 v38->field_34 = v42->distance; |
2742 v43 = v94; | |
638 | 2743 v38->terrain_grid_z = v94; |
0 | 2744 v44 = 2 * (LODWORD(v41) + (v43 << 7)); |
2745 LODWORD(v93) = v44 * 2; | |
2746 v45 = pTerrainNormalIndices[v44 + 1]; | |
2747 if ( v45 < 0 || v45 > (signed int)(uNumTerrainNormals - 1) ) | |
2748 v46 = 0; | |
2749 else | |
2750 v46 = &pTerrainNormals[v45]; | |
2751 pNormala = v46; | |
2752 if ( v46 ) | |
2753 { | |
2754 v47 = -(v97 * v46->z + v96 * v46->y + v95 * v46->x); | |
2755 if ( v47 < 0.0 ) | |
2756 v47 = 0.0; | |
2757 v88 = v47 * 31.0; | |
2758 v74 = v88 + 6.7553994e15; | |
2759 v87 = LODWORD(v74); | |
638 | 2760 v38->dimming_level = 31 - LOBYTE(v74); |
0 | 2761 } |
2762 else | |
2763 { | |
638 | 2764 v38->dimming_level = 0; |
2765 } | |
2766 if ( v38->dimming_level < 0 ) | |
2767 v38->dimming_level = 0; | |
0 | 2768 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2769 return; | |
2770 ++pOutdoorCamera->numStru148s; | |
2771 if ( !sub_481FC9((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) | |
2772 goto LABEL_74; | |
2773 v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2774 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2775 array_50AC10[0]._rhw = v48; |
0 | 2776 array_50AC10[0].u = 0.0; |
2777 array_50AC10[0].v = 0.0; | |
2778 v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2779 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
168 | 2780 array_50AC10[1]._rhw = 1.0 / v49; |
0 | 2781 array_50AC10[1].u = 0.0; |
2782 array_50AC10[1].v = 1.0; | |
2783 v50 = v103->vWorldViewPosition.x + 0.0000001; | |
2784 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
168 | 2785 array_50AC10[2]._rhw = 1.0 / v50; |
0 | 2786 array_50AC10[2].u = 1.0; |
2787 array_50AC10[2].v = 1.0; | |
2788 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0); | |
2789 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2790 { | |
2791 v38->field_108 = 0; | |
2792 } | |
2793 else | |
2794 { | |
2795 v51 = pGame; | |
2796 v38->field_108 = 1; | |
2797 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormala); | |
2798 } | |
2799 if ( v104->vWorldViewPosition.x < 8.0 | |
2800 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2801 || (v52 = v103, v103->vWorldViewPosition.x < 8.0) ) | |
2802 { | |
2803 v55 = sr_4250FE(3u); | |
2804 } | |
2805 else | |
2806 { | |
2807 v53 = (double)pOutdoorCamera->shading_dist_mist; | |
2808 if ( v53 >= v104->vWorldViewPosition.x | |
2809 && v53 >= *(float *)(HIDWORD(v101) + 12) | |
2810 && v53 >= v103->vWorldViewPosition.x ) | |
2811 { | |
2812 v54 = sr_4254D2(3); | |
2813 v38->uNumVertices = v54; | |
2814 if ( v54 ) | |
2815 { | |
2816 sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0); | |
2817 LABEL_68: | |
2818 sr_sub_481DB2(array_508690, v54, v38); | |
2819 LABEL_75: | |
2820 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2821 v57 = pOutdoor->GetTileTexture(v101, v100); | |
2822 v17->uTileBitmapID = v57; | |
2823 if ( v57 == -1 ) | |
2824 goto LABEL_105; | |
2825 *(int *)&v17->flags = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2826 v58 = v92; | |
2827 v17->field_59 = 1; | |
2828 v17->field_34 = v58->distance; | |
638 | 2829 v17->terrain_grid_z = v94; |
2830 v17->terrain_grid_x = LOBYTE(v99); | |
0 | 2831 v59 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + LODWORD(v93)); |
2832 if ( v59 > (signed int)(uNumTerrainNormals - 1) ) | |
2833 { | |
2834 pNormalb = 0; | |
2835 v60 = 0; | |
2836 } | |
2837 else | |
2838 { | |
2839 v60 = &pTerrainNormals[v59]; | |
2840 pNormalb = v60; | |
2841 } | |
2842 if ( v60 ) | |
2843 { | |
2844 v61 = -(v97 * v60->z + v96 * v60->y + v95 * v60->x); | |
2845 if ( v61 < 0.0 ) | |
2846 v61 = 0.0; | |
2847 v93 = v61 * 31.0; | |
2848 v72 = v93 + 6.7553994e15; | |
2849 v83 = LODWORD(v72); | |
638 | 2850 v17->dimming_level = 31 - LOBYTE(v72); |
0 | 2851 } |
2852 else | |
2853 { | |
638 | 2854 v17->dimming_level = 0; |
0 | 2855 } |
638 | 2856 if ( v17->dimming_level < 0 ) |
2857 v17->dimming_level = 0; | |
0 | 2858 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2859 return; | |
2860 ++pOutdoorCamera->numStru148s; | |
2861 if ( !sub_481FC9(v102, v104, v103, v17) ) | |
2862 { | |
2863 LABEL_104: | |
2864 --pOutdoorCamera->numStru148s; | |
2865 goto LABEL_105; | |
2866 } | |
2867 v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2868 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2869 array_50AC10[0]._rhw = v62; |
0 | 2870 array_50AC10[0].u = 0.0; |
2871 array_50AC10[0].v = 0.0; | |
2872 v63 = v103->vWorldViewPosition.x + 0.0000001; | |
2873 memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1])); | |
168 | 2874 array_50AC10[1]._rhw = 1.0 / v63; |
0 | 2875 array_50AC10[1].u = 1.0; |
2876 array_50AC10[1].v = 1.0; | |
2877 v64 = v102->vWorldViewPosition.x + 0.0000001; | |
2878 memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2])); | |
168 | 2879 array_50AC10[2]._rhw = 1.0 / v64; |
0 | 2880 array_50AC10[2].u = 1.0; |
2881 array_50AC10[2].v = 0.0; | |
2882 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1); | |
2883 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2884 { | |
2885 v17->field_108 = 0; | |
2886 } | |
2887 else | |
2888 { | |
2889 v65 = pGame; | |
2890 v17->field_108 = 1; | |
2891 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormalb); | |
2892 } | |
2893 if ( v104->vWorldViewPosition.x < 8.0 || v103->vWorldViewPosition.x < 8.0 || v102->vWorldViewPosition.x < 8.0 ) | |
2894 { | |
2895 v37 = sr_4250FE(3u); | |
2896 OutdoorCamera::Project(v37); | |
2897 if ( !v37 ) | |
2898 goto LABEL_104; | |
2899 goto LABEL_102; | |
2900 } | |
2901 v66 = (double)pOutdoorCamera->shading_dist_mist; | |
2902 if ( v66 < v104->vWorldViewPosition.x || v66 < v103->vWorldViewPosition.x || v66 < v102->vWorldViewPosition.x ) | |
2903 { | |
2904 v37 = sr_4252E8(3u); | |
2905 if ( !v37 ) | |
2906 goto LABEL_105; | |
2907 goto LABEL_41; | |
2908 } | |
2909 v33 = sr_4254D2(3); | |
2910 v17->uNumVertices = v33; | |
2911 if ( !v33 ) | |
2912 goto LABEL_104; | |
2913 v34 = v104; | |
2914 v35 = v102; | |
2915 v69 = 0; | |
2916 v68 = v17; | |
2917 v67 = v103; | |
2918 LABEL_37: | |
2919 sr_sub_4829B9(v35, v34, v67, v68, v69); | |
2920 LABEL_38: | |
2921 sr_sub_481DB2(array_508690, v33, v17); | |
2922 goto LABEL_105; | |
2923 } | |
2924 goto LABEL_74; | |
2925 } | |
2926 v55 = sr_4252E8(3u); | |
2927 } | |
2928 v56 = v55; | |
2929 if ( v55 ) | |
2930 { | |
2931 OutdoorCamera::Project(v55); | |
2932 v54 = sr_4254D2(v56); | |
2933 v38->uNumVertices = v54; | |
2934 if ( v54 ) | |
2935 { | |
2936 v38->_48276F_sr(); | |
2937 goto LABEL_68; | |
2938 } | |
2939 } | |
2940 LABEL_74: | |
2941 --pOutdoorCamera->numStru148s; | |
2942 goto LABEL_75; | |
2943 } | |
2944 } | |
2945 | |
2946 //----- (0047BACF) -------------------------------------------------------- | |
2947 void Render::TransformBillboardsAndSetPalettesODM() | |
2948 { | |
142 | 2949 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2950 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2951 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2952 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2953 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2954 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2955 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2956 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2957 //int v8; // ebx@4 |
0 | 2958 unsigned __int16 *v9; // eax@7 |
2959 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2960 //DWORD v11; // eax@13 |
0 | 2961 int v12; // eax@13 |
2962 int v13; // eax@14 | |
2963 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
2964 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 2965 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2966 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 2967 int v18; // [sp+60h] [bp-4h]@13 |
2968 | |
2969 billboard.uParentBillboardID = -1; | |
2970 billboard.pTarget = pRenderer->pTargetSurface; | |
2971 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
2972 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 2973 billboard.uViewportX = pViewport->uViewportTL_X; |
2974 billboard.uViewportY = pViewport->uViewportTL_Y; | |
2975 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
2976 billboard.uViewportW = pViewport->uViewportBR_Y; | |
0 | 2977 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; |
142 | 2978 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2979 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 2980 { |
143 | 2981 auto pBillboard = pBillboardRenderList + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2982 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2983 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2984 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2985 billboard.uParentBillboardID = i; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2986 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2987 billboard.uTintColor = pBillboard->uTintColor; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2988 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2989 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2990 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2991 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2992 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2993 if (pRenderer->pRenderD3D) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2994 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2995 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
657 | 2996 pBillboard->dimming_level, pBillboard); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2997 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2998 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2999 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3000 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3001 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 3002 if ( *(v1 - 10) & 2 ) |
3003 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
3004 else | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3005 v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 3006 v10 = (*(v1 - 9) & 1) == 0; |
3007 billboard.pPalette = v9; | |
3008 if ( !v10 ) | |
3009 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
3010 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
3011 { | |
323 | 3012 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 3013 v15 = abs(v12); |
3014 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
3015 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
3016 } | |
3017 v13 = *((short *)v1 - 8); | |
3018 if ( v13 >= 0 ) | |
733 | 3019 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3020 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3021 } |
0 | 3022 } |
3023 } | |
3024 | |
3025 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3026 void Render::DrawSpriteObjects_ODM() |
0 | 3027 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3028 //char *v0; // edi@2 |
430 | 3029 //ObjectDesc *v1; // ebx@4 |
0 | 3030 __int16 v2; // cx@5 |
3031 RenderBillboard *v3; // esi@10 | |
3032 SpriteFrame *v4; // eax@10 | |
430 | 3033 //SpriteFrame *v5; // ebx@10 |
0 | 3034 unsigned int v6; // eax@10 |
430 | 3035 //int v7; // ecx@10 |
3036 //int v8; // edx@10 | |
0 | 3037 int v9; // ecx@10 |
3038 unsigned __int16 v10; // ax@10 | |
430 | 3039 //int *v11; // eax@14 |
0 | 3040 int v12; // eax@22 |
3041 int v13; // ST3C_4@23 | |
3042 int v14; // eax@23 | |
3043 int v15; // ecx@23 | |
3044 int v16; // ebx@23 | |
3045 int v17; // ecx@25 | |
3046 int v18; // eax@25 | |
3047 int v19; // ST40_4@26 | |
3048 int v20; // ecx@26 | |
3049 int v21; // ST44_4@28 | |
3050 int v22; // ST3C_4@29 | |
3051 signed __int64 v23; // qtt@30 | |
3052 int v24; // ebx@30 | |
3053 int v25; // ST3C_4@30 | |
3054 int v26; // eax@31 | |
3055 char v27; // zf@31 | |
430 | 3056 //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 |
3057 //__int16 a5; // [sp+10h] [bp-30h]@10 | |
0 | 3058 int v30; // [sp+14h] [bp-2Ch]@23 |
3059 int v31; // [sp+14h] [bp-2Ch]@29 | |
3060 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
3061 int v33; // [sp+18h] [bp-28h]@23 | |
3062 int v34; // [sp+18h] [bp-28h]@26 | |
3063 int v35; // [sp+18h] [bp-28h]@30 | |
3064 int v36; // [sp+1Ch] [bp-24h]@10 | |
3065 int v37; // [sp+1Ch] [bp-24h]@23 | |
3066 int a6; // [sp+20h] [bp-20h]@10 | |
3067 int a6a; // [sp+20h] [bp-20h]@23 | |
3068 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3069 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 3070 int v42; // [sp+2Ch] [bp-14h]@23 |
3071 int y; // [sp+30h] [bp-10h]@10 | |
3072 int x; // [sp+34h] [bp-Ch]@10 | |
3073 int z; // [sp+38h] [bp-8h]@10 | |
3074 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
3075 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3076 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3077 for (int i = 0; i < uNumSpriteObjects; ++i) |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3078 { |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3079 auto object = pSpriteObjects + i; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3080 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3081 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3082 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3083 //{ |
430 | 3084 if (!object->uObjectDescID) // item probably pciked up |
3085 continue; | |
3086 | |
3087 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
3088 auto object_desc = pObjectList->pObjects + object->uObjectDescID; | |
3089 if (object_desc->NoSprite()) | |
3090 continue; | |
3091 | |
3092 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
3093 //if ( !(v1->uFlags & 1) ) | |
3094 //{ | |
3095 //v2 = *((short *)v0 - 14) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3096 v2 = object->uType; |
430 | 3097 if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) |
3098 { | |
3099 //a5 = *(short *)v0; | |
3100 x = object->vPosition.x; | |
3101 y = object->vPosition.y; | |
3102 z = object->vPosition.z; | |
3103 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; | |
3104 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
3105 //v5 = v4; | |
3106 //v28 = v4; | |
3107 v36 = v4->uFlags; | |
3108 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; | |
3109 v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCamera->pos.x, object->vPosition.y - pIndoorCamera->pos.y); | |
3110 //LOWORD(v7) = object->uFacing; | |
3111 //v8 = v36; | |
3112 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
3113 v10 = v4->pHwSpriteIDs[v9]; | |
0 | 3114 v3->uHwSpriteID = v10; |
3115 if ( v36 & 0x20 ) | |
3116 { | |
430 | 3117 //v8 = v36; |
3118 z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
0 | 3119 } |
3120 v46 = 0; | |
430 | 3121 if ( v36 & 2 ) |
0 | 3122 v46 = 2; |
430 | 3123 //v11 = (int *)(256 << v9); |
3124 if ( (256 << v9) & v36 ) | |
0 | 3125 v46 |= 4u; |
430 | 3126 if ( v36 & 0x40000 ) |
0 | 3127 v46 |= 0x40u; |
430 | 3128 if ( v36 & 0x20000 ) |
0 | 3129 LOBYTE(v46) = v46 | 0x80; |
3130 if ( a6 ) | |
3131 { | |
430 | 3132 //LOBYTE(v11) = byte_4E94D3; |
3133 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
0 | 3134 } |
3135 v12 = (x - pIndoorCamera->pos.x) << 16; | |
3136 if ( pIndoorCamera->sRotationX ) | |
3137 { | |
3138 v13 = (y - pIndoorCamera->pos.y) << 16; | |
3139 v30 = ((unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3140 + ((unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3141 v37 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3142 a6a = (unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3143 v33 = (z - pIndoorCamera->pos.z) << 16; | |
3144 v14 = (unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3145 v15 = (unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3146 v16 = v15 + v14; | |
3147 v42 = v15 + v14; | |
3148 if ( v15 + v14 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3149 { | |
3150 v17 = a6a - v37; | |
3151 v40 = a6a - v37; | |
3152 v18 = ((unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | |
3153 - ((unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3154 goto LABEL_29; | |
3155 } | |
3156 } | |
3157 else | |
3158 { | |
3159 v34 = (y - pIndoorCamera->pos.y) << 16; | |
3160 v19 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3161 v20 = (unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3162 v16 = v20 + v19; | |
3163 v42 = v20 + v19; | |
3164 if ( v20 + v19 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3165 { | |
430 | 3166 v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; |
3167 v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
3168 v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
0 | 3169 v18 = (z - pIndoorCamera->pos.z) << 16; |
3170 LABEL_29: | |
3171 v31 = v18; | |
3172 v22 = abs(v17); | |
3173 if ( abs(v16) >= v22 ) | |
3174 { | |
3175 LODWORD(v23) = 0; | |
3176 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3177 v24 = v23 / v42; | |
3178 v25 = v23 / v42; | |
3179 LODWORD(v23) = 0; | |
3180 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
430 | 3181 v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); |
3182 v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
3183 | |
3184 //if (::uNumBillboardsToDraw >= 500) | |
3185 // return; | |
3186 assert(::uNumBillboardsToDraw < 500); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3187 ++::uNumBillboardsToDraw; |
0 | 3188 ++uNumSpritesDrawnThisFrame; |
430 | 3189 |
3190 object->uAttributes |= 1; | |
3191 v3->uPalette = v4->uPaletteIndex; | |
3192 v3->uIndoorSectorID = object->uSectorID; | |
3193 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3194 v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3195 v3->pSpriteFrame = v4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3196 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 3197 v3->field_1E = v46; |
430 | 3198 v3->world_x = x; |
3199 v3->world_y = y; | |
3200 v3->world_z = z; | |
0 | 3201 v3->uScreenSpaceX = v35; |
3202 v3->uScreenSpaceY = v32; | |
3203 HIWORD(v26) = HIWORD(v42); | |
3204 LOWORD(v26) = 0; | |
430 | 3205 v27 = (object->uAttributes & 0x20) == 0; |
862 | 3206 v3->sZValue = v26 + (PID(OBJECT_Item,i)); |
657 | 3207 v3->dimming_level = 0; |
0 | 3208 v3->uTintColor = 0; |
3209 if ( !v27 ) | |
3210 { | |
3211 if ( !pRenderer->pRenderD3D ) | |
3212 v3->sZValue = 0; | |
3213 } | |
3214 } | |
3215 goto LABEL_34; | |
3216 } | |
3217 } | |
3218 } | |
430 | 3219 //} |
0 | 3220 LABEL_34: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3221 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3222 //++v41; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3223 //v0 += 112; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3224 //} |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3225 //while ( v41 < (signed int)uNumSpriteObjects ); |
0 | 3226 } |
3227 } | |
3228 // 4E94D3: using guessed type char byte_4E94D3; | |
3229 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; | |
3230 | |
3231 //----- (0049D9BC) -------------------------------------------------------- | |
3232 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
3233 { | |
3234 size_t v4; // eax@1 | |
3235 size_t v5; // eax@1 | |
3236 IUnknown *v6; // eax@10 | |
3237 size_t v7; // eax@13 | |
3238 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
3239 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
3240 int v11; // [sp+430h] [bp-CCh]@16 | |
3241 int v12; // [sp+434h] [bp-C8h]@16 | |
3242 int v13; // [sp+438h] [bp-C4h]@16 | |
3243 int v14; // [sp+474h] [bp-88h]@16*/ | |
3244 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
3245 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
3246 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
3247 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
3248 int v19; // [sp+4C8h] [bp-34h]@16 | |
3249 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
3250 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
3251 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
3252 | |
3253 v4 = strlen(lpDriverName); | |
3254 v20.pDriverName = new char[v4 + 1]; | |
3255 v5 = strlen(lpDevDesc); | |
3256 v20.pDeviceDesc = new char[v5 + 1]; | |
3257 strcpy(v20.pDriverName, lpDriverName); | |
3258 strcpy(v20.pDeviceDesc, lpDevDesc); | |
3259 if ( lpGUID ) | |
3260 { | |
3261 v20.pGUID = new GUID; | |
3262 memcpy(v20.pGUID, lpGUID, 0x10u); | |
3263 } | |
3264 else | |
3265 { | |
3266 v20.pGUID = 0; | |
3267 } | |
3268 | |
3269 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
3270 { | |
3271 delete [] v20.pDriverName; | |
3272 delete [] v20.pDeviceDesc; | |
3273 if ( v20.pGUID ) | |
3274 delete v20.pGUID; | |
3275 } | |
3276 else | |
3277 { | |
3278 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
3279 { | |
3280 delete [] v20.pDriverName; | |
3281 delete [] v20.pDeviceDesc; | |
3282 if ( v20.pGUID ) | |
3283 delete v20.pGUID; | |
3284 v6 = (IUnknown *)pDirectDraw; | |
3285 } | |
3286 else | |
3287 { | |
3288 pDirectDraw->Release(); | |
3289 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
3290 { | |
3291 v20.pDDraw4DevDesc = 0; | |
3292 } | |
3293 else | |
3294 { | |
3295 v7 = strlen(ddDevId.szDescription); | |
3296 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
3297 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
3298 } | |
3299 memset(&ddsCaps, 0, 0x10u); | |
3300 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
3301 &ddsCaps, | |
3302 (LPDWORD)&v20.uVideoMem, | |
3303 (LPDWORD)&uFreeVideoMem))) | |
3304 v20.uVideoMem = 0; | |
3305 memset(&v10, 0, 0x7Cu); | |
3306 v10.dwSize = 124; | |
3307 v10.dwFlags = 6; | |
3308 v10.dwHeight = 640; | |
3309 v10.dwWidth = 480; | |
3310 v10.ddpfPixelFormat.dwSize = 32; | |
3311 | |
3312 v19 = 0; | |
3313 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
3314 0, | |
3315 0, | |
3316 &v19, | |
3317 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
3318 || !v19 | |
3319 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
3320 { | |
3321 delete [] v20.pDriverName; | |
3322 delete [] v20.pDeviceDesc; | |
3323 if ( v20.pDDraw4DevDesc ) | |
3324 free(v20.pDDraw4DevDesc); | |
3325 if ( v20.pGUID ) | |
3326 delete v20.pGUID; | |
3327 v6 = (IUnknown *)pDirectDraw4; | |
3328 } | |
3329 else | |
3330 { | |
3331 aux.pInfo = pOut; | |
3332 aux.ptr_4 = &v20; | |
3333 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
3334 delete [] v20.pDriverName; | |
3335 delete [] v20.pDeviceDesc; | |
3336 if ( v20.pDDraw4DevDesc ) | |
3337 free(v20.pDDraw4DevDesc); | |
3338 if ( v20.pGUID ) | |
3339 delete v20.pGUID; | |
3340 pDirectDraw4->Release(); | |
3341 v6 = (IUnknown *)pDirect3D3; | |
3342 pDirectDraw4 = 0; | |
3343 } | |
3344 } | |
3345 v6->Release(); | |
3346 } | |
3347 return 1; | |
3348 } | |
3349 | |
3350 //----- (0049D784) -------------------------------------------------------- | |
3351 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
3352 { | |
3353 int v6; // eax@1 | |
3354 signed int v7; // edi@1 | |
3355 signed int v8; // edi@14 | |
3356 size_t v9; // eax@30 | |
3357 size_t v10; // eax@30 | |
3358 size_t v11; // eax@30 | |
3359 size_t v12; // eax@30 | |
3360 size_t v13; // eax@30 | |
3361 | |
3362 v6 = pHWDesc->dwFlags; | |
3363 v7 = -1; | |
3364 if ( v6 ) | |
3365 { | |
3366 if ( !a6->ptr_4->pGUID ) | |
3367 v7 = 0; | |
3368 if ( v6 && a6->ptr_4->pGUID ) | |
3369 v7 = 1; | |
3370 } | |
3371 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
3372 v7 = 2; | |
3373 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
3374 v7 = 3; | |
3375 if ( v7 != -1 ) | |
3376 { | |
3377 v8 = v7; | |
3378 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
3379 a6->pInfo[v8].uCaps = 0; | |
3380 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
3381 a6->pInfo[v8].uCaps |= 2u; | |
3382 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
3383 a6->pInfo[v8].uCaps |= 4u; | |
3384 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
3385 a6->pInfo[v8].uCaps |= 8u; | |
3386 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
3387 a6->pInfo[v8].uCaps |= 0x10u; | |
3388 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
3389 a6->pInfo[v8].uCaps |= 0x20u; | |
3390 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
3391 a6->pInfo[v8].uCaps |= 0x40u; | |
3392 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
3393 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
3394 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
3395 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
3396 v9 = strlen(lpDeviceName); | |
3397 a6->pInfo[v8].pName = new char[v9 + 1]; | |
3398 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
3399 v10 = strlen(lpDeviceDesc); | |
3400 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
3401 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
3402 a6->pInfo[v8].pGUID = (GUID *)operator new(0x10u); | |
3403 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); | |
3404 v11 = strlen(a6->ptr_4->pDriverName); | |
3405 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
3406 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
3407 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
3408 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
3409 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
3410 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
3411 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
3412 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
3413 if ( a6->ptr_4->pGUID ) | |
3414 { | |
3415 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
3416 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
3417 } | |
3418 else | |
3419 { | |
3420 a6->pInfo[v8].pDirectDrawGUID = 0; | |
3421 } | |
3422 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
3423 } | |
3424 return 1; | |
3425 } | |
3426 | |
3427 //----- (0049D75C) -------------------------------------------------------- | |
3428 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
3429 { | |
3430 HRESULT result; // eax@3 | |
3431 | |
3432 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
3433 { | |
3434 *a2 = 1; | |
3435 result = 0; | |
3436 } | |
3437 else | |
3438 { | |
3439 result = 1; | |
3440 } | |
3441 return result; | |
3442 } | |
3443 | |
3444 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3445 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3446 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3447 //char *v0; // esi@2 |
639 | 3448 //DecorationDesc *v1; // ebx@6 |
0 | 3449 __int16 v2; // ax@6 |
3450 double v3; // st7@7 | |
639 | 3451 //int v4; // eax@9 |
3452 //int v5; // edx@9 | |
0 | 3453 unsigned int v6; // edi@9 |
3454 int v7; // eax@9 | |
3455 SpriteFrame *v8; // eax@9 | |
635 | 3456 //SpriteFrame *v9; // edi@9 |
0 | 3457 unsigned __int16 *v10; // eax@9 |
3458 int v11; // ecx@9 | |
3459 int v12; // eax@9 | |
3460 int v13; // ecx@9 | |
3461 int v14; // ecx@20 | |
3462 char v15; // dl@20 | |
3463 signed int v16; // eax@20 | |
3464 int v17; // eax@23 | |
3465 int v18; // ecx@24 | |
3466 int v19; // eax@24 | |
3467 int v20; // ecx@24 | |
3468 int v21; // ebx@26 | |
3469 int v22; // eax@26 | |
3470 int v23; // eax@30 | |
3471 signed __int64 v24; // qtt@31 | |
3472 int v25; // ebx@31 | |
3473 int v26; // ecx@32 | |
3474 RenderBillboard *v27; // eax@37 | |
3475 __int16 v28; // dx@37 | |
3476 __int16 v29; // cx@37 | |
3477 int v30; // ecx@37 | |
3478 int v31; // ebx@37 | |
619 | 3479 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
639 | 3480 //int x; // [sp+74h] [bp-30h]@9 |
3481 //int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3482 //int v35; // [sp+7Ch] [bp-28h]@1 |
639 | 3483 //int v36; // [sp+80h] [bp-24h]@9 |
0 | 3484 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
3485 int v38; // [sp+88h] [bp-1Ch]@9 | |
3486 int v39; // [sp+8Ch] [bp-18h]@24 | |
3487 int v40; // [sp+90h] [bp-14h]@24 | |
3488 int v41; // [sp+94h] [bp-10h]@24 | |
3489 int v42; // [sp+98h] [bp-Ch]@9 | |
3490 int a5; // [sp+9Ch] [bp-8h]@9 | |
3491 int b; // [sp+A0h] [bp-4h]@22 | |
3492 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3493 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3494 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3495 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3496 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3497 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3498 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3499 { |
635 | 3500 auto decor = pLevelDecorations + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3501 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3502 |
639 | 3503 if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) ) |
3504 { | |
3505 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
3506 auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; | |
3507 v2 = decor_desc->uFlags; | |
0 | 3508 if ( (char)v2 >= 0 ) |
3509 { | |
3510 if ( !(v2 & 0x22) ) | |
3511 { | |
639 | 3512 //v4 = decor->vPosition.x; |
3513 //v5 = decor->vPosition.z; | |
0 | 3514 v6 = pMiscTimer->uTotalGameTimeElapsed; |
639 | 3515 //y = decor->vPosition.y; |
3516 //x = decor->vPosition.x; | |
3517 //v36 = decor->vPosition.z; | |
3518 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
635 | 3519 |
3520 | |
3521 #pragma region "New: seasons change" | |
3522 extern bool change_seasons; | |
3523 if (change_seasons) | |
3524 switch (pParty->uCurrentMonth) | |
3525 { | |
3526 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
3527 case 11: case 0: case 1: // winter | |
639 | 3528 switch (decor_desc->uSpriteID) |
635 | 3529 { |
3530 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3531 case 548: // flower10 | |
3532 case 547: // flower09 | |
3533 case 541: // flower03 | |
3534 case 539: continue; // flower01 | |
3535 | |
3536 case 483: // tree01 | |
3537 case 486: // tree04 | |
3538 case 492: // tree10 | |
639 | 3539 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); |
3540 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
635 | 3541 break; |
3542 | |
3543 default: | |
639 | 3544 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3545 } |
3546 break; | |
3547 | |
3548 case 2: case 3: case 4: // spring | |
639 | 3549 switch (decor_desc->uSpriteID) |
635 | 3550 { |
3551 } | |
639 | 3552 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3553 break; |
3554 | |
3555 case 8: case 9: case 10: // autumn | |
639 | 3556 switch (decor_desc->uSpriteID) |
635 | 3557 { |
3558 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3559 case 548: // flower10 | |
3560 case 547: // flower09 | |
3561 case 541: // flower03 | |
3562 case 539: continue; // flower01 | |
3563 | |
3564 case 483: // tree01 | |
3565 case 486: // tree04 | |
3566 case 492: // tree10 | |
639 | 3567 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); |
3568 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
635 | 3569 break; |
3570 | |
3571 default: | |
639 | 3572 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3573 } |
3574 break; | |
3575 | |
3576 case 5: case 6: case 7: // summer | |
3577 //all green by default | |
639 | 3578 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3579 break; |
3580 | |
3581 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
3582 } | |
637 | 3583 else |
639 | 3584 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3585 #pragma endregion |
639 | 3586 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3587 |
3588 //v9 = v8; | |
0 | 3589 v42 = v8->uFlags; |
3590 a5 = v8->uGlowRadius; | |
639 | 3591 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, |
3592 decor->vPosition.y - pIndoorCamera->pos.y); | |
0 | 3593 v11 = *((int *)v0 + 2); |
3594 v37 = v10; | |
3595 v12 = v42; | |
3596 v38 = 0; | |
3597 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
3598 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
3599 + v11 | |
3600 - (signed int)v37) >> 8) & 7; | |
3601 v37 = (unsigned __int16 *)v13; | |
3602 if ( v42 & 2 ) | |
3603 v38 = 2; | |
3604 if ( (256 << v13) & v42 ) | |
3605 v38 |= 4u; | |
3606 if ( v12 & 0x40000 ) | |
3607 v38 |= 0x40u; | |
3608 if ( v12 & 0x20000 ) | |
3609 LOBYTE(v38) = v38 | 0x80; | |
3610 if ( a5 ) | |
3611 { | |
3612 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) | |
3613 { | |
639 | 3614 v14 = decor_desc->uColoredLightRed; |
3615 v15 = decor_desc->uColoredLightGreen; | |
3616 v16 = decor_desc->uColoredLightBlue; | |
0 | 3617 } |
3618 else | |
3619 { | |
3620 v16 = 255; | |
3621 v14 = 255; | |
3622 v15 = 255; | |
3623 } | |
3624 b = v16; | |
3625 pStationaryLightsStack->AddLight( | |
639 | 3626 decor->vPosition.x, |
3627 decor->vPosition.y, | |
3628 decor->vPosition.z + decor_desc->uDecorationHeight / 2, | |
0 | 3629 a5, |
3630 v14, | |
3631 v15, | |
3632 v16, | |
3633 byte_4E94D0); | |
3634 } | |
639 | 3635 v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
0 | 3636 if ( pIndoorCamera->sRotationX ) |
3637 { | |
639 | 3638 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; |
0 | 3639 v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) |
3640 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3641 v42 = v18; | |
3642 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3643 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
639 | 3644 v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3645 v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; |
3646 v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3647 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3648 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3649 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3650 { | |
3651 v21 = a5 - b; | |
3652 v41 = a5 - b; | |
3653 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3654 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3655 v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; | |
3656 LABEL_30: | |
3657 v42 = v22; | |
3658 v40 = 2 * abs(v20); | |
3659 v23 = abs(v21); | |
3660 if ( v40 >= v23 ) | |
3661 { | |
3662 LODWORD(v24) = 0; | |
3663 HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3664 a5 = v24 / v39; | |
3665 v25 = pViewport->uScreenCenterX | |
3666 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
3667 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
3668 v41 = v24 / v39; | |
3669 v40 = pViewport->uScreenCenterY | |
3670 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
635 | 3671 v42 = v8->scale; |
0 | 3672 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; |
635 | 3673 v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; |
0 | 3674 if ( pRenderer->pRenderD3D ) |
3675 { | |
3676 v26 = v41; | |
3677 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
3678 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3679 } | |
3680 else | |
3681 { | |
3682 v26 = v41; | |
3683 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
3684 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3685 } | |
693 | 3686 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
0 | 3687 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3688 if (::uNumBillboardsToDraw >= 500) |
0 | 3689 return; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3690 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; |
0 | 3691 ++uNumDecorationsDrawnThisFrame; |
3692 v27->uHwSpriteID = *v37; | |
635 | 3693 v28 = v8->uPaletteIndex; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3694 v27->_screenspace_x_scaler_packedfloat = v26; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3695 v27->_screenspace_y_scaler_packedfloat = v26; |
0 | 3696 v29 = v38; |
3697 v27->uScreenSpaceX = v25; | |
3698 HIBYTE(v29) |= 2u; | |
3699 v27->uPalette = v28; | |
3700 v27->field_1E = v29; | |
639 | 3701 v27->world_x = decor->vPosition.x; |
3702 v27->world_y = decor->vPosition.y; | |
3703 v27->world_z = decor->vPosition.z; | |
0 | 3704 v27->uScreenSpaceY = v40; |
3705 HIWORD(v30) = HIWORD(v39); | |
862 | 3706 v31 = PID(OBJECT_Decoration,i); |
0 | 3707 LOWORD(v30) = 0; |
3708 v27->uIndoorSectorID = 0; | |
3709 v27->sZValue = v30 + v31; | |
657 | 3710 v27->dimming_level = 0; |
635 | 3711 v27->pSpriteFrame = v8; |
0 | 3712 v27->uTintColor = 0; |
3713 } | |
3714 } | |
3715 goto LABEL_38; | |
3716 } | |
3717 } | |
3718 else | |
3719 { | |
639 | 3720 v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
3721 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; | |
0 | 3722 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; |
3723 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3724 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3725 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3726 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3727 { | |
3728 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3729 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3730 v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
3731 v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
639 | 3732 v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3733 goto LABEL_30; |
3734 } | |
3735 } | |
3736 } | |
3737 } | |
3738 else | |
3739 { | |
3740 memset(&local_0, 0, 0x68u); | |
3741 v3 = (double)*((signed int *)v0 - 1); | |
619 | 3742 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
3743 local_0.uDiffuse = 0xFF3C1E; | |
0 | 3744 local_0.x = v3; |
3745 local_0.y = (double)*(signed int *)v0; | |
3746 local_0.z = (double)*((signed int *)v0 + 1); | |
3747 local_0.flt_10 = 0.0; | |
3748 local_0.flt_14 = 0.0; | |
3749 local_0.flt_18 = 0.0; | |
3750 local_0.flt_28 = 1.0; | |
3751 local_0.timeToLive = (rand() & 0x80) + 128; | |
3752 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
3753 pGame->pParticleEngine->AddParticle(&local_0); | |
3754 } | |
3755 } | |
3756 LABEL_38: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3757 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3758 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3759 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3760 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3761 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 3762 } |
3763 // 4E94D0: using guessed type char byte_4E94D0; | |
3764 // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; | |
3765 | |
3766 //----- (0049D717) -------------------------------------------------------- | |
3767 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
3768 { | |
3769 HRESULT v2; // esi@2 | |
3770 | |
3771 if ( Src->dwFlags & 0x400 | 0x2000 ) | |
3772 { | |
3773 v2 = 0; | |
3774 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
3775 goto LABEL_6; | |
3776 if ( !Dst->dwSize ) | |
3777 { | |
3778 v2 = 1; | |
3779 LABEL_6: | |
3780 memcpy(Dst, Src, 0x20u); | |
3781 return v2; | |
3782 } | |
3783 } | |
3784 return 1; | |
3785 } | |
3786 | |
3787 //----- (0049DC28) -------------------------------------------------------- | |
3788 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
3789 { | |
3790 RenderD3D__DevInfo *v2; // eax@1 | |
3791 | |
3792 v2 = new RenderD3D__DevInfo[4];// 4 items | |
3793 *pOutDevices = v2; | |
3794 memset(v2, 0, 0xA0u); | |
3795 DirectDrawEnumerateA((LPDDENUMCALLBACKA)RenderD3D__DeviceEnumerator, *pOutDevices); | |
3796 } | |
3797 | |
3798 //----- (0049DC58) -------------------------------------------------------- | |
3799 RenderD3D::RenderD3D() | |
3800 { | |
3801 RenderD3D *v1; // esi@1 | |
3802 | |
3803 v1 = this; | |
3804 this->pHost = 0; | |
3805 this->pDirect3D = 0; | |
3806 this->pUnk = 0; | |
3807 this->pBackBuffer = 0; | |
3808 this->pFrontBuffer = 0; | |
3809 this->pZBuffer = 0; | |
3810 this->pDevice = 0; | |
3811 this->pViewport = 0; | |
3812 this->field_40 = 1; | |
3813 this->field_44 = 10; | |
3814 GetAvailableDevices(&this->pAvailableDevices); | |
3815 } | |
3816 | |
3817 //----- (0049DC90) -------------------------------------------------------- | |
3818 void RenderD3D::Release() | |
3819 { | |
3820 RenderD3D *v1; // esi@1 | |
3821 IDirectDraw4 *v2; // eax@2 | |
3822 signed int v3; // edi@4 | |
3823 IDirect3DViewport3 *v4; // eax@22 | |
3824 IUnknown *v5; // eax@24 | |
3825 IDirectDrawSurface4 *v6; // eax@26 | |
3826 IDirect3DDevice3 *v7; // eax@28 | |
3827 IDirect3D3 *v8; // eax@30 | |
3828 IDirectDrawSurface4 *v9; // eax@32 | |
3829 IDirectDrawSurface4 *v10; // eax@34 | |
3830 IDirectDraw4 *v11; // eax@36 | |
3831 | |
3832 v1 = this; | |
3833 if ( !this->bWindowed ) | |
3834 { | |
3835 v2 = this->pHost; | |
3836 if ( v2 ) | |
3837 { | |
3838 v2->RestoreDisplayMode(); | |
3839 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
3840 v1->pHost->FlipToGDISurface(); | |
3841 } | |
3842 } | |
3843 v3 = 0; | |
3844 do | |
3845 { | |
3846 if ( v1->pAvailableDevices[v3].pDriverName ) | |
3847 { | |
3848 free(v1->pAvailableDevices[v3].pDriverName); | |
3849 v1->pAvailableDevices[v3].pDriverName = 0; | |
3850 } | |
3851 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
3852 { | |
3853 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
3854 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
3855 } | |
3856 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
3857 { | |
3858 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
3859 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
3860 } | |
3861 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
3862 { | |
3863 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
3864 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
3865 } | |
3866 if ( v1->pAvailableDevices[v3].pName ) | |
3867 { | |
3868 free(v1->pAvailableDevices[v3].pName); | |
3869 v1->pAvailableDevices[v3].pName = 0; | |
3870 } | |
3871 if ( v1->pAvailableDevices[v3].pDescription ) | |
3872 { | |
3873 free(v1->pAvailableDevices[v3].pDescription); | |
3874 v1->pAvailableDevices[v3].pDescription = 0; | |
3875 } | |
3876 if ( v1->pAvailableDevices[v3].pGUID ) | |
3877 { | |
3878 free(v1->pAvailableDevices[v3].pGUID); | |
3879 v1->pAvailableDevices[v3].pGUID = 0; | |
3880 } | |
3881 ++v3; | |
3882 } | |
3883 while ( v3 < 4 ); | |
3884 if ( v1->pAvailableDevices ) | |
3885 { | |
3886 free(v1->pAvailableDevices); | |
3887 v1->pAvailableDevices = 0; | |
3888 } | |
3889 v4 = v1->pViewport; | |
3890 if ( v4 ) | |
3891 { | |
3892 v4->Release(); | |
3893 v1->pViewport = 0; | |
3894 } | |
3895 v5 = v1->pUnk; | |
3896 if ( v5 ) | |
3897 { | |
3898 v5->Release(); | |
3899 v1->pUnk = 0; | |
3900 } | |
3901 v6 = v1->pZBuffer; | |
3902 if ( v6 ) | |
3903 { | |
3904 v6->Release(); | |
3905 v1->pZBuffer = 0; | |
3906 } | |
3907 v7 = v1->pDevice; | |
3908 if ( v7 ) | |
3909 { | |
3910 v7->Release(); | |
3911 v1->pDevice = 0; | |
3912 } | |
3913 v8 = v1->pDirect3D; | |
3914 if ( v8 ) | |
3915 { | |
3916 v8->Release(); | |
3917 v1->pDirect3D = 0; | |
3918 } | |
3919 v9 = v1->pBackBuffer; | |
3920 if ( v9 ) | |
3921 { | |
3922 v9->Release(); | |
3923 v1->pBackBuffer = 0; | |
3924 } | |
3925 v10 = v1->pFrontBuffer; | |
3926 if ( v10 ) | |
3927 { | |
3928 v10->Release(); | |
3929 v1->pFrontBuffer = 0; | |
3930 } | |
3931 v11 = v1->pHost; | |
3932 if ( v11 ) | |
3933 { | |
3934 v11->Release(); | |
3935 v1->pHost = 0; | |
3936 } | |
3937 } | |
3938 | |
3939 //----- (0049DE14) -------------------------------------------------------- | |
3940 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | |
3941 { | |
3942 //IDirectDraw4 *v8; // eax@12 | |
3943 //IDirectDraw4 *v9; // eax@16 | |
3944 //IDirectDraw4 *v10; // eax@20 | |
3945 //IDirectDraw4 *v13; // eax@35 | |
3946 const char *v23; // [sp-4h] [bp-DCh]@9 | |
3947 const char *v24; // [sp-4h] [bp-DCh]@13 | |
3948 const char *v25; // [sp-4h] [bp-DCh]@19 | |
3949 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
3950 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
3951 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
3952 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
3953 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
3954 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
3955 | |
3956 this->bWindowed = bWindowed; | |
3957 this->hWindow = hWnd; | |
3958 | |
3959 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
3960 { | |
3961 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
3962 return 0; | |
3963 } | |
3964 | |
3965 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
3966 { | |
3967 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
3968 if (lpDD) | |
3969 lpDD->Release(); | |
3970 return 0; | |
3971 } | |
3972 lpDD->Release(); | |
3973 lpDD = 0; | |
3974 | |
3975 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
3976 { | |
3977 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
3978 { | |
3979 v23 = "Init - Failed to set cooperative level.\n"; | |
3980 sprintf(pErrorMessage, v23); | |
3981 LABEL_65: | |
3982 if (pHost) | |
3983 { | |
3984 pHost->Release(); | |
3985 pHost = 0; | |
3986 } | |
3987 return 0; | |
3988 } | |
3989 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
3990 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3991 ddsd2.dwFlags = DDSD_CAPS; | |
3992 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
3993 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
3994 { | |
3995 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3996 pHost->GetDisplayMode(&ddsd2); | |
3997 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
3998 { | |
3999 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
4000 goto LABEL_14; | |
4001 } | |
4002 | |
4003 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
4004 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
4005 ddsd2.dwWidth = 640; | |
4006 ddsd2.dwHeight = 480; | |
4007 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | |
4008 { | |
4009 v24 = "Init - Failed to create back buffer.\n"; | |
4010 LABEL_14: | |
4011 sprintf(pErrorMessage, v24); | |
4012 if (pFrontBuffer) | |
4013 { | |
4014 pFrontBuffer->Release(); | |
4015 pFrontBuffer = 0; | |
4016 } | |
4017 goto LABEL_65; | |
4018 } | |
4019 if ( pHost->CreateClipper(0, &v30, 0) ) | |
4020 { | |
4021 v25 = "Init - Failed to create clipper.\n"; | |
4022 goto LABEL_45; | |
4023 } | |
4024 v30->SetHWnd(0, hWnd); | |
4025 pFrontBuffer->SetClipper(v30); | |
4026 | |
4027 v30->Release(); | |
4028 v30 = 0; | |
4029 | |
4030 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4031 | |
4032 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4033 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4034 ddsd2.dwWidth = 640; | |
4035 ddsd2.dwHeight = 480; | |
4036 | |
4037 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4038 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4039 &ddsd2.ddpfPixelFormat) ) | |
4040 goto LABEL_21; | |
4041 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4042 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
4043 | |
4044 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4045 { | |
4046 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
4047 { | |
4048 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4049 pBackBuffer, | |
4050 &pDevice, | |
4051 0) ) | |
4052 { | |
4053 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4054 d3dvp2.dvClipWidth = 2.0; | |
4055 d3dvp2.dvClipY = 1.0; | |
4056 d3dvp2.dvClipHeight = 2.0; | |
4057 d3dvp2.dvMaxZ = 1.0; | |
4058 d3dvp2.dvMinZ = 0.0; | |
4059 goto LABEL_54; | |
4060 } | |
4061 LABEL_51: | |
4062 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
4063 if (pDirect3D) | |
4064 { | |
4065 pDirect3D->Release(); | |
4066 pDirect3D = 0; | |
4067 } | |
4068 goto LABEL_59; | |
4069 } | |
4070 LABEL_48: | |
4071 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
4072 if (pZBuffer) | |
4073 { | |
4074 pZBuffer->Release(); | |
4075 pZBuffer = 0; | |
4076 } | |
4077 goto LABEL_61; | |
4078 } | |
4079 goto LABEL_44; | |
4080 } | |
4081 LABEL_36: | |
4082 v23 = "Init - Failed to create front buffer.\n"; | |
4083 sprintf(pErrorMessage, v23); | |
4084 goto LABEL_65; | |
4085 } | |
4086 if ( uDeviceID == 1 ) | |
4087 v26 = 1045; | |
4088 else | |
4089 v26 = 1041; | |
4090 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
4091 { | |
4092 v23 = "Init - Failed to set cooperative level.\n"; | |
4093 sprintf(pErrorMessage, v23); | |
4094 goto LABEL_65; | |
4095 } | |
4096 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
4097 { | |
4098 v23 = "Init - Failed to set display mode.\n"; | |
4099 sprintf(pErrorMessage, v23); | |
4100 goto LABEL_65; | |
4101 } | |
4102 | |
4103 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
4104 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
4105 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4106 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
4107 ddsd2.dwBackBufferCount = 1; | |
4108 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
4109 goto LABEL_36; | |
4110 //a3a = &pBackBuffer; | |
4111 //v14 = *v34; | |
4112 memset(&v27, 0, sizeof(DDSCAPS2)); | |
4113 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
4114 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
4115 //hWnda = &pDirect3D; | |
4116 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4117 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
4118 { | |
4119 v25 = "Init - Failed to get D3D interface.\n"; | |
4120 goto LABEL_45; | |
4121 } | |
4122 | |
4123 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4124 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4125 ddsd2.dwWidth = 640; | |
4126 ddsd2.dwHeight = 480; | |
4127 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4128 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4129 &ddsd2.ddpfPixelFormat) ) | |
4130 { | |
4131 LABEL_21: | |
4132 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
4133 goto LABEL_45; | |
4134 } | |
4135 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4136 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
4137 //uDeviceIDa = &pZBuffer; | |
4138 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4139 { | |
4140 LABEL_44: | |
4141 v25 = "Init - Failed to create z-buffer.\n"; | |
4142 LABEL_45: | |
4143 sprintf(pErrorMessage, v25); | |
4144 if (pBackBuffer) | |
4145 { | |
4146 pBackBuffer->Release(); | |
4147 pBackBuffer = 0; | |
4148 } | |
4149 LABEL_63: | |
4150 //v19 = &pFrontBuffer; | |
4151 if (pFrontBuffer) | |
4152 { | |
4153 pFrontBuffer->Release(); | |
4154 pFrontBuffer= 0; | |
4155 } | |
4156 goto LABEL_65; | |
4157 } | |
4158 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
4159 goto LABEL_48; | |
4160 //v33 = &pDevice; | |
4161 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4162 pBackBuffer, | |
4163 &pDevice, | |
4164 0) ) | |
4165 goto LABEL_51; | |
4166 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4167 d3dvp2.dvClipWidth = 2.0; | |
4168 d3dvp2.dvClipY = 1.0; | |
4169 d3dvp2.dvClipHeight = 2.0; | |
4170 d3dvp2.dvMaxZ = 1.0; | |
4171 | |
4172 LABEL_54: | |
4173 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
4174 //v17 = *hWnda; | |
4175 d3dvp2.dwWidth = 640; | |
4176 d3dvp2.dwHeight = 480; | |
4177 d3dvp2.dvClipX = -1.0; | |
4178 //v18 = v17->lpVtbl; | |
4179 //v32 = &v4->pViewport; | |
4180 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
4181 { | |
4182 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
4183 if (pDevice) | |
4184 { | |
4185 pDevice->Release(); | |
4186 pDevice = 0; | |
4187 } | |
4188 if (pDirect3D) | |
4189 { | |
4190 pDirect3D->Release(); | |
4191 pDirect3D = 0; | |
4192 } | |
4193 LABEL_59: | |
4194 if (pZBuffer) | |
4195 { | |
4196 pZBuffer->Release(); | |
4197 pZBuffer = 0; | |
4198 } | |
4199 LABEL_61: | |
4200 if (pBackBuffer) | |
4201 { | |
4202 pBackBuffer->Release(); | |
4203 pBackBuffer = 0; | |
4204 } | |
4205 goto LABEL_63; | |
4206 } | |
4207 | |
4208 pDevice->AddViewport(pViewport); | |
4209 pViewport->SetViewport2(&d3dvp2); | |
4210 pDevice->SetCurrentViewport(pViewport); | |
4211 return 1; | |
4212 } | |
4213 | |
4214 //----- (0049E444) -------------------------------------------------------- | |
4215 unsigned int RenderD3D::GetDeviceCaps() | |
4216 { | |
4217 unsigned int v1; // ebx@1 | |
4218 RenderD3D *v2; // edi@1 | |
4219 IDirect3DDevice3 *v3; // eax@1 | |
4220 unsigned int result; // eax@2 | |
4221 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
4222 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
4223 | |
4224 v1 = 0; | |
4225 v2 = this; | |
4226 memset(&halCaps, 0, 0xFCu); | |
4227 halCaps.dwSize = 252; | |
4228 memset(&refCaps, 0, 0xFCu); | |
4229 v3 = v2->pDevice; | |
4230 refCaps.dwSize = 252; | |
4231 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
4232 { | |
4233 result = 1; | |
4234 } | |
4235 else | |
4236 { | |
4237 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
4238 v1 = 2; | |
4239 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
4240 v1 |= 4u; | |
4241 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
4242 v1 |= 8u; | |
4243 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
4244 v1 |= 0x10u; | |
4245 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
4246 v1 |= 0x20u; | |
4247 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
4248 v1 |= 0x40u; | |
4249 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
4250 LOBYTE(v1) = v1 | 0x80; | |
4251 result = v1; | |
4252 } | |
4253 return result; | |
4254 } | |
4255 | |
4256 //----- (0049E4FC) -------------------------------------------------------- | |
4257 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
4258 { | |
4259 uint uClearFlags = 0; | |
4260 | |
4261 if (bClearColor) | |
4262 uClearFlags |= D3DCLEAR_TARGET; | |
4263 if (bClearDepth) | |
4264 uClearFlags |= D3DCLEAR_ZBUFFER; | |
4265 | |
4266 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
4267 if (uClearFlags) | |
4268 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
4269 } | |
4270 | |
4271 //----- (0049E54D) -------------------------------------------------------- | |
4272 void RenderD3D::Present(bool bForceBlit) | |
4273 { | |
4274 RECT v5; // [sp+18h] [bp-18h]@1 | |
4275 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
4276 | |
4277 v5.left = 0; | |
4278 v5.top = 0; | |
4279 v5.bottom = 480; | |
4280 v5.right = 640; | |
4281 | |
4282 if (bWindowed || bForceBlit) | |
4283 { | |
4284 RECT rc; | |
4285 GetClientRect(hWindow, &rc); | |
4286 Point.y = 0; | |
4287 Point.x = 0; | |
4288 ClientToScreen(hWindow, &Point); | |
4289 OffsetRect(&rc, Point.x, Point.y); | |
4290 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
4291 } | |
4292 else | |
4293 pFrontBuffer->Flip(0, 1); | |
4294 } | |
4295 | |
4296 //----- (0049E5D4) -------------------------------------------------------- | |
4297 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
4298 { | |
4299 unsigned int v8; // edx@4 | |
4300 unsigned int v9; // ebx@5 | |
4301 unsigned int v10; // eax@5 | |
4302 DWORD v11; // edx@5 | |
4303 //int v12; // edx@7 | |
4304 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
4305 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
4306 | |
4307 //v15 = this; | |
4308 memset(&ddsd2, 0, 0x7Cu); | |
4309 ddsd2.dwSize = 0x7Cu; | |
4310 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4311 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
4312 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
4313 ddsd2.dwHeight = uTextureHeight; | |
4314 ddsd2.dwWidth = uTextureWidth; | |
4315 if ( bMipmaps ) | |
4316 { | |
4317 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
4318 { | |
4319 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
4320 LABEL_8: | |
4321 ddsd2.dwMipMapCount = v8; | |
4322 if ( !v8 ) | |
4323 goto LABEL_12; | |
4324 goto LABEL_11; | |
4325 } | |
4326 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
4327 { | |
4328 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
4329 goto LABEL_8; | |
4330 } | |
4331 v9 = GetMaxMipLevels(uTextureWidth); | |
4332 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
4333 ddsd2.dwMipMapCount = v9 - v10; | |
4334 if ( v9 == v10 ) | |
4335 { | |
4336 ddsd2.dwFlags = 0x1007u; | |
4337 ddsd2.ddsCaps.dwCaps = v11; | |
4338 goto LABEL_12; | |
4339 } | |
4340 } | |
4341 else | |
4342 { | |
4343 ddsd2.dwMipMapCount = 1; | |
4344 } | |
4345 LABEL_11: | |
4346 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
4347 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
4348 LABEL_12: | |
4349 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
4350 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
4351 if (bAlphaChannel) | |
4352 { | |
4353 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
4354 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
4355 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
4356 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4357 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
4358 } | |
4359 else | |
4360 { | |
4361 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
4362 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
4363 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
4364 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4365 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
4366 } | |
4367 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
4368 return false; | |
4369 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
4370 { | |
4371 (*pOutSurface)->Release(); | |
4372 *pOutSurface = 0; | |
4373 return false; | |
4374 } | |
4375 return true; | |
4376 } | |
4377 | |
4378 //----- (004A5190) -------------------------------------------------------- | |
4379 void RenderD3D::HandleLostResources() | |
4380 { | |
4381 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
4382 pBitmaps_LOD->_410423_move_textures_to_device(); | |
4383 pSprites_LOD->ReleaseLostHardwareSprites(); | |
4384 } | |
4385 | |
4386 //----- (004A2050) -------------------------------------------------------- | |
4387 void Render::DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) | |
4388 { | |
4389 Render *v5; // edi@1 | |
4390 unsigned int v6; // ebx@1 | |
4391 LightmapBuilder *v7; // esi@3 | |
4392 int v8; // eax@7 | |
4393 ODMFace *v9; // eax@12 | |
4394 char *v10; // esi@12 | |
4395 double v11; // st7@14 | |
4396 double v12; // st7@14 | |
4397 int v13; // eax@14 | |
4398 ODMFace *v14; // ecx@14 | |
4399 double v15; // st7@14 | |
4400 float v16; // ST48_4@15 | |
4401 int v17; // eax@15 | |
4402 char v18; // zf@17 | |
4403 HRESULT v19; // eax@18 | |
4404 HRESULT v20; // eax@18 | |
4405 HRESULT v21; // eax@20 | |
4406 HRESULT v22; // eax@20 | |
4407 unsigned int v23; // ecx@20 | |
4408 char *v24; // eax@21 | |
4409 HRESULT v25; // eax@23 | |
4410 HRESULT v26; // eax@23 | |
4411 HRESULT v27; // eax@24 | |
4412 HRESULT v28; // eax@25 | |
4413 HRESULT v29; // eax@25 | |
4414 HRESULT v30; // eax@25 | |
4415 HRESULT v31; // eax@25 | |
4416 HRESULT v32; // eax@26 | |
4417 unsigned int v33; // ecx@26 | |
4418 char *v34; // eax@27 | |
4419 int v35; // edx@28 | |
4420 HRESULT v36; // eax@29 | |
4421 HRESULT v37; // eax@29 | |
4422 HRESULT v38; // eax@29 | |
4423 HRESULT v39; // eax@29 | |
4424 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
4425 unsigned int v41; // eax@29 | |
4426 HRESULT v42; // eax@30 | |
4427 HRESULT v43; // eax@30 | |
4428 HRESULT v44; // eax@30 | |
4429 char *v45; // esi@34 | |
4430 int v46; // ecx@35 | |
4431 double v47; // st6@35 | |
4432 int v48; // eax@36 | |
4433 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
4434 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
4435 int v51; // [sp+50h] [bp-18h]@0 | |
4436 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
4437 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
4438 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
4439 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
4440 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
4441 int v57; // [sp+60h] [bp-8h]@34 | |
638 | 4442 unsigned int a2; // [sp+64h] [bp-4h]@4 |
0 | 4443 |
4444 v5 = this; | |
4445 v6 = 0; | |
4446 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
4447 { | |
4448 v7 = pGame->pLightmapBuilder; | |
4449 v53 = v7; | |
4450 v54 = v7->std__vector_000004_size; | |
4451 if ( v7->std__vector_000004_size) | |
638 | 4452 a2 = 0xFFFFFFFF; |
4453 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 4454 if ( byte_4D864C && pGame->uFlags & 1 ) |
4455 { | |
638 | 4456 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
0 | 4457 v7->_45D74F_MessWithLight(v8, 0); |
4458 } | |
4459 else | |
4460 { | |
4461 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
4462 { | |
323 | 4463 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4464 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
4465 if (bUsingSpecular) | |
4466 { | |
186 | 4467 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
4468 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4469 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4470 } |
4471 if ( (signed int)uNumVertices > 0 ) | |
4472 { | |
4473 v45 = (char *)&array_50AC10[0].vWorldViewPosition; | |
186 | 4474 v57 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 4475 v55 = uNumVertices; |
4476 do | |
4477 { | |
638 | 4478 a2 = ::GetActorTintColor(a3->dimming_level, 0, *(float *)v45, 0, 0); |
4479 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 4480 v46 = v57; |
4481 v47 = *(float *)v45 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
4482 *(int *)(v57 - 4) = *((int *)v45 + 3); | |
4483 *(int *)v57 = *((int *)v45 + 4); | |
4484 *(int *)(v57 + 12) = a2; | |
4485 *(float *)(v57 + 4) = 1.0 - 1.0 / v47; | |
4486 *(float *)(v57 + 8) = 1.0 / (*(float *)v45 + 0.0000001); | |
4487 if ( v5->bUsingSpecular ) | |
4488 { | |
4489 v48 = sub_47C3D7_get_fog_related_stuff(0, 0, *(float *)v45); | |
4490 v46 = v57; | |
4491 } | |
4492 else | |
4493 { | |
4494 v48 = 0; | |
4495 } | |
4496 *(int *)(v46 + 16) = v48; | |
4497 *(int *)(v46 + 20) = *((int *)v45 + 6); | |
4498 *(int *)(v46 + 24) = *((int *)v45 + 7); | |
4499 v45 += 48; | |
4500 v18 = v55-- == 1; | |
4501 v57 = v46 + 32; | |
4502 } | |
4503 while ( !v18 ); | |
4504 } | |
323 | 4505 |
4506 if (a4->uAttributes & FACE_OUTLINED) | |
4507 { | |
4508 int color; | |
4509 if (GetTickCount() % 300 >= 150) | |
4510 color = 0xFFFF2020; | |
4511 else color = 0xFF901010; | |
4512 | |
4513 for (uint i = 0; i < uNumVertices; ++i) | |
4514 d3d_vertex_buffer[i].diffuse = color; | |
4515 } | |
4516 | |
0 | 4517 pRenderD3D->pDevice->SetTexture(0, pTexture); |
4518 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4519 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 4520 d3d_vertex_buffer, |
0 | 4521 uNumVertices, |
4522 D3DDP_DONOTLIGHT); | |
4523 } | |
4524 else | |
4525 { | |
4526 if ( (signed int)uNumVertices > 0 ) | |
4527 { | |
186 | 4528 v9 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; |
0 | 4529 v10 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 4530 a4 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; |
0 | 4531 v56 = uNumVertices; |
4532 while ( 1 ) | |
4533 { | |
4534 v11 = *(float *)v10 * 1000.0; | |
4535 *((int *)v9 - 1) = *((int *)v10 + 3); | |
4536 v12 = v11 / (double)pOutdoorCamera->shading_dist_mist; | |
4537 v9->pFacePlane.vNormal.x = *((int *)v10 + 4); | |
4538 *(float *)&v9->pFacePlane.vNormal.y = 1.0 - 1.0 / v12; | |
4539 *(float *)&v9->pFacePlane.vNormal.z = 1.0 / (*(float *)v10 + 0.0000001); | |
638 | 4540 v13 = GetActorTintColor(a3->dimming_level, 0, *(float *)v10, 0, 0); |
0 | 4541 v14 = a4; |
4542 v15 = *(float *)v10; | |
4543 a4->pFacePlane.dist = v13; | |
4544 if ( v5->bUsingSpecular ) | |
4545 { | |
4546 v16 = v15; | |
4547 v17 = sub_47C3D7_get_fog_related_stuff(0, 0, v16); | |
4548 v14 = a4; | |
4549 } | |
4550 else | |
4551 { | |
4552 v17 = 0; | |
4553 } | |
4554 v14->zCalc1 = v17; | |
4555 v14->zCalc2 = *((int *)v10 + 6); | |
4556 v14->zCalc3 = *((int *)v10 + 7); | |
4557 v10 += 48; | |
4558 v18 = v56-- == 1; | |
4559 a4 = (ODMFace *)((char *)v14 + 32); | |
4560 if ( v18 ) | |
4561 break; | |
4562 v9 = a4; | |
4563 } | |
4564 } | |
186 | 4565 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4566 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 4567 if (bUsingSpecular) |
186 | 4568 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 4569 |
4570 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
4571 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4572 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4573 d3d_vertex_buffer, |
0 | 4574 uNumVertices, |
4575 D3DDP_DONOTLIGHT)); | |
4576 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
4577 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
4578 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
4579 v53->_45D74F_MessWithLight(-1, 0); | |
4580 v23 = uNumVertices; | |
4581 if ( (signed int)uNumVertices > 0 ) | |
4582 { | |
186 | 4583 v24 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 4584 do |
4585 { | |
4586 *(int *)v24 = a2; | |
4587 v24 += 32; | |
4588 --v23; | |
4589 } | |
4590 while ( v23 ); | |
4591 } | |
4592 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); | |
186 | 4593 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4594 if ( !pRenderer->bUsingSpecular ) |
186 | 4595 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4596 | |
4597 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4598 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4599 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 4600 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
4601 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4602 d3d_vertex_buffer, |
0 | 4603 uNumVertices, |
4604 D3DDP_DONOTLIGHT)); | |
4605 if (bUsingSpecular) | |
4606 { | |
186 | 4607 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4608 |
4609 v33 = uNumVertices; | |
4610 if ( (signed int)uNumVertices > 0 ) | |
4611 { | |
186 | 4612 v34 = (char *)&d3d_vertex_buffer[0].specular; |
0 | 4613 do |
4614 { | |
4615 v35 = *(int *)v34; | |
4616 *(int *)v34 = 0; | |
4617 v34 += 32; | |
4618 --v33; | |
4619 *((int *)v34 - 9) = pRenderer->uFogColor | v35 & 0xFF000000; | |
4620 } | |
4621 while ( v33 ); | |
4622 } | |
4623 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
186 | 4624 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4625 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 4626 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
4627 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4628 d3d_vertex_buffer, |
0 | 4629 uNumVertices, |
4630 D3DDP_DONOTLIGHT)); | |
186 | 4631 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4632 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
4633 v41 = GetLevelFogColor(); | |
4634 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
4635 v6 = 0; | |
4636 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4637 } | |
186 | 4638 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4639 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4640 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
4641 } | |
4642 } | |
4643 } | |
4644 } | |
4645 // 4D864C: using guessed type char byte_4D864C; | |
4646 | |
4647 //----- (0049EB79) -------------------------------------------------------- | |
4648 Render::~Render() | |
4649 { | |
4650 Render *v1; // esi@1 | |
4651 | |
4652 v1 = this; | |
4653 pAllocator->FreeChunk(this->pDefaultZBuffer); | |
4654 v1->pD3DBitmaps.Release(); | |
4655 v1->pD3DSprites.Release(); | |
4656 Release(); | |
4657 v1->bWindowMode = 1; | |
4658 //nullsub_1(); | |
4659 //nullsub_1(); | |
4660 } | |
4661 | |
4662 //----- (0049E756) -------------------------------------------------------- | |
4663 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
4664 { | |
4665 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
4666 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
4667 | |
4668 halCaps.dwSize = 380; | |
4669 refCaps.dwSize = 380; | |
4670 this_->GetCaps(&halCaps, &refCaps); | |
4671 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
4672 } | |
4673 | |
4674 //----- (0049E992) -------------------------------------------------------- | |
4675 Render::Render() | |
4676 { | |
4677 Render *v1; // esi@1 | |
4678 int v2; // eax@1 | |
4679 char v3; // zf@1 | |
4680 | |
4681 v1 = this; | |
4682 this->pDirectDraw4 = 0; | |
4683 this->pFrontBuffer4 = 0; | |
4684 this->pBackBuffer4 = 0; | |
4685 this->pColorKeySurface4 = 0; | |
4686 this->pDirectDraw2 = 0; | |
4687 this->pFrontBuffer2 = 0; | |
4688 this->pBackBuffer2 = 0; | |
4689 this->pSomeSurface2 = 0; | |
4690 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
4691 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
4692 v1->bWindowMode = 1; | |
4693 v1->field_40054 = 0; | |
4694 v1->field_10 = 640; | |
4695 v1->field_14 = 480; | |
4696 v1->field_40030 = 0; | |
4697 v1->field_4002C = 0; | |
4698 v1->pActiveZBuffer = 0; | |
4699 v1->pDefaultZBuffer = 0; | |
709 | 4700 v1->raster_clip_y = 0; |
4701 v1->raster_clip_x = 0; | |
4702 v1->raster_clip_z = 639; | |
4703 v1->raster_clip_w = 479; | |
0 | 4704 v1->field_4003C = (int)&unk_4EED80; |
4705 v1->field_40040 = dword_4EED78; | |
4706 v1->uClipZ = 640; | |
4707 v1->field_40044 = 2; | |
4708 v1->field_40048 = 6; | |
4709 v1->pFrontBuffer4 = 0; | |
4710 v1->pBackBuffer4 = 0; | |
4711 v1->pColorKeySurface4 = 0; | |
4712 v1->pDirectDraw4 = 0; | |
4713 v1->pRenderD3D = 0; | |
4714 v1->uNumSceneBegins = 0; | |
4715 v1->uNumD3DSceneBegins = 0; | |
4716 v1->field_40110 = 0; | |
4717 v1->pTargetSurface = 0; | |
4718 v1->uTargetSurfacePitch = 0; | |
4719 v1->uClipY = 0; | |
4720 v1->uClipX = 0; | |
4721 v1->uClipW = 480; | |
4722 v1->bClip = 1; | |
4723 v1->bColorKeySupported = 0; | |
4724 v1->bRequiredTextureStagesAvailable = 0; | |
4725 v1->bTinting = 1; | |
4726 LOBYTE(v1->field_103668) = 0; | |
4727 v1->field_1036B8 = 0; | |
4728 v1->_gpu_memory_used = 0; | |
4729 uNumBillboardsToDraw = 0; | |
4730 bFogEnabled = false; | |
265 | 4731 |
4732 hd_water_tile_id = -1; | |
4733 hd_water_current_frame = 0; | |
0 | 4734 } |
4735 | |
781 | 4736 bool Render::Initialize(bool bWindowed, uint uDefaultDevice, bool bColoredLights, uint uDetailLevel, uint bTinting) |
0 | 4737 { |
4738 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
4739 bStartInWindow = bWindowed; | |
4740 | |
4741 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | |
4742 | |
4743 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
4744 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
4745 | |
4746 this->bTinting = bTinting; | |
4747 | |
4748 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
4749 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
4750 | |
4751 return r1 && r2; | |
4752 } | |
4753 | |
4754 //----- (0049EBF1) -------------------------------------------------------- | |
4755 void Render::_49EBF1() | |
4756 { | |
4757 signed int uNumRedBits; // edx@1 | |
4758 signed int uNuGreenBits; // edi@1 | |
4759 signed int uNumBlueBits; // esi@1 | |
4760 unsigned int v4; // edx@4 | |
4761 unsigned int v5; // edi@4 | |
4762 int v6; // ebx@4 | |
4763 int v7; // edx@4 | |
4764 signed int v8; // [sp+8h] [bp-24h]@1 | |
4765 signed int v9; // [sp+Ch] [bp-20h]@1 | |
4766 signed int v10; // [sp+20h] [bp-Ch]@1 | |
4767 signed int i; // [sp+24h] [bp-8h]@2 | |
4768 signed int v12; // [sp+28h] [bp-4h]@3 | |
4769 | |
4770 v10 = 0; | |
4771 uNumRedBits = 1 << this->uTargetRBits; | |
4772 uNuGreenBits = 1 << this->uTargetGBits; | |
4773 uNumBlueBits = 1 << this->uTargetBBits; | |
4774 v9 = 1 << this->uTargetRBits; | |
4775 v8 = 1 << this->uTargetGBits; | |
4776 if ( uNumRedBits > 0 ) | |
4777 { | |
4778 do | |
4779 { | |
4780 for ( i = 0; i < uNuGreenBits; ++i ) | |
4781 { | |
4782 v12 = 0; | |
4783 if ( uNumBlueBits > 0 ) | |
4784 { | |
4785 do | |
4786 { | |
4787 v4 = this->uTargetBBits; | |
4788 v5 = v4 + this->uTargetGBits; | |
4789 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
4790 v7 = (v10 << v5) + v12++ + (i << v4); | |
4791 this->field_2C[v7] = v6; | |
4792 } | |
4793 while ( v12 < uNumBlueBits ); | |
4794 uNumRedBits = v9; | |
4795 uNuGreenBits = v8; | |
4796 } | |
4797 } | |
4798 ++v10; | |
4799 } | |
4800 while ( v10 < uNumRedBits ); | |
4801 } | |
4802 } | |
4803 | |
4804 //----- (0049ECC4) -------------------------------------------------------- | |
4805 void Render::ClearBlack() | |
4806 { | |
4807 if (pRenderD3D) | |
4808 { | |
4809 if (field_40110) | |
4810 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
4811 } | |
4812 else | |
4813 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
4814 } | |
4815 | |
4816 //----- (0049ED18) -------------------------------------------------------- | |
4817 void Render::PresentBlackScreen() | |
4818 { | |
4819 LONG w; // edx@3 | |
4820 IDirectDrawSurface *v2; // eax@3 | |
4821 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
4822 RECT x; // [sp+68h] [bp-10h]@3 | |
4823 | |
4824 memset(&v3, 0, sizeof(DDBLTFX)); | |
4825 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4826 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
4827 { | |
4828 x.left = uWindowX; | |
4829 x.right = uWindowX + uWindowHeight; | |
4830 x.top = uWindowY; | |
4831 w = uWindowY + uWindowWidth; | |
4832 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
4833 } | |
4834 else | |
4835 { | |
4836 x.left = uWindowX; | |
4837 x.right = uWindowX + uWindowHeight; | |
4838 x.top = uWindowY; | |
4839 w = uWindowY + uWindowWidth; | |
4840 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
4841 } | |
4842 x.bottom = w; | |
4843 v3.dwFillColor = 0; | |
4844 v3.dwSize = 100; | |
4845 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
4846 pRenderer->Present(); | |
4847 } | |
4848 | |
4849 //----- (0049EDB6) -------------------------------------------------------- | |
4850 void Render::SavePCXScreenshot() | |
4851 { | |
4852 Render *v1; // esi@1 | |
4853 __int16 v2; // di@1 | |
4854 int v3; // eax@4 | |
4855 int v4; // ecx@4 | |
4856 int v5; // eax@8 | |
4857 FILE *v6; // edi@10 | |
4858 int v7; // ecx@11 | |
4859 int v8; // eax@11 | |
4860 int v9; // eax@13 | |
4861 int v10; // ecx@15 | |
4862 unsigned __int8 v11; // dl@15 | |
4863 signed int v12; // eax@18 | |
4864 char v13; // zf@27 | |
4865 HRESULT v14; // eax@29 | |
4866 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
4867 __int16 v16; // [sp+44h] [bp-120h]@10 | |
4868 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
4869 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
4870 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
4871 char *v20; // [sp+11Ch] [bp-48h]@14 | |
4872 char *v21; // [sp+120h] [bp-44h]@14 | |
4873 int v24; // [sp+124h] [bp-40h]@11 | |
4874 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
4875 int var38; // [sp+12Ch] [bp-38h]@4 | |
4876 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
4877 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
4878 void *ptr; // [sp+148h] [bp-1Ch]@10 | |
4879 void *v28; // [sp+14Ch] [bp-18h]@8 | |
4880 int v29; // [sp+150h] [bp-14h]@4 | |
4881 int v30; // [sp+154h] [bp-10h]@4 | |
4882 char v31; // [sp+15Ah] [bp-Ah]@25 | |
4883 unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 | |
4884 int i; // [sp+15Ch] [bp-8h]@10 | |
4885 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | |
4886 | |
4887 v1 = this; | |
4888 v2 = 0; | |
4889 if ( !this->pRenderD3D || this->field_40110 ) | |
4890 { | |
4891 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | |
4892 File = fopen(Filename, "wb"); | |
4893 if ( File ) | |
4894 { | |
4895 v3 = v1->field_10; | |
4896 v4 = v1->field_14; | |
4897 var38 = v3; | |
4898 v29 = v4; | |
4899 v30 = v3; | |
4900 if ( v3 & 1 ) | |
4901 v30 = v3 + 1; | |
4902 if ( v1->pRenderD3D ) | |
4903 { | |
4904 memset(&Dst, 0, 0x7Cu); | |
4905 Dst.dwSize = 124; | |
168 | 4906 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 4907 return; |
4908 v28 = Dst.lpSurface; | |
4909 v5 = Dst.lPitch >> 1; | |
4910 v2 = 0; | |
4911 } | |
4912 else | |
4913 { | |
4914 pRenderer->BeginScene(); | |
4915 v28 = pRenderer->pTargetSurface; | |
4916 v5 = pRenderer->uTargetSurfacePitch; | |
4917 } | |
4918 i = v5; | |
4919 header1.right = var38 - 1; | |
4920 header1.left = v2; | |
4921 header1.bottom = v29 - 1; | |
4922 header1.up = v2; | |
4923 header2.pitch = v30; | |
4924 memset(color_map, 0, sizeof(color_map)); | |
4925 memset(v15, 0, sizeof(v15)); | |
4926 header2.reserved = 0; | |
4927 header1.manufacturer = 10; | |
4928 v16 = 0; | |
4929 v6 = File; | |
4930 header1.version = 5; | |
4931 header1.encoding = 1; | |
4932 header1.bpp = 8; | |
4933 header1.hdpi = 75; | |
4934 header1.vdpi = 75; | |
4935 header2.planes = 3; | |
4936 header2.palette_info = 1; | |
4937 fwrite(&header1, 1u, 1u, File); | |
4938 fwrite(&header1.version, 1u, 1u, v6); | |
4939 fwrite(&header1.encoding, 1u, 1u, v6); | |
4940 fwrite(&header1.bpp, 1u, 1u, v6); | |
4941 fwrite(&header1.left, 2u, 1u, v6); | |
4942 fwrite(&header1.up, 2u, 1u, v6); | |
4943 fwrite(&header1.right, 2u, 1u, v6); | |
4944 fwrite(&header1.bottom, 2u, 1u, v6); | |
4945 fwrite(&header1.hdpi, 2u, 1u, v6); | |
4946 fwrite(&header1.vdpi, 2u, 1u, v6); | |
4947 fwrite(color_map, 0x30u, 1u, v6); | |
4948 fwrite(&header2, 1u, 1u, v6); | |
4949 fwrite(&header2.planes, 1u, 1u, v6); | |
4950 fwrite(&header2.pitch, 2u, 1u, v6); | |
4951 fwrite(&header2.palette_info, 2u, 1u, v6); | |
4952 fwrite(v15, 0x3Au, 1u, v6); | |
4953 ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); | |
4954 if ( v29 > 0 ) | |
4955 { | |
4956 v7 = v30; | |
4957 File = (FILE *)v29; | |
4958 v29 = 3 * v30; | |
4959 v24 = 2 * i; | |
4960 v8 = (int)v28; | |
4961 while ( 1 ) | |
4962 { | |
4963 i = v8; | |
4964 v9 = 0; | |
4965 if ( var38 > 0 ) | |
4966 { | |
4967 v21 = (char *)ptr + v7; | |
4968 v20 = (char *)ptr + 2 * v30; | |
4969 do | |
4970 { | |
4971 *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) | |
4972 + LOBYTE(v1->uTargetBBits) | |
4973 + v1->uTargetRBits | |
4974 - 8); | |
4975 v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) | |
4976 + LOBYTE(v1->uTargetGBits) | |
4977 - 8); | |
4978 v10 = i; | |
4979 v11 = LOBYTE(v1->uTargetBMask); | |
4980 i += 2; | |
4981 v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); | |
4982 } | |
4983 while ( v9 < var38 ); | |
4984 } | |
4985 for ( i = 0; i < v29; i += v34 ) | |
4986 { | |
4987 v34 = 1; | |
4988 v32 = *((char *)ptr + i); | |
4989 do | |
4990 { | |
4991 v12 = i + v34; | |
4992 if ( *((char *)ptr + v12) != v32 ) | |
4993 break; | |
4994 if ( !(v12 % v30) ) | |
4995 break; | |
4996 ++v34; | |
4997 } | |
4998 while ( v34 < 0x3Fu ); | |
4999 if ( i + v34 > v29 ) | |
5000 v34 = 3 * v30 - i; | |
5001 if ( v34 > 1u || v32 >= 0xC0u ) | |
5002 { | |
5003 v31 = v34 | 0xC0; | |
5004 fwrite(&v31, 1u, 1u, v6); | |
5005 } | |
5006 fwrite(&v32, 1u, 1u, v6); | |
5007 } | |
5008 v8 = (int)((char *)v28 + v24); | |
5009 v13 = File == (FILE *)1; | |
5010 File = (FILE *)((char *)File - 1); | |
5011 v28 = (char *)v28 + v24; | |
5012 if ( v13 ) | |
5013 break; | |
5014 v7 = v30; | |
5015 } | |
5016 } | |
5017 if ( v1->pRenderD3D ) | |
5018 { | |
5019 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
5020 } | |
5021 else | |
5022 { | |
5023 pRenderer->EndScene(); | |
5024 } | |
5025 | |
5026 pAllocator->FreeChunk(ptr); | |
5027 fclose(v6); | |
5028 } | |
5029 } | |
5030 } | |
5031 // 4EFA80: using guessed type int dword_4EFA80; | |
5032 | |
5033 //----- (0049F1BC) -------------------------------------------------------- | |
5034 void Render::_49F1BC(const char *a1) | |
5035 { | |
5036 Render *v2; // esi@1 | |
5037 __int16 v3; // di@1 | |
5038 int v4; // eax@4 | |
5039 char *v5; // ecx@4 | |
5040 unsigned int v6; // eax@8 | |
5041 FILE *v7; // edi@10 | |
5042 int v8; // ecx@11 | |
5043 int v9; // eax@11 | |
5044 int v10; // eax@13 | |
5045 const char *v11; // ecx@15 | |
5046 unsigned __int8 v12; // dl@15 | |
5047 signed int v13; // eax@18 | |
5048 char v14; // zf@27 | |
5049 HRESULT v15; // eax@29 | |
5050 char v16; // [sp+Ch] [bp-12Ch]@10 | |
5051 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
5052 int Dst; // [sp+48h] [bp-F0h]@7 | |
5053 int v19; // [sp+58h] [bp-E0h]@8 | |
5054 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
5055 char v21; // [sp+C4h] [bp-74h]@10 | |
5056 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
5057 char *v23; // [sp+F8h] [bp-40h]@14 | |
5058 int v24; // [sp+FCh] [bp-3Ch]@11 | |
5059 int v25; // [sp+100h] [bp-38h]@4 | |
5060 FILE *File; // [sp+104h] [bp-34h]@3 | |
5061 char Str; // [sp+108h] [bp-30h]@10 | |
5062 char v28; // [sp+109h] [bp-2Fh]@10 | |
5063 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
5064 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
5065 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
5066 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
5067 __int16 v33; // [sp+110h] [bp-28h]@10 | |
5068 __int16 v34; // [sp+112h] [bp-26h]@10 | |
5069 __int16 v35; // [sp+114h] [bp-24h]@10 | |
5070 __int16 v36; // [sp+116h] [bp-22h]@10 | |
5071 char v37; // [sp+118h] [bp-20h]@10 | |
5072 char v38; // [sp+119h] [bp-1Fh]@10 | |
5073 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
5074 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
5075 void *ptr; // [sp+120h] [bp-18h]@10 | |
5076 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
5077 int v43; // [sp+128h] [bp-10h]@4 | |
5078 char v44; // [sp+12Fh] [bp-9h]@25 | |
5079 char *i; // [sp+130h] [bp-8h]@10 | |
5080 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
5081 | |
5082 v2 = this; | |
5083 v3 = 0; | |
5084 if ( !this->pRenderD3D || this->field_40110 ) | |
5085 { | |
5086 ++dword_4EFA84; | |
5087 File = fopen(a1, "wb"); | |
5088 if ( File ) | |
5089 { | |
5090 v4 = v2->field_10; | |
5091 v5 = (char *)v2->field_14; | |
5092 v25 = v4; | |
5093 a1 = v5; | |
5094 v43 = v4; | |
5095 if ( v4 & 1 ) | |
5096 v43 = v4 + 1; | |
5097 if ( v2->pRenderD3D ) | |
5098 { | |
5099 memset(&Dst, 0, 0x7Cu); | |
5100 Dst = 124; | |
168 | 5101 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 5102 return; |
5103 v42 = v20; | |
5104 v6 = v19 >> 1; | |
5105 v3 = 0; | |
5106 } | |
5107 else | |
5108 { | |
5109 pRenderer->BeginScene(); | |
5110 v42 = pRenderer->pTargetSurface; | |
5111 v6 = pRenderer->uTargetSurfacePitch; | |
5112 } | |
5113 i = (char *)v6; | |
5114 v33 = v25 - 1; | |
5115 v31 = v3; | |
5116 v34 = (short)a1 - 1; | |
5117 v32 = v3; | |
5118 v39 = v43; | |
5119 memset(&v21, 0, 0x30u); | |
5120 memset(&v16, 0, 0x38u); | |
5121 v37 = 0; | |
5122 Str = 10; | |
5123 v17 = 0; | |
5124 v7 = File; | |
5125 v28 = 5; | |
5126 v29 = 1; | |
5127 v30 = 8; | |
5128 v35 = 75; | |
5129 v36 = 75; | |
5130 v38 = 3; | |
5131 v40 = 1; | |
5132 fwrite(&Str, 1u, 1u, File); | |
5133 fwrite(&v28, 1u, 1u, v7); | |
5134 fwrite(&v29, 1u, 1u, v7); | |
5135 fwrite(&v30, 1u, 1u, v7); | |
5136 fwrite(&v31, 2u, 1u, v7); | |
5137 fwrite(&v32, 2u, 1u, v7); | |
5138 fwrite(&v33, 2u, 1u, v7); | |
5139 fwrite(&v34, 2u, 1u, v7); | |
5140 fwrite(&v35, 2u, 1u, v7); | |
5141 fwrite(&v36, 2u, 1u, v7); | |
5142 fwrite(&v21, 0x30u, 1u, v7); | |
5143 fwrite(&v37, 1u, 1u, v7); | |
5144 fwrite(&v38, 1u, 1u, v7); | |
5145 fwrite(&v39, 2u, 1u, v7); | |
5146 fwrite(&v40, 2u, 1u, v7); | |
5147 fwrite(&v16, 0x3Au, 1u, v7); | |
5148 ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); | |
5149 if ( (signed int)a1 > 0 ) | |
5150 { | |
5151 v8 = v43; | |
5152 File = (FILE *)a1; | |
5153 v24 = 3 * v43; | |
5154 v22 = 2 * (int)i; | |
5155 v9 = (int)v42; | |
5156 while ( 1 ) | |
5157 { | |
5158 a1 = (const char *)v9; | |
5159 v10 = 0; | |
5160 if ( v25 > 0 ) | |
5161 { | |
5162 i = (char *)ptr + v8; | |
5163 v23 = (char *)ptr + 2 * v43; | |
5164 do | |
5165 { | |
5166 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
5167 + LOBYTE(v2->uTargetBBits) | |
5168 + v2->uTargetRBits | |
5169 - 8); | |
5170 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
5171 + LOBYTE(v2->uTargetGBits) | |
5172 - 8); | |
5173 v11 = a1; | |
5174 v12 = LOBYTE(v2->uTargetBMask); | |
5175 a1 += 2; | |
5176 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
5177 } | |
5178 while ( v10 < v25 ); | |
5179 } | |
5180 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
5181 { | |
5182 BYTE3(a1) = 1; | |
5183 v46 = *((char *)ptr + (int)i); | |
5184 do | |
5185 { | |
5186 v13 = (signed int)&i[BYTE3(a1)]; | |
5187 if ( *((char *)ptr + v13) != v46 ) | |
5188 break; | |
5189 if ( !(v13 % v43) ) | |
5190 break; | |
5191 ++BYTE3(a1); | |
5192 } | |
5193 while ( BYTE3(a1) < 0x3Fu ); | |
5194 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
5195 BYTE3(a1) = 3 * v43 - (char)i; | |
5196 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
5197 { | |
5198 v44 = BYTE3(a1) | 0xC0; | |
5199 fwrite(&v44, 1u, 1u, v7); | |
5200 } | |
5201 fwrite(&v46, 1u, 1u, v7); | |
5202 } | |
5203 v9 = (int)&v42[v22 / 2]; | |
5204 v14 = File == (FILE *)1; | |
5205 File = (FILE *)((char *)File - 1); | |
5206 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
5207 if ( v14 ) | |
5208 break; | |
5209 v8 = v43; | |
5210 } | |
5211 } | |
5212 if ( v2->pRenderD3D ) | |
5213 { | |
5214 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
5215 } | |
5216 else | |
5217 { | |
5218 pRenderer->EndScene(); | |
5219 } | |
5220 pAllocator->FreeChunk(ptr); | |
5221 fclose(v7); | |
5222 } | |
5223 } | |
5224 } | |
5225 // 4EFA84: using guessed type int dword_4EFA84; | |
5226 | |
5227 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 5228 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
5229 { | |
0 | 5230 Render *v7; // ebx@1 |
5231 void *v8; // esi@3 | |
5232 void *v9; // esi@3 | |
5233 int v10; // ecx@4 | |
810 | 5234 unsigned short* v11; // eax@4 |
0 | 5235 int v12; // eax@6 |
5236 int v13; // eax@8 | |
5237 int v14; // ecx@8 | |
5238 signed int v15; // eax@11 | |
5239 char v16; // zf@20 | |
5240 int result; // eax@21 | |
5241 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
5242 // __int16 v19; // [sp+44h] [bp-74h]@3 | |
5243 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 5244 char *lineG; // [sp+78h] [bp-40h]@7 |
5245 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 5246 int v23; // [sp+80h] [bp-38h]@4 |
5247 int v24; // [sp+84h] [bp-34h]@4 | |
5248 int v25; // [sp+88h] [bp-30h]@4 | |
5249 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 5250 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
5251 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
5252 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
5253 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 5254 char v43; // [sp+B3h] [bp-5h]@18 |
5255 int i; // [sp+B4h] [bp-4h]@6 | |
810 | 5256 unsigned short* line_pictute_data; |
5257 byte test_byte; | |
5258 unsigned char pict_byte; | |
0 | 5259 |
5260 v7 = this; | |
810 | 5261 pitch = wight; |
5262 if ( wight & 1 ) | |
5263 pitch = wight + 1; | |
5264 Src.left = 0; | |
5265 Src.up = 0; | |
5266 Src.right = wight - 1; | |
5267 Src.bottom = heidth - 1; | |
5268 v27.pitch = pitch; | |
0 | 5269 memset(&v20, 0, 0x30u); |
5270 memset(&v18, 0, 0x38u); | |
810 | 5271 v8 = data_buff; |
5272 v27.reserved = 0; | |
0 | 5273 *(_WORD *)&v18[56] = 0; |
810 | 5274 Src.manufacturer = 10; |
5275 Src.version = 5; | |
5276 Src.encoding = 1; | |
5277 Src.bpp = 8; | |
5278 Src.hdpi = 75; | |
5279 Src.vdpi = 75; | |
5280 v27.planes = 3; | |
5281 v27.palette_info = 1; | |
5282 memcpy(data_buff, &Src, 1u); | |
0 | 5283 v8 = (char *)v8 + 1; |
810 | 5284 memcpy(v8, &Src.version, 1u); |
0 | 5285 v8 = (char *)v8 + 1; |
810 | 5286 memcpy(v8, &Src.encoding, 1u); |
0 | 5287 v8 = (char *)v8 + 1; |
810 | 5288 memcpy(v8, &Src.bpp, 1u); |
0 | 5289 v8 = (char *)v8 + 1; |
810 | 5290 memcpy(v8, &Src.left, 2u); |
0 | 5291 v8 = (char *)v8 + 2; |
810 | 5292 memcpy(v8, &Src.up, 2u); |
0 | 5293 v8 = (char *)v8 + 2; |
810 | 5294 memcpy(v8, &Src.right, 2u); |
0 | 5295 v8 = (char *)v8 + 2; |
810 | 5296 memcpy(v8, &Src.bottom, 2u); |
0 | 5297 v8 = (char *)v8 + 2; |
810 | 5298 memcpy(v8, &Src.hdpi, 2u); |
0 | 5299 v8 = (char *)v8 + 2; |
810 | 5300 memcpy(v8, &Src.vdpi, 2u); |
0 | 5301 v8 = (char *)v8 + 2; |
5302 memcpy(v8, &v20, 0x30u); | |
5303 v8 = (char *)v8 + 48; | |
810 | 5304 memcpy(v8, &v27, 1u); |
0 | 5305 v8 = (char *)v8 + 1; |
810 | 5306 memcpy(v8, &v27.planes, 1u); |
0 | 5307 v8 = (char *)v8 + 1; |
810 | 5308 memcpy(v8, &v27.pitch, 2u); |
0 | 5309 v8 = (char *)v8 + 2; |
810 | 5310 memcpy(v8, &v27.palette_info, 2u); |
0 | 5311 v8 = (char *)v8 + 2; |
5312 memcpy(v8, &v18, 0x3Au); | |
5313 v9 = (char *)v8 + 58; | |
810 | 5314 |
5315 lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); | |
5316 if ( heidth > 0 ) | |
5317 { | |
5318 v10 = pitch; | |
5319 v25 = heidth; | |
5320 v26 = 3 * pitch; | |
5321 v23 = 2 * wight; | |
5322 v11 = picture_data; | |
5323 v24 = (int)picture_data; | |
0 | 5324 while ( 1 ) |
5325 { | |
810 | 5326 line_pictute_data = v11; |
0 | 5327 v12 = 0; |
5328 i = 0; | |
810 | 5329 if ( wight > 0 ) |
5330 { | |
5331 lineG = (char *)lineRGB + pitch; | |
5332 lineB = (char *)lineRGB + 2 * pitch; | |
0 | 5333 do |
5334 { | |
810 | 5335 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); |
5336 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); | |
5337 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); | |
5338 | |
5339 v12++; | |
5340 } | |
5341 while ( v12 < wight ); | |
0 | 5342 } |
5343 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
5344 { | |
810 | 5345 test_byte = 1; |
5346 pict_byte = lineRGB [i]; | |
0 | 5347 do |
5348 { | |
810 | 5349 v15 = i + test_byte; |
5350 if ( *((char *)lineRGB + v15) != pict_byte ) | |
0 | 5351 break; |
810 | 5352 if ( !(v15 % pitch) ) |
0 | 5353 break; |
810 | 5354 ++test_byte; |
5355 } | |
5356 while ( test_byte < 0x3Fu ); | |
5357 if ( i + test_byte > v26 ) | |
5358 test_byte = 3 * pitch - i; | |
5359 if ( test_byte > 1u || pict_byte >= 0xC0u ) | |
5360 { | |
5361 v43 = test_byte | 0xC0; | |
0 | 5362 memcpy(v9, &v43, 1u); |
5363 v9 = (char *)v9 + 1; | |
5364 } | |
810 | 5365 memcpy(v9, &pict_byte, 1u); |
5366 i += test_byte; | |
5367 } | |
5368 v11 +=wight ; | |
0 | 5369 v16 = v25-- == 1; |
810 | 5370 |
0 | 5371 if ( v16 ) |
5372 break; | |
810 | 5373 v10 = pitch; |
5374 } | |
5375 } | |
5376 pAllocator->FreeChunk(lineRGB); | |
5377 *(int *)packed_size = (char *)v9 - data_buff; | |
5378 | |
0 | 5379 } |
5380 | |
5381 //----- (0049F8B5) -------------------------------------------------------- | |
5382 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) | |
5383 { | |
5384 Render *v5; // esi@1 | |
5385 FILE *result; // eax@1 | |
5386 FILE *v7; // edi@4 | |
5387 int v8; // ecx@5 | |
5388 int v9; // eax@5 | |
5389 int v10; // eax@7 | |
5390 int v11; // ecx@9 | |
5391 signed int v12; // eax@12 | |
5392 char v13; // zf@21 | |
5393 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
5394 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
5395 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
5396 int v17; // [sp+70h] [bp-34h]@5 | |
5397 int v18; // [sp+74h] [bp-30h]@5 | |
5398 char *v19; // [sp+78h] [bp-2Ch]@5 | |
5399 int v20; // [sp+7Ch] [bp-28h]@5 | |
5400 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
5401 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
5402 void *ptr; // [sp+98h] [bp-Ch]@4 | |
5403 int v24; // [sp+9Ch] [bp-8h]@2 | |
5404 char *i; // [sp+A0h] [bp-4h]@8 | |
5405 | |
5406 v5 = this; | |
5407 result = fopen(Filename, "wb"); | |
5408 Filename = (const char *)result; | |
5409 if ( result ) | |
5410 { | |
5411 v24 = a4; | |
5412 if ( a4 & 1 ) | |
5413 v24 = a4 + 1; | |
5414 header1.left = 0; | |
5415 header1.up = 0; | |
5416 header1.right = a4 - 1; | |
5417 header1.bottom = a5 - 1; | |
5418 header2.pitch = v24; | |
5419 memset(color_map, 0, sizeof(color_map)); | |
5420 header2.reserved = 0; | |
5421 memset(v14, 0, sizeof(v14)); | |
5422 v15 = 0; | |
5423 header1.manufacturer = 10; | |
5424 header1.version = 5; | |
5425 header1.encoding = 1; | |
5426 header1.bpp = 8; | |
5427 header1.hdpi = 75; | |
5428 header1.vdpi = 75; | |
5429 header2.planes = 3; | |
5430 header2.palette_info = 1; | |
5431 fwrite(&header1, 1u, 1u, (FILE *)Filename); | |
5432 v7 = (FILE *)Filename; | |
5433 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); | |
5434 fwrite(&header1.encoding, 1u, 1u, v7); | |
5435 fwrite(&header1.bpp, 1u, 1u, v7); | |
5436 fwrite(&header1.left, 2u, 1u, v7); | |
5437 fwrite(&header1.up, 2u, 1u, v7); | |
5438 fwrite(&header1.right, 2u, 1u, v7); | |
5439 fwrite(&header1.bottom, 2u, 1u, v7); | |
5440 fwrite(&header1.hdpi, 2u, 1u, v7); | |
5441 fwrite(&header1.vdpi, 2u, 1u, v7); | |
5442 fwrite(color_map, 0x30u, 1u, v7); | |
5443 fwrite(&header2, 1u, 1u, v7); | |
5444 fwrite(&header2.planes, 1u, 1u, v7); | |
5445 fwrite(&header2.pitch, 2u, 1u, v7); | |
5446 fwrite(&header2.palette_info, 2u, 1u, v7); | |
5447 fwrite(v14, 0x3Au, 1u, v7); | |
5448 ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); | |
5449 if ( a5 > 0 ) | |
5450 { | |
5451 v8 = v24; | |
5452 v18 = a5; | |
5453 v20 = 3 * v24; | |
5454 v17 = 2 * a4; | |
5455 v9 = (int)a3; | |
5456 v19 = a3; | |
5457 while ( 1 ) | |
5458 { | |
5459 a5 = v9; | |
5460 v10 = 0; | |
5461 if ( a4 > 0 ) | |
5462 { | |
5463 a3 = (char *)ptr + v8; | |
5464 i = (char *)ptr + 2 * v24; | |
5465 do | |
5466 { | |
5467 *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) | |
5468 + LOBYTE(v5->uTargetBBits) | |
5469 + v5->uTargetRBits | |
5470 - 8); | |
5471 a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) | |
5472 + LOBYTE(v5->uTargetGBits) | |
5473 - 8); | |
5474 v11 = a5; | |
5475 a5 += 2; | |
5476 i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); | |
5477 } | |
5478 while ( v10 < a4 ); | |
5479 } | |
5480 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) | |
5481 { | |
5482 BYTE3(a5) = 1; | |
5483 BYTE3(Filename) = *((char *)ptr + (int)i); | |
5484 do | |
5485 { | |
5486 v12 = (signed int)&i[BYTE3(a5)]; | |
5487 if ( *((char *)ptr + v12) != BYTE3(Filename) ) | |
5488 break; | |
5489 if ( !(v12 % v24) ) | |
5490 break; | |
5491 ++BYTE3(a5); | |
5492 } | |
5493 while ( BYTE3(a5) < 0x3Fu ); | |
5494 if ( (signed int)&i[BYTE3(a5)] > v20 ) | |
5495 BYTE3(a5) = 3 * v24 - (char)i; | |
5496 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) | |
5497 { | |
5498 BYTE3(a3) = BYTE3(a5) | 0xC0; | |
5499 fwrite((char *)&a3 + 3, 1u, 1u, v7); | |
5500 } | |
5501 fwrite((char *)&Filename + 3, 1u, 1u, v7); | |
5502 } | |
5503 v9 = (int)&v19[v17]; | |
5504 v13 = v18-- == 1; | |
5505 v19 += v17; | |
5506 if ( v13 ) | |
5507 break; | |
5508 v8 = v24; | |
5509 } | |
5510 } | |
5511 pAllocator->FreeChunk(ptr); | |
5512 result = (FILE *)fclose(v7); | |
5513 } | |
5514 return result; | |
5515 } | |
5516 | |
5517 //----- (0049FBCD) -------------------------------------------------------- | |
5518 void Render::ClearTarget(unsigned int uColor) | |
5519 { | |
5520 if (pRenderD3D) | |
5521 { | |
5522 if (field_40110) | |
5523 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
5524 } | |
5525 else | |
5526 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
5527 } | |
5528 | |
5529 //----- (0049FC23) -------------------------------------------------------- | |
5530 void Render::Release2() | |
5531 { | |
5532 Release(); | |
5533 bWindowMode = 1; | |
5534 } | |
5535 | |
5536 //----- (0049FC37) -------------------------------------------------------- | |
5537 void Render::Present() | |
5538 { | |
5539 Render *v1; // esi@1 | |
5540 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
5541 RECT a4; // [sp+18h] [bp-18h]@11 | |
5542 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
5543 | |
5544 v1 = this; | |
5545 if ( !pRenderer->pRenderD3D || this->field_40110 ) | |
5546 { | |
5547 this->pBeforePresentFunction(); | |
5548 if ( v1->pRenderD3D ) | |
5549 { | |
5550 if ( v1->field_40110 ) | |
5551 { | |
5552 pRenderD3D->Present(false); | |
5553 } | |
5554 } | |
5555 else | |
5556 { | |
5557 if ( v1->bWindowMode ) | |
5558 { | |
5559 RestoreFrontBuffer(); | |
5560 GetClientRect(v1->hWnd, &Rect); | |
5561 Point.y = 0; | |
5562 Point.x = 0; | |
5563 ClientToScreen(v1->hWnd, &Point); | |
5564 OffsetRect(&Rect, Point.x, Point.y); | |
5565 a4.top = 0; | |
5566 a4.bottom = 480; | |
5567 a4.left = 0; | |
5568 a4.right = 640; | |
5569 PresentRect(&Rect, &a4); | |
5570 } | |
5571 else | |
5572 { | |
5573 RestoreFrontBuffer(); | |
5574 a4.top = 0; | |
5575 a4.bottom = 480; | |
5576 a4.left = 0; | |
5577 a4.right = 640; | |
5578 BltBackToFontFast(0, 0, &a4); | |
5579 } | |
5580 } | |
5581 } | |
5582 } | |
5583 | |
5584 //----- (0049FD3A) -------------------------------------------------------- | |
5585 void Render::_49FD3A() | |
5586 { | |
5587 Render *v2; // esi@1 | |
5588 IDirectDrawSurface4 *v3; // eax@6 | |
5589 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
5590 RECT v5; // [sp+8h] [bp-10h]@6 | |
5591 | |
5592 auto a1 = this; | |
5593 v2 = a1; | |
5594 if ( a1->pRenderD3D ) | |
5595 { | |
5596 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
5597 pFrontBuffer4->Restore(); | |
5598 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
5599 pBackBuffer4->Restore(); | |
5600 v3 = v2->pBackBuffer4; | |
5601 v4 = v2->pFrontBuffer4; | |
5602 v5.top = 0; | |
5603 v5.bottom = 480; | |
5604 v5.left = 0; | |
5605 v5.right = 640; | |
5606 v3->BltFast(0, 0, v4, &v5, 16u); | |
5607 } | |
5608 } | |
5609 | |
5610 //----- (0049FDBF) -------------------------------------------------------- | |
5611 void Render::CreateZBuffer() | |
5612 { | |
5613 if (!pDefaultZBuffer) | |
5614 { | |
5615 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
5616 pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); | |
871 | 5617 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 5618 } |
5619 } | |
5620 | |
5621 //----- (0049FE05) -------------------------------------------------------- | |
5622 void Render::Release() | |
5623 { | |
5624 Render *v1; // esi@1 | |
5625 RenderD3D *v2; // ecx@1 | |
5626 char v3; // zf@4 | |
5627 void *v4; // ebx@6 | |
5628 IDirectDraw *v5; // eax@10 | |
5629 IDirectDrawSurface2 *v6; // eax@11 | |
5630 IDirectDrawSurface2 *v7; // eax@13 | |
5631 IDirectDrawSurface2 *v8; // eax@15 | |
5632 IDirectDraw2 *v9; // eax@17 | |
5633 IDirectDraw4 *v10; // eax@19 | |
5634 IDirectDrawSurface4 *v11; // eax@20 | |
5635 IDirectDrawSurface4 *v12; // eax@22 | |
5636 IDirectDrawSurface4 *v13; // eax@24 | |
5637 IDirectDraw4 *v14; // eax@26 | |
5638 unsigned __int16 **v15; // ebx@28 | |
5639 void **v16; // esi@29 | |
5640 | |
5641 v1 = this; | |
5642 v2 = this->pRenderD3D; | |
5643 if ( v2 ) | |
5644 { | |
5645 if ( v1->field_40110 ) | |
5646 { | |
5647 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5648 pRenderD3D->Present(0); | |
5649 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5650 } | |
5651 v1->pColorKeySurface4 = 0; | |
5652 v1->pBackBuffer4 = 0; | |
5653 v3 = v1->pTargetSurface == 0; | |
5654 v1->pFrontBuffer4 = 0; | |
5655 v1->pDirectDraw4 = 0; | |
5656 if ( !v3 ) | |
5657 { | |
5658 free(v1->ptr_400E8); | |
5659 v1->pTargetSurface = 0; | |
5660 v1->ptr_400E8 = 0; | |
5661 } | |
5662 v4 = v1->pRenderD3D; | |
5663 if ( v4 ) | |
5664 { | |
5665 pRenderD3D->Release(); | |
5666 free(v4); | |
5667 } | |
5668 v1->pRenderD3D = 0; | |
5669 } | |
5670 else | |
5671 { | |
5672 if ( bWinNT4_0 == 1 ) | |
5673 { | |
5674 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
5675 if ( !v5 ) | |
5676 return; | |
5677 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
5678 v1->pDirectDraw2->FlipToGDISurface(); | |
5679 v6 = v1->pSomeSurface2; | |
5680 if ( v6 ) | |
5681 { | |
5682 v6->Release(); | |
5683 v1->pSomeSurface2 = 0; | |
5684 } | |
5685 v7 = v1->pBackBuffer2; | |
5686 if ( v7 ) | |
5687 { | |
5688 v7->Release(); | |
5689 v1->pBackBuffer2 = 0; | |
5690 } | |
5691 v8 = v1->pFrontBuffer2; | |
5692 if ( v8 ) | |
5693 { | |
5694 v8->Release(); | |
5695 v1->pFrontBuffer2 = 0; | |
5696 } | |
5697 v9 = v1->pDirectDraw2; | |
5698 if ( v9 ) | |
5699 { | |
5700 v9->Release(); | |
5701 v1->pDirectDraw2 = 0; | |
5702 } | |
5703 } | |
5704 else | |
5705 { | |
5706 v10 = v1->pDirectDraw4; | |
5707 if ( !v10 ) | |
5708 return; | |
5709 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
5710 v1->pDirectDraw4->FlipToGDISurface(); | |
5711 v11 = v1->pColorKeySurface4; | |
5712 if ( v11 ) | |
5713 { | |
5714 v11->Release(); | |
5715 v1->pColorKeySurface4 = 0; | |
5716 } | |
5717 v12 = v1->pBackBuffer4; | |
5718 if ( v12 ) | |
5719 { | |
5720 v12->Release(); | |
5721 v1->pBackBuffer4 = 0; | |
5722 } | |
5723 v13 = v1->pFrontBuffer4; | |
5724 if ( v13 ) | |
5725 { | |
5726 v13->Release(); | |
5727 v1->pFrontBuffer4 = 0; | |
5728 } | |
5729 v14 = v1->pDirectDraw4; | |
5730 if ( v14 ) | |
5731 { | |
5732 v14->Release(); | |
5733 v1->pDirectDraw4 = 0; | |
5734 } | |
5735 } | |
5736 v15 = &v1->pTargetSurface; | |
5737 if ( v1->pTargetSurface ) | |
5738 { | |
5739 v16 = (void **)&v1->ptr_400E8; | |
5740 free(*v16); | |
5741 *v15 = 0; | |
5742 *v16 = 0; | |
5743 } | |
5744 } | |
5745 } | |
5746 | |
5747 //----- (0049FFD7) -------------------------------------------------------- | |
5748 void Render::CreateSomeTexture() | |
5749 { | |
5750 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
5751 } | |
5752 | |
5753 //----- (0049FFFB) -------------------------------------------------------- | |
5754 bool Render::InitializeFullscreen(HWND hWnd) | |
5755 { | |
5756 //Render *v2; // esi@1 | |
5757 //HWND v3; // ebx@1 | |
5758 //void *v4; // eax@2 | |
5759 //RenderD3D *v5; // eax@3 | |
5760 unsigned int v6; // edx@5 | |
5761 RenderD3D__DevInfo *v7; // ecx@5 | |
5762 bool v8; // eax@6 | |
5763 RenderD3D *v9; // ecx@13 | |
5764 unsigned int v10; // eax@13 | |
5765 RenderD3D *v11; // eax@25 | |
5766 HRESULT v12; // eax@25 | |
5767 int v13; // ecx@25 | |
5768 int v14; // eax@27 | |
5769 signed int v15; // ebx@31 | |
5770 bool v16; // eax@35 | |
5771 char v17; // zf@35 | |
5772 IDirectDraw4 *v18; // eax@38 | |
5773 HRESULT v19; // eax@38 | |
5774 int *v20; // eax@39 | |
5775 int *v22; // eax@42 | |
5776 int v23; // ecx@42 | |
5777 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
5778 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
5779 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
5780 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
5781 void *v28; // [sp+2FCh] [bp-10h]@2 | |
5782 int v29; // [sp+308h] [bp-4h]@2 | |
5783 | |
5784 //v2 = this; | |
5785 this->field_40110 = 0; | |
5786 this->pColorKeySurface4 = 0; | |
5787 this->pBackBuffer4 = 0; | |
5788 this->pFrontBuffer4 = 0; | |
5789 this->pDirectDraw4 = 0; | |
5790 this->bColorKeySupported = 0; | |
5791 Release(); | |
5792 //v3 = hWnd; | |
5793 this->hWnd = hWnd; | |
5794 CreateZBuffer(); | |
5795 if ( bUserDirect3D ) | |
5796 { | |
5797 pRenderD3D = new RenderD3D; | |
5798 v28 = pRenderD3D; | |
5799 v6 = uDesiredDirect3DDevice; | |
5800 v29 = -1; | |
5801 v7 = pRenderD3D->pAvailableDevices; | |
5802 if ( v7[v6].bIsDeviceCompatible ) | |
5803 { | |
5804 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | |
5805 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
5806 } | |
5807 else | |
5808 { | |
5809 if ( v7[1].bIsDeviceCompatible ) | |
5810 { | |
5811 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | |
5812 uAcquiredDirect3DDevice = 1; | |
5813 } | |
5814 else | |
5815 { | |
5816 if ( !v7->bIsDeviceCompatible ) | |
5817 Abortf("There aren't any D3D devices to create."); | |
5818 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); | |
5819 uAcquiredDirect3DDevice = 0; | |
5820 } | |
5821 } | |
5822 if ( !v8 ) | |
5823 Abortf("D3Drend->Init failed."); | |
5824 v9 = pRenderD3D; | |
5825 pBackBuffer4 = v9->pBackBuffer; | |
5826 pFrontBuffer4 = v9->pFrontBuffer; | |
5827 pDirectDraw4 = v9->pHost; | |
5828 v10 = pRenderD3D->GetDeviceCaps(); | |
5829 if ( v10 & 1 ) | |
5830 { | |
5831 if ( pRenderD3D ) | |
5832 { | |
5833 pRenderD3D->Release(); | |
5834 delete pRenderD3D; | |
5835 } | |
5836 pRenderD3D = 0; | |
5837 pBackBuffer4 = 0; | |
5838 pFrontBuffer4 = 0; | |
5839 pDirectDraw4 = 0; | |
5840 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
5841 } | |
5842 if ( v10 & 0x3E ) | |
5843 { | |
5844 if ( pRenderD3D ) | |
5845 { | |
5846 pRenderD3D->Release(); | |
5847 delete pRenderD3D; | |
5848 } | |
5849 pColorKeySurface4 = 0; | |
5850 pRenderD3D = 0; | |
5851 pBackBuffer4 = 0; | |
5852 pFrontBuffer4 = 0; | |
5853 pDirectDraw4 = 0; | |
5854 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
5855 } | |
5856 if ( (v10 & 0x80u) != 0 ) | |
5857 { | |
5858 if ( pRenderD3D ) | |
5859 { | |
5860 pRenderD3D->Release(); | |
5861 delete pRenderD3D; | |
5862 } | |
5863 pRenderD3D = 0; | |
5864 pBackBuffer4 = 0; | |
5865 pFrontBuffer4 = 0; | |
5866 pDirectDraw4 = 0; | |
5867 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
5868 } | |
5869 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
5870 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
5871 memset(&halCaps, 0, 0xFCu); | |
5872 halCaps.dwSize = 252; | |
5873 memset(&refCaps, 0, 0xFCu); | |
5874 v11 = pRenderD3D; | |
5875 refCaps.dwSize = 252; | |
5876 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
5877 v13 = halCaps.dwMinTextureWidth; | |
5878 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
5879 v13 = halCaps.dwMinTextureHeight; | |
5880 v14 = halCaps.dwMaxTextureWidth; | |
5881 uMinDeviceTextureDim = v13; | |
5882 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
5883 v14 = halCaps.dwMaxTextureHeight; | |
5884 uMaxDeviceTextureDim = v14; | |
5885 if ( (unsigned int)v13 < 4 ) | |
5886 uMinDeviceTextureDim = 4; | |
5887 CreateSomeTexture(); | |
5888 v15 = 1; | |
5889 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
5890 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
5891 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
5892 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
5893 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
5894 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
5895 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
5896 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
5897 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
5898 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
5899 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
5900 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
5901 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
5902 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
5903 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
5904 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
5905 } | |
5906 else | |
5907 { | |
5908 CreateDirectDraw(); | |
5909 SetDirectDrawCooperationMode(hWnd, 1); | |
5910 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
5911 CreateDirectDrawPrimarySurface(); | |
5912 v15 = 1; | |
5913 } | |
5914 ddpfPrimareSuface.dwSize = 32; | |
5915 GetTargetPixelFormat(&ddpfPrimareSuface); | |
5916 ParseTargetPixelFormat(); | |
5917 _49EBF1(); | |
5918 if ( pRenderD3D ) | |
5919 { | |
5920 v16 = IsColorKeySupported(pDirectDraw4); | |
5921 v17 = uAcquiredDirect3DDevice == v15; | |
5922 bColorKeySupported = v16; | |
5923 if ( !v17 ) | |
5924 bColorKeySupported = 0; | |
5925 if ( bColorKeySupported ) | |
5926 { | |
5927 memset(&ddsd2, 0, 0x7Cu); | |
5928 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
5929 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
5930 v18 = pDirectDraw4; | |
5931 ddsd2.dwSize = 124; | |
5932 ddsd2.dwFlags = 65543; | |
5933 ddsd2.ddsCaps.dwCaps = 2112; | |
5934 ddsd2.dwWidth = 640; | |
5935 ddsd2.dwHeight = 480; | |
5936 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
5937 pBeforePresentFunction = Present_ColorKey; | |
5938 } | |
5939 else | |
5940 { | |
5941 pTargetSurface = 0; | |
5942 ptr_400E8 = 0; | |
5943 v20 = (int *)operator new(0x96020u); | |
5944 ptr_400E8 = v20; | |
5945 if ( !v20 | |
5946 || (memset(&pDesc, 0, 0x7Cu), | |
5947 pDesc.dwSize = 124, | |
5948 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
5949 return 0; | |
5950 pBackBuffer4->Unlock(0); | |
5951 v22 = ptr_400E8 + 4; | |
5952 v23 = (unsigned int)pDesc.lpSurface & 7; | |
5953 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
5954 uTargetSurfacePitch = 640; | |
5955 pBeforePresentFunction = Present_NoColorKey; | |
5956 v15 = 1; | |
5957 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | |
5958 } | |
5959 field_40110 = v15; | |
5960 } | |
5961 else | |
5962 { | |
5963 pBeforePresentFunction = 0;//nullsub_1; | |
5964 } | |
5965 bWindowMode = 0; | |
5966 pParty->uFlags |= 2u; | |
5967 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; | |
5968 pViewport->_4C02F8(36044); | |
5969 return v15; | |
5970 } | |
5971 // 6BE3A0: using guessed type float flt_6BE3A0; | |
5972 | |
5973 //----- (004A05F3) -------------------------------------------------------- | |
5974 bool Render::SwitchToWindow(HWND hWnd) | |
5975 { | |
5976 //Render *v2; // esi@1 | |
5977 //void *v3; // eax@2 | |
5978 //RenderD3D *v4; // eax@3 | |
5979 //unsigned int v5; // edx@5 | |
5980 //RenderD3D__DevInfo *v6; // ecx@5 | |
5981 bool v7; // eax@7 | |
5982 //RenderD3D *v8; // ecx@12 | |
5983 unsigned int v9; // eax@12 | |
5984 RenderD3D *v10; // eax@24 | |
5985 HRESULT v11; // eax@24 | |
5986 int v12; // eax@24 | |
5987 int v13; // eax@26 | |
5988 bool v14; // eax@32 | |
5989 char v15; // zf@32 | |
5990 IDirectDraw4 *v16; // eax@35 | |
5991 HRESULT v17; // eax@35 | |
5992 int *v18; // eax@36 | |
5993 int *v19; // edx@38 | |
5994 int v20; // eax@38 | |
5995 unsigned int v21; // ecx@38 | |
5996 int v22; // eax@41 | |
5997 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
5998 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
5999 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
6000 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
6001 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
6002 int v29; // [sp+308h] [bp-4h]@2 | |
6003 | |
6004 pParty->uFlags |= 2u; | |
6005 //v2 = this; | |
6006 flt_6BE3A0 = 0.55000001f; | |
6007 pViewport->_4C02F8(36044); | |
6008 field_40110 = 0; | |
6009 Release(); | |
6010 pColorKeySurface4 = 0; | |
6011 pBackBuffer4 = 0; | |
6012 pFrontBuffer4 = 0; | |
6013 pDirectDraw4 = 0; | |
6014 bColorKeySupported = 0; | |
6015 CreateZBuffer(); | |
6016 if ( bUserDirect3D ) | |
6017 { | |
6018 /*v3 = operator new(0x148u); | |
6019 thisa = (RenderD3D *)v3; | |
6020 v29 = 0; | |
6021 if ( v3 ) | |
6022 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
6023 else | |
6024 v4 = 0;*/ | |
6025 pRenderD3D = new RenderD3D; | |
6026 //v4 = pRenderD3D; | |
6027 //v5 = uDesiredDirect3DDevice; | |
6028 v29 = -1; | |
6029 //v6 = pRenderD3D->pAvailableDevices; | |
6030 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
6031 uDesiredDirect3DDevice != 1 ) | |
6032 { | |
6033 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | |
6034 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
6035 } | |
6036 else | |
6037 { | |
6038 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
6039 Abortf("There aren't any D3D devices to init."); | |
6040 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); | |
6041 uAcquiredDirect3DDevice = 0; | |
6042 } | |
6043 if ( !v7 ) | |
6044 Abortf("D3Drend->Init failed."); | |
6045 | |
6046 //v8 = pRenderD3D; | |
6047 pColorKeySurface4 = 0; | |
6048 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
6049 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
6050 pDirectDraw4 = pRenderD3D->pHost; | |
6051 v9 = pRenderD3D->GetDeviceCaps(); | |
6052 if ( v9 & 1 ) | |
6053 { | |
6054 if (pRenderD3D) | |
6055 { | |
6056 pRenderD3D->Release(); | |
6057 delete pRenderD3D; | |
6058 } | |
6059 pRenderD3D = 0; | |
6060 pBackBuffer4 = 0; | |
6061 pFrontBuffer4 = 0; | |
6062 pDirectDraw4 = 0; | |
6063 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
6064 } | |
6065 if ( v9 & 0x3E ) | |
6066 { | |
6067 if (pRenderD3D) | |
6068 { | |
6069 pRenderD3D->Release(); | |
6070 delete pRenderD3D; | |
6071 } | |
6072 pColorKeySurface4 = 0; | |
6073 pRenderD3D = 0; | |
6074 pBackBuffer4 = 0; | |
6075 pFrontBuffer4 = 0; | |
6076 pDirectDraw4 = 0; | |
6077 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
6078 } | |
6079 if ( (v9 & 0x80u) != 0 ) | |
6080 { | |
6081 if (pRenderD3D) | |
6082 { | |
6083 pRenderD3D->Release(); | |
6084 delete pRenderD3D; | |
6085 } | |
6086 pRenderD3D = 0; | |
6087 pBackBuffer4 = 0; | |
6088 pFrontBuffer4 = 0; | |
6089 pDirectDraw4 = 0; | |
6090 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
6091 } | |
6092 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
6093 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
6094 memset(&halCaps, 0, 0xFCu); | |
6095 halCaps.dwSize = 252; | |
6096 memset(&refCaps, 0, 0xFCu); | |
6097 //v10 = v2->pRenderD3D; | |
6098 refCaps.dwSize = 252; | |
6099 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
6100 v12 = halCaps.dwMinTextureWidth; | |
6101 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
6102 v12 = halCaps.dwMinTextureHeight; | |
6103 uMinDeviceTextureDim = v12; | |
6104 v13 = halCaps.dwMaxTextureWidth; | |
6105 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
6106 v13 = halCaps.dwMaxTextureHeight; | |
6107 uMaxDeviceTextureDim = v13; | |
6108 CreateSomeTexture(); | |
6109 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
6110 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
6111 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
6112 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
6113 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
6114 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
6115 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
6116 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
6117 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
6118 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
6119 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
6120 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
6121 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
6122 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
6123 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
6124 } | |
6125 else | |
6126 { | |
6127 CreateDirectDraw(); | |
6128 SetDirectDrawCooperationMode(hWnd, 0); | |
6129 field_4004C = 1; | |
6130 CreateFrontBuffer(); | |
6131 CreateClipper(hWnd); | |
6132 CreateBackBuffer(); | |
6133 field_40030 = 0; | |
6134 field_18_locked_pitch = 0; | |
6135 } | |
6136 ddpfPrimareSuface.dwSize = 32; | |
6137 GetTargetPixelFormat(&ddpfPrimareSuface); | |
6138 ParseTargetPixelFormat(); | |
6139 _49EBF1(); | |
6140 if ( !pRenderD3D ) | |
6141 { | |
6142 pBeforePresentFunction = 0;//nullsub_1; | |
6143 goto LABEL_47; | |
6144 } | |
6145 v14 = IsColorKeySupported(pDirectDraw4); | |
6146 v15 = uAcquiredDirect3DDevice == 1; | |
6147 bColorKeySupported = v14; | |
6148 if ( !v15 ) | |
6149 bColorKeySupported = 0; | |
6150 if ( bColorKeySupported ) | |
6151 { | |
6152 memset(&ddsd2, 0, 0x7Cu); | |
6153 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
6154 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
6155 v16 = pDirectDraw4; | |
6156 ddsd2.dwSize = 124; | |
6157 ddsd2.dwFlags = 65543; | |
6158 ddsd2.ddsCaps.dwCaps = 2112; | |
6159 ddsd2.dwWidth = 640; | |
6160 ddsd2.dwHeight = 480; | |
6161 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
6162 pBeforePresentFunction = Present_ColorKey; | |
6163 LABEL_45: | |
6164 field_40110 = 1; | |
6165 LABEL_47: | |
6166 bWindowMode = 1; | |
6167 hWnd = hWnd; | |
6168 return 0; | |
6169 } | |
6170 pTargetSurface = 0; | |
6171 ptr_400E8 = 0; | |
6172 v18 = (int *)new char[0x96020]; | |
6173 memset(v18, -1, 0x96020); | |
6174 ptr_400E8 = v18; | |
6175 if ( v18 ) | |
6176 { | |
6177 memset(&pDesc, 0, 0x7Cu); | |
6178 pDesc.dwSize = 124; | |
168 | 6179 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) |
0 | 6180 { |
6181 pRenderer->pBackBuffer4->Unlock(0); | |
6182 v19 = ptr_400E8; | |
6183 v20 = (unsigned int)pDesc.lpSurface & 7; | |
6184 v21 = (unsigned int)ptr_400E8 & 7; | |
6185 if ( v21 == v20 ) | |
6186 { | |
6187 pTargetSurface = (unsigned __int16 *)v19; | |
6188 } | |
6189 else | |
6190 { | |
6191 if ( (signed int)v21 >= v20 ) | |
6192 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
6193 else | |
6194 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
6195 pTargetSurface = (unsigned __int16 *)v22; | |
6196 } | |
6197 uTargetSurfacePitch = 640; | |
6198 pBeforePresentFunction = Present_NoColorKey; | |
6199 goto LABEL_45; | |
6200 } | |
6201 } | |
6202 return 0; | |
6203 } | |
6204 | |
6205 //----- (004A0BEE) -------------------------------------------------------- | |
709 | 6206 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) |
0 | 6207 { |
6208 int v6; // edi@1 | |
6209 int v7; // edx@5 | |
6210 unsigned int v8; // ebx@5 | |
6211 int v9; // eax@7 | |
6212 unsigned int v10; // ecx@9 | |
6213 unsigned int v11; // esi@13 | |
6214 int v12; // eax@17 | |
6215 int v13; // eax@21 | |
6216 Render *v14; // edi@21 | |
6217 int v15; // eax@25 | |
6218 int v16; // eax@27 | |
6219 signed int v17; // eax@28 | |
6220 signed int v18; // edi@30 | |
6221 signed __int64 v19; // qax@41 | |
6222 int v20; // edi@41 | |
6223 unsigned int v21; // edi@46 | |
6224 int v22; // esi@47 | |
6225 int v23; // ebx@47 | |
6226 signed int v24; // edx@50 | |
6227 signed int v25; // esi@52 | |
6228 unsigned __int16 *v26; // ecx@52 | |
6229 int v27; // ebx@54 | |
6230 int v28; // edi@55 | |
6231 int v29; // edx@55 | |
6232 int v30; // ebx@60 | |
6233 int v31; // edx@61 | |
6234 int v32; // edi@61 | |
6235 int v34; // [sp+Ch] [bp-10h]@3 | |
6236 Render *v35; // [sp+10h] [bp-Ch]@1 | |
6237 __int64 v36; // [sp+14h] [bp-8h]@1 | |
6238 signed int v37; // [sp+18h] [bp-4h]@28 | |
6239 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
6240 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | |
6241 int uYb; // [sp+28h] [bp+Ch]@47 | |
6242 int uZa; // [sp+2Ch] [bp+10h]@38 | |
6243 | |
6244 v36 = 0i64; | |
709 | 6245 v6 = this->raster_clip_x; |
0 | 6246 v35 = this; |
6247 if ( (signed int)uX < v6 ) | |
6248 HIDWORD(v36) = 8; | |
709 | 6249 v34 = this->raster_clip_z; |
6250 if ( (signed int)uX > this->raster_clip_z ) | |
0 | 6251 HIDWORD(v36) |= 4u; |
709 | 6252 v7 = this->raster_clip_y; |
0 | 6253 v8 = uY; |
6254 if ( (signed int)uY < v7 ) | |
6255 HIDWORD(v36) |= 2u; | |
709 | 6256 v9 = this->raster_clip_w; |
0 | 6257 if ( (signed int)uY > v9 ) |
6258 HIDWORD(v36) |= 1u; | |
6259 v10 = uZ; | |
6260 if ( (signed int)uZ < v6 ) | |
6261 LODWORD(v36) = 8; | |
6262 if ( (signed int)uZ > v34 ) | |
6263 LODWORD(v36) = v36 | 4; | |
6264 v11 = uW; | |
6265 if ( (signed int)uW < v7 ) | |
6266 LODWORD(v36) = v36 | 2; | |
6267 if ( (signed int)uW > v9 ) | |
6268 LODWORD(v36) = v36 | 1; | |
6269 LOBYTE(v12) = v36; | |
6270 if ( (unsigned int)v36 & HIDWORD(v36) ) | |
6271 return v12; | |
6272 if ( !v36 ) | |
6273 { | |
6274 LABEL_46: | |
6275 v21 = pRenderer->uTargetSurfacePitch; | |
6276 if ( pRenderer->uTargetSurfacePitch ) | |
6277 { | |
6278 v12 = uX + v8 * pRenderer->uTargetSurfacePitch; | |
6279 v22 = v11 - v8; | |
6280 v23 = v22; | |
6281 uYb = v22; | |
6282 if ( v22 < 0 ) | |
6283 { | |
6284 v23 = -v22; | |
6285 uYb = -v22; | |
6286 v21 = -pRenderer->uTargetSurfacePitch; | |
6287 } | |
6288 uXa = v10 - uX; | |
6289 if ( (uXa & 0x80000000u) == 0 ) | |
6290 { | |
6291 v24 = 1; | |
6292 } | |
6293 else | |
6294 { | |
6295 uXa = -uXa; | |
6296 v24 = -1; | |
6297 } | |
6298 v25 = 0; | |
6299 v26 = v35->pTargetSurface; | |
6300 if ( v26 ) | |
6301 { | |
6302 if ( (signed int)uXa <= v23 ) | |
6303 { | |
6304 v30 = v23 + 1; | |
6305 if ( v30 > 0 ) | |
6306 { | |
6307 v31 = 2 * v24; | |
6308 v32 = 2 * v21; | |
6309 v12 = (int)&v26[v12]; | |
6310 do | |
6311 { | |
6312 v25 += uXa; | |
6313 *(short *)v12 = uColor; | |
6314 v12 += v32; | |
6315 if ( v25 > 0 ) | |
6316 { | |
6317 v25 -= uYb; | |
6318 v12 += v31; | |
6319 } | |
6320 --v30; | |
6321 } | |
6322 while ( v30 ); | |
6323 } | |
6324 } | |
6325 else | |
6326 { | |
6327 v27 = uXa + 1; | |
6328 if ( (signed int)(uXa + 1) > 0 ) | |
6329 { | |
6330 v28 = 2 * v21; | |
6331 v29 = 2 * v24; | |
6332 v12 = (int)&v26[v12]; | |
6333 do | |
6334 { | |
6335 v25 += uYb; | |
6336 *(short *)v12 = uColor; | |
6337 v12 += v29; | |
6338 if ( v25 > (signed int)uXa ) | |
6339 { | |
6340 v25 -= uXa; | |
6341 v12 += v28; | |
6342 } | |
6343 --v27; | |
6344 } | |
6345 while ( v27 ); | |
6346 } | |
6347 } | |
6348 } | |
6349 } | |
6350 return v12; | |
6351 } | |
6352 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | |
6353 { | |
6354 if ( BYTE4(v36) & 8 ) | |
6355 { | |
6356 v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX); | |
6357 v14 = v35; | |
6358 v8 = v13 + uY; | |
709 | 6359 uX = v35->raster_clip_x; |
0 | 6360 goto LABEL_24; |
6361 } | |
6362 v10 = v6; | |
6363 v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW; | |
6364 } | |
6365 v14 = v35; | |
6366 LABEL_24: | |
6367 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
6368 { | |
709 | 6369 v15 = v14->raster_clip_z; |
0 | 6370 if ( BYTE4(v36) & 4 ) |
6371 { | |
6372 v14 = v35; | |
6373 v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX); | |
709 | 6374 uX = v35->raster_clip_z; |
0 | 6375 } |
6376 else | |
6377 { | |
6378 v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10); | |
709 | 6379 v10 = v14->raster_clip_z; |
0 | 6380 v11 += v16; |
6381 } | |
6382 } | |
709 | 6383 v17 = v14->raster_clip_y; |
0 | 6384 v37 = 0; |
709 | 6385 uYa = v14->raster_clip_y; |
0 | 6386 if ( (signed int)v8 < v17 ) |
6387 v37 = 2; | |
709 | 6388 v18 = v14->raster_clip_w; |
0 | 6389 if ( (signed int)v8 > v18 ) |
6390 v37 |= 1u; | |
6391 if ( (signed int)v11 >= v17 ) | |
6392 v12 = 0; | |
6393 else | |
6394 v12 = 2; | |
6395 if ( (signed int)v11 > v18 ) | |
6396 LOBYTE(v12) = v12 | 1; | |
6397 if ( !(v12 & v37) ) | |
6398 { | |
6399 v12 ^= v37; | |
6400 uZa = v12; | |
6401 if ( v12 & 2 ) | |
6402 { | |
6403 if ( v37 & 2 ) | |
6404 { | |
6405 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | |
6406 LOBYTE(v12) = (char)v35; | |
709 | 6407 v8 = v35->raster_clip_y; |
0 | 6408 } |
6409 else | |
6410 { | |
6411 v19 = (signed int)((uX - v10) * (uYa - v11)); | |
6412 v20 = v8 - v11; | |
6413 v11 = uYa; | |
6414 v12 = v19 / v20; | |
6415 v10 += v12; | |
6416 } | |
6417 } | |
6418 if ( uZa & 1 ) | |
6419 { | |
6420 if ( v37 & 1 ) | |
6421 { | |
709 | 6422 uX += (signed int)((v10 - uX) * (v35->raster_clip_w - v8)) / (signed int)(v11 - v8); |
0 | 6423 LOBYTE(v12) = (char)v35; |
709 | 6424 v8 = v35->raster_clip_w; |
0 | 6425 } |
6426 else | |
6427 { | |
709 | 6428 v12 = (signed int)((uX - v10) * (v35->raster_clip_w - v11)) / (signed int)(v8 - v11); |
6429 v11 = v35->raster_clip_w; | |
0 | 6430 v10 += v12; |
6431 } | |
6432 } | |
6433 goto LABEL_46; | |
6434 } | |
6435 return v12; | |
6436 } | |
6437 | |
6438 //----- (004A0E80) -------------------------------------------------------- | |
6439 void Render::ClearZBuffer(int a2, int a3) | |
6440 { | |
6441 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
6442 } | |
6443 | |
6444 //----- (004A0E97) -------------------------------------------------------- | |
709 | 6445 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
6446 { | |
6447 this->raster_clip_x = uX; | |
6448 this->raster_clip_y = uY; | |
6449 this->raster_clip_z = uZ; | |
6450 this->raster_clip_w = uW; | |
0 | 6451 } |
6452 | |
6453 //----- (004A0EB6) -------------------------------------------------------- | |
6454 void Render::ParseTargetPixelFormat() | |
6455 { | |
6456 Render *v1; // eax@1 | |
6457 signed int v2; // ecx@1 | |
6458 DWORD uRedMask; // edx@1 | |
6459 unsigned int uGreenMask; // esi@5 | |
6460 signed int v5; // ecx@5 | |
6461 unsigned int uBlueMask; // edx@9 | |
6462 signed int v7; // ecx@9 | |
6463 unsigned int v8; // ecx@13 | |
6464 | |
6465 v1 = this; | |
6466 v2 = 0; | |
6467 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | |
6468 v1->uTargetBBits = 0; | |
6469 v1->uTargetGBits = 0; | |
6470 v1->uTargetRBits = 0; | |
6471 do | |
6472 { | |
6473 if ( (1 << v2) & uRedMask ) | |
6474 ++v1->uTargetRBits; | |
6475 ++v2; | |
6476 } | |
6477 while ( v2 < 16 ); | |
6478 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | |
6479 v5 = 0; | |
6480 do | |
6481 { | |
6482 if ( (1 << v5) & uGreenMask ) | |
6483 ++v1->uTargetGBits; | |
6484 ++v5; | |
6485 } | |
6486 while ( v5 < 16 ); | |
6487 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | |
6488 v7 = 0; | |
6489 do | |
6490 { | |
6491 if ( (1 << v7) & uBlueMask ) | |
6492 ++v1->uTargetBBits; | |
6493 ++v7; | |
6494 } | |
6495 while ( v7 < 16 ); | |
6496 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
6497 v1->uTargetGMask = uGreenMask; | |
6498 v1->uTargetRMask = v8; | |
6499 v1->uTargetBMask = uBlueMask; | |
6500 } | |
6501 | |
6502 //----- (004A0F40) -------------------------------------------------------- | |
6503 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
6504 { | |
6505 IDirectDrawSurface4 *v4; // esi@1 | |
168 | 6506 HRESULT result; // eax@1 |
0 | 6507 HRESULT v6; // eax@4 |
6508 int v7; // [sp-8h] [bp-14h]@10 | |
6509 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
6510 char v9; // [sp+Bh] [bp-1h]@1 | |
6511 | |
6512 v4 = pSurface; | |
6513 v9 = 1; | |
6514 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
6515 if ( result == DDERR_SURFACELOST ) | |
6516 { | |
6517 v6 = v4->Restore(); | |
6518 if ( v6 ) | |
6519 { | |
6520 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
6521 { | |
6522 LABEL_20: | |
6523 v9 = 0; | |
6524 result = (bool)memset(pDesc, 0, 4u); | |
6525 goto LABEL_21; | |
6526 } | |
6527 pRenderer->pFrontBuffer4->Restore(); | |
6528 v4->Restore(); | |
6529 } | |
6530 result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
6531 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6532 goto LABEL_20; | |
6533 ErrD3D(result); | |
6534 if ( result ) | |
6535 { | |
6536 //v8 = 0; | |
6537 //v7 = 2161; | |
6538 LABEL_19: | |
6539 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6540 goto LABEL_20; | |
6541 } | |
6542 if ( pRenderer->pRenderD3D ) | |
6543 pRenderD3D->HandleLostResources(); | |
6544 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
6545 } | |
6546 else | |
6547 { | |
6548 if ( result ) | |
6549 { | |
6550 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6551 goto LABEL_20; | |
6552 ErrD3D(result); | |
6553 //v8 = 0; | |
6554 //v7 = 2199; | |
6555 //goto LABEL_19; | |
6556 } | |
6557 } | |
6558 LABEL_21: | |
6559 LOBYTE(result) = v9; | |
6560 return result; | |
6561 } | |
6562 | |
6563 //----- (004A1032) -------------------------------------------------------- | |
6564 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
6565 { | |
6566 IDirectDrawSurface2 *v4; // esi@1 | |
6567 bool v5; // eax@1 | |
6568 HRESULT v6; // eax@2 | |
6569 int v7; // [sp-8h] [bp-10h]@8 | |
6570 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
6571 | |
6572 v4 = pSurface; | |
6573 v5 = pSurface->Lock( | |
6574 0, | |
6575 pDesc, | |
6576 uLockFlags, | |
6577 0); | |
6578 BYTE3(pSurface) = 1; | |
6579 if ( v5 == DDERR_SURFACELOST ) | |
6580 { | |
6581 v6 = v4->Restore(); | |
6582 if ( !v6 ) | |
6583 goto LABEL_5; | |
6584 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
6585 { | |
6586 pRenderer->pFrontBuffer2->Restore(); | |
6587 v4->Restore(); | |
6588 LABEL_5: | |
6589 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
6590 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
6591 goto LABEL_14; | |
6592 if ( !v5 ) | |
6593 return true; | |
6594 ErrD3D(v5); | |
6595 //v8 = 0; | |
6596 //v7 = 2247; | |
6597 goto LABEL_13; | |
6598 } | |
6599 else | |
6600 { | |
6601 pDesc->dwSize = 0; | |
6602 return false; | |
6603 } | |
6604 } | |
6605 else | |
6606 { | |
6607 if ( !v5 ) | |
6608 return true; | |
6609 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
6610 { | |
6611 //v8 = 0; | |
6612 //v7 = 2269; | |
6613 ErrD3D(v5); | |
6614 pDesc->dwSize = 0; | |
6615 return false; | |
6616 LABEL_13: | |
6617 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6618 goto LABEL_14; | |
6619 } | |
6620 } | |
6621 LABEL_14: | |
6622 return true; | |
6623 } | |
6624 | |
6625 //----- (004A10E4) -------------------------------------------------------- | |
6626 void Render::CreateDirectDraw() | |
6627 { | |
6628 Render *v1; // edi@1 | |
6629 HRESULT v2; // eax@1 | |
6630 HRESULT v3; // eax@5 | |
6631 int v6; // [sp-Ch] [bp-20h]@3 | |
6632 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
6633 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
6634 | |
6635 v1 = this; | |
6636 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
6637 | |
6638 pDirectDraw2 = nullptr; | |
6639 pDirectDraw4 = nullptr; | |
6640 | |
6641 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6642 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
6643 else | |
6644 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
6645 | |
6646 lpDD->Release(); | |
6647 lpDD = nullptr; | |
6648 } | |
6649 | |
6650 //----- (004A1169) -------------------------------------------------------- | |
6651 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
6652 { | |
6653 DWORD flags; // eax@1 | |
6654 IDirectDraw *v4; // ecx@3 | |
6655 HRESULT v5; // eax@5 | |
6656 int v6; // [sp-8h] [bp-8h]@3 | |
6657 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
6658 | |
6659 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
6660 DDSCL_NORMAL; | |
6661 | |
6662 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6663 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
6664 else | |
6665 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
6666 } | |
6667 | |
6668 //----- (004A11C6) -------------------------------------------------------- | |
6669 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
6670 { | |
6671 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6672 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6673 else | |
6674 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6675 } | |
6676 | |
6677 //----- (004A121C) -------------------------------------------------------- | |
6678 void Render::CreateFrontBuffer() | |
6679 { | |
6680 Render *v1; // esi@1 | |
6681 IDirectDraw *pDD; // eax@3 | |
6682 IDirectDrawSurface **pOutSurf; // esi@3 | |
6683 struct _DDSURFACEDESC *v4; // edx@3 | |
6684 HRESULT v5; // eax@5 | |
6685 int v6; // [sp-8h] [bp-8Ch]@3 | |
6686 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6687 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6688 | |
6689 v1 = this; | |
6690 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6691 { | |
6692 memset(&a2, 0, 0x7Cu); | |
6693 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
6694 a2.dwSize = 124; | |
6695 a2.dwFlags = 1; | |
6696 v7 = 0; | |
6697 a2.ddsCaps.dwCaps = 512; | |
6698 v6 = 2357; | |
6699 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
6700 v4 = (struct _DDSURFACEDESC *)&a2; | |
6701 } | |
6702 else | |
6703 { | |
6704 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
6705 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
6706 a2.lPitch = 108; | |
6707 a2.dwBackBufferCount = 1; | |
6708 v7 = 0; | |
6709 a2.dwTextureStage = 512; | |
6710 v6 = 2346; | |
6711 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
6712 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
6713 } | |
6714 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
6715 } | |
6716 | |
6717 //----- (004A12CD) -------------------------------------------------------- | |
6718 void Render::CreateBackBuffer() | |
6719 { | |
6720 Render *v1; // esi@1 | |
6721 IDirectDraw *v2; // eax@3 | |
6722 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
6723 struct _DDSURFACEDESC *v4; // edx@3 | |
6724 HRESULT v5; // eax@5 | |
6725 int v6; // [sp-8h] [bp-8Ch]@3 | |
6726 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6727 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6728 | |
6729 v1 = this; | |
6730 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6731 { | |
6732 memset(&a2, 0, 0x7Cu); | |
6733 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
6734 a2.dwSize = 124; | |
6735 a2.dwFlags = 7; | |
6736 v7 = 0; | |
6737 a2.ddsCaps.dwCaps = 2112; | |
6738 a2.dwWidth = 640; | |
6739 a2.dwHeight = 480; | |
6740 v6 = 2387; | |
6741 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6742 v4 = (struct _DDSURFACEDESC *)&a2; | |
6743 } | |
6744 else | |
6745 { | |
6746 memset(&a2.lPitch, 0, 0x6Cu); | |
6747 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
6748 a2.lPitch = 108; | |
6749 a2.dwBackBufferCount = 7; | |
6750 v7 = 0; | |
6751 a2.dwTextureStage = 2112; | |
6752 a2.dwAlphaBitDepth = 640; | |
6753 a2.dwMipMapCount = 480; | |
6754 v6 = 2374; | |
6755 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6756 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
6757 } | |
6758 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
6759 } | |
6760 | |
6761 //----- (004A139A) -------------------------------------------------------- | |
6762 void Render::CreateDirectDrawPrimarySurface() | |
6763 { | |
6764 Render *v1; // esi@1 | |
6765 int v2; // ebx@3 | |
6766 IDirectDraw2 *v3; // eax@3 | |
6767 HRESULT v4; // eax@3 | |
6768 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
6769 DDSCAPS2 *v6; // edx@3 | |
6770 IDirectDraw4 *v7; // eax@4 | |
6771 HRESULT v8; // eax@4 | |
6772 int v9; // ST14_4@5 | |
6773 IDirectDrawSurface *v10; // ST10_4@5 | |
6774 HRESULT v11; // eax@5 | |
6775 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
6776 const char *v13; // [sp+0h] [bp-A0h]@0 | |
6777 int v14; // [sp+4h] [bp-9Ch]@0 | |
6778 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
6779 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
6780 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
6781 int a4; // [sp+98h] [bp-8h]@3 | |
6782 | |
6783 v1 = this; | |
6784 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6785 { | |
6786 v2 = 0; | |
6787 this->field_4004C = 1; | |
6788 memset(&ddsd2, 0, 0x7Cu); | |
6789 v7 = v1->pDirectDraw4; | |
6790 ddsd2.dwBackBufferCount = 1; | |
6791 ddsd2.dwSize = 0x7Cu; | |
6792 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
6793 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
6794 ErrD3D(v7->CreateSurface( | |
6795 &ddsd2, | |
6796 &pFrontBuffer4, | |
6797 0)); | |
6798 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
6799 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6800 } | |
6801 else | |
6802 { | |
6803 v2 = 0; | |
6804 this->field_4004C = 1; | |
6805 | |
6806 DDSURFACEDESC ddsd; | |
6807 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
6808 | |
6809 ddsd.lpSurface = (LPVOID)1; | |
6810 ddsd.lPitch = 108; | |
6811 ddsd.dwBackBufferCount = 33; | |
6812 ddsd.ddsCaps.dwCaps = 8728; | |
6813 ErrD3D(pDirectDraw2->CreateSurface( | |
6814 &ddsd, | |
6815 (IDirectDrawSurface **)&pFrontBuffer2, | |
6816 0)); | |
6817 | |
6818 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
6819 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6820 } | |
6821 v9 = (int)v6; | |
6822 v10 = pFrontBuffer; // BUG | |
6823 | |
6824 v17.dwCaps = 4; | |
6825 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
6826 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
6827 v1->field_40030 = v2; | |
6828 v1->field_18_locked_pitch = v2; | |
6829 } | |
6830 | |
6831 //----- (004A14F4) -------------------------------------------------------- | |
6832 void Render::CreateClipper(HWND a2) | |
6833 { | |
6834 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6835 { | |
6836 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
6837 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6838 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
6839 } | |
6840 else | |
6841 { | |
6842 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
6843 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6844 } | |
6845 } | |
6846 | |
6847 //----- (004A15D8) -------------------------------------------------------- | |
6848 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
6849 { | |
6850 IDirectDrawSurface *v2; // eax@3 | |
6851 | |
6852 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6853 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6854 else | |
6855 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6856 v2->GetPixelFormat(pOut); | |
6857 } | |
6858 | |
6859 //----- (004A1605) -------------------------------------------------------- | |
6860 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
6861 { | |
6862 Render *v3; // esi@1 | |
6863 signed int v4; // eax@3 | |
6864 | |
6865 v3 = this; | |
6866 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6867 { | |
6868 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6869 memset(&pDesc, 0, 0x7Cu); | |
6870 pDesc.dwSize = 124; | |
168 | 6871 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6872 *pOutSurfacePtr = pDesc.lpSurface; |
6873 v4 = pDesc.lPitch; | |
6874 } | |
6875 else | |
6876 { | |
6877 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6878 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6879 pDesc.lPitch = 108; | |
6880 LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); | |
6881 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
6882 v4 = pDesc.dwReserved; | |
6883 } | |
6884 *pOutPixelsPerRow = v4 >> 1; | |
6885 } | |
6886 | |
6887 //----- (004A169E) -------------------------------------------------------- | |
6888 bool Render::UsingDirect3D() | |
6889 { | |
6890 return bUserDirect3D == 0; | |
6891 } | |
6892 | |
6893 //----- (004A16E1) -------------------------------------------------------- | |
6894 void Render::UnlockBackBuffer() | |
6895 { | |
6896 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6897 ErrD3D(pBackBuffer4->Unlock(0)); | |
6898 else | |
6899 ErrD3D(pBackBuffer2->Unlock(0)); | |
6900 } | |
6901 | |
6902 //----- (004A172E) -------------------------------------------------------- | |
6903 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
6904 { | |
6905 Render *v3; // esi@1 | |
6906 signed int v4; // eax@3 | |
6907 | |
6908 v3 = this; | |
6909 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6910 { | |
6911 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6912 memset(&pDesc, 0, 0x7Cu); | |
6913 pDesc.dwSize = 124; | |
168 | 6914 LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6915 *pOutSurface = pDesc.lpSurface; |
6916 v4 = pDesc.lPitch; | |
6917 } | |
6918 else | |
6919 { | |
6920 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6921 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6922 pDesc.lPitch = 108; | |
6923 LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); | |
6924 *pOutSurface = (void *)pDesc.lpSurface; | |
6925 v4 = pDesc.dwReserved; | |
6926 } | |
6927 *pOutPixelsPerRow = v4 >> 1; | |
6928 } | |
6929 | |
6930 //----- (004A17C7) -------------------------------------------------------- | |
6931 void Render::UnlockFrontBuffer() | |
6932 { | |
6933 IDirectDrawSurface *pFront; // eax@3 | |
6934 HRESULT v2; // eax@5 | |
6935 signed int v3; // [sp-8h] [bp-Ch]@3 | |
6936 int v4; // [sp-4h] [bp-8h]@3 | |
6937 | |
6938 auto a5 = this; | |
6939 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6940 { | |
6941 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
6942 v4 = 0; | |
6943 v3 = 2615; | |
6944 } | |
6945 else | |
6946 { | |
6947 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
6948 v4 = 0; | |
6949 v3 = 2611; | |
6950 } | |
6951 ErrD3D(pFront->Unlock(0)); | |
6952 } | |
6953 | |
6954 //----- (004A1814) -------------------------------------------------------- | |
6955 void Render::RestoreFrontBuffer() | |
6956 { | |
6957 IDirectDrawSurface **v1; // esi@2 | |
6958 | |
6959 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6960 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
6961 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
6962 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
6963 (*v1)->Restore(); | |
6964 } | |
6965 | |
6966 //----- (004A184C) -------------------------------------------------------- | |
6967 HRESULT Render::_4A184C() | |
6968 { | |
6969 IDirectDrawSurface **pBack; // esi@2 | |
6970 HRESULT result; // eax@4 | |
6971 | |
6972 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6973 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
6974 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
6975 result = (*pBack)->IsLost(); | |
6976 if ( result == DDERR_SURFACELOST ) | |
6977 result = (*pBack)->Restore(); | |
6978 return result; | |
6979 } | |
6980 | |
6981 //----- (004A1884) -------------------------------------------------------- | |
6982 void Render::PresentRect(RECT *a2, RECT *a3) | |
6983 { | |
6984 IDirectDrawSurface *pFront; // eax@3 | |
6985 HRESULT v4; // eax@5 | |
6986 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
6987 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
6988 DWORD v7; // [sp-14h] [bp-14h]@3 | |
6989 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
6990 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
6991 int v10; // [sp-8h] [bp-8h]@3 | |
6992 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
6993 | |
6994 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6995 { | |
6996 v11 = 0; | |
6997 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6998 v10 = 2657; | |
6999 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
7000 v8 = 0; | |
7001 v7 = DDBLT_WAIT; | |
7002 v6 = a3; | |
7003 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
7004 } | |
7005 else | |
7006 { | |
7007 v11 = 0; | |
7008 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
7009 v10 = 2653; | |
7010 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
7011 v8 = 0; | |
7012 v7 = DDBLT_WAIT; | |
7013 v6 = a3; | |
7014 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7015 } | |
7016 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
7017 } | |
7018 | |
7019 //----- (004A18F5) -------------------------------------------------------- | |
7020 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
7021 { | |
7022 IDirectDrawSurface *pFront; // eax@3 | |
7023 HRESULT v6; // eax@5 | |
7024 int v7; // [sp-8h] [bp-8h]@3 | |
7025 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
7026 | |
7027 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
7028 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7029 else | |
7030 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7031 } | |
7032 | |
7033 //----- (004A194A) -------------------------------------------------------- | |
7034 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
7035 { | |
7036 IDirectDrawSurface *pFront; // eax@3 | |
7037 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
7038 | |
7039 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
7040 { | |
7041 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
7042 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
7043 } | |
7044 else | |
7045 { | |
7046 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
7047 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7048 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7049 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 7050 } |
7051 | |
7052 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7053 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7054 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7055 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7056 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7057 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7058 //int v6; // ecx@5 |
0 | 7059 unsigned int v7; // edx@6 |
7060 char *v8; // ecx@12 | |
7061 void *v9; // edi@16 | |
7062 unsigned int v10; // eax@16 | |
7063 void *v11; // edi@21 | |
7064 unsigned int v12; // eax@21 | |
7065 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7066 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7067 if (uNumBillboardsToDraw >= 999 ) |
0 | 7068 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7069 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7070 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7071 uNumBillboardsToDraw = 1; |
0 | 7072 return 0; |
7073 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7074 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7075 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7076 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7077 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7078 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7079 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7080 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7081 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7082 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7083 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7084 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7085 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7086 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7087 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7088 if (z > *(float *)v8 ) |
0 | 7089 { |
7090 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
7091 { | |
7092 v7 = pRenderer->uNumBillboardsToDraw; | |
7093 } | |
7094 else | |
7095 { | |
7096 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7097 { | |
7098 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7099 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
7100 do | |
7101 { | |
7102 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
7103 v9 = (char *)v9 - 156; | |
7104 --v10; | |
7105 } | |
7106 while ( v10 ); | |
7107 } | |
7108 ++v7; | |
7109 } | |
717 | 7110 //LABEL_23: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7111 uNumBillboardsToDraw++; |
0 | 7112 return v7; |
7113 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7114 if (z <= *(float *)v8 ) |
0 | 7115 { |
7116 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7117 { | |
7118 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7119 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
7120 do | |
7121 { | |
7122 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
7123 v11 = (char *)v11 - 156; | |
7124 --v12; | |
7125 } | |
7126 while ( v12 ); | |
7127 } | |
717 | 7128 //goto LABEL_23; |
7129 uNumBillboardsToDraw++; | |
7130 return v7; | |
0 | 7131 } |
7132 return v7; | |
7133 } | |
7134 | |
7135 //----- (004A1E9D) -------------------------------------------------------- | |
7136 unsigned int Render::GetBillboardDrawListSize() | |
7137 { | |
7138 return pRenderer->uNumBillboardsToDraw; | |
7139 } | |
7140 | |
7141 //----- (004A1EA3) -------------------------------------------------------- | |
7142 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
7143 { | |
7144 return pRenderer->pBillboardRenderListD3D[uBillboardID].uParentBillboardID; | |
7145 } | |
7146 | |
7147 //----- (004A1EB6) -------------------------------------------------------- | |
7148 void Render::BeginSceneD3D() | |
7149 { | |
7150 if (!uNumD3DSceneBegins++) | |
7151 { | |
7152 if (pRenderD3D) | |
7153 { | |
7154 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
7155 pRenderer->uNumBillboardsToDraw = 0; | |
7156 pRenderD3D->pDevice->BeginScene(); | |
7157 if (!pRenderD3D->DoesRaiseExceptions()) | |
7158 { | |
7159 MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); | |
7160 } | |
7161 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
7162 uFogColor = GetLevelFogColor(); | |
7163 else | |
7164 uFogColor = 0; | |
7165 | |
7166 if ( uFogColor & 0xFF000000 ) | |
7167 { | |
7168 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
7169 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
7170 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
7171 bUsingSpecular = true; | |
7172 } | |
7173 else | |
7174 { | |
7175 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
7176 bUsingSpecular = 0; | |
7177 } | |
7178 } | |
7179 else | |
7180 { | |
7181 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
7182 if (pTargetSurface) | |
7183 field_18_locked_pitch = uTargetSurfacePitch; | |
7184 else | |
7185 --uNumD3DSceneBegins; | |
7186 } | |
7187 } | |
7188 } | |
7189 | |
7190 //----- (004A1FE1) -------------------------------------------------------- | |
7191 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
7192 { | |
7193 --uNumD3DSceneBegins; | |
7194 if (uNumD3DSceneBegins) | |
7195 return; | |
7196 | |
7197 if (pRenderD3D) | |
7198 { | |
7199 pGame->draw_debug_outlines(); | |
161 | 7200 DoRenderBillboards_D3D(); |
0 | 7201 pGame->pStru6Instance->RenderSpecialEffects(); |
7202 pRenderD3D->pDevice->EndScene(); | |
7203 } | |
7204 else | |
7205 pGame->pStru6Instance->RenderSpecialEffects(); | |
7206 } | |
7207 | |
7208 //----- (004A2031) -------------------------------------------------------- | |
349 | 7209 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
7210 { | |
638 | 7211 __debugbreak(); // should not fire outside decal builder |
349 | 7212 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 7213 } |
7214 | |
186 | 7215 /*void Render::DrawTerrainPolygon_new(stru148 *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 7216 { |
7217 int v5; // ebx@1 | |
7218 int v6; // edi@1 | |
7219 int v8; // eax@7 | |
7220 float v9; // eax@12 | |
7221 float *v10; // esi@12 | |
7222 float v11; // ecx@14 | |
7223 double v12; // st7@14 | |
7224 double v13; // st7@14 | |
7225 double v14; // st7@14 | |
7226 signed int v15; // eax@14 | |
7227 int v16; // eax@15 | |
7228 float v17; // ST48_4@15 | |
7229 char v18; // zf@17 | |
7230 int v19; // eax@18 | |
7231 int v20; // eax@18 | |
7232 int v21; // edx@20 | |
7233 signed int v22; // ecx@20 | |
7234 int v23; // eax@20 | |
7235 const char *v24; // ST4C_4@20 | |
7236 unsigned int v25; // ST50_4@20 | |
7237 int v26; // ST54_4@20 | |
7238 int v27; // eax@20 | |
7239 _UNKNOWN *v28; // eax@21 | |
7240 int v29; // ecx@23 | |
7241 int v30; // eax@23 | |
7242 int v31; // eax@23 | |
7243 int v32; // eax@24 | |
7244 int v33; // eax@25 | |
7245 int v34; // eax@25 | |
7246 int v35; // eax@25 | |
7247 int v36; // eax@25 | |
7248 signed int v37; // ecx@26 | |
7249 int v38; // eax@26 | |
7250 _UNKNOWN *v39; // eax@27 | |
7251 int v40; // edx@28 | |
7252 int v41; // eax@29 | |
7253 int v42; // eax@29 | |
7254 int v43; // eax@29 | |
7255 int v44; // eax@29 | |
7256 unsigned int v46; // eax@29 | |
7257 int v47; // eax@30 | |
7258 int v48; // eax@30 | |
7259 int v49; // eax@30 | |
7260 double v52; // st6@35 | |
7261 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
7262 int v57; // [sp+5Ch] [bp-Ch]@3 | |
7263 signed int v59; // [sp+60h] [bp-8h]@12 | |
7264 int v61; // [sp+64h] [bp-4h]@4 | |
7265 int i; | |
7266 | |
7267 v6 = (int)this; | |
7268 v5 = 0; | |
7269 if (!this->uNumD3DSceneBegins) | |
7270 return; | |
7271 | |
7272 | |
7273 | |
7274 | |
186 | 7275 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 7276 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
7277 if (this->bUsingSpecular) | |
7278 { | |
186 | 7279 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7280 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7281 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 7282 } |
7283 | |
7284 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
7285 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
7286 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7287 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); | |
7288 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
7289 pVertices[0].specular = 0; | |
7290 pVertices[0].texcoord.x = array_50AC10[0].u; | |
7291 pVertices[0].texcoord.y = array_50AC10[0].v; | |
7292 | |
7293 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
7294 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
7295 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7296 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); | |
7297 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
7298 pVertices[1].specular = 0; | |
7299 pVertices[1].texcoord.x = array_50AC10[3].u; | |
7300 pVertices[1].texcoord.y = array_50AC10[3].v; | |
7301 | |
7302 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
7303 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
7304 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7305 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); | |
7306 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
7307 pVertices[2].specular = 0; | |
7308 pVertices[2].texcoord.x = array_50AC10[1].u; | |
7309 pVertices[2].texcoord.y = array_50AC10[1].v; | |
7310 | |
7311 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
7312 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
7313 | |
7314 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
7315 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
7316 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7317 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); | |
7318 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
7319 pVertices[5].specular = 0; | |
7320 pVertices[5].texcoord.x = array_50AC10[2].u; | |
7321 pVertices[5].texcoord.y = array_50AC10[2].v; | |
7322 | |
7323 | |
7324 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7325 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
7326 | |
186 | 7327 }*/ |
7328 | |
0 | 7329 //----- (004A26BC) -------------------------------------------------------- |
186 | 7330 void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
7331 { | |
7332 //RenderVertexSoft *pVertices; // esi@0 | |
7333 //int v7; // edi@1 | |
0 | 7334 unsigned int v8; // ebx@1 |
7335 LightmapBuilder *v9; // esi@3 | |
7336 unsigned int v10; // edx@3 | |
7337 int v11; // eax@5 | |
7338 int v12; // eax@11 | |
7339 char *v13; // esi@11 | |
7340 double v14; // st7@13 | |
7341 double v15; // st7@13 | |
7342 signed int v16; // eax@13 | |
7343 int v17; // ecx@13 | |
7344 double v18; // st7@13 | |
7345 float v19; // ST78_4@14 | |
7346 int v20; // eax@14 | |
7347 char v21; // zf@16 | |
7348 HRESULT v22; // eax@17 | |
7349 HRESULT v23; // eax@17 | |
7350 HRESULT v24; // eax@19 | |
7351 HRESULT v25; // eax@19 | |
7352 unsigned int v26; // ecx@19 | |
7353 char *v27; // eax@20 | |
7354 HRESULT v28; // eax@22 | |
7355 HRESULT v29; // eax@22 | |
7356 HRESULT v30; // eax@23 | |
7357 HRESULT v31; // eax@24 | |
7358 HRESULT v32; // eax@24 | |
7359 HRESULT v33; // eax@24 | |
7360 HRESULT v34; // eax@24 | |
7361 HRESULT v35; // eax@25 | |
7362 HRESULT v36; // eax@25 | |
7363 unsigned int v37; // ecx@25 | |
7364 char *v38; // eax@26 | |
7365 int v39; // edx@27 | |
7366 HRESULT v40; // eax@28 | |
7367 HRESULT v41; // eax@28 | |
7368 HRESULT v42; // eax@28 | |
7369 HRESULT v43; // eax@28 | |
7370 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
7371 unsigned int v45; // eax@28 | |
7372 HRESULT v46; // eax@29 | |
7373 HRESULT v47; // eax@29 | |
7374 HRESULT v48; // eax@29 | |
186 | 7375 //IDirect3DDevice3 *v49; // eax@35 |
0 | 7376 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
7377 int v51; // eax@40 | |
7378 char *v52; // esi@40 | |
7379 double v53; // st7@42 | |
7380 double v54; // st7@42 | |
7381 signed int v55; // eax@42 | |
7382 int v56; // ecx@42 | |
7383 double v57; // st7@42 | |
7384 float v58; // ST7C_4@43 | |
7385 int v59; // eax@43 | |
186 | 7386 //signed int v60; // [sp+78h] [bp-14h]@31 |
7387 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 7388 const char *v62; // [sp+80h] [bp-Ch]@0 |
7389 const char *v63; // [sp+80h] [bp-Ch]@19 | |
7390 int v64; // [sp+84h] [bp-8h]@0 | |
7391 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
7392 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
7393 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 7394 int a7; |
7395 | |
7396 //v7 = (int)this; | |
0 | 7397 v8 = 0; |
186 | 7398 if (!this->uNumD3DSceneBegins) |
75 | 7399 return; |
7400 if ( uNumVertices < 3) | |
7401 return; | |
7402 | |
186 | 7403 //v61 = pVertices; |
7404 | |
75 | 7405 /* v9 = pGame->pLightmapBuilder; |
0 | 7406 v65 = v9; |
75 | 7407 v10 = v9->std__vector_000004_size;*/ |
0 | 7408 if ( byte_4D864C && pGame->uFlags & 1 ) |
7409 { | |
638 | 7410 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
75 | 7411 pGame->pLightmapBuilder->_45D74F_MessWithLight(v11, 0); |
0 | 7412 } |
7413 else | |
7414 { | |
186 | 7415 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 7416 byte_4D864C && pGame->uFlags & 2 ) |
7417 { | |
186 | 7418 if (clampAtTextureBorders) |
7419 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 7420 else |
186 | 7421 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
7422 | |
7423 if (transparent || this->bUsingSpecular) | |
7424 { | |
7425 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
7426 if (transparent) | |
0 | 7427 { |
186 | 7428 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
7429 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
7430 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
7431 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 7432 } |
7433 else | |
7434 { | |
186 | 7435 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
7436 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 7437 } |
186 | 7438 } |
7439 if (uNumVertices > 0) | |
7440 { | |
7441 v51 = (int)&d3d_vertex_buffer[0].pos.y; | |
0 | 7442 v52 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 7443 a7 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7444 v66 = uNumVertices; |
7445 while ( 1 ) | |
7446 { | |
7447 v53 = *(float *)v52 * 1000.0; | |
7448 *(int *)(v51 - 4) = *((int *)v52 + 3); | |
7449 v54 = v53 / (double)pOutdoorCamera->shading_dist_mist; | |
7450 *(int *)v51 = *((int *)v52 + 4); | |
7451 *(float *)(v51 + 4) = 1.0 - 1.0 / v54; | |
7452 *(float *)(v51 + 8) = 1.0 / (*(float *)v52 + 0.0000001); | |
638 | 7453 v55 = ::GetActorTintColor(a4->dimming_level, 0, *(float *)v52, 0, 0); |
0 | 7454 v56 = a7; |
7455 v57 = *(float *)v52; | |
7456 *(int *)(a7 + 12) = v55; | |
75 | 7457 if ( this->bUsingSpecular ) |
0 | 7458 { |
7459 v58 = v57; | |
7460 v59 = sub_47C3D7_get_fog_related_stuff(0, 0, v58); | |
7461 v56 = a7; | |
7462 } | |
7463 else | |
7464 { | |
7465 v59 = 0; | |
7466 } | |
7467 *(int *)(v56 + 16) = v59; | |
7468 *(int *)(v56 + 20) = *((int *)v52 + 6); | |
7469 *(int *)(v56 + 24) = *((int *)v52 + 7); | |
7470 v52 += 48; | |
7471 v21 = v66-- == 1; | |
7472 a7 = v56 + 32; | |
7473 if ( v21 ) | |
7474 break; | |
7475 v51 = a7; | |
7476 } | |
7477 } | |
86 | 7478 this->pRenderD3D->pDevice->SetTexture(0, a5); |
186 | 7479 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
7480 if (transparent) | |
7481 { | |
7482 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
7483 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
7484 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7485 } |
7486 } | |
7487 else | |
7488 { | |
7489 if ( (signed int)uNumVertices > 0 ) | |
7490 { | |
186 | 7491 v12 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7492 v13 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 7493 a7 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7494 a6a = uNumVertices; |
7495 while ( 1 ) | |
7496 { | |
7497 v14 = *(float *)v13 * 1000.0; | |
7498 *(int *)(v12 - 4) = *((int *)v13 + 3); | |
7499 v15 = v14 / (double)pOutdoorCamera->shading_dist_mist; | |
7500 *(int *)v12 = *((int *)v13 + 4); | |
7501 *(float *)(v12 + 4) = 1.0 - 1.0 / v15; | |
7502 *(float *)(v12 + 8) = 1.0 / (*(float *)v13 + 0.0000001); | |
638 | 7503 v16 = GetActorTintColor(a4->dimming_level, 0, *(float *)v13, 0, 0); |
0 | 7504 v17 = a7; |
7505 v18 = *(float *)v13; | |
7506 *(int *)(a7 + 12) = v16; | |
75 | 7507 if ( this->bUsingSpecular ) |
0 | 7508 { |
7509 v19 = v18; | |
7510 v20 = sub_47C3D7_get_fog_related_stuff(0, 0, v19); | |
7511 v17 = a7; | |
7512 } | |
7513 else | |
7514 { | |
7515 v20 = 0; | |
7516 } | |
7517 *(int *)(v17 + 16) = v20; | |
7518 *(int *)(v17 + 20) = *((int *)v13 + 6); | |
7519 *(int *)(v17 + 24) = *((int *)v13 + 7); | |
7520 v13 += 48; | |
7521 v21 = a6a-- == 1; | |
7522 a7 = v17 + 32; | |
7523 if ( v21 ) | |
7524 break; | |
7525 v12 = a7; | |
7526 } | |
7527 } | |
186 | 7528 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
7529 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
7530 if (pRenderer->bUsingSpecular) | |
7531 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 7532 |
7533 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 7534 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7535 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7536 d3d_vertex_buffer, |
0 | 7537 uNumVertices, |
7538 16)); | |
7539 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 7540 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 7541 //(*(void (**)(void))(*(int *)v63 + 88))(); |
7542 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7543 v26 = uNumVertices; | |
7544 if ( (signed int)uNumVertices > 0 ) | |
7545 { | |
186 | 7546 v27 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 7547 do |
7548 { | |
7549 *(int *)v27 = -1; | |
7550 v27 += 32; | |
7551 --v26; | |
7552 } | |
7553 while ( v26 ); | |
7554 } | |
7555 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); | |
186 | 7556 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7557 if ( !pRenderer->bUsingSpecular ) |
7558 { | |
186 | 7559 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
7560 } | |
7561 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7562 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7563 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7564 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7565 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7566 d3d_vertex_buffer, |
0 | 7567 uNumVertices, |
7568 16)); | |
7569 if ( pRenderer->bUsingSpecular ) | |
7570 { | |
186 | 7571 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 7572 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
7573 v37 = uNumVertices; | |
7574 if ( (signed int)uNumVertices > 0 ) | |
7575 { | |
186 | 7576 v38 = (char *)&d3d_vertex_buffer[0].specular; |
0 | 7577 do |
7578 { | |
7579 v39 = *(int *)v38; | |
7580 *(int *)v38 = 0; | |
7581 v38 += 32; | |
7582 --v37; | |
7583 *((int *)v38 - 9) = pRenderer->uFogColor | v39 & 0xFF000000; | |
7584 } | |
7585 while ( v37 ); | |
7586 } | |
75 | 7587 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 7588 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
7589 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
7590 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7591 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7592 d3d_vertex_buffer, |
0 | 7593 uNumVertices, |
7594 16)); | |
186 | 7595 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 7596 //v44 = pRenderer->pRenderD3D->pDevice; |
7597 v45 = GetLevelFogColor(); | |
7598 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
7599 v8 = 0; | |
7600 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
7601 } | |
186 | 7602 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7603 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7604 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
7605 } | |
7606 } | |
186 | 7607 |
791 | 7608 if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
186 | 7609 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 7610 } |
7611 // 4A26BC: could not find valid save-restore pair for esi | |
7612 // 4D864C: using guessed type char byte_4D864C; | |
7613 | |
7614 //----- (004A2DA3) -------------------------------------------------------- | |
852 | 7615 void Render::DrawSkyPolygon(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) |
7616 { | |
67 | 7617 int v7; // eax@7 |
0 | 7618 float v13; // ST3C_4@8 |
67 | 7619 int i; |
7620 | |
7621 if ( !this->uNumD3DSceneBegins ) | |
7622 return; | |
7623 if ( uNumVertices >= 3 ) | |
7624 { | |
186 | 7625 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 7626 if ( this->bUsingSpecular ) |
7627 { | |
186 | 7628 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7629 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7630 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 7631 } |
840 | 7632 for ( i = 0; i < uNumVertices; ++i ) |
67 | 7633 { |
7634 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7635 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7636 pVertices[i].pos.z = 0.99989998; | |
168 | 7637 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 7638 |
840 | 7639 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 7640 v7 = 0; |
7641 if (this->bUsingSpecular) | |
7642 { | |
7643 v13 = array_50AC10[i].vWorldViewPosition.x; | |
7644 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); | |
7645 } | |
7646 pVertices[i].specular = v7; | |
7647 pVertices[i].texcoord.x = array_50AC10[i].u; | |
7648 pVertices[i].texcoord.y = array_50AC10[i].v; | |
7649 } | |
7650 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7651 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 7652 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 7653 } |
7654 } | |
7655 | |
7656 //----- (004A2ED5) -------------------------------------------------------- | |
7657 void Render::_4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex) | |
7658 { | |
7659 signed int v4; // edi@2 | |
7660 int v5; // eax@3 | |
7661 int v6; // edx@5 | |
7662 char *v7; // eax@6 | |
7663 char *v8; // ecx@6 | |
7664 double v9; // st6@7 | |
7665 int v10; // ebx@7 | |
7666 int v11; // ebx@7 | |
7667 | |
7668 if ( this->uNumD3DSceneBegins ) | |
7669 { | |
7670 v4 = a2; | |
7671 if ( a2 >= 3 ) | |
7672 { | |
186 | 7673 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
638 | 7674 v5 = 31 - (a3->dimming_level & 0x1F); |
7675 if ( v5 < pOutdoor->max_terrain_dimming_level ) | |
7676 v5 = pOutdoor->max_terrain_dimming_level; | |
0 | 7677 v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); |
7678 if ( a2 > 0 ) | |
7679 { | |
186 | 7680 v7 = (char *)&d3d_vertex_buffer[0].pos.y; |
0 | 7681 v8 = (char *)&array_507D30[0].vWorldViewProjY; |
7682 do | |
7683 { | |
7684 v9 = *((float *)v8 - 4) * 0.061758894; | |
7685 v10 = *((int *)v8 - 1); | |
7686 *((int *)v7 + 4) = 0; | |
7687 *((int *)v7 - 1) = v10; | |
7688 *(int *)v7 = *(int *)v8; | |
7689 *((int *)v7 + 2) = *((int *)v8 + 1); | |
7690 *((int *)v7 + 5) = *((int *)v8 + 2); | |
7691 v11 = *((int *)v8 + 3); | |
7692 *((int *)v7 + 3) = v6; | |
7693 *((int *)v7 + 6) = v11; | |
7694 v8 += 48; | |
7695 v7 += 32; | |
7696 --v4; | |
7697 *((float *)v7 - 7) = 1.0 - 1.0 / v9; | |
7698 } | |
7699 while ( v4 ); | |
7700 } | |
7701 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
186 | 7702 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7703 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7704 d3d_vertex_buffer, |
0 | 7705 a2, |
7706 28)); | |
7707 } | |
7708 } | |
7709 } | |
7710 | |
7711 //----- (004A2FC0) -------------------------------------------------------- | |
7712 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
7713 { | |
7714 //Render *v8; // edi@1 | |
7715 //unsigned int v9; // esi@3 | |
7716 char *v12; // ecx@9 | |
7717 char *v13; // eax@9 | |
7718 double v14; // st6@10 | |
7719 int v15; // edx@10 | |
7720 Texture *v16; // edx@10 | |
7721 double v17; // st6@10 | |
7722 //char v18; // zf@10 | |
7723 Texture *v19; // edx@10 | |
595 | 7724 //Texture *v23; // edx@16 |
7725 //char *v24; // ecx@16 | |
7726 //char *v25; // eax@16 | |
7727 //double v26; // st6@17 | |
7728 //int v27; // esi@17 | |
7729 //double v28; // st6@17 | |
7730 //unsigned int v33; // ecx@18 | |
7731 //char *v34; // eax@19 | |
0 | 7732 //Texture *v45; // edx@23 |
7733 //char *v46; // ecx@23 | |
7734 //char *v47; // eax@23 | |
7735 //double v48; // st6@24 | |
7736 //int v49; // esi@24 | |
7737 //double v50; // st6@24 | |
7738 const char *v53; // [sp-Ch] [bp-20h]@21 | |
7739 //int v54; // [sp-8h] [bp-1Ch]@21 | |
7740 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
7741 const char *v56; // [sp+0h] [bp-14h]@0 | |
7742 int v57; // [sp+4h] [bp-10h]@0 | |
7743 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
7744 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
7745 //int a3a; // [sp+10h] [bp-4h]@4 | |
7746 | |
7747 //v8 = this; | |
7748 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
7749 return; | |
7750 | |
7751 //auto a3 = pFace; | |
7752 //auto a6 = uPackedID; | |
7753 //v59 = pGame->pLightmapBuilder; | |
7754 //v9 = v59->std__vector_000004_size; | |
7755 | |
7756 auto uCorrectedColor = uColor; | |
7757 if (pGame->pLightmapBuilder->std__vector_000004_size) | |
7758 uCorrectedColor = 0xFFFFFFFF; | |
638 | 7759 pGame->AlterGamma_BLV(pFace, &uCorrectedColor); |
0 | 7760 |
792 | 7761 |
7762 if (pFace->uAttributes & FACE_OUTLINED) | |
7763 { | |
7764 int color; | |
7765 if (GetTickCount() % 300 >= 150) | |
7766 uColor = uCorrectedColor = 0xFF20FF20; | |
7767 else uColor = uCorrectedColor = 0xFF109010; | |
7768 } | |
7769 | |
0 | 7770 if (byte_4D864C && pGame->uFlags & 1) |
7771 { | |
7772 __debugbreak(); | |
7773 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 7774 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7775 if ( (signed int)uNumVertices > 0 ) |
7776 { | |
7777 v12 = (char *)&array_507D30[0].vWorldViewPosition; | |
186 | 7778 v13 = (char *)&d3d_vertex_buffer[0].pos.y; |
0 | 7779 auto a7 = uNumVertices; |
7780 uint v18; | |
7781 do | |
7782 { | |
7783 v14 = *(float *)v12 * 0.061758894; | |
7784 v15 = *((int *)v12 + 3); | |
7785 *((int *)v13 + 4) = 0; | |
7786 *((int *)v13 - 1) = v15; | |
7787 *(int *)v13 = *((int *)v12 + 4); | |
7788 *((int *)v13 + 3) = uCorrectedColor; | |
7789 v16 = pTex; | |
7790 v13 += 32; | |
7791 *((float *)v13 - 7) = 1.0 - 1.0 / v14; | |
7792 v17 = 1.0 / *(float *)v12; | |
7793 v12 += 48; | |
7794 v18 = a7-- == 1; | |
7795 *((float *)v13 - 6) = v17; | |
7796 pHwTex = (IDirect3DTexture2 *)v16->uTextureWidth; | |
7797 v19 = pTex; | |
7798 *((float *)v13 - 3) = *((float *)v12 - 6) / (double)(signed int)pHwTex; | |
7799 pHwTex = (IDirect3DTexture2 *)v19->uTextureHeight; | |
7800 *((float *)v13 - 2) = *((float *)v12 - 5) / (double)(signed int)pHwTex; | |
7801 } | |
7802 while ( !v18 ); | |
7803 } | |
186 | 7804 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7805 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
7806 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7807 D3DPT_TRIANGLEFAN, | |
7808 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7809 d3d_vertex_buffer, |
0 | 7810 uNumVertices, |
7811 28)); | |
7812 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7813 } | |
7814 else | |
7815 { | |
7816 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
7817 byte_4D864C && pGame->uFlags & 2) | |
7818 { | |
7819 for (uint i = 0; i < uNumVertices; ++i) | |
7820 { | |
186 | 7821 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
7822 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7823 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7824 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7825 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7826 d3d_vertex_buffer[i].specular = 0; | |
7827 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7828 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7829 } | |
7830 | |
7831 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 7832 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
7833 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
7834 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7835 d3d_vertex_buffer, |
0 | 7836 uNumVertices, |
7837 28)); | |
7838 } | |
7839 else | |
7840 { | |
595 | 7841 for (uint i = 0; i < uNumVertices; ++i) |
7842 { | |
7843 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
7844 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7845 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7846 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7847 d3d_vertex_buffer[i].diffuse = uColor; | |
7848 d3d_vertex_buffer[i].specular = 0; | |
7849 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7850 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7851 } | |
7852 //__debugbreak(); | |
7853 //if ( (signed int)uNumVertices > 0 ) | |
7854 //{ | |
7855 //v23 = pTex; | |
7856 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
7857 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
7858 //pTex = (Texture *)uNumVertices; | |
7859 //uint v18; | |
7860 //do | |
7861 //{ | |
7862 //v26 = *(float *)v24 * 0.061758894; | |
7863 //v27 = *((int *)v24 + 3); | |
7864 //*((int *)v25 + 4) = 0; | |
7865 //*((int *)v25 - 1) = v27; | |
7866 //*(int *)v25 = *((int *)v24 + 4); | |
7867 //*((int *)v25 + 3) = uColor; | |
7868 //v25 += 32; | |
7869 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
7870 //v28 = 1.0 / *(float *)v24; | |
7871 //v24 += 48; | |
7872 //v18 = pTex == (Texture *)1; | |
7873 //pTex = (Texture *)((char *)pTex - 1); | |
7874 //*((float *)v25 - 6) = v28; | |
0 | 7875 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 7876 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 7877 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 7878 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
7879 //} | |
7880 //while ( !v18 ); | |
7881 //} | |
0 | 7882 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 7883 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7884 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 7885 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7886 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7887 d3d_vertex_buffer, |
0 | 7888 uNumVertices, |
7889 28)); | |
595 | 7890 |
7891 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 7892 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); |
595 | 7893 |
7894 for (uint i = 0; i < uNumVertices; ++i) | |
7895 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7896 /*v33 = uNumVertices; | |
0 | 7897 if ( (signed int)uNumVertices > 0 ) |
7898 { | |
186 | 7899 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 7900 do |
7901 { | |
7902 *(int *)v34 = uCorrectedColor; | |
7903 v34 += 32; | |
7904 --v33; | |
7905 } | |
7906 while ( v33 ); | |
595 | 7907 }*/ |
0 | 7908 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 7909 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
7910 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
7911 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7912 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7913 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7914 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7915 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7916 d3d_vertex_buffer, |
0 | 7917 uNumVertices, |
7918 28)); | |
186 | 7919 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7920 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
7921 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 7922 } |
7923 } | |
7924 } | |
7925 // 4D864C: using guessed type char byte_4D864C; | |
7926 | |
7927 //----- (004A43B1) -------------------------------------------------------- | |
717 | 7928 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
7929 { | |
7930 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
7931 //double v5; // st7@2 | |
7932 //float v6; // ST08_4@2 | |
0 | 7933 unsigned int v7; // eax@2 |
717 | 7934 //int v8; // ecx@2 |
7935 //unsigned int v9; // esi@2 | |
7936 //Sprite *v10; // edi@5 | |
0 | 7937 signed int v11; // eax@9 |
7938 signed int v12; // eax@9 | |
717 | 7939 //double v13; // st7@12 |
7940 //double v14; // st6@12 | |
0 | 7941 double v15; // st5@12 |
7942 double v16; // st4@12 | |
7943 double v17; // st3@12 | |
7944 double v18; // st2@12 | |
7945 int v19; // ecx@14 | |
7946 double v20; // st3@14 | |
7947 int v21; // ecx@16 | |
7948 double v22; // st3@16 | |
717 | 7949 //IDirect3DTexture2 *v23; // eax@18 |
7950 //signed int v24; // [sp+18h] [bp-18h]@5 | |
7951 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
7952 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 7953 float v27; // [sp+24h] [bp-Ch]@5 |
7954 int v28; // [sp+28h] [bp-8h]@2 | |
7955 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 7956 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 7957 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 7958 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 7959 float a1; // [sp+40h] [bp+10h]@5 |
7960 | |
717 | 7961 //v26 = this; |
0 | 7962 if ( this->uNumD3DSceneBegins ) |
7963 { | |
717 | 7964 //v4 = pSoftBillboard; |
7965 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
7966 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
7967 //v6 = pSoftBillboard->zbuffer_depth; | |
7968 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
7969 //v8 = dimming_level; | |
7970 //v9 = v7; | |
657 | 7971 v28 = dimming_level & 0xFF000000; |
7972 if ( dimming_level & 0xFF000000 ) | |
717 | 7973 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; |
0 | 7974 else |
717 | 7975 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; |
7976 //v10 = a3; | |
7977 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
7978 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
7979 pBillboardRenderListD3D[v7].uParentBillboardID = pSoftBillboard->uParentBillboardID; | |
7980 //v25 = pSoftBillboard->uScreenSpaceX; | |
7981 //v24 = pSoftBillboard->uScreenSpaceY; | |
7982 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
7983 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
7984 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
7985 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
7986 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 7987 v31 = v31 * -1.0; |
717 | 7988 if ( pSoftBillboard->uTintColor && this->bTinting ) |
7989 { | |
7990 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
737 | 7991 v12 = BlendColors(pSoftBillboard->uTintColor, v11); |
0 | 7992 if ( v28 ) |
7993 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
7994 } | |
7995 else | |
7996 { | |
717 | 7997 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
7998 } | |
7999 //v13 = (double)v25; | |
8000 pBillboardRenderListD3D[v7].pQuards[0].specular = 0; | |
8001 pBillboardRenderListD3D[v7].pQuards[0].diffuse = v12; | |
8002 pBillboardRenderListD3D[v7].pQuards[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
8003 //v14 = (double)v24; | |
8004 //v32 = v14; | |
8005 pBillboardRenderListD3D[v7].pQuards[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; | |
8006 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); | |
8007 pBillboardRenderListD3D[v7].pQuards[0].pos.z = v15; | |
8008 v16 = 1.0 / pSoftBillboard->zbuffer_depth; | |
8009 pBillboardRenderListD3D[v7].pQuards[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; | |
8010 pBillboardRenderListD3D[v7].pQuards[0].texcoord.x = 0.0; | |
8011 pBillboardRenderListD3D[v7].pQuards[0].texcoord.y = 0.0; | |
8012 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
8013 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
8014 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8015 v17 = v17 * -1.0; |
717 | 8016 pBillboardRenderListD3D[v7].pQuards[1].specular = 0; |
8017 pBillboardRenderListD3D[v7].pQuards[1].diffuse = v12; | |
8018 pBillboardRenderListD3D[v7].pQuards[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
8019 pBillboardRenderListD3D[v7].pQuards[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
8020 pBillboardRenderListD3D[v7].pQuards[1].pos.z = v15; | |
8021 pBillboardRenderListD3D[v7].pQuards[1].rhw = v16; | |
8022 pBillboardRenderListD3D[v7].pQuards[1].texcoord.x = 0.0; | |
8023 pBillboardRenderListD3D[v7].pQuards[1].texcoord.y = 1.0; | |
8024 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; | |
8025 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
8026 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8027 v20 = v20 * -1.0; |
717 | 8028 pBillboardRenderListD3D[v7].pQuards[2].specular = 0; |
8029 pBillboardRenderListD3D[v7].pQuards[2].diffuse = v12; | |
8030 pBillboardRenderListD3D[v7].pQuards[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
8031 pBillboardRenderListD3D[v7].pQuards[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
8032 pBillboardRenderListD3D[v7].pQuards[2].pos.z = v15; | |
8033 pBillboardRenderListD3D[v7].pQuards[2].rhw = v16; | |
8034 pBillboardRenderListD3D[v7].pQuards[2].texcoord.x = 1.0; | |
8035 pBillboardRenderListD3D[v7].pQuards[2].texcoord.y = 1.0; | |
8036 v21 = pSprite->uBufferHeight - pSprite->uAreaY; | |
8037 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
8038 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8039 v22 = v22 * -1.0; |
717 | 8040 pBillboardRenderListD3D[v7].pQuards[3].specular = 0; |
8041 pBillboardRenderListD3D[v7].pQuards[3].diffuse = v12; | |
8042 pBillboardRenderListD3D[v7].pQuards[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
8043 pBillboardRenderListD3D[v7].pQuards[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
8044 pBillboardRenderListD3D[v7].pQuards[3].pos.z = v15; | |
8045 pBillboardRenderListD3D[v7].pQuards[3].rhw = v16; | |
8046 pBillboardRenderListD3D[v7].pQuards[3].texcoord.x = 1.0; | |
8047 pBillboardRenderListD3D[v7].pQuards[3].texcoord.y = 0.0; | |
8048 //v23 = pSprite->pTexture; | |
8049 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
8050 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
8051 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 8052 } |
8053 } | |
8054 | |
8055 //----- (004A354F) -------------------------------------------------------- | |
8056 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8057 { | |
743 | 8058 //double v5; // st7@3 |
8059 //float v6; // ST20_4@3 | |
8060 //float v7; // ST00_4@3 | |
0 | 8061 unsigned int v8; // esi@3 |
743 | 8062 //int v9; // eax@3 |
8063 //int v10; // ebx@3 | |
0 | 8064 float v11; // ST28_4@3 |
743 | 8065 //double v12; // st7@3 |
8066 //float v13; // ST24_4@3 | |
8067 //double v14; // st6@3 | |
8068 //float v15; // ST1C_4@3 | |
0 | 8069 float v16; // ST2C_4@3 |
8070 float v17; // ST30_4@3 | |
8071 signed int v18; // ST18_4@3 | |
8072 signed int v19; // ST14_4@3 | |
8073 signed int v20; // ST10_4@3 | |
8074 signed int v21; // eax@3 | |
8075 double v22; // st6@3 | |
8076 float v23; // ST2C_4@3 | |
8077 float v24; // ST30_4@3 | |
8078 signed int v25; // ST10_4@3 | |
8079 signed int v26; // ST14_4@3 | |
8080 signed int v27; // ST18_4@3 | |
8081 signed int v28; // eax@3 | |
8082 double v29; // st6@3 | |
8083 float v30; // ecx@3 | |
8084 float v31; // ST2C_4@3 | |
8085 float v32; // ST30_4@3 | |
8086 signed int v33; // ST10_4@3 | |
8087 signed int v34; // ST14_4@3 | |
8088 signed int v35; // ST18_4@3 | |
8089 signed int v36; // eax@3 | |
8090 float v37; // ecx@3 | |
8091 double v38; // st6@3 | |
8092 float v39; // ST2C_4@3 | |
8093 float v40; // ST30_4@3 | |
8094 signed int v41; // ST10_4@3 | |
8095 signed int v42; // ST14_4@3 | |
8096 signed int v43; // ST18_4@3 | |
8097 signed int v44; // eax@3 | |
8098 double v45; // st6@3 | |
8099 float v46; // eax@3 | |
8100 | |
8101 if ( this->uNumD3DSceneBegins ) | |
8102 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8103 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8104 { |
743 | 8105 //v5 = (double)a2->zbuffer_depth; |
8106 //v6 = v5; | |
8107 //v7 = v5; | |
8108 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
0 | 8109 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; |
8110 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8111 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8112 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
743 | 8113 //v9 = a2->uScreenSpaceX; |
8114 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8115 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 8116 //v12 = (double) a2->uScreenSpaceX; |
8117 //v13 = v12; | |
8118 //v14 = (double)(a2->uScreenSpaceY - 12); | |
8119 //v15 = v14; | |
8120 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
8121 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 8122 v18 = stru_5C6E00->Cos(angle); |
8123 v19 = stru_5C6E00->Sin(angle); | |
8124 v20 = stru_5C6E00->Sin(angle); | |
8125 v21 = stru_5C6E00->Cos(angle); | |
0 | 8126 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8127 + (double)(v18 >> 16)) | |
8128 * v16 | |
8129 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
8130 + (double)(v19 >> 16)) | |
8131 * v17) | |
743 | 8132 * v11 + (double) a2->uScreenSpaceX; |
0 | 8133 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
8134 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
8135 - 12.0) | |
8136 * v11 | |
8137 + (double)a2->uScreenSpaceY; | |
8138 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8139 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8140 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22; | |
743 | 8141 pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); |
8142 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; | |
0 | 8143 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8144 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
743 | 8145 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8146 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8147 v25 = stru_5C6E00->Cos(angle); |
8148 v26 = stru_5C6E00->Sin(angle); | |
8149 v27 = stru_5C6E00->Sin(angle); | |
8150 v28 = stru_5C6E00->Cos(angle); | |
0 | 8151 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
8152 + (double)(v25 >> 16)) | |
740 | 8153 * v31 |
0 | 8154 - ((double)(unsigned __int16)v26 * 0.000015259022 |
8155 + (double)(v26 >> 16)) | |
740 | 8156 * v32) |
743 | 8157 * v11 + (double) a2->uScreenSpaceX; |
740 | 8158 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
8159 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 8160 - 12.0) |
8161 * v11 | |
8162 + (double)a2->uScreenSpaceY; | |
8163 pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8164 v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8165 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29; | |
8166 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8167 pBillboardRenderListD3D[v8].pQuards[1].rhw = v30; | |
8168 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8169 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8170 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
743 | 8171 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
8172 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8173 v33 = stru_5C6E00->Cos(angle); |
8174 v34 = stru_5C6E00->Sin(angle); | |
8175 v35 = stru_5C6E00->Sin(angle); | |
8176 v36 = stru_5C6E00->Cos(angle); | |
0 | 8177 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
8178 + (double)(v33 >> 16)) | |
740 | 8179 * v23 |
0 | 8180 - ((double)(unsigned __int16)v34 * 0.000015259022 |
8181 + (double)(v34 >> 16)) | |
740 | 8182 * v24) |
743 | 8183 * v11 + (double) a2->uScreenSpaceX; |
0 | 8184 v37 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; |
740 | 8185 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
8186 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 8187 - 12.0) |
8188 * v11 | |
8189 + (double)a2->uScreenSpaceY; | |
8190 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8191 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37; | |
8192 pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8193 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8194 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38; | |
8195 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8196 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
743 | 8197 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8198 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 8199 v41 = stru_5C6E00->Cos(angle); |
8200 v42 = stru_5C6E00->Sin(angle); | |
8201 v43 = stru_5C6E00->Sin(angle); | |
8202 v44 = stru_5C6E00->Cos(angle); | |
0 | 8203 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
8204 + (double)(v41 >> 16)) | |
8205 * v39 | |
8206 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
8207 + (double)(v42 >> 16)) | |
8208 * v40) | |
743 | 8209 * v11 + (double) a2->uScreenSpaceX; |
0 | 8210 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
8211 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
8212 - 12.0) | |
8213 * v11 | |
8214 + (double)a2->uScreenSpaceY; | |
8215 v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8216 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8217 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46; | |
8218 pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8219 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8220 pBillboardRenderListD3D[v8].pTexture = a3; | |
743 | 8221 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 8222 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8223 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v45; | |
8224 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8225 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8226 } | |
8227 } | |
8228 } | |
8229 | |
8230 //----- (004A3AD9) -------------------------------------------------------- | |
8231 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8232 { | |
8233 double v5; // st7@2 | |
8234 float v6; // ST28_4@2 | |
8235 float v7; // ST00_4@2 | |
8236 unsigned int v8; // esi@2 | |
8237 int v9; // eax@2 | |
8238 int v10; // ebx@2 | |
8239 float v11; // ST34_4@2 | |
8240 double v12; // st7@2 | |
8241 float v13; // ST2C_4@2 | |
8242 double v14; // st6@2 | |
8243 float v15; // ST24_4@2 | |
8244 float v16; // ST38_4@2 | |
8245 float v17; // ST3C_4@2 | |
8246 signed int v18; // ST1C_4@2 | |
8247 int v19; // ST30_4@2 | |
8248 signed int v20; // ST20_4@2 | |
8249 signed int v21; // ST18_4@2 | |
8250 signed int v22; // eax@2 | |
8251 double v23; // st6@2 | |
8252 float v24; // ST20_4@2 | |
8253 float v25; // ST1C_4@2 | |
8254 float v26; // ST38_4@2 | |
8255 float v27; // ST3C_4@2 | |
8256 signed int v28; // ST18_4@2 | |
8257 signed int v29; // ST14_4@2 | |
8258 signed int v30; // ST10_4@2 | |
8259 signed int v31; // eax@2 | |
8260 double v32; // st6@2 | |
8261 float v33; // ST38_4@2 | |
8262 float v34; // ST3C_4@2 | |
8263 signed int v35; // ST10_4@2 | |
8264 signed int v36; // ST14_4@2 | |
8265 signed int v37; // ST18_4@2 | |
8266 signed int v38; // eax@2 | |
8267 double v39; // st6@2 | |
8268 float v40; // ST38_4@2 | |
8269 float v41; // ST3C_4@2 | |
8270 signed int v42; // ST10_4@2 | |
8271 signed int v43; // ST14_4@2 | |
8272 signed int v44; // ST18_4@2 | |
8273 signed int v45; // eax@2 | |
8274 double v46; // st6@2 | |
8275 | |
8276 if ( this->uNumD3DSceneBegins ) | |
8277 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8278 v5 = (double)a2->zbuffer_depth; |
0 | 8279 v6 = v5; |
8280 v7 = v5; | |
8281 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
8282 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
8283 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8284 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8285 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
8286 v9 = a2->uScreenSpaceX; | |
8287 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8288 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 8289 v12 = (double)v9; |
8290 v13 = v12; | |
8291 v14 = (double)(v10 - 12); | |
8292 v15 = v14; | |
8293 v16 = (double)(v9 - 12) - v12; | |
8294 v17 = (double)(v10 - 25) - v14; | |
323 | 8295 v18 = stru_5C6E00->Cos(angle); |
0 | 8296 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 8297 v20 = stru_5C6E00->Sin(angle); |
8298 v21 = stru_5C6E00->Sin(angle); | |
8299 v22 = stru_5C6E00->Cos(angle); | |
0 | 8300 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8301 + (double)(v18 >> 16)) | |
8302 * v16 | |
8303 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
8304 + (double)(v20 >> 16)) | |
8305 * v17) | |
8306 * v11 + v13; | |
8307 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
8308 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
8309 - 12.0) | |
8310 * v11 | |
8311 + (double)a2->uScreenSpaceY; | |
8312 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8313 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8314 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23; | |
8315 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
8316 pBillboardRenderListD3D[v8].pQuards[0].pos.z = v24; | |
8317 v25 = 1.0 / v6; | |
8318 pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; | |
8319 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; | |
8320 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
8321 v26 = (double)(a2->uScreenSpaceX - 12) - v13; | |
8322 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 8323 v28 = stru_5C6E00->Cos(angle); |
8324 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8325 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8326 v31 = stru_5C6E00->Cos(angle); | |
0 | 8327 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
8328 + (double)(v28 >> 16)) | |
8329 * v26 | |
8330 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
8331 + (double)(v29 >> 16)) | |
8332 * v27) | |
8333 * v11 + v13; | |
8334 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
8335 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
8336 - 12.0) | |
8337 * v11 | |
8338 + (double)a2->uScreenSpaceY; | |
8339 pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24; | |
8340 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32; | |
8341 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8342 pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; | |
8343 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8344 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8345 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
8346 v33 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8347 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 8348 v35 = stru_5C6E00->Cos(angle); |
8349 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8350 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8351 v38 = stru_5C6E00->Cos(angle); | |
0 | 8352 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
8353 + (double)(v35 >> 16)) | |
8354 * v33 | |
8355 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
8356 + (double)(v36 >> 16)) | |
8357 * v34) | |
8358 * v11 + v13; | |
8359 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
8360 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
8361 - 12.0) | |
8362 * v11 | |
8363 + (double)a2->uScreenSpaceY; | |
8364 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8365 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24; | |
8366 pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; | |
8367 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8368 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39; | |
8369 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8370 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
8371 v40 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8372 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 8373 v42 = stru_5C6E00->Cos(angle); |
8374 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8375 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8376 v45 = stru_5C6E00->Cos(angle); | |
0 | 8377 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
8378 + (double)(v42 >> 16)) | |
8379 * v40 | |
8380 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
8381 + (double)(v43 >> 16)) | |
8382 * v41) | |
8383 * v11 + v13; | |
8384 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
8385 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
8386 - 12.0) | |
8387 * v11 | |
8388 + (double)a2->uScreenSpaceY; | |
8389 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8390 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24; | |
8391 pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; | |
8392 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8393 pBillboardRenderListD3D[v8].pTexture = a3; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8394 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 8395 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8396 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v46; | |
8397 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8398 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8399 } | |
8400 } | |
8401 | |
8402 //----- (004A4023) -------------------------------------------------------- | |
657 | 8403 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
|
8404 { |
0 | 8405 unsigned int v8; // esi@2 |
8406 double v14; // st6@14 | |
8407 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8408 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8409 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8410 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8411 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8412 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8413 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8414 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8415 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8416 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8417 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 8418 float v29; // [sp+28h] [bp-8h]@5 |
8419 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8420 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8421 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8422 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8423 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8424 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8425 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8426 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8427 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
|
8428 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
|
8429 |
657 | 8430 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
|
8431 if (a2->uTintColor & 0x00FFFFFF && bTinting) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8432 { |
737 | 8433 diffuse = BlendColors(a2->uTintColor, diffuse); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8434 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8435 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8436 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8437 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8438 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8439 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8440 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
|
8441 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8442 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8443 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8444 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8445 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8446 pBillboardRenderListD3D[v8].pQuards[0].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8447 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
|
8448 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
|
8449 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
|
8450 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8451 pBillboardRenderListD3D[v8].pQuards[0].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8452 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8453 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8454 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8455 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8456 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8457 if ( a2->uFlags & 4 ) |
0 | 8458 v14 = v14 * -1.0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8459 pBillboardRenderListD3D[v8].pQuards[1].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8460 pBillboardRenderListD3D[v8].pQuards[1].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8461 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
|
8462 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
|
8463 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
|
8464 pBillboardRenderListD3D[v8].pQuards[1].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8465 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; |
8466 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8467 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8468 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
|
8469 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8470 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8471 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8472 pBillboardRenderListD3D[v8].pQuards[2].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8473 pBillboardRenderListD3D[v8].pQuards[2].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8474 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
|
8475 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
|
8476 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
|
8477 pBillboardRenderListD3D[v8].pQuards[2].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8478 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; |
8479 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8480 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8481 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
|
8482 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8483 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8484 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8485 pBillboardRenderListD3D[v8].pQuards[3].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8486 pBillboardRenderListD3D[v8].pQuards[3].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8487 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
|
8488 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
|
8489 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
|
8490 pBillboardRenderListD3D[v8].pQuards[3].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8491 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; |
8492 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8493 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8494 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8495 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8496 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8497 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8498 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8499 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8500 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8501 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8502 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8503 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8504 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 8505 } |
8506 | |
8507 //----- (004A48E4) -------------------------------------------------------- | |
8508 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
8509 { | |
8510 int v6; // ecx@1 | |
8511 int v7; // ebx@1 | |
8512 int v8; // ecx@1 | |
8513 int v9; // edx@1 | |
8514 int v10; // edi@1 | |
8515 unsigned int x; // esi@1 | |
8516 int result; // eax@8 | |
8517 int v13; // [sp+Ch] [bp-10h]@1 | |
8518 int v14; // [sp+10h] [bp-Ch]@1 | |
8519 int v15; // [sp+14h] [bp-8h]@1 | |
8520 int v16; // [sp+18h] [bp-4h]@1 | |
8521 int v17; // [sp+24h] [bp+8h]@1 | |
8522 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
8523 int v19; // [sp+34h] [bp+18h]@1 | |
8524 | |
8525 v6 = screenSpaceX; | |
8526 v7 = (a6 >> 1) + screenSpaceY; | |
8527 v17 = 0; | |
8528 v15 = 0; | |
8529 v8 = (a6 >> 1) + v6; | |
8530 v14 = (a6 >> 1) * (a6 >> 1); | |
8531 v9 = 2 * (a6 >> 1); | |
8532 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
8533 x = v8 - (a6 >> 1); | |
8534 v16 = (a6 >> 1) + screenSpaceY - v8; | |
8535 v19 = a6 >> 1; | |
8536 v13 = v9; | |
8537 v18 = v8; | |
8538 do | |
8539 { | |
8540 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
8541 if ( v15 ) | |
8542 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
8543 v14 -= v15; | |
8544 if ( v14 <= v10 ) | |
8545 { | |
8546 if ( v19 != v17 ) | |
8547 { | |
8548 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
8549 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
8550 } | |
8551 --v19; | |
8552 v13 -= 2; | |
8553 ++x; | |
8554 v10 -= v13; | |
8555 } | |
8556 result = v17++; | |
8557 v15 += 2; | |
8558 --v18; | |
8559 } | |
8560 while ( result < v19 ); | |
8561 return result; | |
8562 } | |
8563 | |
8564 //----- (004A49D0) -------------------------------------------------------- | |
8565 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
8566 { | |
8567 int v10; // eax@1 | |
8568 unsigned int v11; // ebx@1 | |
8569 unsigned int v12; // ecx@1 | |
8570 int v13; // edx@2 | |
8571 int v14; // edx@4 | |
8572 unsigned int v15; // edx@6 | |
8573 double v16; // st7@7 | |
8574 double v17; // st7@7 | |
8575 double v18; // st6@7 | |
8576 double v19; // st4@7 | |
8577 double v20; // st4@8 | |
8578 double v21; // st4@10 | |
8579 double v22; // st4@10 | |
8580 double v23; // st4@10 | |
8581 double v24; // st4@10 | |
8582 double v25; // st4@11 | |
8583 double v26; // st4@13 | |
8584 double v27; // st5@13 | |
8585 double v28; // st4@13 | |
8586 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
8587 double v30; // [sp+80h] [bp-14h]@1 | |
8588 int v31; // [sp+88h] [bp-Ch]@1 | |
8589 signed int v32; // [sp+8Ch] [bp-8h]@1 | |
8590 int X; // [sp+90h] [bp-4h]@1 | |
8591 float a3a; // [sp+A4h] [bp+10h]@10 | |
8592 float a4a; // [sp+A8h] [bp+14h]@10 | |
8593 | |
8594 *(float *)&X = dstX - srcX; | |
8595 v30 = *(float *)&X + 6.7553994e15; | |
8596 v31 = LODWORD(v30); | |
8597 *(float *)&v32 = dstY - srcY; | |
8598 v30 = *(float *)&v32 + 6.7553994e15; | |
8599 X = LODWORD(v30); | |
8600 HIDWORD(v30) = abs(COERCE_UNSIGNED_INT64(*(float *)&v32 + 6.7553994e15)); | |
8601 v10 = abs(v31); | |
8602 v32 = v10; | |
8603 v11 = HIDWORD(v30); | |
8604 v12 = 0; | |
8605 if ( v10 < SHIDWORD(v30) ) | |
8606 { | |
8607 v13 = v10; | |
8608 v10 = HIDWORD(v30); | |
8609 v11 = v13; | |
8610 } | |
8611 if ( v10 < 0 ) | |
8612 { | |
8613 v14 = v10; | |
8614 v10 = 0; | |
8615 v12 = v14; | |
8616 } | |
8617 if ( (signed int)v11 < (signed int)v12 ) | |
8618 { | |
8619 v15 = v12; | |
8620 v12 = v11; | |
8621 v11 = v15; | |
8622 } | |
8623 v32 = (11 * v11 >> 5) + (v12 >> 2) + v10; | |
8624 v16 = 1.0 / (double)v32; | |
8625 *(float *)&v31 = (double)v31 * v16; | |
8626 *(float *)&X = (double)X * v16; | |
8627 v17 = *(float *)&X * a4; | |
8628 v29[0].pos.x = srcX + v17; | |
8629 v18 = *(float *)&v31 * a4; | |
8630 v29[0].pos.y = srcY - v18; | |
8631 v19 = a3; | |
8632 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8633 v20 = v19 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8634 else | |
8635 v20 = v19 * 0.061758894; | |
8636 v29[0].diffuse = -1; | |
8637 v29[0].specular = 0; | |
8638 v29[0].pos.z = 1.0 - 1.0 / v20; | |
8639 v21 = 1.0 / a3; | |
8640 *((float *)&v30 + 1) = v21; | |
8641 v29[0].rhw = v21; | |
8642 v29[0].texcoord.x = 1.0; | |
8643 v29[0].texcoord.y = 0.0; | |
8644 v22 = *(float *)&X * a8; | |
8645 a3a = v22; | |
8646 v29[1].pos.x = v22 + dstX; | |
8647 v23 = *(float *)&v31 * a8; | |
8648 a4a = v23; | |
8649 v29[1].pos.y = dstY - v23; | |
8650 v24 = a7; | |
8651 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8652 v25 = v24 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8653 else | |
8654 v25 = v24 * 0.061758894; | |
8655 v29[2].diffuse = -1; | |
8656 v29[3].diffuse = -1; | |
8657 *(_QWORD *)&v29[3].pos.z = __PAIR__(HIDWORD(v30), LODWORD(v29[0].pos.z)); | |
8658 v29[1].diffuse = -16711936; | |
8659 v29[1].specular = 0; | |
8660 v29[2].specular = 0; | |
8661 v29[3].specular = 0; | |
8662 v26 = 1.0 - 1.0 / v25; | |
8663 v29[1].pos.z = v26; | |
8664 v27 = v26; | |
8665 v28 = 1.0 / a7; | |
8666 v29[1].rhw = v28; | |
8667 v29[1].texcoord.x = 1.0; | |
8668 v29[1].texcoord.y = 1.0; | |
8669 v29[2].pos.x = dstX - a3a; | |
8670 v29[2].pos.y = a4a + dstY; | |
8671 v29[2].pos.z = v27; | |
8672 v29[2].rhw = v28; | |
8673 v29[2].texcoord.x = 0.0; | |
8674 v29[2].texcoord.y = 1.0; | |
8675 v29[3].pos.x = srcX - v17; | |
8676 v29[3].pos.y = v18 + srcY; | |
8677 v29[3].texcoord.x = 0.0; | |
8678 v29[3].texcoord.y = 0.0; | |
186 | 8679 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
8680 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8681 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8682 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
8683 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8684 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 8685 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
8686 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
8687 D3DPT_TRIANGLEFAN, | |
8688 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8689 v29, | |
8690 4, | |
8691 24)); | |
186 | 8692 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
8693 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8694 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8695 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
8696 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8697 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 8698 } |
8699 | |
8700 //----- (004A4CC9) -------------------------------------------------------- | |
8701 void Render::_4A4CC9(stru6_stru1_indoor_sw_billboard *a1, int a2) | |
8702 { | |
8703 int v3; // eax@1 | |
8704 int v4; // edx@3 | |
8705 unsigned int v5; // eax@7 | |
8706 int v6; // edi@7 | |
8707 char *v7; // edx@8 | |
8708 char *v8; // ecx@8 | |
8709 char v9; // zf@9 | |
8710 double v10; // st6@9 | |
8711 double v11; // st6@10 | |
8712 int v12; // ebx@13 | |
8713 int v13; // ecx@16 | |
8714 unsigned int v14; // [sp+Ch] [bp-4h]@1 | |
8715 | |
8716 auto _this = this; | |
8717 | |
8718 *(float *)&v14 = 1000000.0; | |
8719 v3 = a1->field_10; | |
8720 if ( v3 >= 3 ) | |
8721 { | |
8722 if ( v3 > 0 ) | |
8723 { | |
8724 _this = (Render *)&a1->field_14[62]; | |
8725 v4 = a1->field_10; | |
8726 do | |
8727 { | |
8728 if ( *(float *)&this->bUserDirect3D < (double)*(float *)&v14 ) | |
8729 v14 = this->bUserDirect3D; | |
8730 _this = (Render *)((char *)_this + 16); | |
8731 --v4; | |
8732 } | |
8733 while ( v4 ); | |
8734 } | |
8735 v5 = Billboard_ProbablyAddToListAndSortByZOrder(v14); | |
8736 v6 = 0; | |
8737 pBillboardRenderListD3D[v5].field_90 = 0; | |
8738 pBillboardRenderListD3D[v5].uParentBillboardID = -1; | |
8739 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | |
8740 if ( a1->field_10 > 0 ) | |
8741 { | |
8742 v7 = (char *)&a1->field_14[62]; | |
8743 v8 = (char *)&pBillboardRenderListD3D[v5].pQuards[0].pos.z; | |
8744 do | |
8745 { | |
8746 v9 = uCurrentlyLoadedLevelType == LEVEL_Indoor; | |
8747 *((int *)v8 - 2) = *((int *)v7 - 2); | |
8748 *((int *)v8 - 1) = *((int *)v7 - 1); | |
8749 v10 = *(float *)v7; | |
8750 if ( v9 ) | |
8751 v11 = v10 * 0.061758894; | |
8752 else | |
8753 v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8754 *(float *)v8 = 1.0 - 1.0 / v11; | |
8755 *((float *)v8 + 1) = 1.0 / *(float *)v7; | |
8756 if ( a2 & 0xFF000000 ) | |
8757 v12 = *((int *)v7 + 1); | |
8758 else | |
8759 v12 = a2; | |
8760 *((int *)v8 + 3) = 0; | |
8761 *((int *)v8 + 2) = v12; | |
8762 ++v6; | |
8763 v7 += 16; | |
8764 *((float *)v8 + 4) = 0.0; | |
8765 *((float *)v8 + 5) = 0.0; | |
8766 v8 += 32; | |
8767 } | |
8768 while ( v6 < a1->field_10 ); | |
8769 } | |
8770 v13 = a1->field_10; | |
8771 pBillboardRenderListD3D[v5].pTexture = 0; | |
8772 pBillboardRenderListD3D[v5].uNumVertices = v13; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8773 LODWORD(pBillboardRenderListD3D[v5].z_order) = v14; |
0 | 8774 } |
8775 } | |
8776 | |
8777 //----- (004A4DE1) -------------------------------------------------------- | |
8778 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
8779 { | |
8780 HRESULT v12; // eax@14 | |
8781 unsigned __int16 *v13; // ecx@19 | |
8782 unsigned __int16 *v14; // eax@19 | |
8783 DWORD v15; // edx@20 | |
8784 HRESULT v16; // eax@23 | |
8785 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
8786 | |
8787 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
8788 if ( pHWLTexture ) | |
8789 { | |
8790 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
8791 if ( !pRenderD3D->CreateTexture( | |
8792 pHWLTexture->uWidth, | |
8793 pHWLTexture->uHeight, | |
8794 pOutSurface, | |
8795 pOutTexture, | |
8796 true, | |
8797 bMipMaps, | |
8798 uMinDeviceTextureDim) ) | |
8799 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
8800 //v10 = *pOutSurface; | |
8801 //v11 = 0; | |
8802 if ( bMipMaps ) | |
8803 { | |
8804 Dst._450DDE(); | |
8805 //v20 = 0; | |
8806 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
8807 | |
8808 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
8809 while ( 1 ) | |
8810 { | |
8811 DDSCAPS2 v19; | |
8812 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8813 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8814 | |
8815 DDSURFACEDESC2 desc; | |
8816 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8817 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8818 | |
168 | 8819 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8820 { |
8821 Dst.sub_451007_scale_image_bicubic( | |
8822 pHWLTexture->pPixels, | |
8823 pHWLTexture->uWidth, | |
8824 pHWLTexture->uHeight, | |
8825 pHWLTexture->uWidth, | |
8826 (unsigned short *)desc.lpSurface, | |
8827 desc.dwWidth, | |
8828 desc.dwHeight, | |
8829 desc.lPitch >> 1, | |
8830 0, | |
8831 0); | |
8832 ErrD3D(pNextSurf->Unlock(0)); | |
8833 //bMipMaps = 0x4D86ACu; | |
8834 } | |
8835 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
8836 break; | |
8837 //v10 = (IDirectDrawSurface4 *)pName; | |
8838 //v11 = 0; | |
8839 } | |
8840 //v20 = -1; | |
8841 //nullsub_1(); | |
8842 } | |
8843 else | |
8844 { | |
8845 DDSCAPS2 v19; | |
8846 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8847 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8848 | |
8849 DDSURFACEDESC2 desc; | |
8850 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8851 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8852 | |
168 | 8853 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8854 { |
8855 bMipMaps = 0; | |
8856 v13 = pHWLTexture->pPixels; | |
8857 v14 = (unsigned __int16 *)desc.lpSurface; | |
8858 if ( desc.dwHeight ) | |
8859 { | |
8860 do | |
8861 { | |
8862 v15 = 0; | |
8863 if ( desc.dwWidth ) | |
8864 { | |
8865 do | |
8866 { | |
8867 ++v15; | |
8868 *v14 = *v13; | |
8869 ++v14; | |
8870 ++v13; | |
8871 } | |
8872 while ( v15 < desc.dwWidth ); | |
8873 } | |
8874 ++bMipMaps; | |
8875 v14 += (desc.lPitch >> 1) - desc.dwWidth; | |
8876 } | |
8877 while ( bMipMaps < desc.dwHeight ); | |
8878 } | |
8879 ErrD3D((*pOutSurface)->Unlock(0)); | |
8880 } | |
8881 } | |
8882 delete [] pHWLTexture->pPixels; | |
8883 delete pHWLTexture; | |
8884 return true; | |
8885 } | |
8886 return false; | |
8887 } | |
8888 | |
8889 //----- (004A5048) -------------------------------------------------------- | |
670 | 8890 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
8891 { | |
8892 | |
8893 HWLTexture *sprite_texture; // eax@1 | |
0 | 8894 unsigned __int16 *v9; // edx@5 |
8895 LPVOID v10; // eax@5 | |
8896 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8897 | |
670 | 8898 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
8899 if ( sprite_texture ) | |
8900 { | |
8901 _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; | |
8902 pSprite->uAreaX = sprite_texture->uAreaX; | |
8903 pSprite->uAreaY = sprite_texture->uAreaY; | |
8904 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
8905 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
8906 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
8907 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8908 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8909 //v7 = v3->pRenderD3D; |
670 | 8910 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
0 | 8911 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
8912 //pSprite = v2->pTextureSurface; | |
8913 //pSprite = (Sprite *)pSprite->pName; | |
8914 //v8 = pSprite; | |
670 | 8915 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 8916 Dst.dwSize = 124; |
670 | 8917 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
8918 { | |
8919 v9 = sprite_texture->pPixels; | |
8920 v10 = Dst.lpSurface; | |
8921 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 8922 { |
670 | 8923 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
8924 { | |
0 | 8925 *(int *)v10 = *(int *)v9; |
8926 v9 += 2; | |
8927 v10 = (char *)v10 + 4; | |
670 | 8928 } |
8929 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 8930 } |
670 | 8931 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
8932 } | |
8933 free(sprite_texture->pPixels); | |
8934 free(sprite_texture); | |
8935 return true; | |
8936 } | |
8937 return false; | |
0 | 8938 } |
8939 | |
8940 //----- (004A51CB) -------------------------------------------------------- | |
8941 void Render::BeginScene() | |
8942 { | |
8943 Render *v1; // esi@1 | |
8944 unsigned int v2; // eax@1 | |
8945 int v3; // eax@5 | |
8946 unsigned __int16 **v4; // edi@6 | |
8947 char *v5; // ebx@7 | |
8948 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8949 | |
8950 v1 = this; | |
8951 v2 = this->uNumSceneBegins; | |
8952 this->uNumSceneBegins = v2 + 1; | |
8953 if ( !v2 ) | |
8954 { | |
8955 if ( this->pRenderD3D ) | |
8956 { | |
8957 if ( this->bColorKeySupported ) | |
8958 { | |
8959 memset(&Dst, 0, 0x7Cu); | |
8960 Dst.dwSize = 124; | |
168 | 8961 if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) |
0 | 8962 { |
8963 v1->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; | |
8964 v3 = Dst.lPitch >> 1; | |
8965 v1->uTargetSurfacePitch = Dst.lPitch >> 1; | |
8966 LABEL_10: | |
8967 v1->field_18_locked_pitch = v3; | |
8968 goto LABEL_11; | |
8969 } | |
8970 goto LABEL_8; | |
8971 } | |
8972 } | |
8973 else | |
8974 { | |
8975 v4 = &this->pTargetSurface; | |
8976 if ( !this->pTargetSurface ) | |
8977 { | |
8978 v5 = (char *)&this->uTargetSurfacePitch; | |
8979 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
8980 if ( *v4 ) | |
8981 { | |
8982 v3 = *(int *)v5; | |
8983 goto LABEL_10; | |
8984 } | |
8985 LABEL_8: | |
8986 --v1->uNumSceneBegins; | |
8987 return; | |
8988 } | |
8989 } | |
8990 LABEL_11: | |
8991 RestoreFrontBuffer(); | |
8992 } | |
8993 } | |
8994 | |
8995 //----- (004A527D) -------------------------------------------------------- | |
8996 void Render::EndScene() | |
8997 { | |
8998 unsigned int v1; // edx@1 | |
8999 unsigned int v2; // edx@2 | |
9000 HRESULT v3; // eax@5 | |
9001 | |
9002 v1 = this->uNumSceneBegins; | |
9003 if ( v1 ) | |
9004 { | |
9005 v2 = v1 - 1; | |
9006 this->uNumSceneBegins = v2; | |
9007 if ( !v2 ) | |
9008 { | |
9009 if ( this->pRenderD3D ) | |
9010 { | |
9011 if ( this->bColorKeySupported ) | |
9012 { | |
9013 this->pTargetSurface = 0; | |
9014 this->uTargetSurfacePitch = 0; | |
9015 this->field_18_locked_pitch = 0; | |
9016 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
9017 } | |
9018 } | |
9019 else | |
9020 { | |
9021 this->pTargetSurface = 0; | |
9022 this->uTargetSurfacePitch = 0; | |
9023 this->field_18_locked_pitch = 0; | |
9024 UnlockBackBuffer(); | |
9025 } | |
9026 } | |
9027 } | |
9028 } | |
9029 | |
9030 //----- ( ) -------------------------------------------------------- | |
9031 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
9032 { | |
9033 unsigned int v3; // esi@1 | |
9034 double v4; // st7@2 | |
9035 double v5; // st7@6 | |
9036 double v6; // st6@6 | |
9037 unsigned int v7; // eax@6 | |
9038 double v8; // st5@6 | |
9039 double v9; // st4@6 | |
9040 HRESULT v10; // eax@6 | |
9041 HRESULT v11; // eax@6 | |
9042 unsigned int result; // eax@6 | |
9043 unsigned int v13; // eax@7 | |
9044 unsigned __int16 *v14; // ecx@7 | |
9045 int *v15; // eax@7 | |
9046 unsigned int v16; // ecx@8 | |
9047 __int16 v17; // ax@10 | |
9048 int v18; // esi@10 | |
9049 float v19; // edi@10 | |
9050 void *v20; // esi@10 | |
9051 int v21; // edx@10 | |
9052 int v22; // ecx@11 | |
9053 int v23; // edx@12 | |
9054 __int16 v24; // ax@15 | |
9055 int v25; // esi@15 | |
9056 float v26; // edi@15 | |
9057 char *v27; // esi@15 | |
9058 int v28; // edx@15 | |
9059 int v29; // ecx@16 | |
9060 int v30; // edx@17 | |
9061 int v31; // [sp-Ch] [bp-ACh]@11 | |
9062 int v32; // [sp-Ch] [bp-ACh]@16 | |
9063 const char *v33; // [sp+0h] [bp-A0h]@0 | |
9064 int v34; // [sp+4h] [bp-9Ch]@0 | |
9065 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
9066 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
9067 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
9068 int v38; // [sp+90h] [bp-10h]@7 | |
9069 double v39; // [sp+94h] [bp-Ch]@6 | |
9070 float v40; // [sp+9Ch] [bp-4h]@6 | |
9071 | |
9072 auto ecx0 = this; | |
9073 v3 = 0; | |
9074 if ( ecx0->pRenderD3D ) | |
9075 { | |
9076 v4 = a3; | |
9077 if ( a3 <= 1.0 ) | |
9078 { | |
9079 if ( v4 < 0.0 ) | |
9080 v4 = 0.0; | |
9081 } | |
9082 else | |
9083 { | |
9084 v4 = 1.0; | |
9085 } | |
9086 a3 = v4 * 255.0; | |
9087 v39 = a3 + 6.7553994e15; | |
9088 LODWORD(v40) = LODWORD(v39); | |
693 | 9089 v5 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 9090 v36[0].pos.x = v5; |
693 | 9091 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 9092 v7 = this_ | (LODWORD(v39) << 24); |
693 | 9093 this_ = pViewport->uViewportBR_Y + 1; |
0 | 9094 v36[0].specular = 0; |
9095 v36[0].pos.y = v6; | |
9096 v36[0].diffuse = v7; | |
9097 v36[1].diffuse = v7; | |
9098 v36[0].pos.z = 0.0; | |
9099 v36[2].diffuse = v7; | |
9100 v36[3].diffuse = v7; | |
9101 v36[0].rhw = 1.0; | |
9102 v36[1].specular = 0; | |
9103 v36[0].texcoord.x = 0.0; | |
9104 v36[2].specular = 0; | |
9105 v36[3].specular = 0; | |
9106 v36[0].texcoord.y = 0.0; | |
9107 v36[1].pos.x = v5; | |
693 | 9108 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 9109 v36[1].pos.y = v8; |
9110 v36[1].pos.z = 0.0; | |
9111 v36[1].rhw = 1.0; | |
9112 v36[1].texcoord.x = 0.0; | |
9113 v36[1].texcoord.y = 0.0; | |
693 | 9114 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 9115 v36[2].pos.x = v9; |
9116 v36[2].pos.y = v8; | |
9117 v36[2].pos.z = 0.0; | |
9118 v36[2].rhw = 1.0; | |
9119 v36[2].texcoord.x = 0.0; | |
9120 v36[2].texcoord.y = 0.0; | |
9121 v36[3].pos.x = v9; | |
9122 v36[3].pos.y = v6; | |
9123 v36[3].pos.z = 0.0; | |
9124 v36[3].rhw = 1.0; | |
9125 v36[3].texcoord.x = 0.0; | |
9126 v36[3].texcoord.y = 0.0; | |
9127 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 9128 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
9129 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9130 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9131 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9132 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9133 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9134 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 9135 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
9136 D3DPT_TRIANGLEFAN, | |
9137 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9138 v36, | |
9139 4, | |
9140 28)); | |
186 | 9141 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
9142 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9143 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9144 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9145 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9146 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
0 | 9147 } |
9148 else | |
9149 { | |
9150 v40 = (1.0 - a3) * 65536.0; | |
9151 v39 = v40 + 6.7553994e15; | |
9152 LODWORD(a3) = LODWORD(v39); | |
693 | 9153 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
9154 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
9155 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
9156 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 9157 v37 = 2 * v13; |
9158 LODWORD(v40) = (int)v14; | |
9159 | |
9160 int __i = 0; | |
9161 v15 = dword_F1B430; | |
9162 do | |
9163 { | |
9164 v16 = v3; | |
9165 v3 += LODWORD(a3); | |
9166 dword_F1B430[__i++] = v16 >> 16; | |
9167 } | |
9168 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
9169 while (__i < 32); | |
9170 | |
9171 if ( pRenderer->uTargetGBits == 6 ) | |
9172 { | |
9173 v17 = _42690D_colors_cvt(this_); | |
9174 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); | |
9175 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); | |
9176 v19 = v40; | |
9177 v20 = off_4EFDB0; | |
9178 v21 = HIDWORD(v39); | |
9179 do | |
9180 { | |
9181 v22 = v38; | |
9182 v31 = v21; | |
9183 do | |
9184 { | |
9185 v23 = (*(int *)((char *)v20 | |
9186 + ((((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; | |
9187 result = this_ | |
9188 + (*((int *)v20 | |
9189 + (((unsigned __int8)(*((char *)v20 | |
9190 + ((((unsigned __int16)(*(short *)((char *)v20 | |
9191 + ((*(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); | |
9192 *(unsigned int *)LODWORD(v19) = result; | |
9193 LODWORD(v19) += 4; | |
9194 --v22; | |
9195 } | |
9196 while ( v22 ); | |
9197 LODWORD(v19) += v37; | |
9198 v21 = v31 - 1; | |
9199 } | |
9200 while ( v31 != 1 ); | |
9201 } | |
9202 else | |
9203 { | |
9204 v24 = _4268E3_smthn_to_a1r5g5b5(this_); | |
9205 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); | |
9206 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
9207 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
9208 v26 = v40; | |
9209 v27 = (char *)off_4EFDB0; | |
9210 v28 = HIDWORD(v39); | |
9211 do | |
9212 { | |
9213 v29 = v38; | |
9214 v32 = v28; | |
9215 do | |
9216 { | |
9217 v30 = 32 | |
9218 * *(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; | |
9219 result = this_ | |
9220 + (*(int *)&v27[4 | |
9221 * (((unsigned __int8)(32 | |
9222 * 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); | |
9223 *(unsigned int *)LODWORD(v26) = result; | |
9224 LODWORD(v26) += 4; | |
9225 --v29; | |
9226 } | |
9227 while ( v29 ); | |
9228 LODWORD(v26) += v37; | |
9229 v28 = v32 - 1; | |
9230 } | |
9231 while ( v32 != 1 ); | |
9232 } | |
9233 } | |
9234 return result; | |
9235 } | |
9236 | |
9237 //----- (004A5B81) -------------------------------------------------------- | |
727 | 9238 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 9239 { |
9240 this->bClip = 1; | |
9241 this->uClipY = uY; | |
9242 this->uClipX = uX; | |
9243 this->uClipW = uW; | |
9244 this->uClipZ = uZ; | |
9245 } | |
9246 | |
9247 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 9248 void Render::ResetTextureClipRect() |
0 | 9249 { |
9250 this->uClipY = 0; | |
9251 this->uClipX = 0; | |
9252 this->bClip = 1; | |
9253 this->uClipW = 480; | |
9254 this->uClipZ = 640; | |
9255 } | |
9256 | |
9257 //----- (004A5BE3) -------------------------------------------------------- | |
9258 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
9259 { | |
9260 int v4; // edi@3 | |
9261 unsigned __int16 *v5; // edx@3 | |
9262 unsigned __int16 *v6; // esi@3 | |
9263 unsigned int v7; // ebx@4 | |
9264 unsigned int v8; // eax@5 | |
9265 unsigned int v9; // ebx@5 | |
9266 unsigned int v10; // eax@6 | |
9267 unsigned int v11; // eax@7 | |
9268 unsigned int v12; // ebx@8 | |
9269 unsigned int v13; // eax@10 | |
9270 unsigned int v14; // edi@11 | |
9271 unsigned int v15; // eax@14 | |
9272 unsigned int v16; // ebx@17 | |
9273 int v17; // eax@23 | |
9274 char v18; // zf@25 | |
9275 int v19; // [sp+10h] [bp-8h]@3 | |
9276 int v20; // [sp+14h] [bp-4h]@3 | |
9277 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
9278 int uOutXb; // [sp+20h] [bp+8h]@21 | |
9279 int v23; // [sp+28h] [bp+10h]@3 | |
9280 | |
9281 if ( this->uNumSceneBegins && a4 ) | |
9282 { | |
9283 v4 = a4->uWidth; | |
9284 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9285 v6 = a4->pPixels; | |
9286 v20 = v4; | |
9287 v23 = a4->uHeight; | |
9288 v19 = v4; | |
9289 if ( this->bClip ) | |
9290 { | |
9291 v7 = this->uClipX; | |
9292 if ( (signed int)uOutX < (signed int)v7 ) | |
9293 { | |
9294 v8 = v7 - uOutX; | |
9295 v9 = uOutX - v7; | |
9296 v8 *= 2; | |
9297 v4 += v9; | |
9298 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
9299 v20 += v9; | |
9300 v5 = (unsigned __int16 *)((char *)v5 + v8); | |
9301 } | |
9302 v10 = this->uClipY; | |
9303 if ( (signed int)uOutY < (signed int)v10 ) | |
9304 { | |
9305 v11 = v10 - uOutY; | |
9306 v6 += v19 * v11; | |
9307 v23 += uOutY - this->uClipY; | |
9308 v4 = v20; | |
9309 v5 += this->uTargetSurfacePitch * v11; | |
9310 } | |
9311 v12 = this->uClipX; | |
9312 if ( (signed int)v12 < (signed int)uOutX ) | |
9313 v12 = uOutX; | |
9314 v13 = this->uClipZ; | |
9315 if ( (signed int)(v4 + v12) > (signed int)v13 ) | |
9316 { | |
9317 v14 = this->uClipX; | |
9318 if ( (signed int)v14 < (signed int)uOutX ) | |
9319 v14 = uOutX; | |
9320 v4 = v13 - v14; | |
9321 } | |
9322 v15 = this->uClipY; | |
9323 if ( (signed int)v15 < (signed int)uOutY ) | |
9324 v15 = uOutY; | |
9325 uOutXa = this->uClipW; | |
9326 if ( (signed int)(v15 + v23) > (signed int)uOutXa ) | |
9327 { | |
9328 v16 = this->uClipY; | |
9329 if ( (signed int)v16 < (signed int)uOutY ) | |
9330 v16 = uOutY; | |
9331 v23 = uOutXa - v16; | |
9332 } | |
9333 } | |
9334 if ( v23 > 0 ) | |
9335 { | |
9336 uOutXb = v23; | |
9337 do | |
9338 { | |
9339 if ( v4 > 0 ) | |
9340 { | |
9341 v17 = v4; | |
9342 do | |
9343 { | |
9344 *v5 = *v6; | |
9345 ++v5; | |
9346 ++v6; | |
9347 --v17; | |
9348 } | |
9349 while ( v17 ); | |
9350 } | |
9351 v6 += v19 - v4; | |
9352 v18 = uOutXb-- == 1; | |
9353 v5 += this->uTargetSurfacePitch - v4; | |
9354 } | |
9355 while ( !v18 ); | |
9356 } | |
9357 } | |
9358 } | |
9359 | |
9360 //----- (004A5D33) -------------------------------------------------------- | |
9361 void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture) | |
9362 { | |
9363 Render *v6; // esi@1 | |
9364 unsigned __int16 *v7; // ebx@3 | |
9365 int v8; // ecx@3 | |
9366 int v9; // edx@3 | |
9367 int v10; // ecx@3 | |
9368 int v11; // edi@3 | |
9369 signed int v12; // eax@4 | |
9370 unsigned int v13; // eax@5 | |
9371 signed int v14; // eax@6 | |
9372 unsigned int v15; // eax@7 | |
9373 unsigned int v16; // edx@8 | |
9374 int v17; // eax@10 | |
9375 unsigned int v18; // ecx@11 | |
9376 unsigned int v19; // ecx@14 | |
9377 int v20; // eax@16 | |
9378 unsigned int v21; // ecx@17 | |
9379 int v22; // eax@21 | |
9380 int v23; // edi@23 | |
9381 int v24; // [sp+Ch] [bp-4h]@3 | |
9382 int a2a; // [sp+18h] [bp+8h]@21 | |
9383 unsigned int teal; // [sp+1Ch] [bp+Ch]@20 | |
9384 int a4a; // [sp+20h] [bp+10h]@3 | |
9385 int a4b; // [sp+20h] [bp+10h]@21 | |
9386 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
9387 | |
9388 v6 = this; | |
9389 if ( this->uNumSceneBegins && pTexture ) | |
9390 { | |
9391 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | |
9392 v8 = pTexture->uWidth; | |
9393 v24 = pTexture->uWidth; | |
9394 v9 = a4 + a5 * v8; | |
9395 v10 = v8 - a4; | |
9396 a4a = v10; | |
9397 v11 = pTexture->uHeight - a5; | |
9398 pTexturea = &pTexture->pPixels[v9]; | |
9399 if ( v6->bClip ) | |
9400 { | |
9401 v12 = v6->uClipX; | |
9402 if ( (signed int)pX < v12 ) | |
9403 { | |
9404 v13 = 2 * (v12 - pX); | |
9405 pTexturea = (unsigned __int16 *)((char *)pTexturea + v13); | |
9406 v10 += pX - v6->uClipX; | |
9407 v7 = (unsigned __int16 *)((char *)v7 + v13); | |
9408 a4a = v10; | |
9409 } | |
9410 v14 = v6->uClipY; | |
9411 if ( (signed int)pY < v14 ) | |
9412 { | |
9413 v15 = v14 - pY; | |
9414 pTexturea += v24 * v15; | |
9415 v11 += pY - v6->uClipY; | |
9416 v10 = a4a; | |
9417 v7 += v6->uTargetSurfacePitch * v15; | |
9418 } | |
9419 v16 = v6->uClipX; | |
9420 if ( (signed int)v16 < (signed int)pX ) | |
9421 v16 = pX; | |
9422 v17 = v6->uClipZ; | |
9423 if ( (signed int)(v10 + v16) > v17 ) | |
9424 { | |
9425 v18 = v6->uClipX; | |
9426 if ( (signed int)v18 < (signed int)pX ) | |
9427 v18 = pX; | |
9428 a4a = v17 - v18; | |
9429 } | |
9430 v19 = v6->uClipY; | |
9431 if ( (signed int)v19 < (signed int)pY ) | |
9432 v19 = pY; | |
9433 v20 = v6->uClipW; | |
9434 if ( (signed int)(v11 + v19) > v20 ) | |
9435 { | |
9436 v21 = v6->uClipY; | |
9437 if ( (signed int)v21 < (signed int)pY ) | |
9438 v21 = pY; | |
9439 v11 = v20 - v21; | |
9440 } | |
9441 } | |
949 | 9442 teal = TargetColor(0, 0xFFu, 0xFFu); |
0 | 9443 if ( v11 > 0 ) |
9444 { | |
9445 v22 = a4a; | |
9446 a2a = v11; | |
9447 a4b = 2 * (v24 - a4a); | |
9448 do | |
9449 { | |
9450 if ( v22 > 0 ) | |
9451 { | |
9452 v23 = v22; | |
9453 do | |
9454 { | |
9455 if ( *pTexturea != teal ) | |
9456 *v7 = *pTexturea; | |
9457 ++pTexturea; | |
9458 ++v7; | |
9459 --v23; | |
9460 } | |
9461 while ( v23 ); | |
9462 } | |
9463 v7 += v6->uTargetSurfacePitch - v22; | |
9464 pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b); | |
9465 --a2a; | |
9466 } | |
9467 while ( a2a ); | |
9468 } | |
9469 } | |
9470 } | |
9471 | |
9472 //----- (004A6E7E) -------------------------------------------------------- | |
9473 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
9474 { | |
9475 unsigned __int16 *v4; // eax@4 | |
9476 int v5; // edx@4 | |
9477 unsigned int v6; // edi@4 | |
9478 unsigned int v7; // edx@5 | |
9479 unsigned int v8; // edx@6 | |
9480 unsigned int v9; // edx@7 | |
9481 unsigned int v10; // edx@8 | |
9482 unsigned int v11; // ebx@9 | |
9483 unsigned int v12; // esi@11 | |
9484 unsigned int v13; // edx@12 | |
9485 unsigned int v14; // ebx@15 | |
9486 unsigned int v15; // esi@17 | |
9487 unsigned int v16; // edi@18 | |
9488 char v17; // zf@29 | |
9489 int v18; // [sp+14h] [bp-Ch]@4 | |
9490 int v19; // [sp+18h] [bp-8h]@4 | |
9491 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
9492 int v21; // [sp+28h] [bp+8h]@25 | |
9493 int v22; // [sp+28h] [bp+8h]@34 | |
9494 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
9495 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
9496 | |
9497 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
9498 { | |
9499 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9500 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9501 v5 = a4->uTextureWidth; |
9502 v6 = a4->uTextureHeight; | |
9503 v19 = a4->uTextureWidth; | |
9504 v18 = a4->uTextureWidth; | |
9505 if ( this->bClip ) | |
9506 { | |
9507 v7 = this->uClipX; | |
9508 if ( (signed int)a2 < (signed int)v7 ) | |
9509 { | |
9510 v8 = v7 - a2; | |
9511 v20 += v8; | |
9512 v19 += a2 - this->uClipX; | |
9513 v4 += v8; | |
9514 } | |
9515 v9 = this->uClipY; | |
9516 if ( (signed int)a3 < (signed int)v9 ) | |
9517 { | |
9518 v10 = v9 - a3; | |
9519 v20 += v18 * v10; | |
9520 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
9521 v4 += this->uTargetSurfacePitch * v10; | |
9522 } | |
9523 v11 = this->uClipX; | |
9524 v5 = v19; | |
9525 if ( (signed int)v11 < (signed int)a2 ) | |
9526 v11 = a2; | |
9527 v12 = this->uClipZ; | |
9528 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
9529 { | |
9530 v13 = this->uClipX; | |
9531 if ( (signed int)v13 < (signed int)a2 ) | |
9532 v13 = a2; | |
9533 v5 = v12 - v13; | |
9534 } | |
9535 v14 = this->uClipY; | |
9536 if ( (signed int)v14 < (signed int)a3 ) | |
9537 v14 = a3; | |
9538 v15 = this->uClipW; | |
9539 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
9540 { | |
9541 v16 = this->uClipY; | |
9542 if ( (signed int)v16 < (signed int)a3 ) | |
9543 v16 = a3; | |
9544 v6 = v15 - v16; | |
9545 } | |
9546 } | |
9547 if ( pRenderer->uTargetGBits == 5 ) | |
9548 { | |
9549 if ( (signed int)v6 > 0 ) | |
9550 { | |
9551 v23 = v6; | |
9552 do | |
9553 { | |
9554 if ( v5 > 0 ) | |
9555 { | |
9556 v21 = v5; | |
9557 do | |
9558 { | |
9559 if ( *v20 ) | |
9560 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
9561 ++v4; | |
9562 ++v20; | |
9563 --v21; | |
9564 } | |
9565 while ( v21 ); | |
9566 } | |
9567 v20 += v18 - v5; | |
9568 v17 = v23-- == 1; | |
9569 v4 += this->uTargetSurfacePitch - v5; | |
9570 } | |
9571 while ( !v17 ); | |
9572 } | |
9573 } | |
9574 else | |
9575 { | |
9576 if ( (signed int)v6 > 0 ) | |
9577 { | |
9578 v24 = v6; | |
9579 do | |
9580 { | |
9581 if ( v5 > 0 ) | |
9582 { | |
9583 v22 = v5; | |
9584 do | |
9585 { | |
9586 if ( *v20 ) | |
9587 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
9588 ++v4; | |
9589 ++v20; | |
9590 --v22; | |
9591 } | |
9592 while ( v22 ); | |
9593 } | |
9594 v20 += v18 - v5; | |
9595 v17 = v24-- == 1; | |
9596 v4 += this->uTargetSurfacePitch - v5; | |
9597 } | |
9598 while ( !v17 ); | |
9599 } | |
9600 } | |
9601 } | |
9602 } | |
9603 | |
9604 //----- (004A6DF5) -------------------------------------------------------- | |
9605 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
9606 { | |
9607 int result; // eax@0 | |
9608 int v8; // ecx@3 | |
9609 unsigned __int16 *v9; // edi@4 | |
9610 unsigned __int16 *v10; // ebx@4 | |
9611 int v11; // esi@4 | |
9612 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | |
9613 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | |
9614 | |
9615 if ( pBitmap ) | |
9616 { | |
9617 if ( pTarget ) | |
9618 { | |
9619 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | |
9620 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | |
9621 v8 = a7->z - a7->x; | |
9622 result = a7->w - a7->y; | |
9623 if ( result > 0 ) | |
9624 { | |
9625 v9 = pBitmapa; | |
9626 v10 = pTargeta; | |
9627 v11 = a7->w - a7->y; | |
9628 do | |
9629 { | |
9630 if ( v8 > 0 ) | |
9631 { | |
9632 result = v8; | |
9633 do | |
9634 { | |
9635 *v9 = *v10; | |
9636 ++v9; | |
9637 ++v10; | |
9638 --result; | |
9639 } | |
9640 while ( result ); | |
9641 } | |
9642 v9 += uBitmapPitch - v8; | |
9643 v10 += uTargetPitch - v8; | |
9644 --v11; | |
9645 } | |
9646 while ( v11 ); | |
9647 } | |
9648 } | |
9649 } | |
9650 return result; | |
9651 } | |
9652 | |
9653 //----- (004A6D87) -------------------------------------------------------- | |
9654 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
9655 { | |
9656 if (!uNumSceneBegins) | |
9657 return; | |
9658 | |
9659 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
9660 for (uint y = 0; y < uHeight; ++y) | |
9661 { | |
9662 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | |
9663 | |
9664 memset32(pDst, twoColors, uWidth / 2); | |
9665 if (uWidth & 1) | |
9666 pDst[uWidth - 1] = uColor16; | |
9667 } | |
9668 } | |
9669 | |
9670 //----- (004A6C4F) -------------------------------------------------------- | |
9671 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) | |
9672 { | |
9673 unsigned int v9; // edi@2 | |
9674 unsigned int v10; // esi@2 | |
9675 unsigned __int16 *v11; // eax@2 | |
9676 unsigned int v12; // ebx@3 | |
9677 signed int v13; // edx@5 | |
9678 int v14; // edx@6 | |
9679 signed int v15; // ebx@7 | |
9680 unsigned int v16; // edx@9 | |
9681 signed int v17; // edi@10 | |
9682 signed int v18; // ebx@13 | |
9683 unsigned int v19; // edx@15 | |
9684 signed int v20; // esi@16 | |
9685 unsigned int v21; // esi@22 | |
9686 unsigned __int16 v22; // dx@24 | |
9687 char v23; // zf@28 | |
9688 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
9689 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | |
9690 | |
9691 if ( this->uNumSceneBegins ) | |
9692 { | |
9693 v9 = uCharWidth; | |
9694 v10 = uCharHeight; | |
9695 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9696 v24 = pFontPixels; | |
9697 if ( this->bClip ) | |
9698 { | |
9699 v12 = this->uClipX; | |
9700 if ( uOutX < (signed int)v12 ) | |
9701 { | |
9702 v24 = &pFontPixels[v12 - uOutX]; | |
9703 v11 += v12 - uOutX; | |
9704 v9 = uCharWidth + uOutX - v12; | |
9705 } | |
9706 v13 = this->uClipY; | |
9707 if ( uOutY < v13 ) | |
9708 { | |
9709 v14 = v13 - uOutY; | |
9710 v24 += uCharWidth * v14; | |
9711 v10 = uCharHeight + uOutY - this->uClipY; | |
9712 v11 += this->uTargetSurfacePitch * v14; | |
9713 } | |
9714 v15 = this->uClipX; | |
9715 if ( v15 < uOutX ) | |
9716 v15 = uOutX; | |
9717 v16 = this->uClipZ; | |
9718 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
9719 { | |
9720 v17 = this->uClipX; | |
9721 if ( v17 < uOutX ) | |
9722 v17 = uOutX; | |
9723 v9 = v16 - v17; | |
9724 } | |
9725 v18 = this->uClipY; | |
9726 if ( v18 < uOutY ) | |
9727 v18 = uOutY; | |
9728 v19 = this->uClipW; | |
9729 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
9730 { | |
9731 v20 = this->uClipY; | |
9732 if ( v20 < uOutY ) | |
9733 v20 = uOutY; | |
9734 v10 = v19 - v20; | |
9735 } | |
9736 } | |
9737 if ( (signed int)v10 > 0 ) | |
9738 { | |
9739 uOutXa = v10; | |
9740 do | |
9741 { | |
9742 if ( (signed int)v9 > 0 ) | |
9743 { | |
9744 v21 = v9; | |
9745 do | |
9746 { | |
9747 if ( *v24 ) | |
9748 { | |
9749 v22 = uShadowColor; | |
9750 if ( *v24 != 1 ) | |
9751 v22 = uFaceColor; | |
9752 *v11 = v22; | |
9753 } | |
9754 ++v11; | |
9755 ++v24; | |
9756 --v21; | |
9757 } | |
9758 while ( v21 ); | |
9759 } | |
9760 v24 += uCharWidth - v9; | |
9761 v23 = uOutXa-- == 1; | |
9762 v11 += this->uTargetSurfacePitch - v9; | |
9763 } | |
9764 while ( !v23 ); | |
9765 } | |
9766 } | |
9767 } | |
9768 | |
9769 //----- (004A6A68) -------------------------------------------------------- | |
9770 void Render::_4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | |
9771 { | |
9772 Render *v5; // ebx@1 | |
9773 unsigned __int16 v6; // ax@1 | |
9774 | |
9775 v5 = this; | |
9776 | |
9777 Texture tex; // [sp+Ch] [bp-48h]@1 | |
9778 //Texture::Texture(&tex); | |
9779 | |
9780 v6 = a4->uTextureHeight - height; | |
9781 memcpy(&tex, a4, sizeof(tex)); | |
9782 tex.uTextureHeight = v6; | |
9783 if ( (signed __int16)v6 > 0 ) | |
9784 DrawTextureIndexed(a2, a3, &tex); | |
9785 } | |
9786 | |
9787 //----- (004A6AB1) -------------------------------------------------------- | |
9788 void Render::DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8) | |
9789 { | |
9790 int v8; // edi@2 | |
9791 unsigned int v9; // esi@2 | |
9792 unsigned __int16 *v10; // eax@2 | |
9793 unsigned char *v11; // edx@2 | |
9794 unsigned int v12; // ebx@3 | |
9795 signed int v13; // edx@5 | |
9796 int v14; // edx@6 | |
9797 signed int v15; // ebx@7 | |
9798 unsigned int v16; // edx@9 | |
9799 signed int v17; // edi@10 | |
9800 signed int v18; // ebx@13 | |
9801 unsigned int v19; // edx@15 | |
9802 signed int v20; // esi@16 | |
9803 int v21; // ebx@22 | |
9804 char v22; // zf@28 | |
9805 int v23; // ebx@31 | |
9806 unsigned __int16 v24; // si@35 | |
9807 int v25; // [sp+Ch] [bp-4h]@2 | |
9808 int v26; // [sp+1Ch] [bp+Ch]@24 | |
9809 int v27; // [sp+1Ch] [bp+Ch]@33 | |
9810 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
9811 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
9812 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
9813 | |
9814 auto a2 = x; | |
9815 auto a3 = y; | |
9816 auto a6 = uFontHeight; | |
9817 if ( this->uNumSceneBegins ) | |
9818 { | |
9819 v8 = a5; | |
9820 v9 = a6; | |
9821 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
9822 v11 = (unsigned char *)a4; | |
9823 v25 = a4; | |
9824 if ( this->bClip ) | |
9825 { | |
9826 v12 = this->uClipX; | |
9827 if ( a2 < (signed int)v12 ) | |
9828 { | |
9829 v25 = v12 - a2 + a4; | |
9830 v10 += v12 - a2; | |
9831 v8 = a5 + a2 - v12; | |
9832 } | |
9833 v13 = this->uClipY; | |
9834 if ( a3 < v13 ) | |
9835 { | |
9836 v14 = v13 - a3; | |
9837 v25 += a5 * v14; | |
9838 v9 = a6 + a3 - this->uClipY; | |
9839 v10 += this->uTargetSurfacePitch * v14; | |
9840 } | |
9841 v15 = this->uClipX; | |
9842 if ( v15 < a2 ) | |
9843 v15 = a2; | |
9844 v16 = this->uClipZ; | |
9845 if ( v8 + v15 > (signed int)v16 ) | |
9846 { | |
9847 v17 = this->uClipX; | |
9848 if ( v17 < a2 ) | |
9849 v17 = a2; | |
9850 v8 = v16 - v17; | |
9851 } | |
9852 v18 = this->uClipY; | |
9853 if ( v18 < a3 ) | |
9854 v18 = a3; | |
9855 v19 = this->uClipW; | |
9856 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
9857 { | |
9858 v20 = this->uClipY; | |
9859 if ( v20 < a3 ) | |
9860 v20 = a3; | |
9861 v9 = v19 - v20; | |
9862 } | |
9863 v11 = (unsigned char *)v25; | |
9864 } | |
9865 if ( a8 ) | |
9866 { | |
9867 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
9868 if ( (signed int)v9 > 0 ) | |
9869 { | |
9870 v23 = a5; | |
9871 v30 = v9; | |
9872 do | |
9873 { | |
9874 if ( v8 > 0 ) | |
9875 { | |
9876 v27 = v8; | |
9877 do | |
9878 { | |
9879 if ( *v11 ) | |
9880 v24 = pPalette[*v11]; | |
9881 else | |
9882 v24 = v28; | |
9883 *v10 = v24; | |
9884 ++v10; | |
9885 ++v11; | |
9886 --v27; | |
9887 } | |
9888 while ( v27 ); | |
9889 } | |
9890 v11 += v23 - v8; | |
9891 v22 = v30-- == 1; | |
9892 v10 += this->uTargetSurfacePitch - v8; | |
9893 } | |
9894 while ( !v22 ); | |
9895 } | |
9896 } | |
9897 else | |
9898 { | |
9899 if ( (signed int)v9 > 0 ) | |
9900 { | |
9901 v21 = a5; | |
9902 v29 = v9; | |
9903 do | |
9904 { | |
9905 if ( v8 > 0 ) | |
9906 { | |
9907 v26 = v8; | |
9908 do | |
9909 { | |
9910 if ( *v11 ) | |
9911 *v10 = pPalette[*v11]; | |
9912 ++v10; | |
9913 ++v11; | |
9914 --v26; | |
9915 } | |
9916 while ( v26 ); | |
9917 } | |
9918 v11 += v21 - v8; | |
9919 v22 = v29-- == 1; | |
9920 v10 += this->uTargetSurfacePitch - v8; | |
9921 } | |
9922 while ( !v22 ); | |
9923 } | |
9924 } | |
9925 } | |
9926 } | |
9927 | |
9928 //----- (004A68EF) -------------------------------------------------------- | |
9929 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
9930 { | |
9931 Texture *v4; // edi@2 | |
9932 unsigned int v5; // ebx@4 | |
9933 unsigned __int16 *v6; // eax@4 | |
9934 signed int v7; // edx@5 | |
9935 int v8; // edx@6 | |
9936 signed int v9; // edx@7 | |
9937 int v10; // edx@8 | |
9938 signed int v11; // edx@9 | |
9939 signed int v12; // esi@12 | |
9940 signed int v13; // esi@15 | |
9941 unsigned int v14; // edx@17 | |
9942 signed int v15; // esi@18 | |
9943 unsigned __int8 *v16; // ebx@22 | |
9944 char v17; // zf@28 | |
9945 int v18; // [sp+10h] [bp-10h]@4 | |
9946 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
9947 int v20; // [sp+1Ch] [bp-4h]@4 | |
9948 int v21; // [sp+28h] [bp+8h]@24 | |
9949 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
9950 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
9951 | |
9952 if ( this->uNumSceneBegins ) | |
9953 { | |
9954 v4 = pTexture; | |
9955 if ( pTexture ) | |
9956 { | |
9957 if ( pTexture->pPalette16 ) | |
9958 { | |
9959 v5 = pTexture->uTextureHeight; | |
9960 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9961 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9962 v20 = pTexture->uTextureWidth; |
9963 v18 = pTexture->uTextureWidth; | |
9964 if ( this->bClip ) | |
9965 { | |
9966 v7 = this->uClipX; | |
9967 if ( a2 < v7 ) | |
9968 { | |
9969 v8 = v7 - a2; | |
9970 v19 += v8; | |
9971 v20 += a2 - this->uClipX; | |
9972 v6 += v8; | |
9973 } | |
9974 v9 = this->uClipY; | |
9975 v5 = pTexture->uTextureHeight; | |
9976 if ( a3 < v9 ) | |
9977 { | |
9978 v10 = v9 - a3; | |
9979 v19 += v18 * v10; | |
9980 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
9981 v4 = pTexture; | |
9982 v6 += this->uTargetSurfacePitch * v10; | |
9983 } | |
9984 v11 = this->uClipX; | |
9985 if ( v11 < a2 ) | |
9986 v11 = a2; | |
9987 pTexturea = this->uClipZ; | |
9988 if ( v11 + v20 > (signed int)pTexturea ) | |
9989 { | |
9990 v12 = this->uClipX; | |
9991 if ( v12 < a2 ) | |
9992 v12 = a2; | |
9993 v20 = pTexturea - v12; | |
9994 } | |
9995 v13 = this->uClipY; | |
9996 if ( v13 < a3 ) | |
9997 v13 = a3; | |
9998 v14 = this->uClipW; | |
9999 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10000 { | |
10001 v15 = this->uClipY; | |
10002 if ( v15 < a3 ) | |
10003 v15 = a3; | |
10004 v5 = v14 - v15; | |
10005 } | |
10006 } | |
10007 if ( (signed int)v5 > 0 ) | |
10008 { | |
10009 v22 = v5; | |
10010 v16 = v19; | |
10011 do | |
10012 { | |
10013 if ( v20 > 0 ) | |
10014 { | |
10015 v21 = v20; | |
10016 do | |
10017 { | |
10018 if ( *v16 ) | |
10019 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
10020 ++v6; | |
10021 ++v16; | |
10022 --v21; | |
10023 } | |
10024 while ( v21 ); | |
10025 } | |
10026 v16 += v18 - v20; | |
10027 v17 = v22-- == 1; | |
10028 v6 += this->uTargetSurfacePitch - v20; | |
10029 } | |
10030 while ( !v17 ); | |
10031 } | |
10032 } | |
10033 } | |
10034 } | |
10035 } | |
10036 | |
10037 //----- (004A6776) -------------------------------------------------------- | |
315 | 10038 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 10039 { |
10040 Texture *v4; // edi@2 | |
10041 unsigned int v5; // ebx@4 | |
10042 unsigned __int16 *v6; // eax@4 | |
10043 unsigned int v7; // edx@5 | |
10044 unsigned int v8; // edx@6 | |
10045 unsigned int v9; // edx@7 | |
10046 unsigned int v10; // edx@8 | |
10047 unsigned int v11; // edx@9 | |
10048 unsigned int v12; // esi@12 | |
10049 unsigned int v13; // esi@15 | |
10050 unsigned int v14; // edx@17 | |
10051 unsigned int v15; // esi@18 | |
10052 unsigned __int8 *v16; // ebx@22 | |
10053 char v17; // zf@28 | |
10054 int v18; // [sp+10h] [bp-10h]@4 | |
10055 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10056 int v20; // [sp+1Ch] [bp-4h]@4 | |
10057 int a2a; // [sp+28h] [bp+8h]@24 | |
10058 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
10059 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
10060 | |
10061 if ( this->uNumSceneBegins ) | |
10062 { | |
10063 v4 = a4; | |
10064 if ( a4 ) | |
10065 { | |
10066 if ( a4->pPalette16 ) | |
10067 { | |
10068 v5 = a4->uTextureHeight; | |
10069 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 10070 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10071 v20 = a4->uTextureWidth; |
10072 v18 = a4->uTextureWidth; | |
10073 if ( this->bClip ) | |
10074 { | |
10075 v7 = this->uClipX; | |
10076 if ( (signed int)a2 < (signed int)v7 ) | |
10077 { | |
10078 v8 = v7 - a2; | |
10079 v19 += v8; | |
10080 v20 += a2 - this->uClipX; | |
10081 v6 += v8; | |
10082 } | |
10083 v9 = this->uClipY; | |
10084 v5 = a4->uTextureHeight; | |
10085 if ( (signed int)a3 < (signed int)v9 ) | |
10086 { | |
10087 v10 = v9 - a3; | |
10088 v19 += v18 * v10; | |
10089 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
10090 v4 = a4; | |
10091 v6 += this->uTargetSurfacePitch * v10; | |
10092 } | |
10093 v11 = this->uClipX; | |
10094 if ( (signed int)v11 < (signed int)a2 ) | |
10095 v11 = a2; | |
10096 a4a = this->uClipZ; | |
10097 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
10098 { | |
10099 v12 = this->uClipX; | |
10100 if ( (signed int)v12 < (signed int)a2 ) | |
10101 v12 = a2; | |
10102 v20 = a4a - v12; | |
10103 } | |
10104 v13 = this->uClipY; | |
10105 if ( (signed int)v13 < (signed int)a3 ) | |
10106 v13 = a3; | |
10107 v14 = this->uClipW; | |
10108 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10109 { | |
10110 v15 = this->uClipY; | |
10111 if ( (signed int)v15 < (signed int)a3 ) | |
10112 v15 = a3; | |
10113 v5 = v14 - v15; | |
10114 } | |
10115 } | |
10116 if ( (signed int)v5 > 0 ) | |
10117 { | |
10118 a3a = v5; | |
10119 v16 = v19; | |
10120 do | |
10121 { | |
10122 if ( v20 > 0 ) | |
10123 { | |
10124 a2a = v20; | |
10125 do | |
10126 { | |
10127 if ( *v16 ) | |
10128 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
10129 ++v6; | |
10130 ++v16; | |
10131 --a2a; | |
10132 } | |
10133 while ( a2a ); | |
10134 } | |
10135 v16 += v18 - v20; | |
10136 v17 = a3a-- == 1; | |
10137 v6 += this->uTargetSurfacePitch - v20; | |
10138 } | |
10139 while ( !v17 ); | |
10140 } | |
10141 } | |
10142 } | |
10143 } | |
10144 } | |
10145 | |
10146 //----- (004A65CC) -------------------------------------------------------- | |
10147 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10148 { | |
10149 unsigned __int16 *v8; // esi@6 | |
10150 unsigned int v9; // edi@6 | |
10151 unsigned int v10; // eax@7 | |
10152 unsigned int v11; // eax@8 | |
10153 unsigned int v12; // eax@9 | |
10154 unsigned int v13; // eax@10 | |
10155 unsigned int v14; // edx@11 | |
10156 unsigned int v15; // eax@13 | |
10157 unsigned int v16; // edx@14 | |
10158 unsigned int v17; // edx@17 | |
10159 unsigned int v18; // eax@19 | |
10160 unsigned int v19; // edx@20 | |
10161 int v20; // eax@27 | |
10162 int v21; // edx@29 | |
10163 int v22; // [sp+Ch] [bp-Ch]@6 | |
10164 int v23; // [sp+Ch] [bp-Ch]@24 | |
10165 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
10166 int xa; // [sp+20h] [bp+8h]@26 | |
10167 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
10168 int v27; // [sp+2Ch] [bp+14h]@6 | |
10169 | |
10170 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
10171 { | |
10172 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | |
710 | 10173 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10174 v27 = a4->uTextureWidth; |
10175 v9 = a4->uTextureHeight; | |
10176 v22 = a4->uTextureWidth; | |
10177 if ( this->bClip ) | |
10178 { | |
10179 v10 = this->uClipX; | |
10180 if ( (signed int)x < (signed int)v10 ) | |
10181 { | |
10182 v11 = v10 - x; | |
10183 v24 += v11; | |
10184 v27 += x - this->uClipX; | |
10185 v8 += v11; | |
10186 } | |
10187 v12 = this->uClipY; | |
10188 if ( (signed int)y < (signed int)v12 ) | |
10189 { | |
10190 v13 = v12 - y; | |
10191 v24 += v22 * v13; | |
10192 v9 = y - this->uClipY + a4->uTextureHeight; | |
10193 v8 += this->uTargetSurfacePitch * v13; | |
10194 } | |
10195 v14 = this->uClipX; | |
10196 if ( (signed int)v14 < (signed int)x ) | |
10197 v14 = x; | |
10198 v15 = this->uClipZ; | |
10199 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
10200 { | |
10201 v16 = this->uClipX; | |
10202 if ( (signed int)v16 < (signed int)x ) | |
10203 v16 = x; | |
10204 v27 = v15 - v16; | |
10205 } | |
10206 v17 = this->uClipY; | |
10207 if ( (signed int)v17 < (signed int)y ) | |
10208 v17 = y; | |
10209 v18 = this->uClipW; | |
10210 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
10211 { | |
10212 v19 = this->uClipY; | |
10213 if ( (signed int)v19 < (signed int)y ) | |
10214 v19 = y; | |
10215 v9 = v18 - v19; | |
10216 } | |
10217 } | |
10218 if ( (signed int)v9 > 0 ) | |
10219 { | |
10220 ya = v9; | |
10221 v23 = v22 - v27; | |
10222 do | |
10223 { | |
10224 if ( v27 > 0 ) | |
10225 { | |
10226 xa = v27; | |
10227 do | |
10228 { | |
10229 v20 = *v24; | |
10230 if ( v20 >= a7 && v20 <= a8 ) | |
10231 { | |
10232 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10233 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10234 v21 = 2 * a8 - v21 - a7; | |
10235 *v8 = a4->pPalette16[v21]; | |
10236 } | |
10237 ++v8; | |
10238 ++v24; | |
10239 --xa; | |
10240 } | |
10241 while ( xa ); | |
10242 } | |
10243 v8 += this->uTargetSurfacePitch - v27; | |
10244 v24 += v23; | |
10245 --ya; | |
10246 } | |
10247 while ( ya ); | |
10248 } | |
10249 } | |
10250 } | |
10251 | |
10252 //----- (004A63E6) -------------------------------------------------------- | |
10253 void Render::_4A63E6(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10254 { | |
10255 Texture *v8; // eax@2 | |
10256 Texture *v9; // ebx@4 | |
10257 unsigned __int16 *v10; // esi@6 | |
10258 unsigned int v11; // edi@7 | |
10259 unsigned int v12; // eax@9 | |
10260 unsigned int v13; // eax@10 | |
10261 unsigned int v14; // edx@11 | |
10262 unsigned int v15; // eax@13 | |
10263 unsigned int v16; // edx@14 | |
10264 unsigned int v17; // edx@17 | |
10265 unsigned int v18; // eax@19 | |
10266 unsigned int v19; // edx@20 | |
10267 int v20; // eax@27 | |
10268 int v21; // edx@29 | |
10269 int v22; // [sp+Ch] [bp-Ch]@6 | |
10270 int v23; // [sp+Ch] [bp-Ch]@24 | |
10271 int v24; // [sp+10h] [bp-8h]@6 | |
10272 int v25; // [sp+14h] [bp-4h]@6 | |
10273 int i; // [sp+20h] [bp+8h]@25 | |
10274 int v27; // [sp+24h] [bp+Ch]@23 | |
10275 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
10276 | |
10277 if ( this->uNumSceneBegins ) | |
10278 { | |
10279 v8 = a4; | |
10280 if ( a4 ) | |
10281 { | |
10282 if ( a4->pPalette16 ) | |
10283 { | |
10284 v9 = a5; | |
10285 if ( a5 ) | |
10286 { | |
10287 if ( a5->pPalette16 ) | |
10288 { | |
10289 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 10290 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10291 v25 = v8->uTextureWidth; |
10292 v24 = v8->uTextureHeight; | |
10293 v22 = v8->uTextureWidth; | |
10294 if ( this->bClip ) | |
10295 { | |
10296 v11 = this->uClipX; | |
10297 if ( (signed int)a2 < (signed int)v11 ) | |
10298 { | |
10299 v28 += v11 - a2; | |
10300 v25 += a2 - v11; | |
10301 v9 = a5; | |
10302 v10 += v11 - a2; | |
10303 } | |
10304 v12 = this->uClipY; | |
10305 if ( (signed int)a3 < (signed int)v12 ) | |
10306 { | |
10307 v13 = v12 - a3; | |
10308 v9 = a5; | |
10309 v28 += v22 * v13; | |
10310 v24 += a3 - this->uClipY; | |
10311 v10 += this->uTargetSurfacePitch * v13; | |
10312 } | |
10313 v14 = this->uClipX; | |
10314 if ( (signed int)v14 < (signed int)a2 ) | |
10315 v14 = a2; | |
10316 v15 = this->uClipZ; | |
10317 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
10318 { | |
10319 v16 = this->uClipX; | |
10320 if ( (signed int)v16 < (signed int)a2 ) | |
10321 v16 = a2; | |
10322 v25 = v15 - v16; | |
10323 } | |
10324 v17 = this->uClipY; | |
10325 if ( (signed int)v17 < (signed int)a3 ) | |
10326 v17 = a3; | |
10327 v18 = this->uClipW; | |
10328 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
10329 { | |
10330 v19 = this->uClipY; | |
10331 if ( (signed int)v19 < (signed int)a3 ) | |
10332 v19 = a3; | |
10333 v24 = v18 - v19; | |
10334 } | |
10335 } | |
10336 v27 = 0; | |
10337 if ( v24 > 0 ) | |
10338 { | |
10339 v23 = v22 - v25; | |
10340 do | |
10341 { | |
10342 for ( i = 0; i < v25; ++v28 ) | |
10343 { | |
10344 if ( *v28 ) | |
10345 { | |
710 | 10346 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 10347 if ( v20 >= a7 ) |
10348 { | |
10349 if ( v20 <= a8 ) | |
10350 { | |
10351 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10352 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10353 v21 = 2 * a8 - v21 - a7; | |
10354 v9 = a5; | |
10355 *v10 = a5->pPalette16[v21]; | |
10356 } | |
10357 } | |
10358 } | |
10359 ++i; | |
10360 ++v10; | |
10361 } | |
10362 ++v27; | |
10363 v10 += this->uTargetSurfacePitch - v25; | |
10364 v28 += v23; | |
10365 } | |
10366 while ( v27 < v24 ); | |
10367 } | |
10368 } | |
10369 } | |
10370 } | |
10371 } | |
10372 } | |
10373 } | |
10374 | |
10375 //----- (004A6274) -------------------------------------------------------- | |
10376 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
10377 { | |
10378 Texture *pCurrentTexture; // edi@2 | |
10379 int uHeight; // ebx@4 | |
10380 unsigned __int16 *v6; // eax@4 | |
10381 unsigned int v7; // edx@5 | |
10382 unsigned int v8; // edx@6 | |
10383 unsigned int v9; // edx@7 | |
10384 unsigned int v10; // edx@8 | |
10385 unsigned int v11; // edx@9 | |
10386 unsigned int v12; // esi@12 | |
10387 unsigned int v13; // esi@15 | |
10388 unsigned int v14; // edx@17 | |
10389 unsigned int v15; // esi@18 | |
10390 unsigned __int8 *v16; // ebx@22 | |
10391 char uFlag; // zf@28 | |
10392 int v18; // [sp+10h] [bp-10h]@4 | |
10393 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10394 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
10395 int uXa; // [sp+28h] [bp+8h]@24 | |
10396 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10397 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
10398 | |
10399 if ( this->uNumSceneBegins ) | |
10400 { | |
10401 pCurrentTexture = pTexture; | |
10402 if ( pTexture ) | |
10403 { | |
10404 if ( pTexture->pPalette16 ) | |
10405 { | |
10406 uHeight = pTexture->uTextureHeight; | |
10407 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10408 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10409 uWidth = pTexture->uTextureWidth; |
10410 v18 = pTexture->uTextureWidth; | |
10411 if ( this->bClip ) | |
10412 { | |
10413 v7 = this->uClipX; | |
10414 if ( (signed int)uX < (signed int)v7 ) | |
10415 { | |
10416 v8 = v7 - uX; | |
10417 v19 += v8; | |
10418 uWidth += uX - this->uClipX; | |
10419 v6 += v8; | |
10420 } | |
10421 v9 = this->uClipY; | |
10422 uHeight = pTexture->uTextureHeight; | |
10423 if ( (signed int)uY < (signed int)v9 ) | |
10424 { | |
10425 v10 = v9 - uY; | |
10426 v19 += v18 * v10; | |
10427 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
10428 pCurrentTexture = pTexture; | |
10429 v6 += this->uTargetSurfacePitch * v10; | |
10430 } | |
10431 v11 = this->uClipX; | |
10432 if ( (signed int)v11 < (signed int)uX ) | |
10433 v11 = uX; | |
10434 pTexturea = this->uClipZ; | |
10435 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
10436 { | |
10437 v12 = this->uClipX; | |
10438 if ( (signed int)v12 < (signed int)uX ) | |
10439 v12 = uX; | |
10440 uWidth = pTexturea - v12; | |
10441 } | |
10442 v13 = this->uClipY; | |
10443 if ( (signed int)v13 < (signed int)uY ) | |
10444 v13 = uY; | |
10445 v14 = this->uClipW; | |
10446 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
10447 { | |
10448 v15 = this->uClipY; | |
10449 if ( (signed int)v15 < (signed int)uY ) | |
10450 v15 = uY; | |
10451 uHeight = v14 - v15; | |
10452 } | |
10453 } | |
10454 if ( (signed int)uHeight > 0 ) | |
10455 { | |
10456 uYa = uHeight; | |
10457 v16 = v19; | |
10458 do | |
10459 { | |
10460 if ( uWidth > 0 ) | |
10461 { | |
10462 uXa = uWidth; | |
10463 do | |
10464 { | |
10465 if ( *v16 ) | |
10466 *v6 = pCurrentTexture->pPalette16[*v16]; | |
10467 ++v6; | |
10468 ++v16; | |
10469 } | |
10470 while ( uXa-- !=1 ); | |
10471 } | |
10472 v16 += v18 - uWidth; | |
10473 uFlag = uYa-- == 1; | |
10474 v6 += this->uTargetSurfacePitch - uWidth; | |
10475 } | |
10476 while ( !uFlag ); | |
10477 } | |
10478 } | |
10479 } | |
10480 } | |
10481 } | |
10482 | |
10483 //----- (004A612A) -------------------------------------------------------- | |
710 | 10484 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 10485 { |
10486 Texture *v5; // eax@2 | |
10487 unsigned int v6; // edx@3 | |
10488 int v7; // ebx@3 | |
10489 int v8; // edi@3 | |
10490 signed int v9; // eax@4 | |
10491 int v10; // eax@5 | |
10492 unsigned int v11; // esi@6 | |
10493 signed int v12; // esi@8 | |
10494 unsigned int v13; // eax@10 | |
10495 signed int v14; // esi@11 | |
10496 unsigned int v15; // esi@14 | |
10497 unsigned int v16; // eax@16 | |
10498 unsigned int v17; // ecx@17 | |
10499 int v18; // edx@23 | |
10500 int v19; // [sp+Ch] [bp-Ch]@3 | |
10501 int v20; // [sp+10h] [bp-8h]@3 | |
10502 int uOutXa; // [sp+20h] [bp+8h]@21 | |
10503 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
10504 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
10505 | |
10506 if ( this->uNumSceneBegins ) | |
10507 { | |
10508 v5 = pTexture; | |
10509 if ( pTexture ) | |
10510 { | |
10511 v6 = uOutY; | |
10512 v7 = pTexture->uTextureHeight; | |
10513 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
710 | 10514 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10515 v8 = v5->uTextureWidth; |
10516 v20 = v5->uTextureWidth; | |
10517 v19 = v5->uTextureWidth; | |
10518 if ( this->bClip ) | |
10519 { | |
10520 v9 = this->uClipX; | |
10521 if ( uOutX < v9 ) | |
10522 { | |
10523 v10 = v9 - uOutX; | |
10524 uOutYa += v10; | |
10525 v8 += uOutX - this->uClipX; | |
10526 v20 = v8; | |
10527 pZBuffer += v10; | |
10528 } | |
10529 v11 = this->uClipY; | |
10530 if ( (signed int)v6 < (signed int)v11 ) | |
10531 { | |
10532 uOutYa += v19 * (v11 - v6); | |
10533 v7 += v6 - v11; | |
10534 pZBuffer += 640 * (v11 - v6); | |
10535 v8 = v20; | |
10536 } | |
10537 v12 = this->uClipX; | |
10538 if ( v12 < uOutX ) | |
10539 v12 = uOutX; | |
10540 v13 = this->uClipZ; | |
10541 if ( v8 + v12 > (signed int)v13 ) | |
10542 { | |
10543 v14 = this->uClipX; | |
10544 if ( v14 < uOutX ) | |
10545 v14 = uOutX; | |
10546 v8 = v13 - v14; | |
10547 } | |
10548 v15 = this->uClipY; | |
10549 if ( (signed int)v15 < (signed int)v6 ) | |
10550 v15 = v6; | |
10551 v16 = this->uClipW; | |
10552 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
10553 { | |
10554 v17 = this->uClipY; | |
10555 if ( (signed int)v17 >= (signed int)v6 ) | |
10556 v6 = v17; | |
10557 v7 = v16 - v6; | |
10558 } | |
10559 } | |
10560 if ( v7 > 0 ) | |
10561 { | |
10562 uOutXa = v7; | |
10563 do | |
10564 { | |
10565 if ( v8 > 0 ) | |
10566 { | |
10567 v18 = v8; | |
10568 do | |
10569 { | |
10570 if ( *uOutYa ) | |
10571 *pZBuffer = zVal; | |
10572 ++pZBuffer; | |
10573 ++uOutYa; | |
10574 --v18; | |
10575 } | |
10576 while ( v18 ); | |
10577 } | |
10578 pZBuffer += 640 - v8; | |
10579 uOutYa += v19 - v8; | |
10580 --uOutXa; | |
10581 } | |
10582 while ( uOutXa ); | |
10583 } | |
10584 } | |
10585 } | |
10586 } | |
10587 | |
10588 //----- (004A601E) -------------------------------------------------------- | |
991 | 10589 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 10590 { |
10591 signed int v5; // edx@3 | |
10592 int v6; // ebx@3 | |
10593 int v7; // esi@3 | |
10594 void *v8; // esi@3 | |
10595 unsigned int v9; // eax@4 | |
10596 unsigned int v10; // eax@6 | |
10597 signed int v11; // edi@8 | |
10598 unsigned int v12; // eax@10 | |
10599 signed int v13; // edi@11 | |
10600 unsigned int v14; // edi@14 | |
10601 unsigned int v15; // eax@16 | |
10602 unsigned int v16; // ecx@17 | |
10603 int v17; // [sp+18h] [bp+Ch]@3 | |
10604 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
10605 | |
10606 if ( this->uNumSceneBegins && pTexture ) | |
10607 { | |
10608 v5 = a3; | |
10609 v6 = pTexture->uTextureHeight; | |
10610 v7 = 5 * a3; | |
10611 v17 = pTexture->uTextureHeight; | |
10612 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
10613 pTexturea = pTexture->uTextureWidth; | |
10614 if ( this->bClip ) | |
10615 { | |
10616 v9 = this->uClipX; | |
10617 if ( a2 < (signed int)v9 ) | |
10618 { | |
10619 pTexturea += a2 - v9; | |
10620 v8 = (char *)v8 + 4 * (v9 - a2); | |
10621 } | |
10622 v10 = this->uClipY; | |
10623 if ( v5 < (signed int)v10 ) | |
10624 { | |
10625 v17 += v5 - v10; | |
10626 v8 = (char *)v8 + 2560 * (v10 - v5); | |
10627 } | |
10628 v11 = this->uClipX; | |
10629 if ( v11 < a2 ) | |
10630 v11 = a2; | |
10631 v12 = this->uClipZ; | |
10632 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
10633 { | |
10634 v13 = this->uClipX; | |
10635 if ( v13 < a2 ) | |
10636 v13 = a2; | |
10637 pTexturea = v12 - v13; | |
10638 } | |
10639 v14 = this->uClipY; | |
10640 if ( (signed int)v14 < v5 ) | |
10641 v14 = v5; | |
10642 v6 = v17; | |
10643 v15 = this->uClipW; | |
10644 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
10645 { | |
10646 v16 = this->uClipY; | |
10647 if ( (signed int)v16 < v5 ) | |
10648 v16 = v5; | |
10649 v6 = v15 - v16; | |
10650 } | |
10651 } | |
10652 if ( v6 > 0 ) | |
10653 { | |
10654 do | |
10655 { | |
10656 if ( (signed int)pTexturea > 0 ) | |
10657 { | |
10658 memset32(v8, a5, pTexturea); | |
10659 v8 = (char *)v8 + 4 * pTexturea; | |
10660 } | |
10661 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
10662 --v6; | |
10663 } | |
10664 while ( v6 ); | |
10665 } | |
10666 } | |
10667 } | |
10668 | |
10669 //----- (004A5EB2) -------------------------------------------------------- | |
10670 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
10671 { | |
10672 Texture *v4; // edi@2 | |
10673 unsigned int v5; // ebx@4 | |
10674 unsigned __int16 *pTarget; // eax@4 | |
10675 unsigned int v7; // edx@5 | |
10676 unsigned int v8; // edx@6 | |
10677 unsigned int v9; // edx@7 | |
10678 unsigned int v10; // edx@8 | |
10679 unsigned int v11; // edx@9 | |
10680 unsigned int v12; // esi@12 | |
10681 unsigned int v13; // esi@15 | |
10682 unsigned int v14; // edx@17 | |
10683 unsigned int v15; // esi@18 | |
10684 unsigned __int8 *v16; // edx@22 | |
10685 char v17; // zf@26 | |
10686 int v18; // [sp+10h] [bp-10h]@4 | |
10687 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10688 int v20; // [sp+1Ch] [bp-4h]@4 | |
10689 int uXa; // [sp+28h] [bp+8h]@24 | |
10690 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10691 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
10692 | |
10693 if ( this->uNumSceneBegins ) | |
10694 { | |
10695 v4 = a4; | |
10696 if ( a4 ) | |
10697 { | |
10698 if ( a4->pPalette16 ) | |
10699 { | |
10700 v5 = a4->uTextureHeight; | |
10701 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10702 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10703 v20 = a4->uTextureWidth; |
10704 v18 = a4->uTextureWidth; | |
10705 if ( this->bClip ) | |
10706 { | |
10707 v7 = this->uClipX; | |
10708 if ( (signed int)uX < (signed int)v7 ) | |
10709 { | |
10710 v8 = v7 - uX; | |
10711 v19 += v8; | |
10712 v20 += uX - this->uClipX; | |
10713 pTarget += v8; | |
10714 } | |
10715 v9 = this->uClipY; | |
10716 v5 = a4->uTextureHeight; | |
10717 if ( (signed int)uY < (signed int)v9 ) | |
10718 { | |
10719 v10 = v9 - uY; | |
10720 v19 += v18 * v10; | |
10721 v5 = uY - this->uClipY + a4->uTextureHeight; | |
10722 v4 = a4; | |
10723 pTarget += this->uTargetSurfacePitch * v10; | |
10724 } | |
10725 v11 = this->uClipX; | |
10726 if ( (signed int)v11 < (signed int)uX ) | |
10727 v11 = uX; | |
10728 v23 = this->uClipZ; | |
10729 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
10730 { | |
10731 v12 = this->uClipX; | |
10732 if ( (signed int)v12 < (signed int)uX ) | |
10733 v12 = uX; | |
10734 v20 = v23 - v12; | |
10735 } | |
10736 v13 = this->uClipY; | |
10737 if ( (signed int)v13 < (signed int)uY ) | |
10738 v13 = uY; | |
10739 v14 = this->uClipW; | |
10740 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10741 { | |
10742 v15 = this->uClipY; | |
10743 if ( (signed int)v15 < (signed int)uY ) | |
10744 v15 = uY; | |
10745 v5 = v14 - v15; | |
10746 } | |
10747 } | |
10748 if ( (signed int)v5 > 0 ) | |
10749 { | |
10750 uYa = v5; | |
10751 v16 = v19; | |
10752 do | |
10753 { | |
10754 if ( v20 > 0 ) | |
10755 { | |
10756 uXa = v20; | |
10757 do | |
10758 { | |
10759 *pTarget = v4->pPalette16[*v16]; | |
10760 ++pTarget; | |
10761 ++v16; | |
10762 --uXa; | |
10763 } | |
10764 while ( uXa ); | |
10765 } | |
10766 v16 += v18 - v20; | |
10767 v17 = uYa-- == 1; | |
10768 pTarget += this->uTargetSurfacePitch - v20; | |
10769 } | |
10770 while ( !v17 ); | |
10771 } | |
10772 } | |
10773 } | |
10774 } | |
10775 } | |
10776 | |
10777 //----- (004667E9) -------------------------------------------------------- | |
10778 void Render::ChangeBetweenWinFullscreenModes() | |
10779 { | |
10780 float v0; // ST14_4@17 | |
10781 int v1; // edx@24 | |
10782 signed int v2; // ecx@24 | |
10783 int v3; // esi@25 | |
10784 int v4; // edx@26 | |
10785 ObjectDesc *v5; // eax@26 | |
10786 RGBTexture *v6; // esi@33 | |
10787 const char *v7; // eax@34 | |
10788 const char *v8; // [sp-4h] [bp-28h]@33 | |
10789 int v9; // [sp+0h] [bp-24h]@33 | |
10790 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
10791 | |
10792 if ( pRenderer->bWindowMode ) | |
10793 goto LABEL_52; | |
10794 if ( dword_6BE364_game_settings_1 & 2 ) | |
10795 { | |
10796 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." | |
10797 return; | |
10798 } | |
10799 if ( !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) | |
10800 { | |
10801 LABEL_52: | |
10802 if ( pEventTimer->bPaused ) | |
10803 BYTE1(dword_6BE364_game_settings_1) |= 8u; | |
10804 else | |
10805 pEventTimer->Pause(); | |
10806 if ( pMiscTimer->bPaused ) | |
10807 BYTE1(dword_6BE364_game_settings_1) |= 0x10u; | |
10808 else | |
10809 pMiscTimer->Pause(); | |
10810 pMouse->bActive = 0; | |
10811 if ( pRenderer->pRenderD3D ) | |
10812 { | |
10813 pBitmaps_LOD->ReleaseHardwareTextures(); | |
10814 pSprites_LOD->ReleaseAll(); | |
10815 } | |
10816 if ( pRenderer->bWindowMode ) | |
10817 { | |
10818 if ( GetWindowRect(hWnd, &Rect) ) | |
10819 { | |
10820 WriteWindowsRegistryInt("window X", Rect.left); | |
10821 WriteWindowsRegistryInt("window Y", Rect.top); | |
10822 uWindowX = Rect.left; | |
10823 uWindowY = Rect.top; | |
10824 } | |
10825 SetMenu(hWnd, 0); | |
10826 SetWindowLongA(hWnd, -20, 0); | |
10827 SetWindowLongA(hWnd, -16, 0x10000000u); | |
10828 pRenderer->InitializeFullscreen(hWnd); | |
10829 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | |
10830 pGame->pGammaController->Initialize(v0); | |
10831 } | |
10832 else | |
10833 { | |
10834 ClipCursor(0); | |
10835 pRenderer->SwitchToWindow(hWnd); | |
10836 SetWindowLongA(hWnd, -16, uWindowStyle); | |
10837 SetMenu(hWnd, hOSMenu); | |
10838 } | |
10839 if ( pRenderer->pRenderD3D ) | |
10840 { | |
10841 pBitmaps_LOD->_410423_move_textures_to_device(); | |
10842 pSprites_LOD->MoveSpritesToVideoMemory(); | |
10843 } | |
10844 if ( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits | |
10845 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits | |
10846 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits ) | |
10847 goto LABEL_38; | |
10848 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10849 pPaletteManager->RecalculateAll(); | |
10850 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10851 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10852 v2 = 0; | |
10853 if ( (signed int)pObjectList->uNumObjects > 0 ) | |
10854 { | |
10855 v3 = 0; | |
10856 do | |
10857 { | |
10858 BYTE3(v4) = 0; | |
10859 v5 = &pObjectList->pObjects[v3]; | |
10860 ++v3; | |
10861 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; | |
10862 LOBYTE(v4) = v5->uParticleTrailColorG; | |
10863 v1 = v5->uParticleTrailColorB | (v4 << 8); | |
10864 ++v2; | |
10865 v5->uParticleTrailColor = v1; | |
10866 } | |
10867 while ( v2 < (signed int)pObjectList->uNumObjects ); | |
10868 } | |
10869 LOBYTE(v1) = 1; | |
373 | 10870 SetUserInterface(pParty->alignment, v1); |
0 | 10871 if ( pVideoPlayer->pVideoFrame.pPixels ) |
10872 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); | |
10873 if ( uCurrentMenuID ) | |
10874 { | |
10875 if ( uCurrentMenuID != 6 ) | |
10876 { | |
10877 if ( uCurrentMenuID == 8 ) | |
10878 dword_A74C88 = 1; | |
10879 goto LABEL_38; | |
10880 } | |
10881 v6 = &pTexture_PCX; | |
10882 pTexture_PCX.Release(); | |
10883 v9 = 0; | |
10884 v8 = "makeme.pcx"; | |
10885 } | |
10886 else | |
10887 { | |
10888 v6 = &pTexture_PCX; | |
10889 pTexture_PCX.Release(); | |
10890 v7 = "title.pcx"; | |
10891 if ( uCurrentMenuID ) | |
10892 v7 = "lsave640.pcx"; | |
10893 v9 = 0; | |
10894 v8 = v7; | |
10895 } | |
10896 v6->Load(v8, v9); | |
10897 LABEL_38: | |
10898 viewparams->bRedrawGameUI = 1; | |
688 | 10899 viewparams->InitGrayPalette(); |
0 | 10900 pMouse->SetCurrentCursorBitmap(); |
10901 if ( pRenderer->bWindowMode ) | |
10902 { | |
10903 InvalidateRect(0, 0, 0); | |
10904 MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | |
10905 ShowWindow(hWnd, 1); | |
10906 } | |
10907 pMouse->bActive = 1; | |
10908 if ( pVideoPlayer->AnyMovieLoaded() ) | |
898 | 10909 pVideoPlayer->SelectMovieType(); |
0 | 10910 if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) |
10911 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | |
10912 else | |
10913 pEventTimer->Resume(); | |
10914 if ( BYTE1(dword_6BE364_game_settings_1) & 0x10 ) | |
10915 BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; | |
10916 else | |
10917 pMiscTimer->Resume(); | |
10918 } | |
10919 } | |
10920 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
10921 // A74C88: using guessed type int dword_A74C88; | |
10922 | |
10923 //----- (0044EC20) -------------------------------------------------------- | |
10924 bool RenderD3D::DoesRaiseExceptions() | |
10925 { | |
10926 return true; | |
10927 } | |
10928 | |
10929 //----- (0040DBD3) -------------------------------------------------------- | |
10930 void __fastcall Render::SetPixel(Vec2_int_ *pTargetXY, unsigned __int16 uColor) | |
10931 { | |
10932 Vec2_int_ *pTargetXY_; // esi@1 | |
10933 unsigned __int16 v3; // di@1 | |
10934 signed int v4; // ecx@2 | |
10935 signed int v5; // eax@4 | |
10936 | |
10937 pTargetXY_ = pTargetXY; | |
10938 v3 = uColor; | |
10939 pRenderer->BeginScene(); | |
10940 if ( pRenderer->uNumSceneBegins ) | |
10941 { | |
10942 v4 = pTargetXY_->x; | |
10943 if ( pTargetXY_->x >= 0 ) | |
10944 { | |
10945 if ( v4 <= 639 ) | |
10946 { | |
10947 v5 = pTargetXY_->y; | |
10948 if ( v5 >= 0 ) | |
10949 { | |
10950 if ( v5 <= 479 ) | |
10951 pRenderer->pTargetSurface[v4 + pRenderer->uTargetSurfacePitch * v5] = v3; | |
10952 } | |
10953 } | |
10954 } | |
10955 pRenderer->EndScene(); | |
10956 } | |
10957 } | |
10958 | |
10959 //----- (004524D8) -------------------------------------------------------- | |
10960 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
10961 { | |
10962 int v11; // eax@13 | |
10963 int v12; // ecx@13 | |
10964 void *v13; // eax@13 | |
10965 unsigned __int8 v14; // zf@13 | |
10966 unsigned __int8 v15; // sf@13 | |
10967 int v16; // esi@14 | |
10968 int v17; // ecx@16 | |
10969 int v18; // esi@16 | |
10970 unsigned __int16 *v19; // eax@16 | |
10971 int v20; // edx@16 | |
10972 int v21; // ecx@16 | |
10973 int v22; // eax@16 | |
10974 int v23; // esi@16 | |
10975 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
10976 int v27; // [sp+28h] [bp-Ch]@14 | |
10977 int v28; // [sp+2Ch] [bp-8h]@13 | |
10978 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
10979 | |
10980 //v3 = this; | |
10981 //sprintf(Str1, "%s", pName); | |
10982 //v4 = uNumItems; | |
10983 if (!uNumItems) | |
10984 return nullptr; | |
10985 | |
10986 //{ | |
10987 //v5 = 0, pDesta = uNumItems; | |
10988 uint idx1 = 0, | |
10989 idx2 = uNumItems; | |
10990 while (true) | |
10991 { | |
10992 auto i = idx1 + (idx2 - idx1) / 2; | |
10993 | |
10994 auto res = strcmpi(pName, pSpriteNames[i]); | |
10995 if (!res) | |
10996 { | |
10997 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
10998 break; | |
10999 } | |
11000 else if (res < 0) | |
11001 idx2 = idx1 + (idx2 - idx1) / 2; | |
11002 else | |
11003 idx1 = i + 1; | |
11004 | |
11005 if ( idx1 >= idx2 ) | |
11006 return false; | |
11007 } | |
11008 | |
11009 | |
11010 uint uCompressedSize = 0; | |
11011 fread(&uCompressedSize, 4, 1, pFile); | |
11012 | |
11013 auto pTex = new HWLTexture; | |
670 | 11014 fread(&pTex->uBufferWidth, 4, 1, pFile); |
11015 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
11016 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
11017 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 11018 fread(&pTex->uWidth, 4, 1, pFile); |
11019 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 11020 fread(&pTex->uAreaX, 4, 1, pFile); |
11021 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 11022 |
11023 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
11024 if (uCompressedSize) | |
11025 { | |
11026 auto pCompressedData = new char[uCompressedSize]; | |
11027 { | |
11028 fread(pCompressedData, 1, uCompressedSize, pFile); | |
11029 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
11030 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
11031 } | |
11032 delete [] pCompressedData; | |
11033 } | |
11034 else | |
11035 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
11036 | |
11037 if ( field_61A94_scale_hwls_to_half ) | |
11038 { | |
11039 v11 = pTex->uHeight / 2; | |
11040 v12 = pTex->uWidth / 2; | |
11041 pTex->uHeight = v11; | |
11042 pTex->uWidth = v12; | |
11043 v13 = new unsigned __int16[v12 * v11]; | |
11044 v28 = 0; | |
11045 v14 = pTex->uHeight == 0; | |
11046 v15 = (pTex->uHeight & 0x80000000u) != 0; | |
11047 v26 = (unsigned __int16 *)v13; | |
11048 if ( !(v15 | v14) ) | |
11049 { | |
11050 v16 = pTex->uWidth; | |
11051 v27 = 1; | |
11052 do | |
11053 { | |
11054 pDestb = 0; | |
11055 if ( v16 > 0 ) | |
11056 { | |
11057 do | |
11058 { | |
11059 v17 = v16 * v27; | |
11060 v18 = v28 * v16; | |
11061 v19 = pTex->pPixels; | |
11062 v20 = pDestb + 2 * v18; | |
11063 v21 = (int)&v19[2 * (pDestb + v17)]; | |
11064 v22 = (int)&v19[2 * v20]; | |
11065 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
11066 LOWORD(v21) = *(unsigned short *)v21; | |
11067 v23 = pDestb++ + v18; | |
11068 v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
11069 v16 = pTex->uWidth; | |
11070 } | |
11071 while (pDestb < pTex->uWidth); | |
11072 } | |
11073 ++v28; | |
11074 v27 += 2; | |
11075 } | |
11076 while ( v28 < (signed int)pTex->uHeight ); | |
11077 } | |
11078 delete [] pTex->pPixels; | |
11079 pTex->pPixels = v26; | |
11080 } | |
11081 return pTex; | |
11082 //result = pTex; | |
11083 // } | |
11084 // else | |
11085 // { | |
11086 //LABEL_8: | |
11087 // return nullptr; | |
11088 // } | |
11089 } | |
11090 | |
11091 //----- (0045271F) -------------------------------------------------------- | |
11092 bool RenderHWLContainer::Release() | |
11093 { | |
11094 RenderHWLContainer *v1; // esi@1 | |
11095 int v2; // ebx@1 | |
11096 void **v3; // edi@3 | |
11097 __int32 v4; // eax@6 | |
11098 FILE *v5; // ST24_4@6 | |
11099 size_t *v6; // edi@6 | |
11100 int v7; // ebx@7 | |
11101 signed int v9; // [sp+0h] [bp-8h]@6 | |
11102 FILE *File; // [sp+4h] [bp-4h]@6 | |
11103 | |
11104 v1 = this; | |
11105 v2 = 0; | |
11106 if ( this->bDumpDebug ) | |
11107 { | |
11108 File = fopen("logd3d.txt", "w"); | |
11109 v4 = ftell(v1->pFile); | |
11110 v5 = v1->pFile; | |
11111 v6 = &v1->uNumItems; | |
11112 v1->uDataOffset = v4; | |
11113 fwrite(&v1->uNumItems, 4u, 1u, v5); | |
11114 v9 = 0; | |
11115 if ( (signed int)v1->uNumItems > 0 ) | |
11116 { | |
11117 v7 = (int)v1->pSpriteNames; | |
11118 do | |
11119 { | |
11120 fwrite(*(const void **)v7, 1u, 0x14u, v1->pFile); | |
11121 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", *(unsigned int *)v7, *(unsigned int *)(v7 + 200000)); | |
11122 ++v9; | |
11123 v7 += 4; | |
11124 } | |
11125 while ( v9 < (signed int)*v6 ); | |
11126 v2 = 0; | |
11127 } | |
11128 fwrite(v1->pSpriteOffsets, 4u, *v6, v1->pFile); | |
11129 fseek(v1->pFile, 4, v2); | |
11130 fwrite(&v1->uDataOffset, 4u, 1u, v1->pFile); | |
11131 fclose(v1->pFile); | |
11132 fclose(File); | |
11133 } | |
11134 else | |
11135 { | |
11136 fclose(this->pFile); | |
11137 if ( (signed int)v1->uNumItems > 0 ) | |
11138 { | |
11139 v3 = (void **)v1->pSpriteNames; | |
11140 do | |
11141 { | |
11142 free(*v3); | |
11143 ++v2; | |
11144 ++v3; | |
11145 } | |
11146 while ( v2 < (signed int)v1->uNumItems ); | |
11147 } | |
11148 } | |
11149 return 1; | |
11150 } | |
11151 | |
11152 //----- (00452347) -------------------------------------------------------- | |
11153 RenderHWLContainer::RenderHWLContainer(): | |
11154 bDumpDebug(false) | |
11155 { | |
11156 RenderHWLContainer *v1; // esi@1 | |
11157 | |
11158 v1 = this; | |
11159 this->pFile = 0; | |
11160 uSignature = 0; | |
11161 v1->uDataOffset = 0; | |
11162 memset(&v1->uNumItems, 0, 0x61A84u); | |
11163 v1->uNumItems = 0; | |
11164 v1->field_61A94_scale_hwls_to_half = 0; | |
11165 } | |
11166 | |
11167 //----- (0045237F) -------------------------------------------------------- | |
11168 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
11169 { | |
11170 pFile = _wfopen(pFilename, L"rb"); | |
11171 if (!pFile) | |
11172 { | |
11173 Log::Warning(L"Failed to open file: %s", pFilename); | |
11174 return false; | |
11175 } | |
11176 | |
11177 fread(&uSignature, 1, 4, pFile); | |
11178 if (uSignature != 'TD3D') | |
11179 { | |
11180 Log::Warning(L"Invalid format: %s", pFilename); | |
11181 return false; | |
11182 } | |
11183 | |
11184 fread(&uDataOffset, 4, 1, pFile); | |
11185 fseek(pFile, uDataOffset, SEEK_SET); | |
11186 fread(&uNumItems, 4, 1, pFile); | |
11187 | |
11188 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
11189 for (uint i = 0; i < uNumItems; ++i) | |
11190 { | |
11191 pSpriteNames[i] = new char[20]; | |
11192 fread(pSpriteNames[i], 1, 20, pFile); | |
11193 } | |
11194 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
11195 | |
11196 return true; | |
11197 } | |
11198 | |
11199 //----- (004A1C1E) -------------------------------------------------------- | |
11200 void DoRenderBillboards_D3D() | |
11201 { | |
186 | 11202 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
11203 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
11204 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11205 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11206 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11207 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11208 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11209 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11210 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11211 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11212 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
|
11213 //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
|
11214 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11215 p->pQuards[0].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11216 p->pQuards[0].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11217 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11218 p->pQuards[1].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11219 p->pQuards[1].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11220 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11221 p->pQuards[2].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11222 p->pQuards[2].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11223 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11224 p->pQuards[3].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11225 p->pQuards[3].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11226 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11227 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11228 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11229 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11230 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11231 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11232 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11233 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11234 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11235 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11236 }*/ |
0 | 11237 |
11238 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) | |
11239 { | |
101 | 11240 auto p = &pRenderer->pBillboardRenderListD3D[i]; |
0 | 11241 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11242 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
0 | 11243 SetBillboardBlendOptions(p->uOpacity); |
11244 | |
101 | 11245 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11246 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11247 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11248 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11249 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 11250 } |
11251 | |
11252 if (pRenderer->bFogEnabled) | |
11253 { | |
11254 pRenderer->bFogEnabled = false; | |
186 | 11255 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11256 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11257 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11258 } | |
186 | 11259 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
11260 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
11261 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
11262 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11263 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
11264 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11265 } |
11266 | |
11267 //----- (004A1DA8) -------------------------------------------------------- | |
11268 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
11269 { | |
11270 switch (a1) | |
11271 { | |
11272 case RenderBillboardD3D::Transparent: | |
11273 { | |
11274 if (pRenderer->bFogEnabled) | |
11275 { | |
11276 pRenderer->bFogEnabled = false; | |
186 | 11277 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11278 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11279 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11280 } | |
11281 | |
186 | 11282 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); |
11283 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
11284 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11285 } |
11286 break; | |
11287 | |
11288 case RenderBillboardD3D::Opaque_1: | |
11289 case RenderBillboardD3D::Opaque_2: | |
11290 case RenderBillboardD3D::Opaque_3: | |
11291 { | |
11292 if (pRenderer->bUsingSpecular) | |
11293 { | |
11294 if (!pRenderer->bFogEnabled) | |
11295 { | |
11296 pRenderer->bFogEnabled = true; | |
186 | 11297 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
11298 } | |
11299 } | |
11300 | |
11301 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11302 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
11303 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 11304 } |
11305 break; | |
11306 | |
11307 default: | |
11308 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11309 assert(false); |
0 | 11310 break; |
11311 } | |
11312 } | |
11313 |