Mercurial > mm7
annotate Render.cpp @ 2132:49de109bbab5
SavePCXScreenshot() continue
author | Ritor1 |
---|---|
date | Sun, 29 Dec 2013 01:26:15 +0600 |
parents | 651b24553ae9 |
children | e378232bfd36 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
4 |
1277 | 5 #include "Outdoor_stuff.h" |
1016 | 6 #include "VideoPlayer.h" |
7 #include "Sprites.h" | |
8 #include "Mouse.h" | |
9 #include "GammaControl.h" | |
10 #include "stru6.h" | |
1183 | 11 #include "GUIWindow.h" |
1016 | 12 #include "DecalBuilder.h" |
13 #include "ParticleEngine.h" | |
0 | 14 #include "Render.h" |
15 #include "Outdoor.h" | |
16 #include "Party.h" | |
17 #include "LOD.h" | |
18 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2016
diff
changeset
|
19 #include "OurMath.h" |
0 | 20 #include "PaletteManager.h" |
2044 | 21 #include "Timer.h" |
0 | 22 #include "Game.h" |
23 #include "LightmapBuilder.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 "OSInfo.h" | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
28 #include "Actor.h" |
0 | 29 #include "Log.h" |
179 | 30 #include "TileFrameTable.h" |
189 | 31 #include "texts.h" |
0 | 32 #include "mm7_data.h" |
860 | 33 #include "MM7.h" |
1262 | 34 #include "Lights.h" |
1828
35c1e4ff6ba7
party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents:
1814
diff
changeset
|
35 #include "Level/Decoration.h" |
0 | 36 |
1924
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
37 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") |
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
38 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") |
0 | 39 |
40 struct IDirectDrawClipper *pDDrawClipper; | |
41 struct Render *pRenderer; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
42 struct RenderVertexD3D3 pVertices[50]; |
0 | 43 int uNumDecorationsDrawnThisFrame; // weak |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
44 RenderBillboard pBillboardRenderList[500]; |
0 | 45 unsigned int uNumBillboardsToDraw; |
46 int uNumSpritesDrawnThisFrame; // weak | |
47 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
48 RenderVertexSoft array_507D30[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
49 RenderVertexSoft array_50AC10[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
50 RenderVertexSoft array_73D150[20]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
51 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
52 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 53 |
54 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
55 | |
56 /* 384 */ | |
57 #pragma pack(push, 1) | |
58 struct PCXHeader_1 | |
59 { | |
60 char manufacturer; | |
61 char version; | |
62 char encoding; | |
63 char bpp; | |
64 __int16 left; | |
65 __int16 up; | |
66 __int16 right; | |
67 __int16 bottom; | |
68 __int16 hdpi; | |
69 __int16 vdpi; | |
70 }; | |
71 #pragma pack(pop) | |
72 | |
73 /* 385 */ | |
74 #pragma pack(push, 1) | |
75 struct PCXHeader_2 | |
76 { | |
77 char reserved; | |
78 char planes; | |
79 __int16 pitch; | |
80 __int16 palette_info; | |
81 }; | |
82 #pragma pack(pop) | |
83 | |
84 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
85 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
86 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
87 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
88 | |
89 //----- (0049E79F) -------------------------------------------------------- | |
2069 | 90 bool CheckTextureStages() |
0 | 91 { |
92 bool v0; // edi@1 | |
93 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
94 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
95 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
96 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
97 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
98 | |
99 v0 = false; | |
100 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); | |
101 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
102 | |
103 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
186 | 104 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 105 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u)); |
106 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
107 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
108 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
109 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u)); | |
110 | |
111 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
186 | 112 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
0 | 113 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u)); |
114 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u)); | |
115 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u)); | |
116 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u)); | |
117 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u)); | |
118 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u)); | |
119 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u)); | |
120 | |
121 if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
122 v0 = true; | |
123 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); | |
124 pTexture1->Release(); | |
125 pTexture2->Release(); | |
126 pSurface1->Release(); | |
127 pSurface2->Release(); | |
128 return v0; | |
129 } | |
130 | |
2002 | 131 void Render::sub_4A19B0() |
132 { | |
133 char *result; // eax@1 | |
134 signed int v1; // ecx@1 | |
135 /* | |
136 result = (char *)&this->pBillboardRenderListD3D[0].uOpacity; | |
137 v1 = 1000; | |
138 do | |
139 { | |
140 *(_DWORD *)result = 0; | |
141 *((_DWORD *)result + 1) = -1; | |
142 *((_DWORD *)result + 3) = -1; | |
143 *((_DWORD *)result - 34) = 4; | |
144 result += 156; | |
145 --v1; | |
146 } | |
147 while ( v1 ); | |
148 */ | |
149 for( int i = 0; i < 1000; i++ ) | |
150 { | |
151 this->pBillboardRenderListD3D[i].uOpacity = (RenderBillboardD3D::OpacityType)0; | |
152 this->pBillboardRenderListD3D[i].field_90 = -1; | |
153 this->pBillboardRenderListD3D[i].sParentBillboardID = -1; | |
154 this->pBillboardRenderListD3D[i].uNumVertices = 4; | |
155 } | |
156 | |
157 return; | |
158 } | |
159 | |
0 | 160 //----- (00440CB8) -------------------------------------------------------- |
161 void Render::DrawBillboardList_BLV() | |
162 { | |
163 __int16 v2; // ax@3 | |
164 int v5; // eax@11 | |
165 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
166 | |
2002 | 167 soft_billboard.sParentBillboardID = -1; |
0 | 168 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; |
169 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
170 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
171 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
172 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
173 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
174 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
175 | |
1637 | 176 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw; |
617 | 177 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 178 { |
1980 | 179 RenderBillboard* p = &pBillboardRenderList[i]; |
0 | 180 |
181 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
2002 | 182 soft_billboard.sParentBillboardID = i; |
0 | 183 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
184 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
|
185 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 186 soft_billboard.sZValue = p->sZValue; |
187 soft_billboard.uFlags = p->field_1E; | |
2006 | 188 soft_billboard.sTintColor = p->sTintColor; |
0 | 189 v2 = p->uHwSpriteID; |
190 if ( v2 != -1 ) | |
191 { | |
192 if ( pRenderer->pRenderD3D ) | |
657 | 193 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 194 else |
195 { | |
657 | 196 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 197 if (p->field_1E & 0x0100) |
198 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
199 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
200 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
201 v5 = p->uHwSpriteID; | |
202 if ( v5 >= 0 ) | |
733 | 203 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 204 } |
205 } | |
206 } | |
207 } | |
208 | |
209 //----- (004A16A5) -------------------------------------------------------- | |
1806 | 210 bool AreRenderSurfacesOk() |
0 | 211 { |
212 char v0; // zf@4 | |
213 bool result; // eax@8 | |
214 | |
1806 | 215 if (!pRenderer) |
216 return true; | |
0 | 217 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
218 { | |
219 if ( !pRenderer->pBackBuffer4 ) | |
220 goto LABEL_9; | |
221 v0 = pRenderer->pFrontBuffer4 == 0; | |
222 } | |
223 else | |
224 { | |
225 if ( !pRenderer->pBackBuffer2 ) | |
226 goto LABEL_9; | |
227 v0 = pRenderer->pFrontBuffer2 == 0; | |
228 } | |
229 if ( !v0 ) | |
230 { | |
231 LOBYTE(result) = 1; | |
232 return result; | |
233 } | |
234 LABEL_9: | |
235 LOBYTE(result) = 0; | |
236 return result; | |
237 } | |
238 | |
1338 | 239 void Render::RenderTerrainD3D() // New function |
86 | 240 { |
241 int v6; // ecx@8 | |
1427 | 242 struct Polygon *pTilePolygon; // ebx@8 |
186 | 243 |
244 //warning: the game uses CW culling by default, ccw is incosistent | |
245 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
246 | |
1338 | 247 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ |
248 | |
249 //Генерация местоположения вершин------------------------------------------------------------------------- | |
250 //решётка вершин делится на две части от -64 до 0 и от 0 до 64 | |
251 // | |
252 // -64 X 0 64 | |
253 // --------------- 64 | |
254 // | | | | |
255 // | | | | |
256 // | | | | |
257 // 0|------+------| Z | |
258 // | | | | |
259 // | | | | |
260 // | | | | |
261 // --------------- | |
262 // -64 | |
263 | |
264 int blockScale = 512; | |
265 int heightScale = 32; | |
266 for (unsigned int z = 0; z < 128; ++z) | |
267 { | |
268 for (unsigned int x = 0; x < 128; ++x) | |
269 { | |
270 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
271 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
272 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 273 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
274 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 275 } |
276 } | |
1338 | 277 //-------------------------------------------------------------------------------------------------------------------- |
278 | |
279 // | |
1344 | 280 for (unsigned int z = 0; z < 127; ++z) |
281 { | |
282 for (unsigned int x = 0; x < 127; ++x) | |
1338 | 283 { |
1637 | 284 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; |
1427 | 285 pTilePolygon->flags = 0; |
286 pTilePolygon->field_32 = 0; | |
287 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
288 pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; | |
289 if (pTilePolygon->uTileBitmapID == 0xFFFF) | |
106 | 290 continue; |
186 | 291 |
1338 | 292 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1427 | 293 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); |
294 pTilePolygon->field_32 = 0; | |
295 pTilePolygon->field_59 = 1; | |
296 pTilePolygon->sTextureDeltaU = 0; | |
297 pTilePolygon->sTextureDeltaV = 0; | |
1338 | 298 // x,z x+1,z |
299 // .____________. | |
300 // | | | |
301 // | | | |
302 // | | | |
303 // | | | |
304 // | | | |
305 // .____________. | |
306 // x,z+1 x+1,z+1 | |
307 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
106 | 308 array_73D150[0].u = 0; |
309 array_73D150[0].v = 0; | |
1338 | 310 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z |
106 | 311 array_73D150[1].u = 1; |
312 array_73D150[1].v = 0; | |
1338 | 313 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 |
106 | 314 array_73D150[2].u = 1; |
315 array_73D150[2].v = 1; | |
1338 | 316 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 |
106 | 317 array_73D150[3].u = 0; |
318 array_73D150[3].v = 1; | |
1338 | 319 //v58 = 0; |
320 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
321 //pTile->field_32 |= 0x0001; | |
1427 | 322 pTilePolygon->pODMFace = nullptr; |
323 pTilePolygon->uNumVertices = 4; | |
324 pTilePolygon->field_59 = 5; | |
1338 | 325 |
326 //shading (затенение)---------------------------------------------------------------------------- | |
327 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
1424 | 328 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; |
638 | 329 assert(norm_idx < uNumTerrainNormals); |
330 | |
1980 | 331 Vec3_float_* norm = &pTerrainNormals[norm_idx]; |
1338 | 332 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
333 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
334 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
1427 | 335 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); |
1338 | 336 //----------------------------------------------------------------------------------------------- |
638 | 337 |
1637 | 338 ++pODMRenderParams->uNumPolygons; |
339 ++pODMRenderParams->field_44; | |
340 assert(pODMRenderParams->uNumPolygons < 20000); | |
265 | 341 |
1427 | 342 pTilePolygon->uBModelID = 0; |
343 pTilePolygon->uBModelFaceID = 0; | |
344 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
345 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
106 | 346 { |
347 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 348 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 349 } |
140 | 350 |
1338 | 351 // check the transparency and texture (tiles) mapping (проверка прозрачности и наложение текстур (тайлов))---------------------- |
186 | 352 bool transparent = false; |
1427 | 353 if ( !( pTilePolygon->flags & 1 ) ) // не поддерживается TextureFrameTable |
354 { | |
355 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id) | |
1338 | 356 { |
357 //transparent = false; | |
358 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
359 } | |
360 else | |
361 { | |
1427 | 362 v6 = pTilePolygon->uTileBitmapID; |
363 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) ) | |
1338 | 364 transparent = true; |
365 } | |
179 | 366 |
140 | 367 assert(v6 < 1000); // many random crashes here |
186 | 368 |
369 // for all shore tiles - draw a tile water under them since they're half-empty | |
1427 | 370 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX |
371 pTilePolygon->DrawBorderTiles(); | |
372 | |
373 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1338 | 374 } |
375 //else //здесь уже пограничные тайлы воды | |
376 //pTile->DrawBorderTiles(); | |
377 //-------------------------------------------------------------------------------------------------------------------------------- | |
186 | 378 |
1637 | 379 --pODMRenderParams->uNumPolygons; |
380 --pODMRenderParams->field_44; | |
106 | 381 } |
382 } | |
383 } | |
0 | 384 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
385 |
0 | 386 |
387 //----- (0047BACF) -------------------------------------------------------- | |
388 void Render::TransformBillboardsAndSetPalettesODM() | |
389 { | |
142 | 390 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
391 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
392 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
393 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
394 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
395 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
396 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
397 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
398 //int v8; // ebx@4 |
0 | 399 unsigned __int16 *v9; // eax@7 |
400 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
401 //DWORD v11; // eax@13 |
0 | 402 int v12; // eax@13 |
403 int v13; // eax@14 | |
404 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
405 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 406 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
407 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 408 int v18; // [sp+60h] [bp-4h]@13 |
409 | |
2002 | 410 billboard.sParentBillboardID = -1; |
0 | 411 billboard.pTarget = pRenderer->pTargetSurface; |
412 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
413 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 414 billboard.uViewportX = pViewport->uViewportTL_X; |
415 billboard.uViewportY = pViewport->uViewportTL_Y; | |
416 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
417 billboard.uViewportW = pViewport->uViewportBR_Y; | |
1637 | 418 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw; |
142 | 419 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
420 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 421 { |
1980 | 422 RenderBillboard* pBillboard = &pBillboardRenderList[i]; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
423 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
424 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
425 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
2002 | 426 billboard.sParentBillboardID = i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
427 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
2006 | 428 billboard.sTintColor = pBillboard->sTintColor; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
429 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
430 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
431 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
432 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
433 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
434 if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
435 //if (pRenderer->pRenderD3D) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
436 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
437 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
657 | 438 pBillboard->dimming_level, pBillboard); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
439 /*else |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
440 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
441 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
442 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
443 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 444 if ( *(v1 - 10) & 2 ) |
445 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
446 else | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
447 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 448 v10 = (*(v1 - 9) & 1) == 0; |
449 billboard.pPalette = v9; | |
450 if ( !v10 ) | |
451 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
452 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
453 { | |
323 | 454 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 455 v15 = abs(v12); |
456 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
457 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
458 } | |
459 v13 = *((short *)v1 - 8); | |
460 if ( v13 >= 0 ) | |
733 | 461 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
462 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
463 } |
0 | 464 } |
465 } | |
466 | |
467 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
468 void Render::DrawSpriteObjects_ODM() |
0 | 469 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
470 //char *v0; // edi@2 |
430 | 471 //ObjectDesc *v1; // ebx@4 |
0 | 472 __int16 v2; // cx@5 |
473 RenderBillboard *v3; // esi@10 | |
474 SpriteFrame *v4; // eax@10 | |
430 | 475 //SpriteFrame *v5; // ebx@10 |
0 | 476 unsigned int v6; // eax@10 |
430 | 477 //int v7; // ecx@10 |
478 //int v8; // edx@10 | |
0 | 479 int v9; // ecx@10 |
480 unsigned __int16 v10; // ax@10 | |
430 | 481 //int *v11; // eax@14 |
0 | 482 int v12; // eax@22 |
483 int v13; // ST3C_4@23 | |
484 int v14; // eax@23 | |
485 int v15; // ecx@23 | |
486 int v16; // ebx@23 | |
487 int v17; // ecx@25 | |
488 int v18; // eax@25 | |
489 int v19; // ST40_4@26 | |
490 int v20; // ecx@26 | |
491 int v21; // ST44_4@28 | |
492 int v22; // ST3C_4@29 | |
493 signed __int64 v23; // qtt@30 | |
494 int v24; // ebx@30 | |
495 int v25; // ST3C_4@30 | |
496 int v26; // eax@31 | |
497 char v27; // zf@31 | |
430 | 498 //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 |
499 //__int16 a5; // [sp+10h] [bp-30h]@10 | |
0 | 500 int v30; // [sp+14h] [bp-2Ch]@23 |
501 int v31; // [sp+14h] [bp-2Ch]@29 | |
502 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
503 int v33; // [sp+18h] [bp-28h]@23 | |
504 int v34; // [sp+18h] [bp-28h]@26 | |
505 int v35; // [sp+18h] [bp-28h]@30 | |
506 int v36; // [sp+1Ch] [bp-24h]@10 | |
507 int v37; // [sp+1Ch] [bp-24h]@23 | |
508 int a6; // [sp+20h] [bp-20h]@10 | |
509 int a6a; // [sp+20h] [bp-20h]@23 | |
510 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
511 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 512 int v42; // [sp+2Ch] [bp-14h]@23 |
513 int y; // [sp+30h] [bp-10h]@10 | |
514 int x; // [sp+34h] [bp-Ch]@10 | |
515 int z; // [sp+38h] [bp-8h]@10 | |
516 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
517 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
518 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
519 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
|
520 { |
1980 | 521 SpriteObject* object = &pSpriteObjects[i]; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
522 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
523 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
524 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
525 //{ |
430 | 526 if (!object->uObjectDescID) // item probably pciked up |
527 continue; | |
528 | |
529 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
1980 | 530 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID]; |
430 | 531 if (object_desc->NoSprite()) |
532 continue; | |
533 | |
534 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
535 //if ( !(v1->uFlags & 1) ) | |
536 //{ | |
537 //v2 = *((short *)v0 - 14) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
538 v2 = object->uType; |
430 | 539 if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) |
540 { | |
541 //a5 = *(short *)v0; | |
542 x = object->vPosition.x; | |
543 y = object->vPosition.y; | |
544 z = object->vPosition.z; | |
545 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; | |
546 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
547 //v5 = v4; | |
548 //v28 = v4; | |
549 v36 = v4->uFlags; | |
550 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
551 v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
430 | 552 //LOWORD(v7) = object->uFacing; |
553 //v8 = v36; | |
554 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
555 v10 = v4->pHwSpriteIDs[v9]; | |
0 | 556 v3->uHwSpriteID = v10; |
557 if ( v36 & 0x20 ) | |
558 { | |
430 | 559 //v8 = v36; |
560 z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
0 | 561 } |
562 v46 = 0; | |
430 | 563 if ( v36 & 2 ) |
0 | 564 v46 = 2; |
430 | 565 //v11 = (int *)(256 << v9); |
566 if ( (256 << v9) & v36 ) | |
0 | 567 v46 |= 4u; |
430 | 568 if ( v36 & 0x40000 ) |
0 | 569 v46 |= 0x40u; |
430 | 570 if ( v36 & 0x20000 ) |
0 | 571 LOBYTE(v46) = v46 | 0x80; |
572 if ( a6 ) | |
573 { | |
430 | 574 //LOBYTE(v11) = byte_4E94D3; |
575 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
0 | 576 } |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
577 v12 = (x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
578 if (pGame->pIndoorCameraD3D->sRotationX) |
0 | 579 { |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
580 v13 = (y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
1642 | 581 v30 = ((unsigned __int64)(v12 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) |
582 + ((unsigned __int64)(v13 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16); | |
583 v37 = (unsigned __int64)(v12 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16; | |
584 a6a = (unsigned __int64)(v13 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
585 v33 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
1642 | 586 v14 = (unsigned __int64)(v30 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16; |
587 v15 = (unsigned __int64)(v33 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16; | |
0 | 588 v16 = v15 + v14; |
589 v42 = v15 + v14; | |
1637 | 590 if ( v15 + v14 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 ) |
0 | 591 { |
592 v17 = a6a - v37; | |
593 v40 = a6a - v37; | |
1642 | 594 v18 = ((unsigned __int64)(v33 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16) |
595 - ((unsigned __int64)(v30 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16); | |
0 | 596 goto LABEL_29; |
597 } | |
598 } | |
599 else | |
600 { | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
601 v34 = (y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
1642 | 602 v19 = (unsigned __int64)(v12 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16; |
603 v20 = (unsigned __int64)(v34 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16; | |
0 | 604 v16 = v20 + v19; |
605 v42 = v20 + v19; | |
1637 | 606 if ( v20 + v19 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 ) |
0 | 607 { |
1642 | 608 v21 = (unsigned __int64)(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16) * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16; |
609 v17 = ((unsigned __int64)(v34 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - v21; | |
610 v40 = ((unsigned __int64)(v34 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - v21; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
611 v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
0 | 612 LABEL_29: |
613 v31 = v18; | |
614 v22 = abs(v17); | |
615 if ( abs(v16) >= v22 ) | |
616 { | |
617 LODWORD(v23) = 0; | |
1637 | 618 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); |
0 | 619 v24 = v23 / v42; |
620 v25 = v23 / v42; | |
621 LODWORD(v23) = 0; | |
1637 | 622 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); |
430 | 623 v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); |
624 v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
625 | |
626 //if (::uNumBillboardsToDraw >= 500) | |
627 // return; | |
628 assert(::uNumBillboardsToDraw < 500); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
629 ++::uNumBillboardsToDraw; |
0 | 630 ++uNumSpritesDrawnThisFrame; |
430 | 631 |
632 object->uAttributes |= 1; | |
633 v3->uPalette = v4->uPaletteIndex; | |
634 v3->uIndoorSectorID = object->uSectorID; | |
635 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
636 v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
637 v3->pSpriteFrame = v4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
638 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 639 v3->field_1E = v46; |
430 | 640 v3->world_x = x; |
641 v3->world_y = y; | |
642 v3->world_z = z; | |
0 | 643 v3->uScreenSpaceX = v35; |
644 v3->uScreenSpaceY = v32; | |
645 HIWORD(v26) = HIWORD(v42); | |
646 LOWORD(v26) = 0; | |
430 | 647 v27 = (object->uAttributes & 0x20) == 0; |
862 | 648 v3->sZValue = v26 + (PID(OBJECT_Item,i)); |
657 | 649 v3->dimming_level = 0; |
2006 | 650 v3->sTintColor = 0; |
0 | 651 if ( !v27 ) |
652 { | |
653 if ( !pRenderer->pRenderD3D ) | |
654 v3->sZValue = 0; | |
655 } | |
656 } | |
657 goto LABEL_34; | |
658 } | |
659 } | |
660 } | |
430 | 661 //} |
0 | 662 LABEL_34: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
663 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
664 //++v41; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
665 //v0 += 112; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
666 //} |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
667 //while ( v41 < (signed int)uNumSpriteObjects ); |
0 | 668 } |
669 } | |
670 | |
671 //----- (0049D9BC) -------------------------------------------------------- | |
672 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
673 { | |
674 size_t v4; // eax@1 | |
675 size_t v5; // eax@1 | |
676 IUnknown *v6; // eax@10 | |
677 size_t v7; // eax@13 | |
678 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
679 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
680 int v11; // [sp+430h] [bp-CCh]@16 | |
681 int v12; // [sp+434h] [bp-C8h]@16 | |
682 int v13; // [sp+438h] [bp-C4h]@16 | |
683 int v14; // [sp+474h] [bp-88h]@16*/ | |
684 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
685 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
686 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
687 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
688 int v19; // [sp+4C8h] [bp-34h]@16 | |
689 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
690 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
691 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
692 | |
693 v4 = strlen(lpDriverName); | |
694 v20.pDriverName = new char[v4 + 1]; | |
695 v5 = strlen(lpDevDesc); | |
696 v20.pDeviceDesc = new char[v5 + 1]; | |
697 strcpy(v20.pDriverName, lpDriverName); | |
698 strcpy(v20.pDeviceDesc, lpDevDesc); | |
699 if ( lpGUID ) | |
700 { | |
701 v20.pGUID = new GUID; | |
702 memcpy(v20.pGUID, lpGUID, 0x10u); | |
703 } | |
704 else | |
705 { | |
706 v20.pGUID = 0; | |
707 } | |
708 | |
709 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
710 { | |
711 delete [] v20.pDriverName; | |
712 delete [] v20.pDeviceDesc; | |
713 if ( v20.pGUID ) | |
714 delete v20.pGUID; | |
715 } | |
716 else | |
717 { | |
718 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
719 { | |
720 delete [] v20.pDriverName; | |
721 delete [] v20.pDeviceDesc; | |
722 if ( v20.pGUID ) | |
723 delete v20.pGUID; | |
724 v6 = (IUnknown *)pDirectDraw; | |
725 } | |
726 else | |
727 { | |
728 pDirectDraw->Release(); | |
729 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
730 { | |
731 v20.pDDraw4DevDesc = 0; | |
732 } | |
733 else | |
734 { | |
735 v7 = strlen(ddDevId.szDescription); | |
736 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
737 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
738 } | |
739 memset(&ddsCaps, 0, 0x10u); | |
740 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
741 &ddsCaps, | |
742 (LPDWORD)&v20.uVideoMem, | |
743 (LPDWORD)&uFreeVideoMem))) | |
744 v20.uVideoMem = 0; | |
745 memset(&v10, 0, 0x7Cu); | |
746 v10.dwSize = 124; | |
747 v10.dwFlags = 6; | |
748 v10.dwHeight = 640; | |
749 v10.dwWidth = 480; | |
750 v10.ddpfPixelFormat.dwSize = 32; | |
751 | |
752 v19 = 0; | |
753 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
754 0, | |
755 0, | |
756 &v19, | |
757 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
758 || !v19 | |
759 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
760 { | |
761 delete [] v20.pDriverName; | |
762 delete [] v20.pDeviceDesc; | |
763 if ( v20.pDDraw4DevDesc ) | |
764 free(v20.pDDraw4DevDesc); | |
765 if ( v20.pGUID ) | |
766 delete v20.pGUID; | |
767 v6 = (IUnknown *)pDirectDraw4; | |
768 } | |
769 else | |
770 { | |
771 aux.pInfo = pOut; | |
772 aux.ptr_4 = &v20; | |
773 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
774 delete [] v20.pDriverName; | |
775 delete [] v20.pDeviceDesc; | |
776 if ( v20.pDDraw4DevDesc ) | |
777 free(v20.pDDraw4DevDesc); | |
778 if ( v20.pGUID ) | |
779 delete v20.pGUID; | |
780 pDirectDraw4->Release(); | |
781 v6 = (IUnknown *)pDirect3D3; | |
782 pDirectDraw4 = 0; | |
783 } | |
784 } | |
785 v6->Release(); | |
786 } | |
787 return 1; | |
788 } | |
789 | |
790 //----- (0049D784) -------------------------------------------------------- | |
791 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
792 { | |
793 int v6; // eax@1 | |
794 signed int v7; // edi@1 | |
795 signed int v8; // edi@14 | |
796 size_t v9; // eax@30 | |
797 size_t v10; // eax@30 | |
798 size_t v11; // eax@30 | |
799 size_t v12; // eax@30 | |
800 size_t v13; // eax@30 | |
801 | |
802 v6 = pHWDesc->dwFlags; | |
803 v7 = -1; | |
804 if ( v6 ) | |
805 { | |
806 if ( !a6->ptr_4->pGUID ) | |
807 v7 = 0; | |
808 if ( v6 && a6->ptr_4->pGUID ) | |
809 v7 = 1; | |
810 } | |
811 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
812 v7 = 2; | |
813 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
814 v7 = 3; | |
815 if ( v7 != -1 ) | |
816 { | |
817 v8 = v7; | |
818 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
819 a6->pInfo[v8].uCaps = 0; | |
820 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
821 a6->pInfo[v8].uCaps |= 2u; | |
822 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
823 a6->pInfo[v8].uCaps |= 4u; | |
824 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
825 a6->pInfo[v8].uCaps |= 8u; | |
826 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
827 a6->pInfo[v8].uCaps |= 0x10u; | |
828 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
829 a6->pInfo[v8].uCaps |= 0x20u; | |
830 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
831 a6->pInfo[v8].uCaps |= 0x40u; | |
832 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
833 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
834 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
835 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
836 v9 = strlen(lpDeviceName); | |
837 a6->pInfo[v8].pName = new char[v9 + 1]; | |
838 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
839 v10 = strlen(lpDeviceDesc); | |
840 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
841 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
1631 | 842 a6->pInfo[v8].pGUID = new GUID; |
0 | 843 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); |
844 v11 = strlen(a6->ptr_4->pDriverName); | |
845 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
846 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
847 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
848 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
849 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
850 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
851 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
852 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
853 if ( a6->ptr_4->pGUID ) | |
854 { | |
855 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
856 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
857 } | |
858 else | |
859 { | |
860 a6->pInfo[v8].pDirectDrawGUID = 0; | |
861 } | |
862 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
863 } | |
864 return 1; | |
865 } | |
866 | |
867 //----- (0049D75C) -------------------------------------------------------- | |
868 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
869 { | |
870 HRESULT result; // eax@3 | |
871 | |
872 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
873 { | |
874 *a2 = 1; | |
875 result = 0; | |
876 } | |
877 else | |
878 { | |
879 result = 1; | |
880 } | |
881 return result; | |
882 } | |
883 | |
884 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
885 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
886 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
887 //char *v0; // esi@2 |
639 | 888 //DecorationDesc *v1; // ebx@6 |
0 | 889 __int16 v2; // ax@6 |
890 double v3; // st7@7 | |
639 | 891 //int v4; // eax@9 |
892 //int v5; // edx@9 | |
0 | 893 unsigned int v6; // edi@9 |
894 int v7; // eax@9 | |
895 SpriteFrame *v8; // eax@9 | |
635 | 896 //SpriteFrame *v9; // edi@9 |
0 | 897 unsigned __int16 *v10; // eax@9 |
898 int v11; // ecx@9 | |
899 int v12; // eax@9 | |
900 int v13; // ecx@9 | |
901 int v14; // ecx@20 | |
902 char v15; // dl@20 | |
903 signed int v16; // eax@20 | |
904 int v17; // eax@23 | |
905 int v18; // ecx@24 | |
906 int v19; // eax@24 | |
907 int v20; // ecx@24 | |
908 int v21; // ebx@26 | |
909 int v22; // eax@26 | |
910 int v23; // eax@30 | |
911 signed __int64 v24; // qtt@31 | |
912 int v25; // ebx@31 | |
913 int v26; // ecx@32 | |
914 RenderBillboard *v27; // eax@37 | |
915 __int16 v28; // dx@37 | |
916 __int16 v29; // cx@37 | |
917 int v30; // ecx@37 | |
918 int v31; // ebx@37 | |
619 | 919 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
639 | 920 //int x; // [sp+74h] [bp-30h]@9 |
921 //int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
922 //int v35; // [sp+7Ch] [bp-28h]@1 |
639 | 923 //int v36; // [sp+80h] [bp-24h]@9 |
0 | 924 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
925 int v38; // [sp+88h] [bp-1Ch]@9 | |
926 int v39; // [sp+8Ch] [bp-18h]@24 | |
927 int v40; // [sp+90h] [bp-14h]@24 | |
928 int v41; // [sp+94h] [bp-10h]@24 | |
929 int v42; // [sp+98h] [bp-Ch]@9 | |
930 int a5; // [sp+9Ch] [bp-8h]@9 | |
931 int b; // [sp+A0h] [bp-4h]@22 | |
932 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
933 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
934 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
935 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
936 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
937 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
938 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
939 { |
1980 | 940 LevelDecoration* decor = &pLevelDecorations[i]; |
941 char* v0 = (char *)&pLevelDecorations[i].vPosition.y; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
942 |
1491
6d21ef91cb2d
Rename LevelDecoration::_47A825 to LevelDecoration::IsObeliskChestActive().
yoctozepto
parents:
1490
diff
changeset
|
943 if ((!(decor->uFlags & LEVEL_DECORATION_OBELISK_CHEST) || decor->IsObeliskChestActive()) && !(decor->uFlags & LEVEL_DECORATION_INVISIBLE)) |
1490 | 944 { |
945 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
1980 | 946 DecorationDesc* decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; |
1490 | 947 v2 = decor_desc->uFlags; |
948 if ( (char)v2 >= 0 ) | |
949 { | |
950 if ( !(v2 & 0x22) ) | |
0 | 951 { |
1490 | 952 //v4 = decor->vPosition.x; |
953 //v5 = decor->vPosition.z; | |
954 v6 = pMiscTimer->uTotalGameTimeElapsed; | |
955 //y = decor->vPosition.y; | |
956 //x = decor->vPosition.x; | |
957 //v36 = decor->vPosition.z; | |
958 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
959 | |
960 | |
961 #pragma region "New: seasons change" | |
962 extern bool change_seasons; | |
963 if (change_seasons) | |
964 switch (pParty->uCurrentMonth) | |
965 { | |
966 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
967 case 11: case 0: case 1: // winter | |
968 switch (decor_desc->uSpriteID) | |
969 { | |
970 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
971 case 548: // flower10 | |
972 case 547: // flower09 | |
973 case 541: // flower03 | |
974 case 539: continue; // flower01 | |
975 | |
976 case 483: // tree01 | |
977 case 486: // tree04 | |
978 case 492: // tree10 | |
979 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); | |
980 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
981 break; | |
982 | |
983 default: | |
984 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
985 } | |
986 break; | |
987 | |
988 case 2: case 3: case 4: // spring | |
989 switch (decor_desc->uSpriteID) | |
990 { | |
991 } | |
992 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
993 break; | |
994 | |
995 case 8: case 9: case 10: // autumn | |
996 switch (decor_desc->uSpriteID) | |
997 { | |
998 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
999 case 548: // flower10 | |
1000 case 547: // flower09 | |
1001 case 541: // flower03 | |
1002 case 539: continue; // flower01 | |
1003 | |
1004 case 483: // tree01 | |
1005 case 486: // tree04 | |
1006 case 492: // tree10 | |
1007 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); | |
1008 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
1009 break; | |
1010 | |
1011 default: | |
1012 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1013 } | |
1014 break; | |
1015 | |
1016 case 5: case 6: case 7: // summer | |
1017 //all green by default | |
1018 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1019 break; | |
1020 | |
1021 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
1022 } | |
1023 else | |
1024 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1025 #pragma endregion | |
1026 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1027 | |
1028 //v9 = v8; | |
1029 v42 = v8->uFlags; | |
1030 a5 = v8->uGlowRadius; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1031 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1032 decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
1490 | 1033 v11 = *((int *)v0 + 2); |
1034 v37 = v10; | |
1035 v12 = v42; | |
1036 v38 = 0; | |
1037 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
1038 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
1039 + v11 | |
1040 - (signed int)v37) >> 8) & 7; | |
1041 v37 = (unsigned __int16 *)v13; | |
1042 if ( v42 & 2 ) | |
1043 v38 = 2; | |
1044 if ( (256 << v13) & v42 ) | |
1045 v38 |= 4u; | |
1046 if ( v12 & 0x40000 ) | |
1047 v38 |= 0x40u; | |
1048 if ( v12 & 0x20000 ) | |
1049 LOBYTE(v38) = v38 | 0x80; | |
1050 if ( a5 ) | |
0 | 1051 { |
1490 | 1052 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) |
0 | 1053 { |
1490 | 1054 v14 = decor_desc->uColoredLightRed; |
1055 v15 = decor_desc->uColoredLightGreen; | |
1056 v16 = decor_desc->uColoredLightBlue; | |
0 | 1057 } |
1058 else | |
1059 { | |
1490 | 1060 v16 = 255; |
1061 v14 = 255; | |
1062 v15 = 255; | |
1063 } | |
1064 b = v16; | |
1065 pStationaryLightsStack->AddLight( | |
1066 decor->vPosition.x, | |
1067 decor->vPosition.y, | |
1068 decor->vPosition.z + decor_desc->uDecorationHeight / 2, | |
1069 a5, | |
1070 v14, | |
1071 v15, | |
1072 v16, | |
1073 byte_4E94D0); | |
1074 } | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1075 v17 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1076 if (pGame->pIndoorCameraD3D->sRotationX) |
1490 | 1077 { |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1078 v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
1642 | 1079 v18 = ((unsigned __int64)(v17 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) |
1080 + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16); | |
1490 | 1081 v42 = v18; |
1642 | 1082 b = (unsigned __int64)(v17 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16; |
1083 a5 = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1084 v40 = (decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
1642 | 1085 v41 = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16; |
1086 v19 = (unsigned __int64)(v18 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16; | |
1087 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16); | |
1088 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16); | |
1637 | 1089 if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1090 { |
1091 v21 = a5 - b; | |
1092 v41 = a5 - b; | |
1642 | 1093 a5 = (unsigned __int64)(v42 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16; |
1094 b = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16; | |
1095 v22 = ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16) - a5; | |
1490 | 1096 LABEL_30: |
1097 v42 = v22; | |
1098 v40 = 2 * abs(v20); | |
1099 v23 = abs(v21); | |
1100 if ( v40 >= v23 ) | |
0 | 1101 { |
1490 | 1102 LODWORD(v24) = 0; |
1637 | 1103 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
1490 | 1104 a5 = v24 / v39; |
1105 v25 = pViewport->uScreenCenterX | |
1106 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
1107 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
1108 v41 = v24 / v39; | |
1109 v40 = pViewport->uScreenCenterY | |
1110 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
1111 v42 = v8->scale; | |
1112 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; | |
1113 v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; | |
1114 if ( pRenderer->pRenderD3D ) | |
1115 { | |
1116 v26 = v41; | |
1117 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
1118 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
1119 } | |
1120 else | |
1121 { | |
1122 v26 = v41; | |
1123 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
1124 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
1125 } | |
1126 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) | |
1127 { | |
1128 if (::uNumBillboardsToDraw >= 500) | |
1129 return; | |
1130 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; | |
1131 ++uNumDecorationsDrawnThisFrame; | |
1132 v27->uHwSpriteID = *v37; | |
1133 v28 = v8->uPaletteIndex; | |
1134 v27->_screenspace_x_scaler_packedfloat = v26; | |
1135 v27->_screenspace_y_scaler_packedfloat = v26; | |
1136 v29 = v38; | |
1137 v27->uScreenSpaceX = v25; | |
1138 HIBYTE(v29) |= 2u; | |
1139 v27->uPalette = v28; | |
1140 v27->field_1E = v29; | |
1141 v27->world_x = decor->vPosition.x; | |
1142 v27->world_y = decor->vPosition.y; | |
1143 v27->world_z = decor->vPosition.z; | |
1144 v27->uScreenSpaceY = v40; | |
1145 HIWORD(v30) = HIWORD(v39); | |
1146 v31 = PID(OBJECT_Decoration,i); | |
1147 LOWORD(v30) = 0; | |
1148 v27->uIndoorSectorID = 0; | |
1149 v27->sZValue = v30 + v31; | |
1150 v27->dimming_level = 0; | |
1151 v27->pSpriteFrame = v8; | |
2006 | 1152 v27->sTintColor = 0; |
1490 | 1153 } |
0 | 1154 } |
1490 | 1155 goto LABEL_38; |
1156 } | |
1157 } | |
1158 else | |
1159 { | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1160 v42 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1161 v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
1642 | 1162 b = (unsigned __int64)(v17 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16; |
1163 a5 = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16; | |
1164 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16); | |
1165 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16); | |
1637 | 1166 if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1167 { |
1642 | 1168 a5 = (unsigned __int64)(v42 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16; |
1169 b = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16; | |
1170 v21 = ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - a5; | |
1171 v41 = ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - a5; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1172 v22 = (decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
1490 | 1173 goto LABEL_30; |
0 | 1174 } |
1175 } | |
1176 } | |
1490 | 1177 } |
1178 else | |
1179 { | |
1180 memset(&local_0, 0, 0x68u); | |
1181 v3 = (double)*((signed int *)v0 - 1); | |
1182 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; | |
1183 local_0.uDiffuse = 0xFF3C1E; | |
1184 local_0.x = v3; | |
1185 local_0.y = (double)*(signed int *)v0; | |
1186 local_0.z = (double)*((signed int *)v0 + 1); | |
1187 local_0.r = 0.0; | |
1188 local_0.g = 0.0; | |
1189 local_0.b = 0.0; | |
1190 local_0.flt_28 = 1.0; | |
1191 local_0.timeToLive = (rand() & 0x80) + 128; | |
1192 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
1193 pGame->pParticleEngine->AddParticle(&local_0); | |
1194 } | |
1195 } | |
0 | 1196 LABEL_38: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1197 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1198 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1199 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1200 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1201 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 1202 } |
1203 | |
1204 //----- (0049D717) -------------------------------------------------------- | |
1205 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1206 { | |
1207 HRESULT v2; // esi@2 | |
1208 | |
2069 | 1209 if ( Src->dwFlags & (0x400 | 0x2000)) |
0 | 1210 { |
1211 v2 = 0; | |
1212 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
1213 goto LABEL_6; | |
1214 if ( !Dst->dwSize ) | |
1215 { | |
1216 v2 = 1; | |
1217 LABEL_6: | |
2078 | 1218 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
0 | 1219 return v2; |
1220 } | |
1221 } | |
1222 return 1; | |
1223 } | |
1224 | |
1225 //----- (0049DC28) -------------------------------------------------------- | |
1226 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1227 { | |
1228 RenderD3D__DevInfo *v2; // eax@1 | |
1229 | |
1230 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1231 *pOutDevices = v2; | |
1232 memset(v2, 0, 0xA0u); | |
1985 | 1233 DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)RenderD3D__DeviceEnumerator, *pOutDevices, DDENUM_ATTACHEDSECONDARYDEVICES); |
0 | 1234 } |
1235 | |
1236 //----- (0049DC58) -------------------------------------------------------- | |
1237 RenderD3D::RenderD3D() | |
1238 { | |
1239 RenderD3D *v1; // esi@1 | |
1240 | |
1241 v1 = this; | |
1242 this->pHost = 0; | |
1243 this->pDirect3D = 0; | |
1244 this->pUnk = 0; | |
1245 this->pBackBuffer = 0; | |
1246 this->pFrontBuffer = 0; | |
1247 this->pZBuffer = 0; | |
1248 this->pDevice = 0; | |
1249 this->pViewport = 0; | |
1250 this->field_40 = 1; | |
1251 this->field_44 = 10; | |
1252 GetAvailableDevices(&this->pAvailableDevices); | |
1253 } | |
1254 | |
1255 //----- (0049DC90) -------------------------------------------------------- | |
1256 void RenderD3D::Release() | |
1257 { | |
1258 RenderD3D *v1; // esi@1 | |
1259 IDirectDraw4 *v2; // eax@2 | |
1260 signed int v3; // edi@4 | |
1261 IDirect3DViewport3 *v4; // eax@22 | |
1262 IUnknown *v5; // eax@24 | |
1263 IDirectDrawSurface4 *v6; // eax@26 | |
1264 IDirect3DDevice3 *v7; // eax@28 | |
1265 IDirect3D3 *v8; // eax@30 | |
1266 IDirectDrawSurface4 *v9; // eax@32 | |
1267 IDirectDrawSurface4 *v10; // eax@34 | |
1268 IDirectDraw4 *v11; // eax@36 | |
1269 | |
1270 v1 = this; | |
1271 if ( !this->bWindowed ) | |
1272 { | |
1273 v2 = this->pHost; | |
1274 if ( v2 ) | |
1275 { | |
1276 v2->RestoreDisplayMode(); | |
1277 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
1278 v1->pHost->FlipToGDISurface(); | |
1279 } | |
1280 } | |
1281 v3 = 0; | |
1282 do | |
1283 { | |
1284 if ( v1->pAvailableDevices[v3].pDriverName ) | |
1285 { | |
1286 free(v1->pAvailableDevices[v3].pDriverName); | |
1287 v1->pAvailableDevices[v3].pDriverName = 0; | |
1288 } | |
1289 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
1290 { | |
1291 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
1292 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
1293 } | |
1294 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
1295 { | |
1296 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
1297 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
1298 } | |
1299 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
1300 { | |
1301 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
1302 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
1303 } | |
1304 if ( v1->pAvailableDevices[v3].pName ) | |
1305 { | |
1306 free(v1->pAvailableDevices[v3].pName); | |
1307 v1->pAvailableDevices[v3].pName = 0; | |
1308 } | |
1309 if ( v1->pAvailableDevices[v3].pDescription ) | |
1310 { | |
1311 free(v1->pAvailableDevices[v3].pDescription); | |
1312 v1->pAvailableDevices[v3].pDescription = 0; | |
1313 } | |
1314 if ( v1->pAvailableDevices[v3].pGUID ) | |
1315 { | |
1316 free(v1->pAvailableDevices[v3].pGUID); | |
1317 v1->pAvailableDevices[v3].pGUID = 0; | |
1318 } | |
1319 ++v3; | |
1320 } | |
1321 while ( v3 < 4 ); | |
1322 if ( v1->pAvailableDevices ) | |
1323 { | |
1324 free(v1->pAvailableDevices); | |
1325 v1->pAvailableDevices = 0; | |
1326 } | |
1327 v4 = v1->pViewport; | |
1328 if ( v4 ) | |
1329 { | |
1330 v4->Release(); | |
1331 v1->pViewport = 0; | |
1332 } | |
1333 v5 = v1->pUnk; | |
1334 if ( v5 ) | |
1335 { | |
1336 v5->Release(); | |
1337 v1->pUnk = 0; | |
1338 } | |
1339 v6 = v1->pZBuffer; | |
1340 if ( v6 ) | |
1341 { | |
1342 v6->Release(); | |
1343 v1->pZBuffer = 0; | |
1344 } | |
1345 v7 = v1->pDevice; | |
1346 if ( v7 ) | |
1347 { | |
1348 v7->Release(); | |
1349 v1->pDevice = 0; | |
1350 } | |
1351 v8 = v1->pDirect3D; | |
1352 if ( v8 ) | |
1353 { | |
1354 v8->Release(); | |
1355 v1->pDirect3D = 0; | |
1356 } | |
1357 v9 = v1->pBackBuffer; | |
1358 if ( v9 ) | |
1359 { | |
1360 v9->Release(); | |
1361 v1->pBackBuffer = 0; | |
1362 } | |
1363 v10 = v1->pFrontBuffer; | |
1364 if ( v10 ) | |
1365 { | |
1366 v10->Release(); | |
1367 v1->pFrontBuffer = 0; | |
1368 } | |
1369 v11 = v1->pHost; | |
1370 if ( v11 ) | |
1371 { | |
1372 v11->Release(); | |
1373 v1->pHost = 0; | |
1374 } | |
1375 } | |
1376 | |
1377 //----- (0049DE14) -------------------------------------------------------- | |
2069 | 1378 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window) |
0 | 1379 { |
1380 //IDirectDraw4 *v8; // eax@12 | |
1381 //IDirectDraw4 *v9; // eax@16 | |
1382 //IDirectDraw4 *v10; // eax@20 | |
1383 //IDirectDraw4 *v13; // eax@35 | |
1384 const char *v23; // [sp-4h] [bp-DCh]@9 | |
1385 const char *v24; // [sp-4h] [bp-DCh]@13 | |
1386 const char *v25; // [sp-4h] [bp-DCh]@19 | |
1387 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1388 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1389 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1390 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1391 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
1392 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1393 | |
2069 | 1394 auto hWnd = window->GetApiHandle(); |
1395 int game_width = window->GetWidth(); | |
1396 int game_height = window->GetHeight(); | |
1397 | |
0 | 1398 this->bWindowed = bWindowed; |
1399 this->hWindow = hWnd; | |
1400 | |
1401 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
1402 { | |
1403 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1404 return 0; | |
1405 } | |
1406 | |
1407 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1408 { | |
1409 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1410 if (lpDD) | |
1411 lpDD->Release(); | |
1412 return 0; | |
1413 } | |
1414 lpDD->Release(); | |
1415 lpDD = 0; | |
1416 | |
1417 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1418 { | |
1419 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
1420 { | |
1421 v23 = "Init - Failed to set cooperative level.\n"; | |
1422 sprintf(pErrorMessage, v23); | |
1423 LABEL_65: | |
1424 if (pHost) | |
1425 { | |
1426 pHost->Release(); | |
1427 pHost = 0; | |
1428 } | |
1429 return 0; | |
1430 } | |
1431 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1432 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1433 ddsd2.dwFlags = DDSD_CAPS; | |
1434 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
1435 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1436 { | |
1437 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1438 pHost->GetDisplayMode(&ddsd2); | |
2069 | 1439 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) |
0 | 1440 { |
1441 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
1442 goto LABEL_14; | |
1443 } | |
1444 | |
1445 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
1446 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
2069 | 1447 ddsd2.dwWidth = game_width; |
1448 ddsd2.dwHeight = game_height; | |
0 | 1449 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) |
1450 { | |
1451 v24 = "Init - Failed to create back buffer.\n"; | |
1452 LABEL_14: | |
1453 sprintf(pErrorMessage, v24); | |
1454 if (pFrontBuffer) | |
1455 { | |
1456 pFrontBuffer->Release(); | |
1457 pFrontBuffer = 0; | |
1458 } | |
1459 goto LABEL_65; | |
1460 } | |
1461 if ( pHost->CreateClipper(0, &v30, 0) ) | |
1462 { | |
1463 v25 = "Init - Failed to create clipper.\n"; | |
1464 goto LABEL_45; | |
1465 } | |
1466 v30->SetHWnd(0, hWnd); | |
1467 pFrontBuffer->SetClipper(v30); | |
1468 | |
1469 v30->Release(); | |
1470 v30 = 0; | |
1471 | |
1472 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1473 | |
1474 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1475 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
2069 | 1476 ddsd2.dwWidth = game_width; |
1477 ddsd2.dwHeight = game_height; | |
0 | 1478 |
1479 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1480 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1481 &ddsd2.ddpfPixelFormat) ) | |
1482 goto LABEL_21; | |
1483 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1484 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
1485 | |
1486 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1487 { | |
1488 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
1489 { | |
1490 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1491 pBackBuffer, | |
1492 &pDevice, | |
1493 0) ) | |
1494 { | |
1495 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1496 d3dvp2.dvClipWidth = 2.0; | |
1497 d3dvp2.dvClipY = 1.0; | |
1498 d3dvp2.dvClipHeight = 2.0; | |
1499 d3dvp2.dvMaxZ = 1.0; | |
1500 d3dvp2.dvMinZ = 0.0; | |
1501 goto LABEL_54; | |
1502 } | |
1503 LABEL_51: | |
1504 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1505 if (pDirect3D) | |
1506 { | |
1507 pDirect3D->Release(); | |
1508 pDirect3D = 0; | |
1509 } | |
1510 goto LABEL_59; | |
1511 } | |
1512 LABEL_48: | |
1513 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1514 if (pZBuffer) | |
1515 { | |
1516 pZBuffer->Release(); | |
1517 pZBuffer = 0; | |
1518 } | |
1519 goto LABEL_61; | |
1520 } | |
1521 goto LABEL_44; | |
1522 } | |
1523 LABEL_36: | |
1524 v23 = "Init - Failed to create front buffer.\n"; | |
1525 sprintf(pErrorMessage, v23); | |
1526 goto LABEL_65; | |
1527 } | |
1528 if ( uDeviceID == 1 ) | |
1529 v26 = 1045; | |
1530 else | |
1531 v26 = 1041; | |
1532 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
1533 { | |
1534 v23 = "Init - Failed to set cooperative level.\n"; | |
1535 sprintf(pErrorMessage, v23); | |
1536 goto LABEL_65; | |
1537 } | |
1538 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
1539 { | |
1540 v23 = "Init - Failed to set display mode.\n"; | |
1541 sprintf(pErrorMessage, v23); | |
1542 goto LABEL_65; | |
1543 } | |
1544 | |
1545 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1546 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1547 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
1548 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
1549 ddsd2.dwBackBufferCount = 1; | |
1550 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1551 goto LABEL_36; | |
1552 //a3a = &pBackBuffer; | |
1553 //v14 = *v34; | |
1554 memset(&v27, 0, sizeof(DDSCAPS2)); | |
1555 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
1556 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
1557 //hWnda = &pDirect3D; | |
1558 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1559 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
1560 { | |
1561 v25 = "Init - Failed to get D3D interface.\n"; | |
1562 goto LABEL_45; | |
1563 } | |
1564 | |
1565 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1566 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1567 ddsd2.dwWidth = 640; | |
1568 ddsd2.dwHeight = 480; | |
1569 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1570 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1571 &ddsd2.ddpfPixelFormat) ) | |
1572 { | |
1573 LABEL_21: | |
1574 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
1575 goto LABEL_45; | |
1576 } | |
1577 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1578 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
1579 //uDeviceIDa = &pZBuffer; | |
1580 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1581 { | |
1582 LABEL_44: | |
1583 v25 = "Init - Failed to create z-buffer.\n"; | |
1584 LABEL_45: | |
1585 sprintf(pErrorMessage, v25); | |
1586 if (pBackBuffer) | |
1587 { | |
1588 pBackBuffer->Release(); | |
1589 pBackBuffer = 0; | |
1590 } | |
1591 LABEL_63: | |
1592 //v19 = &pFrontBuffer; | |
1593 if (pFrontBuffer) | |
1594 { | |
1595 pFrontBuffer->Release(); | |
1596 pFrontBuffer= 0; | |
1597 } | |
1598 goto LABEL_65; | |
1599 } | |
1600 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
1601 goto LABEL_48; | |
1602 //v33 = &pDevice; | |
1603 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1604 pBackBuffer, | |
1605 &pDevice, | |
1606 0) ) | |
1607 goto LABEL_51; | |
1608 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1609 d3dvp2.dvClipWidth = 2.0; | |
1610 d3dvp2.dvClipY = 1.0; | |
1611 d3dvp2.dvClipHeight = 2.0; | |
1612 d3dvp2.dvMaxZ = 1.0; | |
1613 | |
1614 LABEL_54: | |
1615 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
1616 //v17 = *hWnda; | |
2069 | 1617 d3dvp2.dwWidth = game_width; |
1618 d3dvp2.dwHeight = game_height; | |
0 | 1619 d3dvp2.dvClipX = -1.0; |
1620 //v18 = v17->lpVtbl; | |
1621 //v32 = &v4->pViewport; | |
1622 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
1623 { | |
1624 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
1625 if (pDevice) | |
1626 { | |
1627 pDevice->Release(); | |
1628 pDevice = 0; | |
1629 } | |
1630 if (pDirect3D) | |
1631 { | |
1632 pDirect3D->Release(); | |
1633 pDirect3D = 0; | |
1634 } | |
1635 LABEL_59: | |
1636 if (pZBuffer) | |
1637 { | |
1638 pZBuffer->Release(); | |
1639 pZBuffer = 0; | |
1640 } | |
1641 LABEL_61: | |
1642 if (pBackBuffer) | |
1643 { | |
1644 pBackBuffer->Release(); | |
1645 pBackBuffer = 0; | |
1646 } | |
1647 goto LABEL_63; | |
1648 } | |
1649 | |
1650 pDevice->AddViewport(pViewport); | |
1651 pViewport->SetViewport2(&d3dvp2); | |
1652 pDevice->SetCurrentViewport(pViewport); | |
1653 return 1; | |
1654 } | |
1655 | |
1656 //----- (0049E444) -------------------------------------------------------- | |
1657 unsigned int RenderD3D::GetDeviceCaps() | |
1658 { | |
1659 unsigned int v1; // ebx@1 | |
1660 RenderD3D *v2; // edi@1 | |
1661 IDirect3DDevice3 *v3; // eax@1 | |
1662 unsigned int result; // eax@2 | |
1663 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
1664 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
1665 | |
1666 v1 = 0; | |
1667 v2 = this; | |
1668 memset(&halCaps, 0, 0xFCu); | |
1669 halCaps.dwSize = 252; | |
1670 memset(&refCaps, 0, 0xFCu); | |
1671 v3 = v2->pDevice; | |
1672 refCaps.dwSize = 252; | |
1673 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
1674 { | |
1675 result = 1; | |
1676 } | |
1677 else | |
1678 { | |
1679 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
1680 v1 = 2; | |
1681 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
1682 v1 |= 4u; | |
1683 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
1684 v1 |= 8u; | |
1685 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
1686 v1 |= 0x10u; | |
1687 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
1688 v1 |= 0x20u; | |
1689 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
1690 v1 |= 0x40u; | |
1691 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
1692 LOBYTE(v1) = v1 | 0x80; | |
1693 result = v1; | |
1694 } | |
1695 return result; | |
1696 } | |
1697 | |
1698 //----- (0049E4FC) -------------------------------------------------------- | |
1699 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
1700 { | |
1701 uint uClearFlags = 0; | |
1702 | |
1703 if (bClearColor) | |
1704 uClearFlags |= D3DCLEAR_TARGET; | |
1705 if (bClearDepth) | |
1706 uClearFlags |= D3DCLEAR_ZBUFFER; | |
1707 | |
1708 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
1709 if (uClearFlags) | |
1710 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
1711 } | |
1712 | |
1713 //----- (0049E54D) -------------------------------------------------------- | |
1714 void RenderD3D::Present(bool bForceBlit) | |
1715 { | |
1716 RECT v5; // [sp+18h] [bp-18h]@1 | |
1717 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
1718 | |
1719 v5.left = 0; | |
1720 v5.top = 0; | |
1721 v5.bottom = 480; | |
1722 v5.right = 640; | |
1723 | |
1724 if (bWindowed || bForceBlit) | |
1725 { | |
1726 RECT rc; | |
1727 GetClientRect(hWindow, &rc); | |
1728 Point.y = 0; | |
1729 Point.x = 0; | |
1730 ClientToScreen(hWindow, &Point); | |
1731 OffsetRect(&rc, Point.x, Point.y); | |
1732 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
1733 } | |
1734 else | |
1735 pFrontBuffer->Flip(0, 1); | |
1736 } | |
1737 | |
1738 //----- (0049E5D4) -------------------------------------------------------- | |
1739 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
1740 { | |
1741 unsigned int v8; // edx@4 | |
1742 unsigned int v9; // ebx@5 | |
1743 unsigned int v10; // eax@5 | |
1744 DWORD v11; // edx@5 | |
1745 //int v12; // edx@7 | |
1746 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
1747 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
1748 | |
1749 //v15 = this; | |
1750 memset(&ddsd2, 0, 0x7Cu); | |
1751 ddsd2.dwSize = 0x7Cu; | |
1752 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1753 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
1754 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
1755 ddsd2.dwHeight = uTextureHeight; | |
1756 ddsd2.dwWidth = uTextureWidth; | |
1757 if ( bMipmaps ) | |
1758 { | |
1759 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
1760 { | |
1761 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
1762 LABEL_8: | |
1763 ddsd2.dwMipMapCount = v8; | |
1764 if ( !v8 ) | |
1765 goto LABEL_12; | |
1766 goto LABEL_11; | |
1767 } | |
1768 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
1769 { | |
1770 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
1771 goto LABEL_8; | |
1772 } | |
1773 v9 = GetMaxMipLevels(uTextureWidth); | |
1774 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
1775 ddsd2.dwMipMapCount = v9 - v10; | |
1776 if ( v9 == v10 ) | |
1777 { | |
1778 ddsd2.dwFlags = 0x1007u; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
1779 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used |
0 | 1780 ddsd2.ddsCaps.dwCaps = v11; |
1781 goto LABEL_12; | |
1782 } | |
1783 } | |
1784 else | |
1785 { | |
1786 ddsd2.dwMipMapCount = 1; | |
1787 } | |
1788 LABEL_11: | |
1789 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1790 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1791 LABEL_12: | |
1792 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
1793 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
1794 if (bAlphaChannel) | |
1795 { | |
1796 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
1797 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
1798 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
1799 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1800 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
1801 } | |
1802 else | |
1803 { | |
1804 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
1805 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
1806 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
1807 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1808 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
1809 } | |
1810 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
1811 return false; | |
1812 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
1813 { | |
1814 (*pOutSurface)->Release(); | |
1815 *pOutSurface = 0; | |
1816 return false; | |
1817 } | |
1818 return true; | |
1819 } | |
1820 | |
1821 //----- (004A5190) -------------------------------------------------------- | |
1822 void RenderD3D::HandleLostResources() | |
1823 { | |
1824 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
1825 pBitmaps_LOD->_410423_move_textures_to_device(); | |
1826 pSprites_LOD->ReleaseLostHardwareSprites(); | |
1827 } | |
1828 | |
1829 //----- (004A2050) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
1830 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) |
0 | 1831 { |
1832 Render *v5; // edi@1 | |
1833 unsigned int v6; // ebx@1 | |
1834 LightmapBuilder *v7; // esi@3 | |
1835 int v8; // eax@7 | |
1836 ODMFace *v9; // eax@12 | |
1837 char *v10; // esi@12 | |
1838 double v11; // st7@14 | |
1839 double v12; // st7@14 | |
1840 int v13; // eax@14 | |
1841 ODMFace *v14; // ecx@14 | |
1842 double v15; // st7@14 | |
1843 float v16; // ST48_4@15 | |
1844 int v17; // eax@15 | |
1845 char v18; // zf@17 | |
1846 HRESULT v19; // eax@18 | |
1847 HRESULT v20; // eax@18 | |
1848 HRESULT v21; // eax@20 | |
1849 HRESULT v22; // eax@20 | |
1850 unsigned int v23; // ecx@20 | |
1851 char *v24; // eax@21 | |
1852 HRESULT v25; // eax@23 | |
1853 HRESULT v26; // eax@23 | |
1854 HRESULT v27; // eax@24 | |
1855 HRESULT v28; // eax@25 | |
1856 HRESULT v29; // eax@25 | |
1857 HRESULT v30; // eax@25 | |
1858 HRESULT v31; // eax@25 | |
1859 HRESULT v32; // eax@26 | |
1860 unsigned int v33; // ecx@26 | |
1861 char *v34; // eax@27 | |
1862 int v35; // edx@28 | |
1863 HRESULT v36; // eax@29 | |
1864 HRESULT v37; // eax@29 | |
1865 HRESULT v38; // eax@29 | |
1866 HRESULT v39; // eax@29 | |
1867 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
1868 unsigned int v41; // eax@29 | |
1869 HRESULT v42; // eax@30 | |
1870 HRESULT v43; // eax@30 | |
1871 HRESULT v44; // eax@30 | |
1872 char *v45; // esi@34 | |
1873 int v46; // ecx@35 | |
1874 double v47; // st6@35 | |
1875 int v48; // eax@36 | |
1876 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
1877 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
1878 int v51; // [sp+50h] [bp-18h]@0 | |
1879 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
1880 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
1881 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
1882 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
1883 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
1884 int v57; // [sp+60h] [bp-8h]@34 | |
2006 | 1885 signed int a2; // [sp+64h] [bp-4h]@4 |
0 | 1886 |
1887 v5 = this; | |
1888 v6 = 0; | |
1889 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
1890 { | |
1891 v7 = pGame->pLightmapBuilder; | |
1892 v53 = v7; | |
1893 v54 = v7->std__vector_000004_size; | |
1894 if ( v7->std__vector_000004_size) | |
2006 | 1895 a2 = -1; |
638 | 1896 pGame->AlterGamma_ODM(a4, &a2); |
1394 | 1897 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) |
0 | 1898 { |
638 | 1899 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 1900 v7->DrawLightmaps(/*v8, 0*/); |
0 | 1901 } |
1902 else | |
1903 { | |
1904 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
1905 { | |
323 | 1906 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1907 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
1908 if (bUsingSpecular) | |
1909 { | |
186 | 1910 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
1911 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1912 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1913 } |
1073 | 1914 for (uint i = 0; i < uNumVertices; ++i) |
1915 { | |
1916 | |
1917 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1918 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1919 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1920 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1921 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1922 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
1923 | |
1924 if ( this->bUsingSpecular ) | |
0 | 1925 { |
1073 | 1926 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1927 } |
1073 | 1928 else |
1929 { | |
1930 d3d_vertex_buffer[i].specular = 0; | |
1931 } | |
1932 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1933 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1934 | |
1935 } | |
323 | 1936 |
1937 if (a4->uAttributes & FACE_OUTLINED) | |
1938 { | |
1939 int color; | |
1940 if (GetTickCount() % 300 >= 150) | |
1941 color = 0xFFFF2020; | |
1942 else color = 0xFF901010; | |
1943 | |
1944 for (uint i = 0; i < uNumVertices; ++i) | |
1945 d3d_vertex_buffer[i].diffuse = color; | |
1946 } | |
1947 | |
0 | 1948 pRenderD3D->pDevice->SetTexture(0, pTexture); |
1949 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1950 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1951 d3d_vertex_buffer, |
0 | 1952 uNumVertices, |
1953 D3DDP_DONOTLIGHT); | |
1954 } | |
1955 else | |
1956 { | |
1073 | 1957 for (uint i = 0; i < uNumVertices; ++i) |
1958 { | |
1959 | |
1960 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1961 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1962 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1963 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1964 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1965 if ( this->bUsingSpecular ) | |
0 | 1966 { |
1073 | 1967 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1968 } |
1073 | 1969 else |
1970 { | |
1971 d3d_vertex_buffer[i].specular = 0; | |
1972 } | |
1973 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1974 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1975 | |
1976 } | |
1977 | |
186 | 1978 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
1979 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 1980 if (bUsingSpecular) |
186 | 1981 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 1982 |
1983 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
1984 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1985 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1986 d3d_vertex_buffer, |
0 | 1987 uNumVertices, |
1988 D3DDP_DONOTLIGHT)); | |
1989 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
1990 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1991 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
1394 | 1992 v53->DrawLightmaps(/*-1, 0*/); |
1073 | 1993 for (uint i = 0; i < uNumVertices; ++i) |
1994 { | |
1995 d3d_vertex_buffer[i].diffuse = a2; | |
1996 } | |
0 | 1997 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 1998 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1999 if ( !pRenderer->bUsingSpecular ) |
186 | 2000 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
2001 | |
2002 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
2003 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
2004 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 2005 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
2006 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2007 d3d_vertex_buffer, |
0 | 2008 uNumVertices, |
2009 D3DDP_DONOTLIGHT)); | |
2010 if (bUsingSpecular) | |
2011 { | |
186 | 2012 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 2013 |
1073 | 2014 for (uint i = 0; i < uNumVertices; ++i) |
2015 { | |
2016 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
2017 d3d_vertex_buffer[i].specular = 0; | |
2018 } | |
2019 | |
0 | 2020 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 2021 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
2022 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 2023 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
2024 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2025 d3d_vertex_buffer, |
0 | 2026 uNumVertices, |
2027 D3DDP_DONOTLIGHT)); | |
186 | 2028 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 2029 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
2030 v41 = GetLevelFogColor(); | |
2031 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
2032 v6 = 0; | |
2033 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
2034 } | |
186 | 2035 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
2036 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 2037 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
2038 } | |
2039 } | |
2040 } | |
2041 } | |
2042 // 4D864C: using guessed type char byte_4D864C; | |
2043 | |
2044 //----- (0049EB79) -------------------------------------------------------- | |
2045 Render::~Render() | |
2046 { | |
2047 Render *v1; // esi@1 | |
2048 | |
2049 v1 = this; | |
1583 | 2050 free(this->pDefaultZBuffer); |
0 | 2051 v1->pD3DBitmaps.Release(); |
2052 v1->pD3DSprites.Release(); | |
2053 Release(); | |
2054 v1->bWindowMode = 1; | |
2055 //nullsub_1(); | |
2056 //nullsub_1(); | |
2057 } | |
2058 | |
2059 //----- (0049E756) -------------------------------------------------------- | |
2060 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
2061 { | |
2062 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
2063 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
2064 | |
2065 halCaps.dwSize = 380; | |
2066 refCaps.dwSize = 380; | |
2067 this_->GetCaps(&halCaps, &refCaps); | |
2068 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
2069 } | |
2070 | |
2071 //----- (0049E992) -------------------------------------------------------- | |
2072 Render::Render() | |
2073 { | |
2074 Render *v1; // esi@1 | |
2075 int v2; // eax@1 | |
2076 char v3; // zf@1 | |
2077 | |
2078 v1 = this; | |
2079 this->pDirectDraw4 = 0; | |
2080 this->pFrontBuffer4 = 0; | |
2081 this->pBackBuffer4 = 0; | |
2082 this->pColorKeySurface4 = 0; | |
2083 this->pDirectDraw2 = 0; | |
2084 this->pFrontBuffer2 = 0; | |
2085 this->pBackBuffer2 = 0; | |
2086 this->pSomeSurface2 = 0; | |
2087 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
2088 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2089 v1->bWindowMode = 1; | |
2090 v1->field_40054 = 0; | |
2091 v1->field_10 = 640; | |
2092 v1->field_14 = 480; | |
2093 v1->field_40030 = 0; | |
2094 v1->field_4002C = 0; | |
2095 v1->pActiveZBuffer = 0; | |
2096 v1->pDefaultZBuffer = 0; | |
709 | 2097 v1->raster_clip_y = 0; |
2098 v1->raster_clip_x = 0; | |
2099 v1->raster_clip_z = 639; | |
2100 v1->raster_clip_w = 479; | |
0 | 2101 v1->field_4003C = (int)&unk_4EED80; |
2102 v1->field_40040 = dword_4EED78; | |
2103 v1->uClipZ = 640; | |
2104 v1->field_40044 = 2; | |
2105 v1->field_40048 = 6; | |
2106 v1->pFrontBuffer4 = 0; | |
2107 v1->pBackBuffer4 = 0; | |
2108 v1->pColorKeySurface4 = 0; | |
2109 v1->pDirectDraw4 = 0; | |
2110 v1->pRenderD3D = 0; | |
2111 v1->uNumSceneBegins = 0; | |
2112 v1->uNumD3DSceneBegins = 0; | |
2069 | 2113 v1->using_software_screen_buffer = 0; |
0 | 2114 v1->pTargetSurface = 0; |
2115 v1->uTargetSurfacePitch = 0; | |
2116 v1->uClipY = 0; | |
2117 v1->uClipX = 0; | |
2118 v1->uClipW = 480; | |
2119 v1->bClip = 1; | |
2069 | 2120 //v1->bColorKeySupported = 0; |
0 | 2121 v1->bRequiredTextureStagesAvailable = 0; |
2122 v1->bTinting = 1; | |
2123 LOBYTE(v1->field_103668) = 0; | |
2124 v1->field_1036B8 = 0; | |
2125 v1->_gpu_memory_used = 0; | |
2126 uNumBillboardsToDraw = 0; | |
2127 bFogEnabled = false; | |
265 | 2128 |
2129 hd_water_tile_id = -1; | |
2130 hd_water_current_frame = 0; | |
2002 | 2131 sub_4A19B0(); |
0 | 2132 } |
2133 | |
2069 | 2134 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
0 | 2135 { |
1802 | 2136 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); |
2137 | |
2138 this->window = window; | |
2069 | 2139 //bStartInWindow = true; |
1802 | 2140 //windowed_mode_width = windowed_width; |
2141 //windowed_mode_height = windowed_height; | |
2142 | |
1985 | 2143 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0); |
0 | 2144 |
2145 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
2146 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
2147 | |
2148 this->bTinting = bTinting; | |
2149 | |
1980 | 2150 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); |
2151 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
0 | 2152 |
2153 return r1 && r2; | |
2154 } | |
2155 | |
2156 | |
2157 //----- (0049ECC4) -------------------------------------------------------- | |
2158 void Render::ClearBlack() | |
2159 { | |
2160 if (pRenderD3D) | |
2161 { | |
2069 | 2162 if (using_software_screen_buffer) |
0 | 2163 pRenderD3D->ClearTarget(true, 0, false, 0.0); |
2164 } | |
2165 else | |
2166 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
2167 } | |
2168 | |
2169 //----- (0049ED18) -------------------------------------------------------- | |
2170 void Render::PresentBlackScreen() | |
2171 { | |
2172 IDirectDrawSurface *v2; // eax@3 | |
2173 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
2174 RECT x; // [sp+68h] [bp-10h]@3 | |
2175 | |
2176 memset(&v3, 0, sizeof(DDBLTFX)); | |
1802 | 2177 GetWindowRect(window->GetApiHandle(), &x); |
0 | 2178 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
2179 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
2180 { | |
2181 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
2182 } | |
2183 else | |
2184 { | |
2185 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
2186 } | |
2187 v3.dwFillColor = 0; | |
2188 v3.dwSize = 100; | |
2189 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
2190 pRenderer->Present(); | |
2191 } | |
2192 | |
2193 //----- (0049EDB6) -------------------------------------------------------- | |
2194 void Render::SavePCXScreenshot() | |
2195 { | |
2196 int v5; // eax@8 | |
2132 | 2197 FILE *pOutFile; // edi@10 |
2198 unsigned short * v8; // eax@11 | |
0 | 2199 int v9; // eax@13 |
2200 int v10; // ecx@15 | |
2201 signed int v12; // eax@18 | |
2202 HRESULT v14; // eax@29 | |
2203 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
2204 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2205 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2206 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2132 | 2207 char *lineB; // [sp+11Ch] [bp-48h]@14 |
2208 char *lineG; // [sp+120h] [bp-44h]@14 | |
2209 //int v24; // [sp+124h] [bp-40h]@11 | |
0 | 2210 FILE *File; // [sp+128h] [bp-3Ch]@3 |
2211 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2212 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2132 | 2213 char *lineRGB; // [sp+148h] [bp-1Ch]@10 |
2214 void *surface; // [sp+14Ch] [bp-18h]@8 | |
2215 int image_width; // [sp+150h] [bp-14h]@4 | |
2216 int pitch; // [sp+154h] [bp-10h]@4 | |
0 | 2217 char v31; // [sp+15Ah] [bp-Ah]@25 |
2132 | 2218 unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17 |
2219 unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10 | |
2220 byte test_byte; // [sp+163h] [bp-1h]@17 | |
2221 | |
2222 int num_r_bits = 5; | |
2223 int num_g_bits = 6; | |
2224 int num_b_bits = 5; | |
2225 | |
2226 int r_mask = 0xF800; | |
2227 int g_mask = 0x7E0; | |
2228 int b_mask = 0x1F; | |
2229 | |
2069 | 2230 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2231 { |
2132 | 2232 sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100); |
0 | 2233 File = fopen(Filename, "wb"); |
2234 if ( File ) | |
2235 { | |
2132 | 2236 pitch = this->field_10; |
2237 if ( this->field_10 & 1 ) | |
2238 pitch = this->field_10 + 1; | |
2239 if ( this->pRenderD3D ) | |
2240 { | |
2241 memset(&Dst, 0, 0x7C); | |
0 | 2242 Dst.dwSize = 124; |
168 | 2243 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 2244 return; |
2132 | 2245 surface = Dst.lpSurface; |
2246 v5 = Dst.lPitch / 2; | |
0 | 2247 } |
2248 else | |
2249 { | |
2250 pRenderer->BeginScene(); | |
2132 | 2251 surface = pRenderer->pTargetSurface; |
0 | 2252 v5 = pRenderer->uTargetSurfacePitch; |
2253 } | |
2132 | 2254 header1.right = this->field_10 - 1; |
2255 header1.left = 0; | |
2256 header1.bottom = this->field_14 - 1; | |
2257 header1.up = 0; | |
2258 header2.pitch = pitch; | |
0 | 2259 memset(color_map, 0, sizeof(color_map)); |
2260 memset(v15, 0, sizeof(v15)); | |
2261 header2.reserved = 0; | |
2262 header1.manufacturer = 10; | |
2132 | 2263 pOutFile = File; |
0 | 2264 header1.version = 5; |
2265 header1.encoding = 1; | |
2266 header1.bpp = 8; | |
2267 header1.hdpi = 75; | |
2268 header1.vdpi = 75; | |
2269 header2.planes = 3; | |
2270 header2.palette_info = 1; | |
2132 | 2271 fwrite(&header1, 1, 1, File); |
2272 fwrite(&header1.version, 1, 1, pOutFile); | |
2273 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2274 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2275 fwrite(&header1.left, 2, 1, pOutFile); | |
2276 fwrite(&header1.up, 2, 1, pOutFile); | |
2277 fwrite(&header1.right, 2, 1, pOutFile); | |
2278 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2279 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2280 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2281 fwrite(color_map, 0x30u, 1, pOutFile); | |
2282 fwrite(&header2, 1, 1, pOutFile); | |
2283 fwrite(&header2.planes, 1, 1, pOutFile); | |
2284 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2285 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2286 fwrite(v15, 0x3Au, 1, pOutFile); | |
2287 lineRGB = (char *)malloc(3 * this->field_10 + 6); | |
2288 if ( this->field_14 > 0 ) | |
2289 { | |
2290 image_width = 3 * pitch; | |
2291 //v24 = 2 * v5; | |
2292 v8 = (unsigned short *)surface; | |
2293 for ( int y = 0; y < this->field_14; y++ ) | |
0 | 2294 { |
2132 | 2295 line_picture_data = v8; |
2296 if ( this->field_10 > 0 ) | |
0 | 2297 { |
2132 | 2298 lineG = (char *)lineRGB + pitch; |
2299 lineB = (char *)lineRGB + 2 * pitch; | |
2300 for ( uint x = 0; x < this->field_10; x++ ) | |
0 | 2301 { |
2132 | 2302 lineRGB[x] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2303 lineG[x] = (signed int)(g_mask & *line_picture_data) >> (num_b_bits + num_g_bits - 8); | |
2304 lineB[x] = (b_mask & *line_picture_data) << (8 - num_b_bits); | |
2305 line_picture_data += 2; | |
0 | 2306 } |
2307 } | |
2132 | 2308 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2309 { |
2132 | 2310 pict_byte = lineRGB[i]; |
2311 for ( test_byte = 1; test_byte < 0x3F; ++test_byte ) | |
0 | 2312 { |
2132 | 2313 v12 = i + test_byte; |
2314 if ( lineRGB[v12] != pict_byte ) | |
0 | 2315 break; |
2132 | 2316 if ( !(v12 % pitch) ) |
0 | 2317 break; |
2318 } | |
2132 | 2319 if ( i + test_byte > image_width ) |
2320 test_byte = 3 * pitch - i; | |
2321 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
2322 { | |
2323 v31 = test_byte | 0xC0; | |
2324 fwrite(&v31, 1, 1, pOutFile); | |
2325 } | |
2326 fwrite(&pict_byte, 1, 1, pOutFile); | |
0 | 2327 } |
2132 | 2328 v8 += v5; |
0 | 2329 } |
2330 } | |
2132 | 2331 if ( this->pRenderD3D ) |
0 | 2332 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2333 else | |
2334 pRenderer->EndScene(); | |
2132 | 2335 |
2336 free(lineRGB); | |
2337 fclose(pOutFile); | |
0 | 2338 } |
2339 } | |
2340 } | |
2341 // 4EFA80: using guessed type int dword_4EFA80; | |
2342 | |
2343 //----- (0049F1BC) -------------------------------------------------------- | |
2069 | 2344 void Render::SaveWinnersCertificate(const char *a1) |
0 | 2345 { |
2346 Render *v2; // esi@1 | |
2347 __int16 v3; // di@1 | |
2348 int v4; // eax@4 | |
2349 char *v5; // ecx@4 | |
2350 unsigned int v6; // eax@8 | |
2351 FILE *v7; // edi@10 | |
2352 int v8; // ecx@11 | |
2353 int v9; // eax@11 | |
2354 int v10; // eax@13 | |
2355 const char *v11; // ecx@15 | |
2356 unsigned __int8 v12; // dl@15 | |
2357 signed int v13; // eax@18 | |
2358 char v14; // zf@27 | |
2359 HRESULT v15; // eax@29 | |
2360 char v16; // [sp+Ch] [bp-12Ch]@10 | |
2361 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
2362 int Dst; // [sp+48h] [bp-F0h]@7 | |
2363 int v19; // [sp+58h] [bp-E0h]@8 | |
2364 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
2365 char v21; // [sp+C4h] [bp-74h]@10 | |
2366 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
2367 char *v23; // [sp+F8h] [bp-40h]@14 | |
2368 int v24; // [sp+FCh] [bp-3Ch]@11 | |
2369 int v25; // [sp+100h] [bp-38h]@4 | |
2370 FILE *File; // [sp+104h] [bp-34h]@3 | |
2371 char Str; // [sp+108h] [bp-30h]@10 | |
2372 char v28; // [sp+109h] [bp-2Fh]@10 | |
2373 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
2374 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
2375 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
2376 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
2377 __int16 v33; // [sp+110h] [bp-28h]@10 | |
2378 __int16 v34; // [sp+112h] [bp-26h]@10 | |
2379 __int16 v35; // [sp+114h] [bp-24h]@10 | |
2380 __int16 v36; // [sp+116h] [bp-22h]@10 | |
2381 char v37; // [sp+118h] [bp-20h]@10 | |
2382 char v38; // [sp+119h] [bp-1Fh]@10 | |
2383 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
2384 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
2385 void *ptr; // [sp+120h] [bp-18h]@10 | |
2386 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
2387 int v43; // [sp+128h] [bp-10h]@4 | |
2388 char v44; // [sp+12Fh] [bp-9h]@25 | |
2389 char *i; // [sp+130h] [bp-8h]@10 | |
2390 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
2391 | |
2392 v2 = this; | |
2393 v3 = 0; | |
2069 | 2394 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2395 { |
2396 ++dword_4EFA84; | |
2397 File = fopen(a1, "wb"); | |
2398 if ( File ) | |
2399 { | |
2400 v4 = v2->field_10; | |
2401 v5 = (char *)v2->field_14; | |
2402 v25 = v4; | |
2403 a1 = v5; | |
2404 v43 = v4; | |
2405 if ( v4 & 1 ) | |
2406 v43 = v4 + 1; | |
2407 if ( v2->pRenderD3D ) | |
2408 { | |
2409 memset(&Dst, 0, 0x7Cu); | |
2410 Dst = 124; | |
168 | 2411 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 2412 return; |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
2413 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
0 | 2414 v42 = v20; |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
2415 __debugbreak(); // warning C4700: uninitialized local variable 'v19' used |
0 | 2416 v6 = v19 >> 1; |
2417 v3 = 0; | |
2418 } | |
2419 else | |
2420 { | |
2421 pRenderer->BeginScene(); | |
2069 | 2422 //v42 = pRenderer->pTargetSurface; |
0 | 2423 v6 = pRenderer->uTargetSurfacePitch; |
2424 } | |
2425 i = (char *)v6; | |
2426 v33 = v25 - 1; | |
2427 v31 = v3; | |
2428 v34 = (short)a1 - 1; | |
2429 v32 = v3; | |
2430 v39 = v43; | |
2431 memset(&v21, 0, 0x30u); | |
2432 memset(&v16, 0, 0x38u); | |
2433 v37 = 0; | |
2434 Str = 10; | |
2435 v17 = 0; | |
2436 v7 = File; | |
2437 v28 = 5; | |
2438 v29 = 1; | |
2439 v30 = 8; | |
2440 v35 = 75; | |
2441 v36 = 75; | |
2442 v38 = 3; | |
2443 v40 = 1; | |
2444 fwrite(&Str, 1u, 1u, File); | |
2445 fwrite(&v28, 1u, 1u, v7); | |
2446 fwrite(&v29, 1u, 1u, v7); | |
2447 fwrite(&v30, 1u, 1u, v7); | |
2448 fwrite(&v31, 2u, 1u, v7); | |
2449 fwrite(&v32, 2u, 1u, v7); | |
2450 fwrite(&v33, 2u, 1u, v7); | |
2451 fwrite(&v34, 2u, 1u, v7); | |
2452 fwrite(&v35, 2u, 1u, v7); | |
2453 fwrite(&v36, 2u, 1u, v7); | |
2454 fwrite(&v21, 0x30u, 1u, v7); | |
2455 fwrite(&v37, 1u, 1u, v7); | |
2456 fwrite(&v38, 1u, 1u, v7); | |
2457 fwrite(&v39, 2u, 1u, v7); | |
2458 fwrite(&v40, 2u, 1u, v7); | |
2459 fwrite(&v16, 0x3Au, 1u, v7); | |
1583 | 2460 ptr = malloc(3 * v25 + 6); |
0 | 2461 if ( (signed int)a1 > 0 ) |
2462 { | |
2463 v8 = v43; | |
2464 File = (FILE *)a1; | |
2465 v24 = 3 * v43; | |
2466 v22 = 2 * (int)i; | |
2467 v9 = (int)v42; | |
2468 while ( 1 ) | |
2469 { | |
2470 a1 = (const char *)v9; | |
2471 v10 = 0; | |
2472 if ( v25 > 0 ) | |
2473 { | |
2474 i = (char *)ptr + v8; | |
2475 v23 = (char *)ptr + 2 * v43; | |
2476 do | |
2477 { | |
2478 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
2479 + LOBYTE(v2->uTargetBBits) | |
2480 + v2->uTargetRBits | |
2481 - 8); | |
2482 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
2483 + LOBYTE(v2->uTargetGBits) | |
2484 - 8); | |
2485 v11 = a1; | |
2486 v12 = LOBYTE(v2->uTargetBMask); | |
2487 a1 += 2; | |
2488 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
2489 } | |
2490 while ( v10 < v25 ); | |
2491 } | |
2492 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
2493 { | |
2494 BYTE3(a1) = 1; | |
2495 v46 = *((char *)ptr + (int)i); | |
2496 do | |
2497 { | |
2498 v13 = (signed int)&i[BYTE3(a1)]; | |
2499 if ( *((char *)ptr + v13) != v46 ) | |
2500 break; | |
2501 if ( !(v13 % v43) ) | |
2502 break; | |
2503 ++BYTE3(a1); | |
2504 } | |
2505 while ( BYTE3(a1) < 0x3Fu ); | |
2506 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
2507 BYTE3(a1) = 3 * v43 - (char)i; | |
2508 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
2509 { | |
2510 v44 = BYTE3(a1) | 0xC0; | |
2511 fwrite(&v44, 1u, 1u, v7); | |
2512 } | |
2513 fwrite(&v46, 1u, 1u, v7); | |
2514 } | |
2515 v9 = (int)&v42[v22 / 2]; | |
2516 v14 = File == (FILE *)1; | |
2517 File = (FILE *)((char *)File - 1); | |
2518 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
2519 if ( v14 ) | |
2520 break; | |
2521 v8 = v43; | |
2522 } | |
2523 } | |
2524 if ( v2->pRenderD3D ) | |
2525 { | |
2526 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
2527 } | |
2528 else | |
2529 { | |
2530 pRenderer->EndScene(); | |
2531 } | |
1583 | 2532 free(ptr); |
0 | 2533 fclose(v7); |
2534 } | |
2535 } | |
2536 } | |
2537 // 4EFA84: using guessed type int dword_4EFA84; | |
2538 | |
2539 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 2540 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
2127 | 2541 { |
0 | 2542 void *v8; // esi@3 |
2543 void *v9; // esi@3 | |
810 | 2544 unsigned short* v11; // eax@4 |
0 | 2545 int v13; // eax@8 |
2546 int v14; // ecx@8 | |
2547 signed int v15; // eax@11 | |
2548 char v16; // zf@20 | |
2549 int result; // eax@21 | |
2550 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
2551 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 2552 char *lineG; // [sp+78h] [bp-40h]@7 |
2553 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 2554 int v23; // [sp+80h] [bp-38h]@4 |
2555 int v24; // [sp+84h] [bp-34h]@4 | |
2556 int v25; // [sp+88h] [bp-30h]@4 | |
2557 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 2558 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
2559 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
2560 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
2561 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 2562 char v43; // [sp+B3h] [bp-5h]@18 |
2563 int i; // [sp+B4h] [bp-4h]@6 | |
2132 | 2564 unsigned short* line_picture_data; |
810 | 2565 byte test_byte; |
2566 unsigned char pict_byte; | |
0 | 2567 |
2131 | 2568 int num_r_bits = 5; |
2569 int num_g_bits = 6; | |
2570 int num_b_bits = 5; | |
2571 | |
2572 int r_mask = 0xF800; | |
2573 int g_mask = 0x7E0; | |
2574 int b_mask = 0x1F; | |
2575 | |
810 | 2576 pitch = wight; |
2577 if ( wight & 1 ) | |
2578 pitch = wight + 1; | |
2579 Src.left = 0; | |
2580 Src.up = 0; | |
2581 Src.right = wight - 1; | |
2582 Src.bottom = heidth - 1; | |
2583 v27.pitch = pitch; | |
0 | 2584 memset(&v20, 0, 0x30u); |
2585 memset(&v18, 0, 0x38u); | |
810 | 2586 v8 = data_buff; |
2587 v27.reserved = 0; | |
0 | 2588 *(_WORD *)&v18[56] = 0; |
810 | 2589 Src.manufacturer = 10; |
2590 Src.version = 5; | |
2591 Src.encoding = 1; | |
2592 Src.bpp = 8; | |
2593 Src.hdpi = 75; | |
2594 Src.vdpi = 75; | |
2595 v27.planes = 3; | |
2596 v27.palette_info = 1; | |
2128 | 2597 memcpy(data_buff, &Src, 1); |
0 | 2598 v8 = (char *)v8 + 1; |
2128 | 2599 memcpy(v8, &Src.version, 1); |
0 | 2600 v8 = (char *)v8 + 1; |
2128 | 2601 memcpy(v8, &Src.encoding, 1); |
0 | 2602 v8 = (char *)v8 + 1; |
2128 | 2603 memcpy(v8, &Src.bpp, 1); |
0 | 2604 v8 = (char *)v8 + 1; |
2128 | 2605 memcpy(v8, &Src.left, 2); |
0 | 2606 v8 = (char *)v8 + 2; |
2128 | 2607 memcpy(v8, &Src.up, 2); |
0 | 2608 v8 = (char *)v8 + 2; |
2128 | 2609 memcpy(v8, &Src.right, 2); |
0 | 2610 v8 = (char *)v8 + 2; |
2128 | 2611 memcpy(v8, &Src.bottom, 2); |
0 | 2612 v8 = (char *)v8 + 2; |
2127 | 2613 memcpy(v8, &Src.hdpi, 2); |
0 | 2614 v8 = (char *)v8 + 2; |
2127 | 2615 memcpy(v8, &Src.vdpi, 2); |
0 | 2616 v8 = (char *)v8 + 2; |
2617 memcpy(v8, &v20, 0x30u); | |
2618 v8 = (char *)v8 + 48; | |
810 | 2619 memcpy(v8, &v27, 1u); |
0 | 2620 v8 = (char *)v8 + 1; |
2127 | 2621 memcpy(v8, &v27.planes, 1); |
0 | 2622 v8 = (char *)v8 + 1; |
2127 | 2623 memcpy(v8, &v27.pitch, 2); |
0 | 2624 v8 = (char *)v8 + 2; |
2127 | 2625 memcpy(v8, &v27.palette_info, 2); |
0 | 2626 v8 = (char *)v8 + 2; |
2627 memcpy(v8, &v18, 0x3Au); | |
2628 v9 = (char *)v8 + 58; | |
810 | 2629 |
1583 | 2630 lineRGB = (char*)malloc(3 * (wight + 2)); |
810 | 2631 if ( heidth > 0 ) |
2632 { | |
2633 v26 = 3 * pitch; | |
2634 v23 = 2 * wight; | |
2635 v11 = picture_data; | |
2636 v24 = (int)picture_data; | |
2127 | 2637 for ( v25 = heidth; v25; v25-- ) |
0 | 2638 { |
2132 | 2639 line_picture_data = v11; |
810 | 2640 if ( wight > 0 ) |
2641 { | |
2642 lineG = (char *)lineRGB + pitch; | |
2643 lineB = (char *)lineRGB + 2 * pitch; | |
2127 | 2644 for ( uint i = 0; i < wight; i++ ) |
0 | 2645 { |
2132 | 2646 lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2647 lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8); | |
2648 lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits); | |
2649 line_picture_data += 1; | |
810 | 2650 } |
0 | 2651 } |
2652 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
2653 { | |
2128 | 2654 pict_byte = lineRGB[i]; |
2127 | 2655 for ( test_byte = 1; test_byte < 63; ++test_byte ) |
0 | 2656 { |
810 | 2657 v15 = i + test_byte; |
2128 | 2658 if ( lineRGB[v15] != pict_byte ) |
0 | 2659 break; |
810 | 2660 if ( !(v15 % pitch) ) |
0 | 2661 break; |
810 | 2662 } |
2663 if ( i + test_byte > v26 ) | |
2664 test_byte = 3 * pitch - i; | |
2127 | 2665 if ( test_byte > 1 || pict_byte >= 192 ) |
810 | 2666 { |
2667 v43 = test_byte | 0xC0; | |
2127 | 2668 memcpy(v9, &v43, 1); |
0 | 2669 v9 = (char *)v9 + 1; |
2670 } | |
2127 | 2671 memcpy(v9, &pict_byte, 1); |
810 | 2672 i += test_byte; |
2673 } | |
2128 | 2674 v11 += wight; |
810 | 2675 } |
2676 } | |
1583 | 2677 free(lineRGB); |
810 | 2678 *(int *)packed_size = (char *)v9 - data_buff; |
0 | 2679 } |
2680 | |
2681 //----- (0049F8B5) -------------------------------------------------------- | |
2128 | 2682 FILE *Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) |
0 | 2683 { |
2684 FILE *result; // eax@1 | |
2127 | 2685 FILE *pOutFile; // edi@4 |
2128 | 2686 unsigned short* v9; // eax@5 |
0 | 2687 int v10; // eax@7 |
2688 signed int v12; // eax@12 | |
2689 char v13; // zf@21 | |
2690 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
2691 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
2692 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
2693 int v18; // [sp+74h] [bp-30h]@5 | |
2694 char *v19; // [sp+78h] [bp-2Ch]@5 | |
2127 | 2695 int image_width; // [sp+7Ch] [bp-28h]@5 |
0 | 2696 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 |
2697 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
2128 | 2698 char *lineRGB; // [sp+98h] [bp-Ch]@4 |
2699 int pitch; // [sp+9Ch] [bp-8h]@2 | |
2700 char *lineB; // [sp+A0h] [bp-4h]@8 | |
2701 char *lineG; | |
2702 unsigned short* line_pictute_data; | |
2703 byte test_byte; | |
2704 char v43; | |
2127 | 2705 |
2706 int num_r_bits = 5; | |
2707 int num_g_bits = 6; | |
2708 int num_b_bits = 5; | |
2709 | |
2710 int r_mask = 0xF800; | |
2711 int g_mask = 0x7E0; | |
2712 int b_mask = 0x1F; | |
0 | 2713 |
2714 result = fopen(Filename, "wb"); | |
2715 Filename = (const char *)result; | |
2716 if ( result ) | |
2717 { | |
2128 | 2718 pitch = width; |
2127 | 2719 if ( width & 1 ) |
2128 | 2720 pitch = width + 1; |
0 | 2721 header1.left = 0; |
2722 header1.up = 0; | |
2127 | 2723 header1.right = width - 1; |
2724 header1.bottom = height - 1; | |
2128 | 2725 header2.pitch = pitch; |
0 | 2726 memset(color_map, 0, sizeof(color_map)); |
2727 header2.reserved = 0; | |
2728 memset(v14, 0, sizeof(v14)); | |
2729 v15 = 0; | |
2730 header1.manufacturer = 10; | |
2731 header1.version = 5; | |
2732 header1.encoding = 1; | |
2733 header1.bpp = 8; | |
2734 header1.hdpi = 75; | |
2735 header1.vdpi = 75; | |
2736 header2.planes = 3; | |
2737 header2.palette_info = 1; | |
2127 | 2738 fwrite(&header1, 1, 1, (FILE *)Filename); |
2739 pOutFile = (FILE *)Filename; | |
2740 fwrite(&header1.version, 1, 1, (FILE *)Filename); | |
2741 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2742 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2743 fwrite(&header1.left, 2, 1, pOutFile); | |
2744 fwrite(&header1.up, 2, 1, pOutFile); | |
2745 fwrite(&header1.right, 2, 1, pOutFile); | |
2746 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2747 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2748 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2749 fwrite(color_map, 0x30u, 1, pOutFile); | |
2750 fwrite(&header2, 1, 1, pOutFile); | |
2751 fwrite(&header2.planes, 1, 1, pOutFile); | |
2752 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2753 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2754 fwrite(v14, 0x3Au, 1, pOutFile); | |
2128 | 2755 |
2756 lineRGB = (char *)malloc(3 * (width + 2)); | |
2131 | 2757 //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя |
2758 //указывается цвет группы пикселей и их количество. | |
2128 | 2759 image_width = 3 * pitch; |
2760 v9 = picture_data; | |
2127 | 2761 for ( v18 = 0; v18 < height; v18++ )//столбец |
2762 { | |
2128 | 2763 line_pictute_data = v9; |
2764 lineG = (char *)lineRGB + pitch; | |
2765 lineB = (char *)lineRGB + 2 * pitch; | |
2766 | |
2767 for ( int i = 0; i < width; i++ )//строка | |
2768 { | |
2769 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); | |
2770 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); | |
2771 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); | |
2131 | 2772 line_pictute_data += 1; |
2128 | 2773 } |
2774 test_byte = 1; | |
2131 | 2775 for ( int i = 0; (signed int)i < image_width; i += test_byte ) |
2128 | 2776 { |
2777 unsigned char pic_byte = lineRGB[i]; | |
2778 for ( test_byte; test_byte < 63; ++test_byte )// расчёт количества одинаковых цветов | |
0 | 2779 { |
2128 | 2780 v12 = i + test_byte; |
2781 if ( lineRGB[v12] != pic_byte ) | |
2127 | 2782 break; |
2128 | 2783 if ( !(v12 % pitch) ) |
2127 | 2784 break; |
0 | 2785 } |
2128 | 2786 if ( i + test_byte > image_width ) |
2787 test_byte = 3 * pitch - i; | |
2788 if ( test_byte > 1 || pic_byte >= 0xC0 ) | |
0 | 2789 { |
2128 | 2790 v43 = test_byte | 0xC0;//тест-байт объединения |
2791 fwrite(&v43, 1, 1, pOutFile); | |
0 | 2792 } |
2128 | 2793 fwrite(&pic_byte, 1, 1, pOutFile); |
2794 } | |
2795 v9 += width; | |
2131 | 2796 } |
2128 | 2797 free(lineRGB); |
2127 | 2798 result = (FILE *)fclose(pOutFile); |
0 | 2799 } |
2800 return result; | |
2801 } | |
2802 | |
2803 //----- (0049FBCD) -------------------------------------------------------- | |
2804 void Render::ClearTarget(unsigned int uColor) | |
2805 { | |
2806 if (pRenderD3D) | |
2807 { | |
2069 | 2808 if (using_software_screen_buffer) |
0 | 2809 pRenderD3D->ClearTarget(true, uColor, false, 0.0); |
2810 } | |
2811 else | |
2812 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
2813 } | |
2814 | |
2815 //----- (0049FC23) -------------------------------------------------------- | |
2816 void Render::Release2() | |
2817 { | |
2818 Release(); | |
2819 bWindowMode = 1; | |
2820 } | |
2821 | |
2822 //----- (0049FC37) -------------------------------------------------------- | |
2823 void Render::Present() | |
2824 { | |
2825 Render *v1; // esi@1 | |
2826 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
2827 RECT a4; // [sp+18h] [bp-18h]@11 | |
2828 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
2829 | |
2830 v1 = this; | |
2069 | 2831 if ( !pRenderer->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2832 { |
2833 this->pBeforePresentFunction(); | |
2834 if ( v1->pRenderD3D ) | |
2835 { | |
2069 | 2836 if ( v1->using_software_screen_buffer ) |
0 | 2837 { |
2838 pRenderD3D->Present(false); | |
2839 } | |
2840 } | |
1802 | 2841 else __debugbreak(); // no sr |
2842 /*{ | |
0 | 2843 if ( v1->bWindowMode ) |
2844 { | |
2845 RestoreFrontBuffer(); | |
2846 GetClientRect(v1->hWnd, &Rect); | |
2847 Point.y = 0; | |
2848 Point.x = 0; | |
2849 ClientToScreen(v1->hWnd, &Point); | |
2850 OffsetRect(&Rect, Point.x, Point.y); | |
2851 a4.top = 0; | |
2852 a4.bottom = 480; | |
2853 a4.left = 0; | |
2854 a4.right = 640; | |
2855 PresentRect(&Rect, &a4); | |
2856 } | |
2857 else | |
2858 { | |
2859 RestoreFrontBuffer(); | |
2860 a4.top = 0; | |
2861 a4.bottom = 480; | |
2862 a4.left = 0; | |
2863 a4.right = 640; | |
2864 BltBackToFontFast(0, 0, &a4); | |
2865 } | |
1802 | 2866 }*/ |
0 | 2867 } |
2868 } | |
2869 | |
2870 //----- (0049FD3A) -------------------------------------------------------- | |
2871 void Render::_49FD3A() | |
2872 { | |
2873 Render *v2; // esi@1 | |
2874 IDirectDrawSurface4 *v3; // eax@6 | |
2875 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
2876 RECT v5; // [sp+8h] [bp-10h]@6 | |
2877 | |
1980 | 2878 Render* a1 = this; |
0 | 2879 v2 = a1; |
2880 if ( a1->pRenderD3D ) | |
2881 { | |
2882 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
2883 pFrontBuffer4->Restore(); | |
2884 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
2885 pBackBuffer4->Restore(); | |
2886 v3 = v2->pBackBuffer4; | |
2887 v4 = v2->pFrontBuffer4; | |
2888 v5.top = 0; | |
2889 v5.bottom = 480; | |
2890 v5.left = 0; | |
2891 v5.right = 640; | |
2892 v3->BltFast(0, 0, v4, &v5, 16u); | |
2893 } | |
2894 } | |
2895 | |
2896 //----- (0049FDBF) -------------------------------------------------------- | |
2897 void Render::CreateZBuffer() | |
2898 { | |
2899 if (!pDefaultZBuffer) | |
2900 { | |
2901 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
1583 | 2902 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); |
871 | 2903 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 2904 } |
2905 } | |
2906 | |
2907 //----- (0049FE05) -------------------------------------------------------- | |
2908 void Render::Release() | |
2909 { | |
2910 Render *v1; // esi@1 | |
1802 | 2911 //RenderD3D *v2; // ecx@1 |
2912 //char v3; // zf@4 | |
2913 //void *v4; // ebx@6 | |
0 | 2914 IDirectDraw *v5; // eax@10 |
2915 IDirectDrawSurface2 *v6; // eax@11 | |
2916 IDirectDrawSurface2 *v7; // eax@13 | |
2917 IDirectDrawSurface2 *v8; // eax@15 | |
2918 IDirectDraw2 *v9; // eax@17 | |
2919 IDirectDraw4 *v10; // eax@19 | |
2920 IDirectDrawSurface4 *v11; // eax@20 | |
2921 IDirectDrawSurface4 *v12; // eax@22 | |
2922 IDirectDrawSurface4 *v13; // eax@24 | |
2923 IDirectDraw4 *v14; // eax@26 | |
2924 unsigned __int16 **v15; // ebx@28 | |
2925 void **v16; // esi@29 | |
2926 | |
2927 v1 = this; | |
1802 | 2928 if (pRenderD3D) |
0 | 2929 { |
2069 | 2930 if ( v1->using_software_screen_buffer ) |
0 | 2931 { |
1802 | 2932 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2933 pRenderD3D->Present(0); |
1802 | 2934 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2935 } |
2936 v1->pColorKeySurface4 = 0; | |
2937 v1->pBackBuffer4 = 0; | |
2938 v1->pFrontBuffer4 = 0; | |
2939 v1->pDirectDraw4 = 0; | |
1802 | 2940 if (v1->pTargetSurface) |
0 | 2941 { |
2069 | 2942 delete [] v1->pTargetSurface_unaligned; |
0 | 2943 v1->pTargetSurface = 0; |
2069 | 2944 v1->pTargetSurface_unaligned = 0; |
0 | 2945 } |
1802 | 2946 if (pRenderD3D) |
0 | 2947 { |
2948 pRenderD3D->Release(); | |
1802 | 2949 delete pRenderD3D; |
2950 } | |
2951 pRenderD3D = 0; | |
0 | 2952 } |
2953 else | |
1802 | 2954 ;//__debugbreak(); // no sr |
2955 /*{ | |
0 | 2956 if ( bWinNT4_0 == 1 ) |
2957 { | |
2958 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
2959 if ( !v5 ) | |
2960 return; | |
2961 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
2962 v1->pDirectDraw2->FlipToGDISurface(); | |
2963 v6 = v1->pSomeSurface2; | |
2964 if ( v6 ) | |
2965 { | |
2966 v6->Release(); | |
2967 v1->pSomeSurface2 = 0; | |
2968 } | |
2969 v7 = v1->pBackBuffer2; | |
2970 if ( v7 ) | |
2971 { | |
2972 v7->Release(); | |
2973 v1->pBackBuffer2 = 0; | |
2974 } | |
2975 v8 = v1->pFrontBuffer2; | |
2976 if ( v8 ) | |
2977 { | |
2978 v8->Release(); | |
2979 v1->pFrontBuffer2 = 0; | |
2980 } | |
2981 v9 = v1->pDirectDraw2; | |
2982 if ( v9 ) | |
2983 { | |
2984 v9->Release(); | |
2985 v1->pDirectDraw2 = 0; | |
2986 } | |
2987 } | |
2988 else | |
2989 { | |
2990 v10 = v1->pDirectDraw4; | |
2991 if ( !v10 ) | |
2992 return; | |
2993 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
2994 v1->pDirectDraw4->FlipToGDISurface(); | |
2995 v11 = v1->pColorKeySurface4; | |
2996 if ( v11 ) | |
2997 { | |
2998 v11->Release(); | |
2999 v1->pColorKeySurface4 = 0; | |
3000 } | |
3001 v12 = v1->pBackBuffer4; | |
3002 if ( v12 ) | |
3003 { | |
3004 v12->Release(); | |
3005 v1->pBackBuffer4 = 0; | |
3006 } | |
3007 v13 = v1->pFrontBuffer4; | |
3008 if ( v13 ) | |
3009 { | |
3010 v13->Release(); | |
3011 v1->pFrontBuffer4 = 0; | |
3012 } | |
3013 v14 = v1->pDirectDraw4; | |
3014 if ( v14 ) | |
3015 { | |
3016 v14->Release(); | |
3017 v1->pDirectDraw4 = 0; | |
3018 } | |
3019 } | |
3020 v15 = &v1->pTargetSurface; | |
3021 if ( v1->pTargetSurface ) | |
3022 { | |
3023 v16 = (void **)&v1->ptr_400E8; | |
3024 free(*v16); | |
3025 *v15 = 0; | |
3026 *v16 = 0; | |
3027 } | |
1802 | 3028 }*/ |
0 | 3029 } |
3030 | |
3031 //----- (0049FFD7) -------------------------------------------------------- | |
3032 void Render::CreateSomeTexture() | |
3033 { | |
3034 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
3035 } | |
3036 | |
3037 //----- (0049FFFB) -------------------------------------------------------- | |
1802 | 3038 bool Render::InitializeFullscreen() |
0 | 3039 { |
3040 //Render *v2; // esi@1 | |
3041 //HWND v3; // ebx@1 | |
3042 //void *v4; // eax@2 | |
3043 //RenderD3D *v5; // eax@3 | |
3044 unsigned int v6; // edx@5 | |
3045 RenderD3D__DevInfo *v7; // ecx@5 | |
3046 bool v8; // eax@6 | |
3047 RenderD3D *v9; // ecx@13 | |
3048 unsigned int v10; // eax@13 | |
3049 RenderD3D *v11; // eax@25 | |
3050 HRESULT v12; // eax@25 | |
3051 int v13; // ecx@25 | |
3052 int v14; // eax@27 | |
3053 signed int v15; // ebx@31 | |
2069 | 3054 //bool v16; // eax@35 |
3055 //char v17; // zf@35 | |
0 | 3056 IDirectDraw4 *v18; // eax@38 |
3057 HRESULT v19; // eax@38 | |
2069 | 3058 //int *v20; // eax@39 |
0 | 3059 int *v22; // eax@42 |
3060 int v23; // ecx@42 | |
3061 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3062 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3063 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
3064 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
3065 void *v28; // [sp+2FCh] [bp-10h]@2 | |
3066 int v29; // [sp+308h] [bp-4h]@2 | |
3067 | |
2069 | 3068 __debugbreak(); // Nomad |
3069 | |
0 | 3070 //v2 = this; |
2069 | 3071 this->using_software_screen_buffer = 0; |
0 | 3072 this->pColorKeySurface4 = 0; |
3073 this->pBackBuffer4 = 0; | |
3074 this->pFrontBuffer4 = 0; | |
3075 this->pDirectDraw4 = 0; | |
2069 | 3076 //this->bColorKeySupported = 0; |
0 | 3077 Release(); |
3078 //v3 = hWnd; | |
1802 | 3079 this->window = window; |
0 | 3080 CreateZBuffer(); |
1802 | 3081 |
3082 /*if (!bUserDirect3D) | |
3083 { | |
3084 CreateDirectDraw(); | |
3085 SetDirectDrawCooperationMode(hWnd, 1); | |
3086 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3087 CreateDirectDrawPrimarySurface(); | |
3088 v15 = 1; | |
3089 } | |
3090 else | |
3091 {*/ | |
0 | 3092 pRenderD3D = new RenderD3D; |
3093 v28 = pRenderD3D; | |
3094 v6 = uDesiredDirect3DDevice; | |
3095 v29 = -1; | |
3096 v7 = pRenderD3D->pAvailableDevices; | |
3097 if ( v7[v6].bIsDeviceCompatible ) | |
3098 { | |
2069 | 3099 v8 = pRenderD3D->CreateDevice(v6, /*0*/true, window); |
0 | 3100 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; |
3101 } | |
3102 else | |
3103 { | |
3104 if ( v7[1].bIsDeviceCompatible ) | |
3105 { | |
2069 | 3106 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window); |
0 | 3107 uAcquiredDirect3DDevice = 1; |
3108 } | |
3109 else | |
3110 { | |
3111 if ( !v7->bIsDeviceCompatible ) | |
1545 | 3112 Error("There aren't any D3D devices to create."); |
3113 | |
2069 | 3114 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window); |
1985 | 3115 uAcquiredDirect3DDevice = 1; |
0 | 3116 } |
3117 } | |
3118 if ( !v8 ) | |
1545 | 3119 Error("D3Drend->Init failed."); |
3120 | |
0 | 3121 v9 = pRenderD3D; |
3122 pBackBuffer4 = v9->pBackBuffer; | |
3123 pFrontBuffer4 = v9->pFrontBuffer; | |
3124 pDirectDraw4 = v9->pHost; | |
3125 v10 = pRenderD3D->GetDeviceCaps(); | |
3126 if ( v10 & 1 ) | |
3127 { | |
3128 if ( pRenderD3D ) | |
3129 { | |
3130 pRenderD3D->Release(); | |
3131 delete pRenderD3D; | |
3132 } | |
3133 pRenderD3D = 0; | |
3134 pBackBuffer4 = 0; | |
3135 pFrontBuffer4 = 0; | |
3136 pDirectDraw4 = 0; | |
1545 | 3137 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3138 } |
3139 if ( v10 & 0x3E ) | |
3140 { | |
3141 if ( pRenderD3D ) | |
3142 { | |
3143 pRenderD3D->Release(); | |
3144 delete pRenderD3D; | |
3145 } | |
3146 pColorKeySurface4 = 0; | |
3147 pRenderD3D = 0; | |
3148 pBackBuffer4 = 0; | |
3149 pFrontBuffer4 = 0; | |
3150 pDirectDraw4 = 0; | |
1545 | 3151 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3152 } |
3153 if ( (v10 & 0x80u) != 0 ) | |
3154 { | |
3155 if ( pRenderD3D ) | |
3156 { | |
3157 pRenderD3D->Release(); | |
3158 delete pRenderD3D; | |
3159 } | |
3160 pRenderD3D = 0; | |
3161 pBackBuffer4 = 0; | |
3162 pFrontBuffer4 = 0; | |
3163 pDirectDraw4 = 0; | |
1545 | 3164 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3165 } |
3166 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
3167 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
3168 memset(&halCaps, 0, 0xFCu); | |
3169 halCaps.dwSize = 252; | |
3170 memset(&refCaps, 0, 0xFCu); | |
3171 v11 = pRenderD3D; | |
3172 refCaps.dwSize = 252; | |
3173 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
3174 v13 = halCaps.dwMinTextureWidth; | |
3175 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3176 v13 = halCaps.dwMinTextureHeight; | |
3177 v14 = halCaps.dwMaxTextureWidth; | |
3178 uMinDeviceTextureDim = v13; | |
3179 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
3180 v14 = halCaps.dwMaxTextureHeight; | |
3181 uMaxDeviceTextureDim = v14; | |
3182 if ( (unsigned int)v13 < 4 ) | |
3183 uMinDeviceTextureDim = 4; | |
3184 CreateSomeTexture(); | |
3185 v15 = 1; | |
3186 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3187 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
3188 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3189 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
3190 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3191 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
3192 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3193 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3194 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3195 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3196 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3197 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3198 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3199 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3200 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3201 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
1802 | 3202 //} |
2069 | 3203 ddpfPrimarySuface.dwSize = 32; |
3204 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3205 ParseTargetPixelFormat(); |
2069 | 3206 |
3207 if (!pRenderD3D) | |
3208 { | |
3209 __debugbreak(); | |
3210 pBeforePresentFunction = 0;//nullsub_1; | |
3211 } | |
3212 //else | |
3213 //{ | |
3214 /*v16 = IsColorKeySupported(pDirectDraw4); | |
0 | 3215 v17 = uAcquiredDirect3DDevice == v15; |
3216 bColorKeySupported = v16; | |
3217 if ( !v17 ) | |
3218 bColorKeySupported = 0; | |
3219 if ( bColorKeySupported ) | |
3220 { | |
3221 memset(&ddsd2, 0, 0x7Cu); | |
3222 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3223 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3224 v18 = pDirectDraw4; | |
3225 ddsd2.dwSize = 124; | |
3226 ddsd2.dwFlags = 65543; | |
3227 ddsd2.ddsCaps.dwCaps = 2112; | |
3228 ddsd2.dwWidth = 640; | |
3229 ddsd2.dwHeight = 480; | |
3230 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3231 pBeforePresentFunction = Present_ColorKey; | |
3232 } | |
2069 | 3233 else*/ |
0 | 3234 { |
3235 pTargetSurface = 0; | |
2069 | 3236 pTargetSurface_unaligned = 0; |
3237 pTargetSurface_unaligned = (unsigned int *)malloc(640 * 480 * 2 + 32); | |
3238 if ( !pTargetSurface_unaligned | |
0 | 3239 || (memset(&pDesc, 0, 0x7Cu), |
3240 pDesc.dwSize = 124, | |
3241 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
3242 return 0; | |
3243 pBackBuffer4->Unlock(0); | |
2069 | 3244 v22 = (int *)pTargetSurface_unaligned + 4; |
0 | 3245 v23 = (unsigned int)pDesc.lpSurface & 7; |
3246 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
3247 uTargetSurfacePitch = 640; | |
3248 pBeforePresentFunction = Present_NoColorKey; | |
3249 v15 = 1; | |
2069 | 3250 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23); |
3251 } | |
3252 using_software_screen_buffer = v15; | |
3253 //} | |
0 | 3254 bWindowMode = 0; |
3255 pParty->uFlags |= 2u; | |
2069 | 3256 flt_6BE3A0 = 0.55000001f; |
0 | 3257 pViewport->_4C02F8(36044); |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
3258 return v15 != 0; |
0 | 3259 } |
3260 | |
3261 //----- (004A05F3) -------------------------------------------------------- | |
1802 | 3262 bool Render::SwitchToWindow() |
0 | 3263 { |
3264 //Render *v2; // esi@1 | |
3265 //void *v3; // eax@2 | |
3266 //RenderD3D *v4; // eax@3 | |
3267 //unsigned int v5; // edx@5 | |
3268 //RenderD3D__DevInfo *v6; // ecx@5 | |
3269 bool v7; // eax@7 | |
3270 //RenderD3D *v8; // ecx@12 | |
3271 unsigned int v9; // eax@12 | |
3272 RenderD3D *v10; // eax@24 | |
3273 HRESULT v11; // eax@24 | |
3274 int v12; // eax@24 | |
3275 int v13; // eax@26 | |
2069 | 3276 //bool v14; // eax@32 |
3277 //char v15; // zf@32 | |
0 | 3278 IDirectDraw4 *v16; // eax@35 |
3279 HRESULT v17; // eax@35 | |
2069 | 3280 //int *v18; // eax@36 |
0 | 3281 int *v19; // edx@38 |
3282 int v20; // eax@38 | |
3283 unsigned int v21; // ecx@38 | |
3284 int v22; // eax@41 | |
3285 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
3286 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3287 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
3288 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
3289 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
3290 int v29; // [sp+308h] [bp-4h]@2 | |
3291 | |
2069 | 3292 pParty->uFlags |= PARTY_FLAGS_1_0002; |
0 | 3293 //v2 = this; |
3294 flt_6BE3A0 = 0.55000001f; | |
3295 pViewport->_4C02F8(36044); | |
2069 | 3296 using_software_screen_buffer = 0; |
0 | 3297 Release(); |
3298 pColorKeySurface4 = 0; | |
3299 pBackBuffer4 = 0; | |
3300 pFrontBuffer4 = 0; | |
3301 pDirectDraw4 = 0; | |
2069 | 3302 //bColorKeySupported = 0; |
0 | 3303 CreateZBuffer(); |
1802 | 3304 /*if (!bUserDirect3D) |
3305 { | |
3306 CreateDirectDraw(); | |
3307 SetDirectDrawCooperationMode(hWnd, 0); | |
3308 field_4004C = 1; | |
3309 CreateFrontBuffer(); | |
3310 CreateClipper(hWnd); | |
3311 CreateBackBuffer(); | |
3312 field_40030 = 0; | |
3313 field_18_locked_pitch = 0; | |
3314 } | |
3315 else | |
3316 {*/ | |
1631 | 3317 /*v3 = malloc(0x148u); |
0 | 3318 thisa = (RenderD3D *)v3; |
3319 v29 = 0; | |
3320 if ( v3 ) | |
3321 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3322 else | |
3323 v4 = 0;*/ | |
3324 pRenderD3D = new RenderD3D; | |
3325 //v4 = pRenderD3D; | |
3326 //v5 = uDesiredDirect3DDevice; | |
3327 v29 = -1; | |
3328 //v6 = pRenderD3D->pAvailableDevices; | |
3329 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
3330 uDesiredDirect3DDevice != 1 ) | |
3331 { | |
2069 | 3332 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window); |
0 | 3333 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; |
3334 } | |
3335 else | |
3336 { | |
3337 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
1545 | 3338 Error("There aren't any D3D devices to init."); |
3339 | |
2069 | 3340 v7 = pRenderD3D->CreateDevice(0, true, window); |
0 | 3341 uAcquiredDirect3DDevice = 0; |
3342 } | |
3343 if ( !v7 ) | |
1545 | 3344 Error("D3Drend->Init failed."); |
0 | 3345 |
3346 //v8 = pRenderD3D; | |
3347 pColorKeySurface4 = 0; | |
3348 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
3349 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3350 pDirectDraw4 = pRenderD3D->pHost; | |
3351 v9 = pRenderD3D->GetDeviceCaps(); | |
3352 if ( v9 & 1 ) | |
3353 { | |
3354 if (pRenderD3D) | |
3355 { | |
3356 pRenderD3D->Release(); | |
3357 delete pRenderD3D; | |
3358 } | |
3359 pRenderD3D = 0; | |
3360 pBackBuffer4 = 0; | |
3361 pFrontBuffer4 = 0; | |
3362 pDirectDraw4 = 0; | |
1545 | 3363 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3364 } |
3365 if ( v9 & 0x3E ) | |
3366 { | |
3367 if (pRenderD3D) | |
3368 { | |
3369 pRenderD3D->Release(); | |
3370 delete pRenderD3D; | |
3371 } | |
3372 pColorKeySurface4 = 0; | |
3373 pRenderD3D = 0; | |
3374 pBackBuffer4 = 0; | |
3375 pFrontBuffer4 = 0; | |
3376 pDirectDraw4 = 0; | |
1545 | 3377 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3378 } |
3379 if ( (v9 & 0x80u) != 0 ) | |
3380 { | |
3381 if (pRenderD3D) | |
3382 { | |
3383 pRenderD3D->Release(); | |
3384 delete pRenderD3D; | |
3385 } | |
3386 pRenderD3D = 0; | |
3387 pBackBuffer4 = 0; | |
3388 pFrontBuffer4 = 0; | |
3389 pDirectDraw4 = 0; | |
1545 | 3390 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3391 } |
3392 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
3393 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
3394 memset(&halCaps, 0, 0xFCu); | |
3395 halCaps.dwSize = 252; | |
3396 memset(&refCaps, 0, 0xFCu); | |
3397 //v10 = v2->pRenderD3D; | |
3398 refCaps.dwSize = 252; | |
3399 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3400 v12 = halCaps.dwMinTextureWidth; | |
2069 | 3401 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight ) |
0 | 3402 v12 = halCaps.dwMinTextureHeight; |
3403 uMinDeviceTextureDim = v12; | |
3404 v13 = halCaps.dwMaxTextureWidth; | |
3405 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3406 v13 = halCaps.dwMaxTextureHeight; | |
3407 uMaxDeviceTextureDim = v13; | |
3408 CreateSomeTexture(); | |
3409 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
3410 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
3411 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3412 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
3413 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
3414 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3415 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3416 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3417 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3418 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3419 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3420 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3421 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3422 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3423 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
1802 | 3424 //} |
3425 | |
2069 | 3426 ddpfPrimarySuface.dwSize = 32; |
3427 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3428 ParseTargetPixelFormat(); |
2069 | 3429 |
0 | 3430 if ( !pRenderD3D ) |
3431 { | |
2069 | 3432 __debugbreak(); |
3433 //pBeforePresentFunction = 0;//nullsub_1; | |
3434 //goto LABEL_47; | |
3435 } | |
3436 /*v14 = IsColorKeySupported(pDirectDraw4); | |
0 | 3437 v15 = uAcquiredDirect3DDevice == 1; |
3438 bColorKeySupported = v14; | |
3439 if ( !v15 ) | |
2069 | 3440 bColorKeySupported = 0;*/ |
3441 //if ( bColorKeySupported ) | |
3442 if (false) | |
3443 { | |
3444 /*memset(&ddsd2, 0, 0x7Cu); | |
0 | 3445 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; |
3446 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3447 v16 = pDirectDraw4; | |
3448 ddsd2.dwSize = 124; | |
3449 ddsd2.dwFlags = 65543; | |
3450 ddsd2.ddsCaps.dwCaps = 2112; | |
3451 ddsd2.dwWidth = 640; | |
3452 ddsd2.dwHeight = 480; | |
3453 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
2069 | 3454 pBeforePresentFunction = Present_ColorKey;*/ |
0 | 3455 LABEL_45: |
2069 | 3456 using_software_screen_buffer = 1; |
3457 //LABEL_47: | |
0 | 3458 bWindowMode = 1; |
1802 | 3459 //hWnd = hWnd; |
0 | 3460 return 0; |
3461 } | |
3462 pTargetSurface = 0; | |
2069 | 3463 pTargetSurface_unaligned = 0; |
3464 | |
3465 uint num_pixels = window->GetWidth() * window->GetHeight(); | |
3466 pTargetSurface_unaligned = new unsigned int[num_pixels]; | |
3467 | |
3468 if (!pTargetSurface_unaligned) | |
3469 return false; | |
3470 | |
3471 memset(&pDesc, 0, 0x7Cu); | |
3472 pDesc.dwSize = 124; | |
3473 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT)) | |
3474 { | |
3475 delete [] pTargetSurface_unaligned; | |
3476 return false; | |
3477 } | |
3478 | |
3479 memset32(pTargetSurface_unaligned, -1, num_pixels); | |
3480 | |
3481 | |
0 | 3482 pRenderer->pBackBuffer4->Unlock(0); |
2069 | 3483 /*v19 = pTargetSurface_unaligned; |
0 | 3484 v20 = (unsigned int)pDesc.lpSurface & 7; |
3485 v21 = (unsigned int)ptr_400E8 & 7; | |
3486 if ( v21 == v20 ) | |
3487 { | |
3488 pTargetSurface = (unsigned __int16 *)v19; | |
3489 } | |
3490 else | |
3491 { | |
3492 if ( (signed int)v21 >= v20 ) | |
3493 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
3494 else | |
3495 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
3496 pTargetSurface = (unsigned __int16 *)v22; | |
2069 | 3497 }*/ |
3498 pTargetSurface = pTargetSurface_unaligned; | |
3499 uTargetSurfacePitch = window->GetWidth(); | |
0 | 3500 pBeforePresentFunction = Present_NoColorKey; |
3501 goto LABEL_45; | |
3502 } | |
3503 | |
3504 //----- (004A0BEE) -------------------------------------------------------- | |
2102 | 3505 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) |
3506 { | |
2101 | 3507 signed int v12; // eax@17 |
2102 | 3508 //signed int v19; // qax@41 |
3509 //int v20; // edi@41 | |
0 | 3510 unsigned int v21; // edi@46 |
3511 int v22; // esi@47 | |
3512 int v23; // ebx@47 | |
3513 signed int v24; // edx@50 | |
3514 signed int v25; // esi@52 | |
3515 unsigned __int16 *v26; // ecx@52 | |
3516 int v27; // ebx@54 | |
3517 int v28; // edi@55 | |
3518 int v29; // edx@55 | |
3519 int v30; // ebx@60 | |
3520 int v31; // edx@61 | |
3521 int v32; // edi@61 | |
3522 __int64 v36; // [sp+14h] [bp-8h]@1 | |
3523 signed int v37; // [sp+18h] [bp-4h]@28 | |
3524 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
2102 | 3525 //unsigned int uYa; // [sp+28h] [bp+Ch]@28 |
0 | 3526 int uYb; // [sp+28h] [bp+Ch]@47 |
2102 | 3527 //int uZa; // [sp+2Ch] [bp+10h]@38 |
3528 bool left_border; | |
0 | 3529 |
3530 v36 = 0i64; | |
2101 | 3531 if ( uX < this->raster_clip_x )// x выходит за рамки левой границы |
2102 | 3532 HIDWORD(v36) = 8; //left_border = true; |
2101 | 3533 if ( uX > this->raster_clip_z )// x выходит за рамки правой границы |
2102 | 3534 HIDWORD(v36) |= 4;//right_border = true; |
2097 | 3535 |
2101 | 3536 if ( uZ < this->raster_clip_x )// z выходит за рамки левой границы |
2102 | 3537 LODWORD(v36) = 8;// |
2101 | 3538 if ( uZ > this->raster_clip_z )// z выходит за рамки правой границы |
3539 LODWORD(v36) |= 4; | |
3540 | |
3541 if ( uY < this->raster_clip_y )// y выходит за рамки верхней границы | |
2102 | 3542 HIDWORD(v36) |= 2;//upper_border = true; |
2101 | 3543 if ( uY > this->raster_clip_w )// y выходит за рамки нижней границы |
2102 | 3544 HIDWORD(v36) |= 1;//bottom_border = true; |
2101 | 3545 |
3546 if ( uW < this->raster_clip_y )// w выходит за рамки верхней границы | |
3547 LODWORD(v36) |= 2; | |
3548 if ( uW > this->raster_clip_w )// w выходит за рамки нижней границы | |
3549 LODWORD(v36) |= 1; | |
3550 | |
2102 | 3551 //LOBYTE(v12) = v36; |
0 | 3552 if ( (unsigned int)v36 & HIDWORD(v36) ) |
2102 | 3553 return; |
3554 | |
3555 if ( !v36 ) //полностью в рамках | |
0 | 3556 { |
3557 LABEL_46: | |
3558 v21 = pRenderer->uTargetSurfacePitch; | |
3559 if ( pRenderer->uTargetSurfacePitch ) | |
3560 { | |
2096 | 3561 v12 = uX + uY * pRenderer->uTargetSurfacePitch; |
2102 | 3562 v22 = uW - uY; |
0 | 3563 v23 = v22; |
3564 uYb = v22; | |
3565 if ( v22 < 0 ) | |
3566 { | |
3567 v23 = -v22; | |
3568 uYb = -v22; | |
3569 v21 = -pRenderer->uTargetSurfacePitch; | |
3570 } | |
2102 | 3571 uXa = uZ - uX; |
0 | 3572 if ( (uXa & 0x80000000u) == 0 ) |
3573 { | |
3574 v24 = 1; | |
3575 } | |
3576 else | |
3577 { | |
3578 uXa = -uXa; | |
3579 v24 = -1; | |
3580 } | |
3581 v25 = 0; | |
2069 | 3582 |
2093 | 3583 v26 = (unsigned __int16 *)this->pTargetSurface; |
0 | 3584 if ( v26 ) |
3585 { | |
2093 | 3586 if ( (signed int)uXa <= v23 )//рисуем вертикальную линию |
0 | 3587 { |
3588 v30 = v23 + 1; | |
3589 if ( v30 > 0 ) | |
3590 { | |
3591 v31 = 2 * v24; | |
3592 v32 = 2 * v21; | |
3593 v12 = (int)&v26[v12]; | |
2101 | 3594 int y = 0; |
3595 int x = 0; | |
2093 | 3596 for ( v30; v30; --v30 ) |
0 | 3597 { |
3598 v25 += uXa; | |
2096 | 3599 //*(short *)v12 = uColor; |
3600 //v12 += v32; | |
2097 | 3601 WritePixel16(uX + x, uY + y, uColor); |
2096 | 3602 if ( v32 >= 0 ) |
3603 y += 1; | |
3604 else | |
3605 y -= 1; | |
0 | 3606 if ( v25 > 0 ) |
3607 { | |
3608 v25 -= uYb; | |
2097 | 3609 //v12 += v31; |
3610 if ( v31 >= 0 ) | |
3611 x += 1; | |
3612 else | |
3613 x -= 1; | |
0 | 3614 } |
3615 } | |
3616 } | |
3617 } | |
2093 | 3618 else//рисуем горизонтальную линию |
0 | 3619 { |
3620 v27 = uXa + 1; | |
3621 if ( (signed int)(uXa + 1) > 0 ) | |
3622 { | |
3623 v28 = 2 * v21; | |
3624 v29 = 2 * v24; | |
2101 | 3625 int y = 0; |
3626 int x = 0; | |
0 | 3627 v12 = (int)&v26[v12]; |
2093 | 3628 for ( v27; v27; --v27 ) |
0 | 3629 { |
3630 v25 += uYb; | |
2096 | 3631 //*(short *)v12 = uColor; |
3632 //v12 += v29; | |
2097 | 3633 WritePixel16(uX + x, uY + y, uColor); |
2096 | 3634 if ( v29 >= 0 ) |
3635 x += 1; | |
3636 else | |
3637 x -= 1; | |
0 | 3638 if ( v25 > (signed int)uXa ) |
3639 { | |
3640 v25 -= uXa; | |
2097 | 3641 //v12 += v28; |
3642 if ( v28 >= 0 ) | |
3643 y += 1; | |
3644 else | |
3645 y -= 1; | |
0 | 3646 } |
3647 } | |
3648 } | |
3649 } | |
3650 } | |
3651 } | |
2102 | 3652 return; |
3653 } | |
3654 | |
3655 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//левая и | |
3656 { | |
3657 if ( BYTE4(v36) & 8 )//left_border = true; | |
3658 { | |
3659 uY += ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX); | |
2093 | 3660 uX = this->raster_clip_x; |
2102 | 3661 } |
3662 else | |
3663 { | |
3664 uZ = this->raster_clip_x; | |
3665 uW += ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ); | |
3666 } | |
3667 } | |
0 | 3668 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) |
3669 { | |
2102 | 3670 if ( BYTE4(v36) & 4 ) //right_border = true |
3671 { | |
3672 uY += ((uW - uY) * (this->raster_clip_z - uX)) / (uZ - uX); | |
2093 | 3673 uX = this->raster_clip_z; |
0 | 3674 } |
3675 else | |
3676 { | |
2102 | 3677 uW += ((uY - uW) * (this->raster_clip_z - uZ)) / (uX - uZ); |
3678 uY = this->raster_clip_z; | |
0 | 3679 } |
3680 } | |
3681 v37 = 0; | |
2102 | 3682 if ( uY < this->raster_clip_y ) |
0 | 3683 v37 = 2; |
2102 | 3684 if ( uY > this->raster_clip_w ) |
2093 | 3685 v37 |= 1; |
2101 | 3686 |
2102 | 3687 if ( uW >= this->raster_clip_y ) |
0 | 3688 v12 = 0; |
3689 else | |
3690 v12 = 2; | |
2102 | 3691 if ( uW > this->raster_clip_w ) |
3692 v12 |= 1; | |
2101 | 3693 |
0 | 3694 if ( !(v12 & v37) ) |
3695 { | |
3696 v12 ^= v37; | |
3697 if ( v12 & 2 ) | |
3698 { | |
3699 if ( v37 & 2 ) | |
3700 { | |
2102 | 3701 uX += ((uZ - uX) * (this->raster_clip_y - uY)) / (uW - uY); |
3702 uY = this->raster_clip_y; | |
0 | 3703 } |
3704 else | |
3705 { | |
2102 | 3706 uZ += (uX - uZ) * (this->raster_clip_y - uW) / (uY - uW); |
3707 uW = this->raster_clip_y; | |
3708 } | |
3709 } | |
3710 if ( v12 & 1 ) | |
0 | 3711 { |
3712 if ( v37 & 1 ) | |
3713 { | |
2102 | 3714 uX += ((uZ - uX) * (this->raster_clip_w - uY)) / (uW - uY); |
3715 uY = this->raster_clip_w; | |
0 | 3716 } |
3717 else | |
3718 { | |
2102 | 3719 uZ += ((uX - uZ) * (this->raster_clip_w - uW)) / (uY - uW); |
3720 uW = this->raster_clip_w; | |
0 | 3721 } |
3722 } | |
3723 goto LABEL_46; | |
3724 } | |
2102 | 3725 return; |
0 | 3726 } |
3727 | |
3728 //----- (004A0E80) -------------------------------------------------------- | |
3729 void Render::ClearZBuffer(int a2, int a3) | |
3730 { | |
3731 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
3732 } | |
3733 | |
3734 //----- (004A0E97) -------------------------------------------------------- | |
709 | 3735 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
3736 { | |
3737 this->raster_clip_x = uX; | |
3738 this->raster_clip_y = uY; | |
3739 this->raster_clip_z = uZ; | |
3740 this->raster_clip_w = uW; | |
0 | 3741 } |
3742 | |
3743 //----- (004A0EB6) -------------------------------------------------------- | |
3744 void Render::ParseTargetPixelFormat() | |
3745 { | |
3746 signed int v2; // ecx@1 | |
3747 DWORD uRedMask; // edx@1 | |
3748 unsigned int uGreenMask; // esi@5 | |
3749 signed int v5; // ecx@5 | |
3750 unsigned int uBlueMask; // edx@9 | |
3751 signed int v7; // ecx@9 | |
2069 | 3752 //unsigned int v8; // ecx@13 |
0 | 3753 |
3754 v2 = 0; | |
2132 | 3755 uRedMask = this->ddpfPrimarySuface.dwRBitMask; |
3756 this->uTargetBBits = 0; | |
3757 this->uTargetGBits = 0; | |
3758 this->uTargetRBits = 0; | |
0 | 3759 do |
3760 { | |
3761 if ( (1 << v2) & uRedMask ) | |
2132 | 3762 ++this->uTargetRBits; |
0 | 3763 ++v2; |
3764 } | |
2069 | 3765 while ( v2 < 32 ); |
2132 | 3766 uGreenMask = this->ddpfPrimarySuface.dwGBitMask; |
0 | 3767 v5 = 0; |
3768 do | |
3769 { | |
3770 if ( (1 << v5) & uGreenMask ) | |
2132 | 3771 ++this->uTargetGBits; |
0 | 3772 ++v5; |
3773 } | |
2069 | 3774 while ( v5 < 32 ); |
2132 | 3775 uBlueMask = this->ddpfPrimarySuface.dwBBitMask; |
0 | 3776 v7 = 0; |
3777 do | |
3778 { | |
3779 if ( (1 << v7) & uBlueMask ) | |
2132 | 3780 ++this->uTargetBBits; |
0 | 3781 ++v7; |
3782 } | |
2069 | 3783 while ( v7 < 32 ); |
2132 | 3784 this->uTargetGMask = uGreenMask; |
3785 this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask; | |
3786 this->uTargetBMask = uBlueMask; | |
0 | 3787 } |
3788 | |
3789 //----- (004A0F40) -------------------------------------------------------- | |
3790 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
3791 { | |
2132 | 3792 //IDirectDrawSurface4 *v4; // esi@1 |
168 | 3793 HRESULT result; // eax@1 |
0 | 3794 HRESULT v6; // eax@4 |
3795 int v7; // [sp-8h] [bp-14h]@10 | |
3796 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
3797 char v9; // [sp+Bh] [bp-1h]@1 | |
3798 | |
2132 | 3799 //v4 = pSurface; |
0 | 3800 v9 = 1; |
3801 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
3802 if ( result == DDERR_SURFACELOST ) | |
3803 { | |
2132 | 3804 v6 = pSurface->Restore(); |
0 | 3805 if ( v6 ) |
3806 { | |
3807 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
3808 { | |
3809 LABEL_20: | |
3810 v9 = 0; | |
3811 result = (bool)memset(pDesc, 0, 4u); | |
3812 goto LABEL_21; | |
3813 } | |
3814 pRenderer->pFrontBuffer4->Restore(); | |
2132 | 3815 pSurface->Restore(); |
3816 } | |
3817 result = pSurface->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
0 | 3818 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) |
3819 goto LABEL_20; | |
3820 ErrD3D(result); | |
3821 if ( result ) | |
3822 { | |
3823 //v8 = 0; | |
3824 //v7 = 2161; | |
3825 LABEL_19: | |
3826 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
3827 goto LABEL_20; | |
3828 } | |
3829 if ( pRenderer->pRenderD3D ) | |
3830 pRenderD3D->HandleLostResources(); | |
3831 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
3832 } | |
3833 else | |
3834 { | |
3835 if ( result ) | |
3836 { | |
3837 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3838 goto LABEL_20; | |
3839 ErrD3D(result); | |
3840 //v8 = 0; | |
3841 //v7 = 2199; | |
3842 //goto LABEL_19; | |
3843 } | |
3844 } | |
3845 LABEL_21: | |
3846 LOBYTE(result) = v9; | |
3847 return result; | |
3848 } | |
3849 | |
3850 //----- (004A1032) -------------------------------------------------------- | |
3851 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
3852 { | |
3853 IDirectDrawSurface2 *v4; // esi@1 | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
3854 HRESULT v5; // eax@1 |
0 | 3855 HRESULT v6; // eax@2 |
3856 int v7; // [sp-8h] [bp-10h]@8 | |
3857 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
3858 | |
3859 v4 = pSurface; | |
3860 v5 = pSurface->Lock( | |
3861 0, | |
3862 pDesc, | |
3863 uLockFlags, | |
3864 0); | |
3865 BYTE3(pSurface) = 1; | |
3866 if ( v5 == DDERR_SURFACELOST ) | |
3867 { | |
3868 v6 = v4->Restore(); | |
3869 if ( !v6 ) | |
3870 goto LABEL_5; | |
3871 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
3872 { | |
3873 pRenderer->pFrontBuffer2->Restore(); | |
3874 v4->Restore(); | |
3875 LABEL_5: | |
3876 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
3877 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
3878 goto LABEL_14; | |
3879 if ( !v5 ) | |
3880 return true; | |
3881 ErrD3D(v5); | |
3882 //v8 = 0; | |
3883 //v7 = 2247; | |
3884 goto LABEL_13; | |
3885 } | |
3886 else | |
3887 { | |
3888 pDesc->dwSize = 0; | |
3889 return false; | |
3890 } | |
3891 } | |
3892 else | |
3893 { | |
3894 if ( !v5 ) | |
3895 return true; | |
3896 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
3897 { | |
3898 //v8 = 0; | |
3899 //v7 = 2269; | |
3900 ErrD3D(v5); | |
3901 pDesc->dwSize = 0; | |
3902 return false; | |
3903 LABEL_13: | |
3904 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
3905 goto LABEL_14; | |
3906 } | |
3907 } | |
3908 LABEL_14: | |
3909 return true; | |
3910 } | |
3911 | |
3912 //----- (004A10E4) -------------------------------------------------------- | |
3913 void Render::CreateDirectDraw() | |
3914 { | |
3915 Render *v1; // edi@1 | |
3916 HRESULT v2; // eax@1 | |
3917 HRESULT v3; // eax@5 | |
3918 int v6; // [sp-Ch] [bp-20h]@3 | |
3919 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
3920 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
3921 | |
3922 v1 = this; | |
3923 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
3924 | |
3925 pDirectDraw2 = nullptr; | |
3926 pDirectDraw4 = nullptr; | |
3927 | |
1802 | 3928 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
3929 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 3930 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); |
3931 else | |
3932 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
3933 | |
3934 lpDD->Release(); | |
3935 lpDD = nullptr; | |
3936 } | |
3937 | |
3938 //----- (004A1169) -------------------------------------------------------- | |
3939 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
3940 { | |
3941 DWORD flags; // eax@1 | |
3942 IDirectDraw *v4; // ecx@3 | |
3943 HRESULT v5; // eax@5 | |
3944 int v6; // [sp-8h] [bp-8h]@3 | |
3945 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
3946 | |
3947 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
3948 DDSCL_NORMAL; | |
3949 | |
1802 | 3950 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
3951 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 3952 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); |
3953 else | |
3954 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
3955 } | |
3956 | |
3957 //----- (004A11C6) -------------------------------------------------------- | |
3958 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
3959 { | |
1802 | 3960 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
3961 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 3962 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); |
3963 else | |
3964 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
3965 } | |
3966 | |
3967 //----- (004A121C) -------------------------------------------------------- | |
3968 void Render::CreateFrontBuffer() | |
3969 { | |
3970 Render *v1; // esi@1 | |
3971 IDirectDraw *pDD; // eax@3 | |
3972 IDirectDrawSurface **pOutSurf; // esi@3 | |
3973 struct _DDSURFACEDESC *v4; // edx@3 | |
3974 HRESULT v5; // eax@5 | |
3975 int v6; // [sp-8h] [bp-8Ch]@3 | |
3976 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
3977 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
3978 | |
3979 v1 = this; | |
1802 | 3980 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
3981 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 3982 { |
3983 memset(&a2, 0, 0x7Cu); | |
3984 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
3985 a2.dwSize = 124; | |
3986 a2.dwFlags = 1; | |
3987 v7 = 0; | |
3988 a2.ddsCaps.dwCaps = 512; | |
3989 v6 = 2357; | |
3990 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
3991 v4 = (struct _DDSURFACEDESC *)&a2; | |
3992 } | |
3993 else | |
3994 { | |
3995 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
3996 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
3997 a2.lPitch = 108; | |
3998 a2.dwBackBufferCount = 1; | |
3999 v7 = 0; | |
4000 a2.dwTextureStage = 512; | |
4001 v6 = 2346; | |
4002 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
4003 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
4004 } | |
4005 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
4006 } | |
4007 | |
4008 //----- (004A12CD) -------------------------------------------------------- | |
4009 void Render::CreateBackBuffer() | |
4010 { | |
4011 Render *v1; // esi@1 | |
4012 IDirectDraw *v2; // eax@3 | |
4013 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
4014 struct _DDSURFACEDESC *v4; // edx@3 | |
4015 HRESULT v5; // eax@5 | |
4016 int v6; // [sp-8h] [bp-8Ch]@3 | |
4017 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4018 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4019 | |
4020 v1 = this; | |
1802 | 4021 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4022 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4023 { |
4024 memset(&a2, 0, 0x7Cu); | |
4025 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
4026 a2.dwSize = 124; | |
4027 a2.dwFlags = 7; | |
4028 v7 = 0; | |
4029 a2.ddsCaps.dwCaps = 2112; | |
4030 a2.dwWidth = 640; | |
4031 a2.dwHeight = 480; | |
4032 v6 = 2387; | |
4033 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4034 v4 = (struct _DDSURFACEDESC *)&a2; | |
4035 } | |
4036 else | |
4037 { | |
4038 memset(&a2.lPitch, 0, 0x6Cu); | |
4039 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4040 a2.lPitch = 108; | |
4041 a2.dwBackBufferCount = 7; | |
4042 v7 = 0; | |
4043 a2.dwTextureStage = 2112; | |
4044 a2.dwAlphaBitDepth = 640; | |
4045 a2.dwMipMapCount = 480; | |
4046 v6 = 2374; | |
4047 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4048 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
4049 } | |
4050 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
4051 } | |
4052 | |
4053 //----- (004A139A) -------------------------------------------------------- | |
4054 void Render::CreateDirectDrawPrimarySurface() | |
4055 { | |
4056 Render *v1; // esi@1 | |
4057 int v2; // ebx@3 | |
4058 IDirectDraw2 *v3; // eax@3 | |
4059 HRESULT v4; // eax@3 | |
4060 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
4061 DDSCAPS2 *v6; // edx@3 | |
4062 IDirectDraw4 *v7; // eax@4 | |
4063 HRESULT v8; // eax@4 | |
4064 int v9; // ST14_4@5 | |
4065 IDirectDrawSurface *v10; // ST10_4@5 | |
4066 HRESULT v11; // eax@5 | |
4067 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
4068 const char *v13; // [sp+0h] [bp-A0h]@0 | |
4069 int v14; // [sp+4h] [bp-9Ch]@0 | |
4070 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
4071 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
4072 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
4073 int a4; // [sp+98h] [bp-8h]@3 | |
4074 | |
4075 v1 = this; | |
1802 | 4076 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4077 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4078 { |
4079 v2 = 0; | |
4080 this->field_4004C = 1; | |
4081 memset(&ddsd2, 0, 0x7Cu); | |
4082 v7 = v1->pDirectDraw4; | |
4083 ddsd2.dwBackBufferCount = 1; | |
4084 ddsd2.dwSize = 0x7Cu; | |
4085 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4086 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4087 ErrD3D(v7->CreateSurface( | |
4088 &ddsd2, | |
4089 &pFrontBuffer4, | |
4090 0)); | |
4091 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
4092 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4093 } | |
4094 else | |
4095 { | |
4096 v2 = 0; | |
4097 this->field_4004C = 1; | |
4098 | |
4099 DDSURFACEDESC ddsd; | |
4100 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4101 | |
4102 ddsd.lpSurface = (LPVOID)1; | |
4103 ddsd.lPitch = 108; | |
4104 ddsd.dwBackBufferCount = 33; | |
4105 ddsd.ddsCaps.dwCaps = 8728; | |
4106 ErrD3D(pDirectDraw2->CreateSurface( | |
4107 &ddsd, | |
4108 (IDirectDrawSurface **)&pFrontBuffer2, | |
4109 0)); | |
4110 | |
4111 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4112 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4113 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4114 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used |
0 | 4115 v9 = (int)v6; |
4116 v10 = pFrontBuffer; // BUG | |
4117 | |
4118 v17.dwCaps = 4; | |
4119 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4120 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
4121 v1->field_40030 = v2; | |
4122 v1->field_18_locked_pitch = v2; | |
4123 } | |
4124 | |
4125 //----- (004A14F4) -------------------------------------------------------- | |
4126 void Render::CreateClipper(HWND a2) | |
4127 { | |
1802 | 4128 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4129 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4130 { |
4131 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
4132 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4133 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
4134 } | |
4135 else | |
4136 { | |
4137 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
4138 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4139 } | |
4140 } | |
4141 | |
4142 //----- (004A15D8) -------------------------------------------------------- | |
4143 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4144 { | |
4145 IDirectDrawSurface *v2; // eax@3 | |
4146 | |
1802 | 4147 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4148 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4149 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; |
4150 else | |
4151 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4152 v2->GetPixelFormat(pOut); | |
4153 } | |
4154 | |
4155 //----- (004A1605) -------------------------------------------------------- | |
4156 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4157 { | |
4158 signed int v4; // eax@3 | |
4159 | |
1802 | 4160 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4161 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4162 { |
4163 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4164 memset(&pDesc, 0, 0x7Cu); | |
4165 pDesc.dwSize = 124; | |
2132 | 4166 LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4167 *pOutSurfacePtr = pDesc.lpSurface; |
4168 v4 = pDesc.lPitch; | |
4169 } | |
4170 else | |
4171 { | |
4172 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4173 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4174 pDesc.lPitch = 108; | |
2132 | 4175 LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1); |
0 | 4176 *pOutSurfacePtr = (void *)pDesc.lpSurface; |
4177 v4 = pDesc.dwReserved; | |
4178 } | |
4179 *pOutPixelsPerRow = v4 >> 1; | |
4180 } | |
4181 | |
4182 //----- (004A16E1) -------------------------------------------------------- | |
4183 void Render::UnlockBackBuffer() | |
4184 { | |
1802 | 4185 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4186 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4187 ErrD3D(pBackBuffer4->Unlock(0)); |
4188 else | |
4189 ErrD3D(pBackBuffer2->Unlock(0)); | |
4190 } | |
4191 | |
4192 //----- (004A172E) -------------------------------------------------------- | |
4193 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4194 { | |
4195 signed int v4; // eax@3 | |
4196 | |
4197 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4198 { | |
4199 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4200 memset(&pDesc, 0, 0x7Cu); | |
4201 pDesc.dwSize = 124; | |
2132 | 4202 LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4203 *pOutSurface = pDesc.lpSurface; |
4204 v4 = pDesc.lPitch; | |
4205 } | |
4206 else | |
4207 { | |
4208 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4209 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4210 pDesc.lPitch = 108; | |
2132 | 4211 LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1); |
0 | 4212 *pOutSurface = (void *)pDesc.lpSurface; |
4213 v4 = pDesc.dwReserved; | |
4214 } | |
4215 *pOutPixelsPerRow = v4 >> 1; | |
4216 } | |
4217 | |
4218 //----- (004A17C7) -------------------------------------------------------- | |
4219 void Render::UnlockFrontBuffer() | |
4220 { | |
4221 IDirectDrawSurface *pFront; // eax@3 | |
4222 HRESULT v2; // eax@5 | |
4223 signed int v3; // [sp-8h] [bp-Ch]@3 | |
4224 int v4; // [sp-4h] [bp-8h]@3 | |
4225 | |
1980 | 4226 Render* a5 = this; |
0 | 4227 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
4228 { | |
4229 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
4230 v4 = 0; | |
4231 v3 = 2615; | |
4232 } | |
4233 else | |
4234 { | |
4235 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
4236 v4 = 0; | |
4237 v3 = 2611; | |
4238 } | |
4239 ErrD3D(pFront->Unlock(0)); | |
4240 } | |
4241 | |
4242 //----- (004A1814) -------------------------------------------------------- | |
4243 void Render::RestoreFrontBuffer() | |
4244 { | |
4245 IDirectDrawSurface **v1; // esi@2 | |
4246 | |
4247 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
4248 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
4249 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
4250 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
4251 (*v1)->Restore(); | |
4252 } | |
4253 | |
4254 //----- (004A184C) -------------------------------------------------------- | |
4255 HRESULT Render::_4A184C() | |
4256 { | |
4257 IDirectDrawSurface **pBack; // esi@2 | |
4258 HRESULT result; // eax@4 | |
4259 | |
4260 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
4261 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
4262 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
4263 result = (*pBack)->IsLost(); | |
4264 if ( result == DDERR_SURFACELOST ) | |
4265 result = (*pBack)->Restore(); | |
4266 return result; | |
4267 } | |
4268 | |
4269 //----- (004A1884) -------------------------------------------------------- | |
4270 void Render::PresentRect(RECT *a2, RECT *a3) | |
4271 { | |
4272 IDirectDrawSurface *pFront; // eax@3 | |
4273 HRESULT v4; // eax@5 | |
4274 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
4275 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
4276 DWORD v7; // [sp-14h] [bp-14h]@3 | |
4277 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
4278 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
4279 int v10; // [sp-8h] [bp-8h]@3 | |
4280 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
4281 | |
4282 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4283 { | |
4284 v11 = 0; | |
4285 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4286 v10 = 2657; | |
4287 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4288 v8 = 0; | |
4289 v7 = DDBLT_WAIT; | |
4290 v6 = a3; | |
4291 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4292 } | |
4293 else | |
4294 { | |
4295 v11 = 0; | |
4296 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4297 v10 = 2653; | |
4298 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4299 v8 = 0; | |
4300 v7 = DDBLT_WAIT; | |
4301 v6 = a3; | |
4302 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
4303 } | |
4304 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
4305 } | |
4306 | |
4307 //----- (004A18F5) -------------------------------------------------------- | |
4308 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4309 { | |
4310 IDirectDrawSurface *pFront; // eax@3 | |
4311 HRESULT v6; // eax@5 | |
4312 int v7; // [sp-8h] [bp-8h]@3 | |
4313 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
4314 | |
4315 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
4316 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
4317 else | |
4318 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
4319 } | |
4320 | |
4321 //----- (004A194A) -------------------------------------------------------- | |
4322 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
4323 { | |
4324 IDirectDrawSurface *pFront; // eax@3 | |
4325 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
4326 | |
4327 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4328 { | |
4329 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4330 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4331 } | |
4332 else | |
4333 { | |
4334 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4335 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
4336 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4337 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 4338 } |
4339 | |
4340 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4341 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4342 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4343 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4344 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4345 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4346 //int v6; // ecx@5 |
0 | 4347 unsigned int v7; // edx@6 |
4348 char *v8; // ecx@12 | |
4349 void *v9; // edi@16 | |
4350 unsigned int v10; // eax@16 | |
4351 void *v11; // edi@21 | |
4352 unsigned int v12; // eax@21 | |
4353 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4354 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4355 if (uNumBillboardsToDraw >= 999 ) |
0 | 4356 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4357 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4358 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4359 uNumBillboardsToDraw = 1; |
0 | 4360 return 0; |
4361 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4362 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4363 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4364 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4365 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4366 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4367 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4368 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4369 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4370 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4371 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4372 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4373 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4374 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4375 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4376 if (z > *(float *)v8 ) |
0 | 4377 { |
4378 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
4379 { | |
4380 v7 = pRenderer->uNumBillboardsToDraw; | |
4381 } | |
4382 else | |
4383 { | |
4384 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4385 { | |
4386 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
4387 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
4388 do | |
4389 { | |
4390 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
4391 v9 = (char *)v9 - 156; | |
4392 --v10; | |
4393 } | |
4394 while ( v10 ); | |
4395 } | |
4396 ++v7; | |
4397 } | |
717 | 4398 //LABEL_23: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4399 uNumBillboardsToDraw++; |
0 | 4400 return v7; |
4401 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4402 if (z <= *(float *)v8 ) |
0 | 4403 { |
4404 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4405 { | |
4406 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
4407 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
4408 do | |
4409 { | |
4410 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
4411 v11 = (char *)v11 - 156; | |
4412 --v12; | |
4413 } | |
4414 while ( v12 ); | |
4415 } | |
717 | 4416 //goto LABEL_23; |
4417 uNumBillboardsToDraw++; | |
4418 return v7; | |
0 | 4419 } |
4420 return v7; | |
4421 } | |
4422 | |
4423 //----- (004A1E9D) -------------------------------------------------------- | |
4424 unsigned int Render::GetBillboardDrawListSize() | |
4425 { | |
4426 return pRenderer->uNumBillboardsToDraw; | |
4427 } | |
4428 | |
4429 //----- (004A1EA3) -------------------------------------------------------- | |
4430 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
4431 { | |
2002 | 4432 return pRenderer->pBillboardRenderListD3D[uBillboardID].sParentBillboardID; |
0 | 4433 } |
4434 | |
4435 //----- (004A1EB6) -------------------------------------------------------- | |
4436 void Render::BeginSceneD3D() | |
4437 { | |
4438 if (!uNumD3DSceneBegins++) | |
4439 { | |
4440 if (pRenderD3D) | |
4441 { | |
4442 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
4443 pRenderer->uNumBillboardsToDraw = 0; | |
4444 pRenderD3D->pDevice->BeginScene(); | |
1390 | 4445 |
0 | 4446 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
4447 uFogColor = GetLevelFogColor(); | |
4448 else | |
4449 uFogColor = 0; | |
4450 | |
4451 if ( uFogColor & 0xFF000000 ) | |
4452 { | |
4453 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
4454 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
4455 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4456 bUsingSpecular = true; | |
4457 } | |
4458 else | |
4459 { | |
4460 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
4461 bUsingSpecular = 0; | |
4462 } | |
4463 } | |
4464 else | |
4465 { | |
4466 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
4467 if (pTargetSurface) | |
4468 field_18_locked_pitch = uTargetSurfacePitch; | |
4469 else | |
4470 --uNumD3DSceneBegins; | |
4471 } | |
4472 } | |
4473 } | |
4474 | |
4475 //----- (004A1FE1) -------------------------------------------------------- | |
4476 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
4477 { | |
4478 --uNumD3DSceneBegins; | |
4479 if (uNumD3DSceneBegins) | |
4480 return; | |
4481 | |
4482 if (pRenderD3D) | |
4483 { | |
4484 pGame->draw_debug_outlines(); | |
161 | 4485 DoRenderBillboards_D3D(); |
0 | 4486 pGame->pStru6Instance->RenderSpecialEffects(); |
4487 pRenderD3D->pDevice->EndScene(); | |
4488 } | |
4489 else | |
4490 pGame->pStru6Instance->RenderSpecialEffects(); | |
4491 } | |
4492 | |
4493 //----- (004A2031) -------------------------------------------------------- | |
349 | 4494 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
4495 { | |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4496 // __debugbreak(); // should not fire outside decal builder |
349 | 4497 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 4498 } |
4499 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4500 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 4501 { |
4502 int v5; // ebx@1 | |
4503 int v6; // edi@1 | |
4504 int v8; // eax@7 | |
4505 float v9; // eax@12 | |
4506 float *v10; // esi@12 | |
4507 float v11; // ecx@14 | |
4508 double v12; // st7@14 | |
4509 double v13; // st7@14 | |
4510 double v14; // st7@14 | |
4511 signed int v15; // eax@14 | |
4512 int v16; // eax@15 | |
4513 float v17; // ST48_4@15 | |
4514 char v18; // zf@17 | |
4515 int v19; // eax@18 | |
4516 int v20; // eax@18 | |
4517 int v21; // edx@20 | |
4518 signed int v22; // ecx@20 | |
4519 int v23; // eax@20 | |
4520 const char *v24; // ST4C_4@20 | |
4521 unsigned int v25; // ST50_4@20 | |
4522 int v26; // ST54_4@20 | |
4523 int v27; // eax@20 | |
4524 _UNKNOWN *v28; // eax@21 | |
4525 int v29; // ecx@23 | |
4526 int v30; // eax@23 | |
4527 int v31; // eax@23 | |
4528 int v32; // eax@24 | |
4529 int v33; // eax@25 | |
4530 int v34; // eax@25 | |
4531 int v35; // eax@25 | |
4532 int v36; // eax@25 | |
4533 signed int v37; // ecx@26 | |
4534 int v38; // eax@26 | |
4535 _UNKNOWN *v39; // eax@27 | |
4536 int v40; // edx@28 | |
4537 int v41; // eax@29 | |
4538 int v42; // eax@29 | |
4539 int v43; // eax@29 | |
4540 int v44; // eax@29 | |
4541 unsigned int v46; // eax@29 | |
4542 int v47; // eax@30 | |
4543 int v48; // eax@30 | |
4544 int v49; // eax@30 | |
4545 double v52; // st6@35 | |
4546 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
4547 int v57; // [sp+5Ch] [bp-Ch]@3 | |
4548 signed int v59; // [sp+60h] [bp-8h]@12 | |
4549 int v61; // [sp+64h] [bp-4h]@4 | |
4550 int i; | |
4551 | |
4552 v6 = (int)this; | |
4553 v5 = 0; | |
4554 if (!this->uNumD3DSceneBegins) | |
4555 return; | |
4556 | |
4557 | |
4558 | |
4559 | |
186 | 4560 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 4561 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
4562 if (this->bUsingSpecular) | |
4563 { | |
186 | 4564 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4565 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4566 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 4567 } |
4568 | |
4569 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
4570 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
1637 | 4571 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4572 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); |
4573 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
4574 pVertices[0].specular = 0; | |
4575 pVertices[0].texcoord.x = array_50AC10[0].u; | |
4576 pVertices[0].texcoord.y = array_50AC10[0].v; | |
4577 | |
4578 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
4579 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
1637 | 4580 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4581 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); |
4582 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
4583 pVertices[1].specular = 0; | |
4584 pVertices[1].texcoord.x = array_50AC10[3].u; | |
4585 pVertices[1].texcoord.y = array_50AC10[3].v; | |
4586 | |
4587 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
4588 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
1637 | 4589 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4590 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); |
4591 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
4592 pVertices[2].specular = 0; | |
4593 pVertices[2].texcoord.x = array_50AC10[1].u; | |
4594 pVertices[2].texcoord.y = array_50AC10[1].v; | |
4595 | |
4596 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
4597 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
4598 | |
4599 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
4600 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
1637 | 4601 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4602 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); |
4603 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
4604 pVertices[5].specular = 0; | |
4605 pVertices[5].texcoord.x = array_50AC10[2].u; | |
4606 pVertices[5].texcoord.y = array_50AC10[2].v; | |
4607 | |
4608 | |
4609 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4610 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
4611 | |
186 | 4612 }*/ |
4613 | |
0 | 4614 //----- (004A26BC) -------------------------------------------------------- |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4615 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
186 | 4616 { |
4617 //RenderVertexSoft *pVertices; // esi@0 | |
4618 //int v7; // edi@1 | |
0 | 4619 unsigned int v8; // ebx@1 |
4620 LightmapBuilder *v9; // esi@3 | |
4621 unsigned int v10; // edx@3 | |
4622 int v11; // eax@5 | |
4623 int v12; // eax@11 | |
4624 char *v13; // esi@11 | |
4625 double v14; // st7@13 | |
4626 double v15; // st7@13 | |
4627 signed int v16; // eax@13 | |
4628 int v17; // ecx@13 | |
4629 double v18; // st7@13 | |
4630 float v19; // ST78_4@14 | |
4631 int v20; // eax@14 | |
4632 char v21; // zf@16 | |
4633 HRESULT v22; // eax@17 | |
4634 HRESULT v23; // eax@17 | |
4635 HRESULT v24; // eax@19 | |
4636 HRESULT v25; // eax@19 | |
4637 unsigned int v26; // ecx@19 | |
4638 char *v27; // eax@20 | |
4639 HRESULT v28; // eax@22 | |
4640 HRESULT v29; // eax@22 | |
4641 HRESULT v30; // eax@23 | |
4642 HRESULT v31; // eax@24 | |
4643 HRESULT v32; // eax@24 | |
4644 HRESULT v33; // eax@24 | |
4645 HRESULT v34; // eax@24 | |
4646 HRESULT v35; // eax@25 | |
4647 HRESULT v36; // eax@25 | |
4648 unsigned int v37; // ecx@25 | |
4649 char *v38; // eax@26 | |
4650 int v39; // edx@27 | |
4651 HRESULT v40; // eax@28 | |
4652 HRESULT v41; // eax@28 | |
4653 HRESULT v42; // eax@28 | |
4654 HRESULT v43; // eax@28 | |
4655 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
4656 unsigned int v45; // eax@28 | |
4657 HRESULT v46; // eax@29 | |
4658 HRESULT v47; // eax@29 | |
4659 HRESULT v48; // eax@29 | |
186 | 4660 //IDirect3DDevice3 *v49; // eax@35 |
0 | 4661 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
4662 int v51; // eax@40 | |
4663 char *v52; // esi@40 | |
4664 double v53; // st7@42 | |
4665 double v54; // st7@42 | |
4666 signed int v55; // eax@42 | |
4667 int v56; // ecx@42 | |
4668 double v57; // st7@42 | |
4669 float v58; // ST7C_4@43 | |
4670 int v59; // eax@43 | |
186 | 4671 //signed int v60; // [sp+78h] [bp-14h]@31 |
4672 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 4673 const char *v62; // [sp+80h] [bp-Ch]@0 |
4674 const char *v63; // [sp+80h] [bp-Ch]@19 | |
4675 int v64; // [sp+84h] [bp-8h]@0 | |
4676 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
4677 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
4678 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 4679 int a7; |
4680 | |
4681 //v7 = (int)this; | |
0 | 4682 v8 = 0; |
186 | 4683 if (!this->uNumD3DSceneBegins) |
75 | 4684 return; |
4685 if ( uNumVertices < 3) | |
4686 return; | |
4687 | |
186 | 4688 //v61 = pVertices; |
4689 | |
75 | 4690 /* v9 = pGame->pLightmapBuilder; |
0 | 4691 v65 = v9; |
75 | 4692 v10 = v9->std__vector_000004_size;*/ |
1394 | 4693 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) |
0 | 4694 { |
638 | 4695 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 4696 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); |
0 | 4697 } |
4698 else | |
4699 { | |
186 | 4700 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 4701 byte_4D864C && pGame->uFlags & 2 ) |
4702 { | |
186 | 4703 if (clampAtTextureBorders) |
4704 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 4705 else |
186 | 4706 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
4707 | |
4708 if (transparent || this->bUsingSpecular) | |
4709 { | |
4710 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4711 if (transparent) | |
0 | 4712 { |
186 | 4713 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
4714 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
4715 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
4716 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 4717 } |
4718 else | |
4719 { | |
186 | 4720 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
4721 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 4722 } |
186 | 4723 } |
1073 | 4724 |
4725 for (uint i = 0; i < uNumVertices; ++i) | |
4726 { | |
4727 | |
4728 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4729 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4730 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4731 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4732 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4733 if ( this->bUsingSpecular ) | |
0 | 4734 { |
1073 | 4735 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4736 } |
1073 | 4737 else |
4738 { | |
4739 d3d_vertex_buffer[i].specular = 0; | |
4740 } | |
4741 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4742 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4743 } | |
4744 | |
4745 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4746 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
186 | 4747 if (transparent) |
4748 { | |
4749 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
4750 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4751 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4752 } |
4753 } | |
4754 else | |
4755 { | |
1073 | 4756 for (uint i = 0; i < uNumVertices; ++i) |
4757 { | |
4758 | |
4759 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4760 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4761 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4762 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4763 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4764 if ( this->bUsingSpecular ) | |
0 | 4765 { |
1073 | 4766 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4767 } |
1073 | 4768 else |
4769 { | |
4770 d3d_vertex_buffer[i].specular = 0; | |
4771 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4772 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
1073 | 4773 d3d_vertex_buffer[i].specular = v20; |
4774 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4775 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4776 } | |
186 | 4777 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4778 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4779 if (pRenderer->bUsingSpecular) | |
4780 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 4781 |
4782 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 4783 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 4784 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4785 d3d_vertex_buffer, |
0 | 4786 uNumVertices, |
4787 16)); | |
4788 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 4789 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 4790 //(*(void (**)(void))(*(int *)v63 + 88))(); |
1394 | 4791 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
1073 | 4792 for (uint i = 0; i < uNumVertices; ++i) |
4793 { | |
4794 d3d_vertex_buffer[i].diffuse = -1; | |
4795 } | |
0 | 4796 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 4797 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4798 if ( !pRenderer->bUsingSpecular ) |
4799 { | |
186 | 4800 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4801 } | |
4802 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4803 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4804 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
4805 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4806 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4807 d3d_vertex_buffer, |
0 | 4808 uNumVertices, |
4809 16)); | |
4810 if ( pRenderer->bUsingSpecular ) | |
4811 { | |
186 | 4812 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4813 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 4814 for (uint i = 0; i < uNumVertices; ++i) |
4815 { | |
4816 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4817 d3d_vertex_buffer[i].specular = 0; | |
4818 } | |
4819 | |
75 | 4820 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 4821 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4822 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
4823 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4824 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4825 d3d_vertex_buffer, |
0 | 4826 uNumVertices, |
4827 16)); | |
186 | 4828 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4829 //v44 = pRenderer->pRenderD3D->pDevice; |
4830 v45 = GetLevelFogColor(); | |
4831 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
4832 v8 = 0; | |
4833 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
4834 } | |
186 | 4835 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4836 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4837 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
4838 } | |
4839 } | |
186 | 4840 |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
4841 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
1642 | 4842 if (pGame->pIndoorCameraD3D->debug_flags & ODM_RENDER_DRAW_TERRAIN_OUTLINES) |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4843 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 4844 } |
4845 // 4A26BC: could not find valid save-restore pair for esi | |
4846 // 4D864C: using guessed type char byte_4D864C; | |
4847 | |
4848 //----- (004A2DA3) -------------------------------------------------------- | |
1923 | 4849 void Render::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
852 | 4850 { |
67 | 4851 int v7; // eax@7 |
4852 | |
4853 if ( !this->uNumD3DSceneBegins ) | |
4854 return; | |
4855 if ( uNumVertices >= 3 ) | |
4856 { | |
186 | 4857 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 4858 if ( this->bUsingSpecular ) |
4859 { | |
186 | 4860 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4861 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4862 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 4863 } |
1427 | 4864 for ( uint i = 0; i < uNumVertices; ++i ) |
67 | 4865 { |
4866 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4867 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4868 pVertices[i].pos.z = 0.99989998; | |
168 | 4869 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 4870 |
840 | 4871 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 4872 v7 = 0; |
4873 if (this->bUsingSpecular) | |
1427 | 4874 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, array_50AC10[i].vWorldViewPosition.x); |
67 | 4875 pVertices[i].specular = v7; |
4876 pVertices[i].texcoord.x = array_50AC10[i].u; | |
4877 pVertices[i].texcoord.y = array_50AC10[i].v; | |
4878 } | |
4879 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4880 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 4881 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 4882 } |
4883 } | |
4884 | |
4885 //----- (004A2ED5) -------------------------------------------------------- | |
1923 | 4886 void Render::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
0 | 4887 { |
4888 int v5; // eax@3 | |
4889 | |
4890 if ( this->uNumD3DSceneBegins ) | |
4891 { | |
1923 | 4892 if ( uNumVertices >= 3 ) |
0 | 4893 { |
186 | 4894 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1923 | 4895 v5 = 31 - (pSkyPolygon->dimming_level & 0x1F); |
638 | 4896 if ( v5 < pOutdoor->max_terrain_dimming_level ) |
4897 v5 = pOutdoor->max_terrain_dimming_level; | |
1937 | 4898 for (uint i = 0; i < uNumVertices; ++i) |
4899 { | |
4900 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
4901 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
1999 | 4902 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); |
1937 | 4903 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; |
4904 d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); | |
4905 d3d_vertex_buffer[i].specular = 0; | |
4906 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
4907 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
4908 } | |
1923 | 4909 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
1936 | 4910 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
4911 d3d_vertex_buffer, uNumVertices, 28)); | |
0 | 4912 } |
4913 } | |
4914 } | |
4915 | |
1390 | 4916 //----- (00479A53) -------------------------------------------------------- |
1923 | 4917 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID) |
1390 | 4918 { |
4919 BLVFace *pFace; // esi@1 | |
4920 double v5; // st7@3 | |
4921 signed __int64 v6; // qax@3 | |
4922 int v12; // edx@7 | |
4923 int v13; // eax@7 | |
4924 void *v15; // ecx@9 | |
4925 int v17; // edi@9 | |
4926 double v18; // st7@9 | |
4927 signed int v19; // ebx@9 | |
4928 void *v20; // ecx@9 | |
4929 int v21; // ebx@11 | |
4930 int v22; // eax@14 | |
4931 signed __int64 v23; // qtt@16 | |
4932 double v24; // st7@16 | |
4933 unsigned __int8 v25; // sf@16 | |
4934 unsigned __int8 v26; // of@16 | |
4935 double v28; // st7@20 | |
4936 char *v29; // ebx@20 | |
4937 char *v30; // edx@20 | |
4938 unsigned __int8 v31; // c0@21 | |
4939 unsigned __int8 v32; // c3@21 | |
4940 double v33; // st6@23 | |
4941 char *v34; // esi@30 | |
4942 const void *v35; // ecx@31 | |
4943 int v36; // eax@31 | |
4944 const void *v37; // edi@31 | |
4945 signed __int64 v38; // qax@31 | |
4946 int v39; // ecx@31 | |
4947 int v40; // ebx@33 | |
4948 int v41; // eax@36 | |
4949 signed __int64 v42; // qtt@39 | |
4950 int v43; // eax@39 | |
4951 char v44; // zf@39 | |
4952 double v45; // st7@39 | |
4953 double v46; // st7@39 | |
4954 unsigned int v47; // edx@40 | |
4955 double v48; // st7@41 | |
4956 RenderVertexSoft *v49; // ebx@41 | |
4957 void *v50; // edi@43 | |
4958 double v51; // st7@46 | |
4959 RenderVertexSoft *v52; // edx@46 | |
4960 void *v53; // edi@48 | |
4961 signed int v59; // [sp-4h] [bp-178h]@17 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4962 struct Polygon *v60; // [sp+0h] [bp-174h]@17 |
1390 | 4963 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 |
1981 | 4964 struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6 |
1390 | 4965 unsigned int v63; // [sp+120h] [bp-54h]@7 |
4966 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
4967 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4968 //float v67; // [sp+130h] [bp-44h]@7 |
1390 | 4969 __int64 v69; // [sp+13Ch] [bp-38h]@3 |
4970 int v70; // [sp+144h] [bp-30h]@3 | |
4971 int X; // [sp+148h] [bp-2Ch]@9 | |
4972 int v72; // [sp+14Ch] [bp-28h]@7 | |
4973 float v73; // [sp+150h] [bp-24h]@16 | |
4974 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
1999 | 4975 unsigned int v74_; // [sp+154h] [bp-20h]@3 |
1390 | 4976 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 |
4977 float v76; // [sp+15Ch] [bp-18h]@9 | |
4978 int v77; // [sp+160h] [bp-14h]@9 | |
4979 int v78; // [sp+164h] [bp-10h]@7 | |
4980 void *v79; // [sp+168h] [bp-Ch]@9 | |
4981 float v80; // [sp+16Ch] [bp-8h]@3 | |
4982 const void *v81; // [sp+170h] [bp-4h]@7 | |
4983 | |
4984 pFace = &pIndoor->pFaces[uFaceID]; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4985 //for floor and wall(for example Selesta)------------------- |
1644 | 4986 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor) |
4987 { | |
4988 int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x; | |
4989 int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y; | |
4990 for (uint i = 0; i < uNumVertices; ++i) | |
4991 { | |
4992 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f; | |
4993 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f; | |
4994 } | |
4995 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0); | |
1390 | 4996 return; |
4997 } | |
1981 | 4998 //--------------------------------------- |
4999 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179 | |
1641 | 5000 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) |
1390 | 5001 * 65536.0) |
1922 | 5002 + (double)pBLVRenderParams->uViewportCenterY); |
1981 | 5003 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0 |
5004 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183 | |
1641 | 5005 - (double)pBLVRenderParams->fov_rad_fixpoint |
1644 | 5006 / ((cos(v5) * 16192.0 + 0.0000001) |
1390 | 5007 * 65535.0) |
1922 | 5008 * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); |
1644 | 5009 |
1999 | 5010 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); |
1981 | 5011 pSkyPolygon.Create_48607B(&stru_8019C8); |
5012 pSkyPolygon.uTileBitmapID = pFace->uBitmapID; | |
5013 | |
5014 pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID); | |
5015 if ( !pSkyPolygon.pTexture ) | |
1390 | 5016 return; |
1644 | 5017 |
1981 | 5018 pSkyPolygon.dimming_level = 0; |
5019 pSkyPolygon.uNumVertices = uNumVertices; | |
5020 | |
5021 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); | |
5022 pSkyPolygon.v_18.y = 0; | |
5023 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); | |
5024 | |
1644 | 5025 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices])); |
1981 | 5026 pSkyPolygon.field_24 = 0x2000000; |
1644 | 5027 |
5028 extern float _calc_fov(int viewport_width, int angle_degree); | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5029 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5; |
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5030 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); |
1644 | 5031 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74); |
1981 | 5032 v12 = pSkyPolygon.pTexture->uWidthMinus1; |
5033 v13 = pSkyPolygon.pTexture->uHeightMinus1; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5034 //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth; |
1390 | 5035 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; |
5036 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
5037 v78 = 0; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5038 //v81 = 0; |
1981 | 5039 float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight; |
5040 if ( (signed int)pSkyPolygon.uNumVertices <= 0 ) | |
5041 return; | |
1644 | 5042 |
5043 int _507D30_idx = 0; | |
1999 | 5044 for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ ) |
1390 | 5045 { |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5046 //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)); |
1981 | 5047 v77 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_west_east * (signed __int64)(v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY))) >> 16; |
5048 v74 = v77 + pSkyPolygon.ptr_38->angle_from_north; | |
5049 | |
5050 v77 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_north_south * (signed __int64)(v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY))) >> 16; | |
1999 | 5051 v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east; |
1981 | 5052 |
1997 | 5053 v79 = (void *)(((unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))) >> 16); |
1644 | 5054 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX); |
5055 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0; | |
1981 | 5056 v19 = -pSkyPolygon.field_24; |
5057 v77 = -pSkyPolygon.field_24; | |
5058 X = (int)((char *)v79 + pSkyPolygon.v_18.x); | |
1390 | 5059 LODWORD(v76) = (signed __int64)v18; |
5060 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
5061 while ( 1 ) | |
5062 { | |
5063 v79 = v20; | |
5064 if ( !X ) | |
5065 goto LABEL_14; | |
5066 v21 = abs(v19 >> 14); | |
1999 | 5067 if ( v21 <= abs(X) )//0x800 <= 0x28652 |
1390 | 5068 break; |
5069 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5070 break; | |
5071 v19 = v77; | |
5072 v20 = v79; | |
5073 LABEL_14: | |
1981 | 5074 v79 = (void *)((unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(signed int)v20) >> 16); |
5075 v22 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(signed int)v20) >> 16; | |
1390 | 5076 --LODWORD(v76); |
5077 v20 = (char *)v20 + v72; | |
1981 | 5078 X = v22 + pSkyPolygon.v_18.x; |
1390 | 5079 v78 = 1; |
5080 } | |
5081 if ( !v78 ) | |
5082 { | |
5083 LODWORD(v23) = v77 << 16; | |
1981 | 5084 HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000 |
1997 | 5085 v79 = (void *)(v23 / X);//X = FFFF9014(-28652) |
1390 | 5086 v77 = v17; |
1999 | 5087 signed __int64 s = v74 + ((pSkyPolygon.ptr_38->angle_from_west * (signed __int64)v17) >> 16);// s = 0xFFFFFFFF FFFF3EE6 |
5088 LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(s) * (v23 / X)) >> 16) >> 4); | |
1981 | 5089 array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); |
5090 | |
1999 | 5091 signed __int64 s2 = (signed __int64)(v74_ + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)v17) >> 16)); |
5092 LODWORD(v80) = v63 + ((signed int)((unsigned __int64)(SLODWORD(s2) * (v23 / X)) >> 16) >> 4); | |
1981 | 5093 array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68; |
5094 | |
1999 | 5095 v77 = (unsigned __int64)(SLODWORD(s) * (v23 / X)) >> 16; |
5096 LODWORD(v73) = (unsigned __int64)(SLODWORD(s2) * (v23 / X)) >> 16; | |
1644 | 5097 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79; |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5098 |
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5099 //if ( (int)v81 >= pSkyPolygon.uNumVertices ) |
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5100 //{ |
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5101 // pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, |
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5102 // pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5103 // return; |
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5104 //} |
1390 | 5105 continue; |
5106 } | |
5107 break; | |
5108 } | |
1999 | 5109 if ( _507D30_idx >= pSkyPolygon.uNumVertices ) |
5110 { | |
5111 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, | |
5112 pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5113 return; | |
5114 } | |
1390 | 5115 LODWORD(v73) = 0; |
5116 v80 = v76; | |
1981 | 5117 if ( (signed int)pSkyPolygon.uNumVertices > 0 ) |
1390 | 5118 { |
5119 v28 = (double)SLODWORD(v76); | |
5120 LODWORD(v76) = (int)(char *)array_50AC10 + 28; | |
1997 | 5121 uint i = 0; |
5122 for ( v78 = pSkyPolygon.uNumVertices; v78; --v78 ) | |
5123 { | |
1390 | 5124 ++LODWORD(v73); |
1997 | 5125 memcpy(&array_50AC10[i], &array_507D30[i], 0x30u); |
1390 | 5126 LODWORD(v76) += 48; |
1997 | 5127 if ( v28 < array_507D30[i].vWorldViewProjY | v28 == array_507D30[i].vWorldViewProjY |
5128 || v28 >= array_507D30[i + 1].vWorldViewProjY ) | |
5129 { | |
5130 if ( v28 >= array_507D30[i].vWorldViewProjY || v28 <= array_507D30[i + 1].vWorldViewProjY ) | |
5131 { | |
5132 i++; | |
5133 continue; | |
5134 } | |
5135 v33 = (array_507D30[i + 1].vWorldViewProjX - array_507D30[i].vWorldViewProjX) * v28 / (array_507D30[i + 1].vWorldViewProjY - array_507D30[i].vWorldViewProjY) | |
5136 + array_507D30[i + 1].vWorldViewProjX; | |
1390 | 5137 } |
5138 else | |
5139 { | |
1997 | 5140 v33 = (array_507D30[i].vWorldViewProjX - array_507D30[i + 1].vWorldViewProjX) * v28 / (array_507D30[i].vWorldViewProjY - array_507D30[i + 1].vWorldViewProjY) |
5141 + array_507D30[i].vWorldViewProjX; | |
5142 } | |
5143 array_50AC10[i + 1].vWorldViewProjX = v33; | |
1390 | 5144 ++LODWORD(v73); |
5145 *(unsigned int *)LODWORD(v76) = v28; | |
5146 LODWORD(v76) += 48; | |
1997 | 5147 i++; |
5148 } | |
1390 | 5149 } |
5150 if ( SLODWORD(v73) <= 0 ) | |
5151 goto LABEL_40; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5152 //v34 = (char *)&array_50AC10[0].vWorldViewProjY; |
1997 | 5153 uint j = 0; |
1390 | 5154 v65 = v77 >> 14; |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5155 //HIDWORD(v69) = LODWORD(v73); |
1997 | 5156 for ( int t = (int)LODWORD(v73); t > 1; t-- ) |
5157 { | |
5158 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjY)); | |
5159 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5160 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east; |
1997 | 5161 v81 = (const void *)((unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_west_east * (signed __int64)(signed int)v35) >> 16); |
1981 | 5162 v36 = (int)((char *)v81 + pSkyPolygon.ptr_38->angle_from_north); |
1997 | 5163 |
1390 | 5164 v81 = v35; |
5165 v74 = v36; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5166 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south; |
1997 | 5167 v81 = (const void *)((unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_north_south * (signed __int64)(signed int)v35) >> 16); |
1390 | 5168 v78 = (int)v35; |
1981 | 5169 v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east); |
5170 v81 = (const void *)pSkyPolygon.v_18.z; | |
5171 v78 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(signed int)v35) >> 16; | |
1390 | 5172 v37 = (const void *)(v72 |
1997 | 5173 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX)); |
5174 v38 = (signed __int64)(array_50AC10[j].vWorldViewProjY - 1.0); | |
1390 | 5175 v81 = 0; |
5176 LODWORD(v76) = v38; | |
5177 v39 = v72 * (v70 - v38); | |
5178 while ( 1 ) | |
5179 { | |
5180 v78 = v39; | |
5181 if ( !X ) | |
5182 goto LABEL_36; | |
5183 v40 = abs(X); | |
5184 if ( abs((signed __int64)v65) <= v40 ) | |
5185 break; | |
5186 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5187 break; | |
5188 v39 = v78; | |
5189 LABEL_36: | |
1981 | 5190 v78 = pSkyPolygon.v_18.z; |
5191 v41 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v39) >> 16; | |
1390 | 5192 --LODWORD(v76); |
5193 v39 += v72; | |
1981 | 5194 X = v41 + pSkyPolygon.v_18.x; |
1390 | 5195 v81 = (const void *)1; |
5196 } | |
5197 if ( v81 ) | |
5198 { | |
1981 | 5199 v79 = (void *)pSkyPolygon.v_18.z; |
1390 | 5200 v78 = 2 * LODWORD(v76); |
1981 | 5201 v81 = (const void *)((unsigned __int64)(pSkyPolygon.v_18.z |
1390 | 5202 * (signed __int64)(signed int)(signed __int64)(((double)v70 |
5203 - ((double)(2 * LODWORD(v76)) | |
1997 | 5204 - array_50AC10[j].vWorldViewProjY)) |
1390 | 5205 * (double)v72)) >> 16); |
1981 | 5206 X = (int)((char *)v81 + pSkyPolygon.v_18.x); |
1390 | 5207 } |
5208 LODWORD(v42) = v77 << 16; | |
5209 HIDWORD(v42) = v77 >> 16; | |
5210 v79 = (void *)(v42 / X); | |
5211 v81 = v37; | |
1997 | 5212 |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5213 //v78 = pSkyPolygon.ptr_38->angle_from_west; |
1997 | 5214 v81 = (const void *)((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_west * (signed __int64)(signed int)v37) >> 16); |
5215 v43 = v74 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_west * (signed __int64)(signed int)v37) >> 16); | |
1390 | 5216 v74 = (unsigned int)v37; |
5217 LODWORD(v76) = v43; | |
1997 | 5218 |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5219 //v78 = pSkyPolygon.ptr_38->angle_from_south; |
1997 | 5220 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)(signed int)v37) >> 16)); |
1390 | 5221 v74 = (unsigned __int64)(v43 * v42 / X) >> 16; |
5222 v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16); | |
1997 | 5223 |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5224 //v34 += 48; |
1390 | 5225 v78 = v66 + ((signed int)v74 >> 4); |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5226 //v44 = HIDWORD(v69)-- == 1; |
1390 | 5227 v45 = (double)v78 * 0.000015259022; |
5228 v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4); | |
1997 | 5229 array_50AC10[j].u = v45 * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); |
5230 array_50AC10[j].v = (double)v78 * 0.000015259022 * v68; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5231 //v46 = (double)(signed int)v79; |
1997 | 5232 array_50AC10[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79; |
5233 array_50AC10[j]._rhw = 65536.0 / (double)(signed int)v79; | |
5234 ++j; | |
5235 } | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5236 //while ( !v44 ); |
1390 | 5237 LABEL_40: |
1997 | 5238 uint i = 0; |
1390 | 5239 if ( SLODWORD(v73) > 0 ) |
5240 { | |
5241 v48 = (double)SLODWORD(v80); | |
1997 | 5242 for ( HIDWORD(v69) = LODWORD(v73); HIDWORD(v69); --HIDWORD(v69) ) |
5243 { | |
5244 if ( v48 >= array_50AC10[i].vWorldViewProjY ) | |
5245 { | |
5246 ++i; | |
5247 memcpy(&array_507D30[i], &array_50AC10[i], 0x30u); | |
5248 } | |
5249 } | |
5250 } | |
5251 pSkyPolygon.uNumVertices = i; | |
5252 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5253 int pNumVertices = 0; | |
1390 | 5254 if ( SLODWORD(v73) > 0 ) |
5255 { | |
5256 v51 = (double)SLODWORD(v80); | |
1997 | 5257 for ( v80 = v73; v80 != 0.0; --LODWORD(v80) ) |
5258 { | |
5259 if ( v51 <= array_50AC10[pNumVertices].vWorldViewProjY ) | |
5260 { | |
5261 ++pNumVertices; | |
5262 memcpy(&array_507D30[pNumVertices], &array_50AC10[pNumVertices], 0x30u); | |
5263 } | |
5264 } | |
5265 } | |
5266 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
1390 | 5267 } |
5268 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений слияния: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5269 |
0 | 5270 //----- (004A2FC0) -------------------------------------------------------- |
5271 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
5272 { | |
5273 //Render *v8; // edi@1 | |
5274 //unsigned int v9; // esi@3 | |
1072 | 5275 RenderVertexSoft *v12; // ecx@9 |
5276 RenderVertexD3D3 *v13; // eax@9 | |
0 | 5277 double v14; // st6@10 |
5278 int v15; // edx@10 | |
5279 Texture *v16; // edx@10 | |
5280 double v17; // st6@10 | |
5281 //char v18; // zf@10 | |
5282 Texture *v19; // edx@10 | |
595 | 5283 //Texture *v23; // edx@16 |
5284 //char *v24; // ecx@16 | |
5285 //char *v25; // eax@16 | |
5286 //double v26; // st6@17 | |
5287 //int v27; // esi@17 | |
5288 //double v28; // st6@17 | |
5289 //unsigned int v33; // ecx@18 | |
5290 //char *v34; // eax@19 | |
0 | 5291 //Texture *v45; // edx@23 |
5292 //char *v46; // ecx@23 | |
5293 //char *v47; // eax@23 | |
5294 //double v48; // st6@24 | |
5295 //int v49; // esi@24 | |
5296 //double v50; // st6@24 | |
5297 const char *v53; // [sp-Ch] [bp-20h]@21 | |
5298 //int v54; // [sp-8h] [bp-1Ch]@21 | |
5299 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
5300 const char *v56; // [sp+0h] [bp-14h]@0 | |
5301 int v57; // [sp+4h] [bp-10h]@0 | |
5302 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
5303 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
5304 //int a3a; // [sp+10h] [bp-4h]@4 | |
5305 | |
5306 //v8 = this; | |
5307 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
5308 return; | |
5309 | |
5310 //auto a3 = pFace; | |
5311 //auto a6 = uPackedID; | |
5312 //v59 = pGame->pLightmapBuilder; | |
5313 //v9 = v59->std__vector_000004_size; | |
5314 | |
2006 | 5315 int sCorrectedColor = uColor; |
0 | 5316 if (pGame->pLightmapBuilder->std__vector_000004_size) |
2006 | 5317 sCorrectedColor = -1; |
5318 pGame->AlterGamma_BLV(pFace, &sCorrectedColor); | |
0 | 5319 |
792 | 5320 |
5321 if (pFace->uAttributes & FACE_OUTLINED) | |
5322 { | |
5323 int color; | |
5324 if (GetTickCount() % 300 >= 150) | |
2006 | 5325 uColor = sCorrectedColor = 0xFF20FF20; |
5326 else uColor = sCorrectedColor = 0xFF109010; | |
792 | 5327 } |
5328 | |
1394 | 5329 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) |
0 | 5330 { |
5331 __debugbreak(); | |
5332 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 5333 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 5334 for (uint i = 0; i < uNumVertices; ++i) |
5335 { | |
5336 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5337 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5338 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5339 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5340 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
1072 | 5341 d3d_vertex_buffer[i].specular = 0; |
5342 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5343 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5344 } | |
5345 | |
186 | 5346 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5347 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
5348 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
5349 D3DPT_TRIANGLEFAN, | |
5350 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5351 d3d_vertex_buffer, |
0 | 5352 uNumVertices, |
5353 28)); | |
1394 | 5354 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
0 | 5355 } |
5356 else | |
5357 { | |
5358 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
5359 byte_4D864C && pGame->uFlags & 2) | |
5360 { | |
5361 for (uint i = 0; i < uNumVertices; ++i) | |
5362 { | |
186 | 5363 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
5364 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5365 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5366 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5367 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
186 | 5368 d3d_vertex_buffer[i].specular = 0; |
5369 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5370 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5371 } | |
5372 | |
5373 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 5374 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
5375 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5376 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5377 d3d_vertex_buffer, |
0 | 5378 uNumVertices, |
5379 28)); | |
5380 } | |
5381 else | |
5382 { | |
595 | 5383 for (uint i = 0; i < uNumVertices; ++i) |
5384 { | |
5385 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5386 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5387 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5388 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5389 d3d_vertex_buffer[i].diffuse = uColor; | |
5390 d3d_vertex_buffer[i].specular = 0; | |
5391 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5392 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5393 } | |
5394 //__debugbreak(); | |
5395 //if ( (signed int)uNumVertices > 0 ) | |
5396 //{ | |
5397 //v23 = pTex; | |
5398 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
5399 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
5400 //pTex = (Texture *)uNumVertices; | |
5401 //uint v18; | |
5402 //do | |
5403 //{ | |
5404 //v26 = *(float *)v24 * 0.061758894; | |
5405 //v27 = *((int *)v24 + 3); | |
5406 //*((int *)v25 + 4) = 0; | |
5407 //*((int *)v25 - 1) = v27; | |
5408 //*(int *)v25 = *((int *)v24 + 4); | |
5409 //*((int *)v25 + 3) = uColor; | |
5410 //v25 += 32; | |
5411 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
5412 //v28 = 1.0 / *(float *)v24; | |
5413 //v24 += 48; | |
5414 //v18 = pTex == (Texture *)1; | |
5415 //pTex = (Texture *)((char *)pTex - 1); | |
5416 //*((float *)v25 - 6) = v28; | |
0 | 5417 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 5418 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 5419 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 5420 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
5421 //} | |
5422 //while ( !v18 ); | |
5423 //} | |
0 | 5424 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 5425 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5426 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 5427 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5428 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5429 d3d_vertex_buffer, |
0 | 5430 uNumVertices, |
5431 28)); | |
595 | 5432 |
5433 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1394 | 5434 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
595 | 5435 |
5436 for (uint i = 0; i < uNumVertices; ++i) | |
2006 | 5437 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
595 | 5438 /*v33 = uNumVertices; |
0 | 5439 if ( (signed int)uNumVertices > 0 ) |
5440 { | |
186 | 5441 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 5442 do |
5443 { | |
5444 *(int *)v34 = uCorrectedColor; | |
5445 v34 += 32; | |
5446 --v33; | |
5447 } | |
5448 while ( v33 ); | |
595 | 5449 }*/ |
0 | 5450 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5451 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
5452 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5453 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5454 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5455 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
5456 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 5457 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5458 d3d_vertex_buffer, |
0 | 5459 uNumVertices, |
5460 28)); | |
186 | 5461 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
5462 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5463 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 5464 } |
5465 } | |
5466 } | |
5467 // 4D864C: using guessed type char byte_4D864C; | |
5468 | |
5469 //----- (004A43B1) -------------------------------------------------------- | |
717 | 5470 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
5471 { | |
5472 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
5473 //double v5; // st7@2 | |
5474 //float v6; // ST08_4@2 | |
0 | 5475 unsigned int v7; // eax@2 |
717 | 5476 //int v8; // ecx@2 |
5477 //unsigned int v9; // esi@2 | |
5478 //Sprite *v10; // edi@5 | |
0 | 5479 signed int v11; // eax@9 |
5480 signed int v12; // eax@9 | |
717 | 5481 //double v13; // st7@12 |
5482 //double v14; // st6@12 | |
0 | 5483 double v15; // st5@12 |
5484 double v16; // st4@12 | |
5485 double v17; // st3@12 | |
5486 double v18; // st2@12 | |
5487 int v19; // ecx@14 | |
5488 double v20; // st3@14 | |
5489 int v21; // ecx@16 | |
5490 double v22; // st3@16 | |
717 | 5491 //IDirect3DTexture2 *v23; // eax@18 |
5492 //signed int v24; // [sp+18h] [bp-18h]@5 | |
5493 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
5494 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 5495 float v27; // [sp+24h] [bp-Ch]@5 |
5496 int v28; // [sp+28h] [bp-8h]@2 | |
5497 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 5498 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 5499 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 5500 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 5501 float a1; // [sp+40h] [bp+10h]@5 |
5502 | |
717 | 5503 //v26 = this; |
0 | 5504 if ( this->uNumD3DSceneBegins ) |
5505 { | |
717 | 5506 //v4 = pSoftBillboard; |
5507 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
5508 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
5509 //v6 = pSoftBillboard->zbuffer_depth; | |
5510 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
5511 //v8 = dimming_level; | |
5512 //v9 = v7; | |
657 | 5513 v28 = dimming_level & 0xFF000000; |
5514 if ( dimming_level & 0xFF000000 ) | |
717 | 5515 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; |
0 | 5516 else |
717 | 5517 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; |
5518 //v10 = a3; | |
5519 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
5520 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
2002 | 5521 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID; |
717 | 5522 //v25 = pSoftBillboard->uScreenSpaceX; |
5523 //v24 = pSoftBillboard->uScreenSpaceY; | |
5524 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
5525 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
5526 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5527 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
5528 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5529 v31 = v31 * -1.0; |
2006 | 5530 if ( pSoftBillboard->sTintColor && this->bTinting ) |
717 | 5531 { |
5532 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
2006 | 5533 v12 = BlendColors(pSoftBillboard->sTintColor, v11); |
0 | 5534 if ( v28 ) |
5535 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
5536 } | |
5537 else | |
5538 { | |
717 | 5539 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
5540 } | |
5541 //v13 = (double)v25; | |
1390 | 5542 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; |
5543 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
5544 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
717 | 5545 //v14 = (double)v24; |
5546 //v32 = v14; | |
1390 | 5547 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; |
717 | 5548 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); |
1390 | 5549 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; |
717 | 5550 v16 = 1.0 / pSoftBillboard->zbuffer_depth; |
1390 | 5551 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; |
5552 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
5553 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
717 | 5554 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); |
5555 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
5556 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5557 v17 = v17 * -1.0; |
1390 | 5558 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; |
5559 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
5560 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
5561 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
5562 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
5563 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
5564 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
5565 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
717 | 5566 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; |
5567 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5568 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5569 v20 = v20 * -1.0; |
1390 | 5570 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; |
5571 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
5572 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
5573 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
5574 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
5575 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
5576 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
5577 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
717 | 5578 v21 = pSprite->uBufferHeight - pSprite->uAreaY; |
5579 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5580 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5581 v22 = v22 * -1.0; |
1390 | 5582 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; |
5583 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
5584 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
5585 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
5586 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
5587 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
5588 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
5589 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
717 | 5590 //v23 = pSprite->pTexture; |
5591 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
5592 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
5593 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 5594 } |
5595 } | |
5596 | |
5597 //----- (004A354F) -------------------------------------------------------- | |
5598 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5599 { | |
743 | 5600 //double v5; // st7@3 |
5601 //float v6; // ST20_4@3 | |
5602 //float v7; // ST00_4@3 | |
0 | 5603 unsigned int v8; // esi@3 |
743 | 5604 //int v9; // eax@3 |
5605 //int v10; // ebx@3 | |
0 | 5606 float v11; // ST28_4@3 |
743 | 5607 //double v12; // st7@3 |
5608 //float v13; // ST24_4@3 | |
5609 //double v14; // st6@3 | |
5610 //float v15; // ST1C_4@3 | |
0 | 5611 float v16; // ST2C_4@3 |
5612 float v17; // ST30_4@3 | |
5613 signed int v18; // ST18_4@3 | |
5614 signed int v19; // ST14_4@3 | |
5615 signed int v20; // ST10_4@3 | |
5616 signed int v21; // eax@3 | |
5617 double v22; // st6@3 | |
5618 float v23; // ST2C_4@3 | |
5619 float v24; // ST30_4@3 | |
5620 signed int v25; // ST10_4@3 | |
5621 signed int v26; // ST14_4@3 | |
5622 signed int v27; // ST18_4@3 | |
5623 signed int v28; // eax@3 | |
5624 double v29; // st6@3 | |
5625 float v30; // ecx@3 | |
5626 float v31; // ST2C_4@3 | |
5627 float v32; // ST30_4@3 | |
5628 signed int v33; // ST10_4@3 | |
5629 signed int v34; // ST14_4@3 | |
5630 signed int v35; // ST18_4@3 | |
5631 signed int v36; // eax@3 | |
5632 float v37; // ecx@3 | |
5633 double v38; // st6@3 | |
5634 float v39; // ST2C_4@3 | |
5635 float v40; // ST30_4@3 | |
5636 signed int v41; // ST10_4@3 | |
5637 signed int v42; // ST14_4@3 | |
5638 signed int v43; // ST18_4@3 | |
5639 signed int v44; // eax@3 | |
5640 double v45; // st6@3 | |
5641 float v46; // eax@3 | |
5642 | |
5643 if ( this->uNumD3DSceneBegins ) | |
5644 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5645 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5646 { |
743 | 5647 //v5 = (double)a2->zbuffer_depth; |
5648 //v6 = v5; | |
5649 //v7 = v5; | |
5650 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
0 | 5651 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; |
5652 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
5653 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5654 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
743 | 5655 //v9 = a2->uScreenSpaceX; |
5656 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5657 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 5658 //v12 = (double) a2->uScreenSpaceX; |
5659 //v13 = v12; | |
5660 //v14 = (double)(a2->uScreenSpaceY - 12); | |
5661 //v15 = v14; | |
5662 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5663 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5664 v18 = stru_5C6E00->Cos(angle); |
5665 v19 = stru_5C6E00->Sin(angle); | |
5666 v20 = stru_5C6E00->Sin(angle); | |
5667 v21 = stru_5C6E00->Cos(angle); | |
1390 | 5668 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5669 + (double)(v18 >> 16)) |
5670 * v16 | |
5671 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
5672 + (double)(v19 >> 16)) | |
5673 * v17) | |
743 | 5674 * v11 + (double) a2->uScreenSpaceX; |
0 | 5675 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
5676 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
5677 - 12.0) | |
5678 * v11 | |
5679 + (double)a2->uScreenSpaceY; | |
1390 | 5680 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5681 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5682 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
5683 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
5684 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5685 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5686 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
743 | 5687 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5688 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5689 v25 = stru_5C6E00->Cos(angle); |
5690 v26 = stru_5C6E00->Sin(angle); | |
5691 v27 = stru_5C6E00->Sin(angle); | |
5692 v28 = stru_5C6E00->Cos(angle); | |
1390 | 5693 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
0 | 5694 + (double)(v25 >> 16)) |
740 | 5695 * v31 |
0 | 5696 - ((double)(unsigned __int16)v26 * 0.000015259022 |
5697 + (double)(v26 >> 16)) | |
740 | 5698 * v32) |
743 | 5699 * v11 + (double) a2->uScreenSpaceX; |
740 | 5700 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
5701 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 5702 - 12.0) |
5703 * v11 | |
5704 + (double)a2->uScreenSpaceY; | |
1390 | 5705 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5706 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5707 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
5708 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5709 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
5710 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5711 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5712 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
743 | 5713 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
5714 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5715 v33 = stru_5C6E00->Cos(angle); |
5716 v34 = stru_5C6E00->Sin(angle); | |
5717 v35 = stru_5C6E00->Sin(angle); | |
5718 v36 = stru_5C6E00->Cos(angle); | |
1390 | 5719 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
0 | 5720 + (double)(v33 >> 16)) |
740 | 5721 * v23 |
0 | 5722 - ((double)(unsigned __int16)v34 * 0.000015259022 |
5723 + (double)(v34 >> 16)) | |
740 | 5724 * v24) |
743 | 5725 * v11 + (double) a2->uScreenSpaceX; |
1390 | 5726 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
740 | 5727 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
5728 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 5729 - 12.0) |
5730 * v11 | |
5731 + (double)a2->uScreenSpaceY; | |
1390 | 5732 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5733 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
5734 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5735 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5736 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
5737 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5738 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
743 | 5739 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5740 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5741 v41 = stru_5C6E00->Cos(angle); |
5742 v42 = stru_5C6E00->Sin(angle); | |
5743 v43 = stru_5C6E00->Sin(angle); | |
5744 v44 = stru_5C6E00->Cos(angle); | |
1390 | 5745 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
0 | 5746 + (double)(v41 >> 16)) |
5747 * v39 | |
5748 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
5749 + (double)(v42 >> 16)) | |
5750 * v40) | |
743 | 5751 * v11 + (double) a2->uScreenSpaceX; |
0 | 5752 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
5753 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
5754 - 12.0) | |
5755 * v11 | |
5756 + (double)a2->uScreenSpaceY; | |
1390 | 5757 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5758 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5759 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
5760 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5761 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5762 pBillboardRenderListD3D[v8].pTexture = a3; |
743 | 5763 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 5764 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5765 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; |
5766 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5767 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5768 } |
5769 } | |
5770 } | |
5771 | |
5772 //----- (004A3AD9) -------------------------------------------------------- | |
5773 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5774 { | |
5775 double v5; // st7@2 | |
5776 float v6; // ST28_4@2 | |
5777 float v7; // ST00_4@2 | |
5778 unsigned int v8; // esi@2 | |
5779 int v9; // eax@2 | |
5780 int v10; // ebx@2 | |
5781 float v11; // ST34_4@2 | |
5782 double v12; // st7@2 | |
5783 float v13; // ST2C_4@2 | |
5784 double v14; // st6@2 | |
5785 float v15; // ST24_4@2 | |
5786 float v16; // ST38_4@2 | |
5787 float v17; // ST3C_4@2 | |
5788 signed int v18; // ST1C_4@2 | |
5789 int v19; // ST30_4@2 | |
5790 signed int v20; // ST20_4@2 | |
5791 signed int v21; // ST18_4@2 | |
5792 signed int v22; // eax@2 | |
5793 double v23; // st6@2 | |
5794 float v24; // ST20_4@2 | |
5795 float v25; // ST1C_4@2 | |
5796 float v26; // ST38_4@2 | |
5797 float v27; // ST3C_4@2 | |
5798 signed int v28; // ST18_4@2 | |
5799 signed int v29; // ST14_4@2 | |
5800 signed int v30; // ST10_4@2 | |
5801 signed int v31; // eax@2 | |
5802 double v32; // st6@2 | |
5803 float v33; // ST38_4@2 | |
5804 float v34; // ST3C_4@2 | |
5805 signed int v35; // ST10_4@2 | |
5806 signed int v36; // ST14_4@2 | |
5807 signed int v37; // ST18_4@2 | |
5808 signed int v38; // eax@2 | |
5809 double v39; // st6@2 | |
5810 float v40; // ST38_4@2 | |
5811 float v41; // ST3C_4@2 | |
5812 signed int v42; // ST10_4@2 | |
5813 signed int v43; // ST14_4@2 | |
5814 signed int v44; // ST18_4@2 | |
5815 signed int v45; // eax@2 | |
5816 double v46; // st6@2 | |
5817 | |
5818 if ( this->uNumD3DSceneBegins ) | |
5819 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5820 v5 = (double)a2->zbuffer_depth; |
0 | 5821 v6 = v5; |
5822 v7 = v5; | |
5823 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
5824 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
5825 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
5826 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5827 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
0 | 5828 v9 = a2->uScreenSpaceX; |
5829 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5830 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 5831 v12 = (double)v9; |
5832 v13 = v12; | |
5833 v14 = (double)(v10 - 12); | |
5834 v15 = v14; | |
5835 v16 = (double)(v9 - 12) - v12; | |
5836 v17 = (double)(v10 - 25) - v14; | |
323 | 5837 v18 = stru_5C6E00->Cos(angle); |
0 | 5838 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 5839 v20 = stru_5C6E00->Sin(angle); |
5840 v21 = stru_5C6E00->Sin(angle); | |
5841 v22 = stru_5C6E00->Cos(angle); | |
1390 | 5842 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5843 + (double)(v18 >> 16)) |
5844 * v16 | |
5845 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
5846 + (double)(v20 >> 16)) | |
5847 * v17) | |
5848 * v11 + v13; | |
5849 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
5850 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
5851 - 12.0) | |
5852 * v11 | |
5853 + (double)a2->uScreenSpaceY; | |
1390 | 5854 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5855 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5856 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
1637 | 5857 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5858 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; |
0 | 5859 v25 = 1.0 / v6; |
1390 | 5860 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; |
5861 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5862 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
0 | 5863 v26 = (double)(a2->uScreenSpaceX - 12) - v13; |
5864 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 5865 v28 = stru_5C6E00->Cos(angle); |
5866 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5867 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5868 v31 = stru_5C6E00->Cos(angle); | |
1390 | 5869 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
0 | 5870 + (double)(v28 >> 16)) |
5871 * v26 | |
5872 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
5873 + (double)(v29 >> 16)) | |
5874 * v27) | |
5875 * v11 + v13; | |
5876 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
5877 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
5878 - 12.0) | |
5879 * v11 | |
5880 + (double)a2->uScreenSpaceY; | |
1390 | 5881 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; |
5882 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
5883 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5884 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
5885 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5886 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5887 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
0 | 5888 v33 = (double)(a2->uScreenSpaceX + 12) - v13; |
5889 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 5890 v35 = stru_5C6E00->Cos(angle); |
5891 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5892 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5893 v38 = stru_5C6E00->Cos(angle); | |
1390 | 5894 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
0 | 5895 + (double)(v35 >> 16)) |
5896 * v33 | |
5897 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
5898 + (double)(v36 >> 16)) | |
5899 * v34) | |
5900 * v11 + v13; | |
5901 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
5902 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
5903 - 12.0) | |
5904 * v11 | |
5905 + (double)a2->uScreenSpaceY; | |
1390 | 5906 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5907 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
5908 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
5909 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5910 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
5911 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5912 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
0 | 5913 v40 = (double)(a2->uScreenSpaceX + 12) - v13; |
5914 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 5915 v42 = stru_5C6E00->Cos(angle); |
5916 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5917 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5918 v45 = stru_5C6E00->Cos(angle); | |
1390 | 5919 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
0 | 5920 + (double)(v42 >> 16)) |
5921 * v40 | |
5922 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
5923 + (double)(v43 >> 16)) | |
5924 * v41) | |
5925 * v11 + v13; | |
5926 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
5927 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
5928 - 12.0) | |
5929 * v11 | |
5930 + (double)a2->uScreenSpaceY; | |
1390 | 5931 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; |
5932 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
5933 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
5934 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5935 pBillboardRenderListD3D[v8].pTexture = a3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5936 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 5937 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5938 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; |
5939 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5940 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5941 } |
5942 } | |
5943 | |
5944 //----- (004A4023) -------------------------------------------------------- | |
657 | 5945 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
|
5946 { |
0 | 5947 unsigned int v8; // esi@2 |
5948 double v14; // st6@14 | |
5949 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5950 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5951 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5952 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5953 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5954 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5955 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5956 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5957 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5958 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5959 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 5960 float v29; // [sp+28h] [bp-8h]@5 |
5961 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5962 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5963 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5964 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5965 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5966 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5967 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5968 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5969 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
|
5970 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
|
5971 |
657 | 5972 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); |
2006 | 5973 if (a2->sTintColor & 0x00FFFFFF && bTinting) |
5974 { | |
5975 diffuse = BlendColors(a2->sTintColor, diffuse); | |
5976 if (a2->sTintColor & 0xFF000000) | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5977 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5978 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5979 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5980 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5981 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5982 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
|
5983 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5984 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5985 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5986 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5987 v14 *= -1.0; |
1390 | 5988 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; |
5989 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5990 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5991 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5992 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; |
5993 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
5994 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5995 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5996 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5997 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5998 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5999 if ( a2->uFlags & 4 ) |
0 | 6000 v14 = v14 * -1.0; |
1390 | 6001 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; |
6002 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
6003 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
6004 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 6005 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 6006 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; |
6007 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
6008 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6009 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6010 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
|
6011 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6012 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6013 v14 *= -1.0; |
1390 | 6014 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; |
6015 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
6016 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
6017 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 6018 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 6019 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; |
6020 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
6021 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6022 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6023 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
|
6024 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6025 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6026 v14 *= -1.0; |
1390 | 6027 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; |
6028 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
6029 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
6030 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 6031 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 6032 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; |
6033 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
6034 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6035 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6036 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6037 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6038 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6039 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6040 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
2002 | 6041 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6042 |
2006 | 6043 if (a2->sTintColor & 0xFF000000) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6044 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6045 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6046 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 6047 } |
6048 | |
6049 | |
6050 //----- (004A49D0) -------------------------------------------------------- | |
6051 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
6052 { | |
1159 | 6053 int absXDifference; // eax@1 |
6054 int absYDifference; // eax@1 | |
6055 unsigned int smallerabsdiff; // ebx@1 | |
6056 unsigned int largerabsdiff; | |
0 | 6057 double v16; // st7@7 |
6058 double v17; // st7@7 | |
6059 double v18; // st6@7 | |
6060 double v20; // st4@8 | |
6061 double v21; // st4@10 | |
6062 double v22; // st4@10 | |
6063 double v23; // st4@10 | |
6064 double v25; // st4@11 | |
6065 double v26; // st4@13 | |
6066 double v28; // st4@13 | |
6067 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
1159 | 6068 int xDifference; // [sp+88h] [bp-Ch]@1 |
0 | 6069 signed int v32; // [sp+8Ch] [bp-8h]@1 |
1159 | 6070 int yDifference; // [sp+90h] [bp-4h]@1 |
6071 | |
6072 xDifference = bankersRounding(dstX - srcX); | |
6073 yDifference = bankersRounding(dstY - srcY); | |
6074 absYDifference = abs(yDifference); | |
6075 absXDifference = abs(xDifference); | |
6076 smallerabsdiff = min(absXDifference, absYDifference); | |
6077 largerabsdiff = max(absXDifference, absYDifference); | |
6078 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
0 | 6079 v16 = 1.0 / (double)v32; |
1159 | 6080 v17 = (double)yDifference * v16 * a4; |
6081 v18 = (double)xDifference * v16 * a4; | |
6082 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
6083 { | |
1637 | 6084 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
6085 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
1159 | 6086 } |
6087 else | |
6088 { | |
6089 v20 = a3 * 0.061758894; | |
6090 v25 = a7 * 0.061758894; | |
6091 } | |
6092 v21 = 1.0 / a3; | |
6093 v22 = (double)yDifference * v16 * a8; | |
6094 v23 = (double)xDifference * v16 * a8; | |
6095 v26 = 1.0 - 1.0 / v25; | |
6096 v28 = 1.0 / a7; | |
0 | 6097 v29[0].pos.x = srcX + v17; |
6098 v29[0].pos.y = srcY - v18; | |
1159 | 6099 v29[0].pos.z = 1.0 - 1.0 / v20; |
6100 v29[0].rhw = v21; | |
0 | 6101 v29[0].diffuse = -1; |
6102 v29[0].specular = 0; | |
6103 v29[0].texcoord.x = 1.0; | |
6104 v29[0].texcoord.y = 0.0; | |
1159 | 6105 |
0 | 6106 v29[1].pos.x = v22 + dstX; |
6107 v29[1].pos.y = dstY - v23; | |
1159 | 6108 v29[1].pos.z = v26; |
6109 v29[1].rhw = v28; | |
0 | 6110 v29[1].diffuse = -16711936; |
6111 v29[1].specular = 0; | |
6112 v29[1].texcoord.x = 1.0; | |
6113 v29[1].texcoord.y = 1.0; | |
1159 | 6114 |
6115 v29[2].pos.x = dstX - v22; | |
6116 v29[2].pos.y = v23 + dstY; | |
6117 v29[2].pos.z = v26; | |
0 | 6118 v29[2].rhw = v28; |
1159 | 6119 v29[2].diffuse = -1; |
6120 v29[2].specular = 0; | |
0 | 6121 v29[2].texcoord.x = 0.0; |
6122 v29[2].texcoord.y = 1.0; | |
1159 | 6123 |
0 | 6124 v29[3].pos.x = srcX - v17; |
6125 v29[3].pos.y = v18 + srcY; | |
1159 | 6126 v29[3].pos.z = v29[0].pos.z; |
6127 v29[3].rhw = v21; | |
6128 v29[3].diffuse = -1; | |
6129 v29[3].specular = 0; | |
0 | 6130 v29[3].texcoord.x = 0.0; |
6131 v29[3].texcoord.y = 0.0; | |
186 | 6132 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
6133 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6134 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
6135 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6136 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6137 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 6138 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
6139 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
6140 D3DPT_TRIANGLEFAN, | |
6141 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6142 v29, | |
6143 4, | |
6144 24)); | |
186 | 6145 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
6146 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6147 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6148 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6149 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6150 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 6151 } |
6152 | |
6153 //----- (004A4CC9) -------------------------------------------------------- | |
1390 | 6154 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) |
6155 { | |
0 | 6156 unsigned int v5; // eax@7 |
6157 char *v7; // edx@8 | |
6158 double v10; // st6@9 | |
6159 double v11; // st6@10 | |
6160 int v12; // ebx@13 | |
1390 | 6161 |
6162 if (a1->uNumVertices < 3) | |
6163 return; | |
6164 | |
6165 float depth = 1000000.0; | |
6166 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6167 { | |
6168 if (a1->field_104[i].z < depth) | |
6169 depth = a1->field_104[i * 4].z; | |
6170 } | |
6171 | |
6172 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
6173 pBillboardRenderListD3D[v5].field_90 = 0; | |
2002 | 6174 pBillboardRenderListD3D[v5].sParentBillboardID = -1; |
1390 | 6175 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; |
6176 pBillboardRenderListD3D[v5].pTexture = 0; | |
6177 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
6178 pBillboardRenderListD3D[v5].z_order = depth; | |
6179 | |
6180 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6181 { | |
6182 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
6183 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
6184 | |
6185 v10 = a1->field_104[i].z; | |
6186 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
6187 v11 = v10 * 0.061758894; | |
6188 else | |
1637 | 6189 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
1390 | 6190 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; |
6191 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
6192 | |
6193 if (diffuse & 0xFF000000) | |
6194 v12 = a1->field_104[i].diffuse; | |
6195 else | |
6196 v12 = diffuse; | |
6197 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
6198 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
6199 | |
6200 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
6201 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
0 | 6202 } |
6203 } | |
6204 | |
6205 //----- (004A4DE1) -------------------------------------------------------- | |
6206 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
6207 { | |
6208 HRESULT v12; // eax@14 | |
6209 unsigned __int16 *v13; // ecx@19 | |
6210 unsigned __int16 *v14; // eax@19 | |
6211 DWORD v15; // edx@20 | |
6212 HRESULT v16; // eax@23 | |
6213 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
6214 | |
1980 | 6215 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); |
0 | 6216 if ( pHWLTexture ) |
6217 { | |
6218 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
6219 if ( !pRenderD3D->CreateTexture( | |
6220 pHWLTexture->uWidth, | |
6221 pHWLTexture->uHeight, | |
6222 pOutSurface, | |
6223 pOutTexture, | |
6224 true, | |
6225 bMipMaps, | |
6226 uMinDeviceTextureDim) ) | |
1545 | 6227 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6228 //v10 = *pOutSurface; |
6229 //v11 = 0; | |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1574
diff
changeset
|
6230 if (bMipMaps) |
0 | 6231 { |
6232 Dst._450DDE(); | |
6233 //v20 = 0; | |
6234 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
6235 | |
6236 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
6237 while ( 1 ) | |
6238 { | |
6239 DDSCAPS2 v19; | |
6240 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6241 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6242 | |
6243 DDSURFACEDESC2 desc; | |
6244 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6245 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6246 | |
168 | 6247 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6248 { |
1831 | 6249 Dst.sub_451007_scale_image_bicubic( |
0 | 6250 pHWLTexture->pPixels, |
6251 pHWLTexture->uWidth, | |
6252 pHWLTexture->uHeight, | |
6253 pHWLTexture->uWidth, | |
6254 (unsigned short *)desc.lpSurface, | |
6255 desc.dwWidth, | |
6256 desc.dwHeight, | |
6257 desc.lPitch >> 1, | |
6258 0, | |
1831 | 6259 0); |
0 | 6260 ErrD3D(pNextSurf->Unlock(0)); |
6261 //bMipMaps = 0x4D86ACu; | |
6262 } | |
6263 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
6264 break; | |
6265 //v10 = (IDirectDrawSurface4 *)pName; | |
6266 //v11 = 0; | |
6267 } | |
6268 //v20 = -1; | |
6269 //nullsub_1(); | |
6270 } | |
6271 else | |
6272 { | |
6273 DDSCAPS2 v19; | |
6274 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6275 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6276 | |
6277 DDSURFACEDESC2 desc; | |
6278 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6279 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6280 | |
168 | 6281 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6282 { |
6283 bMipMaps = 0; | |
6284 v13 = pHWLTexture->pPixels; | |
6285 v14 = (unsigned __int16 *)desc.lpSurface; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6286 for(int bMipMaps = 0; bMipMaps < desc.dwHeight; bMipMaps++) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6287 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6288 for (v15 = 0; v15 < desc.dwWidth; v15++) |
0 | 6289 { |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6290 *v14 = *v13; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6291 ++v14; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6292 ++v13; |
0 | 6293 } |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6294 v14 += (desc.lPitch >> 1) - desc.dwWidth; |
0 | 6295 } |
6296 ErrD3D((*pOutSurface)->Unlock(0)); | |
6297 } | |
6298 } | |
6299 delete [] pHWLTexture->pPixels; | |
6300 delete pHWLTexture; | |
6301 return true; | |
6302 } | |
6303 return false; | |
6304 } | |
6305 | |
6306 //----- (004A5048) -------------------------------------------------------- | |
670 | 6307 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
6308 { | |
6309 | |
6310 HWLTexture *sprite_texture; // eax@1 | |
0 | 6311 unsigned __int16 *v9; // edx@5 |
6312 LPVOID v10; // eax@5 | |
6313 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6314 | |
670 | 6315 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
6316 if ( sprite_texture ) | |
6317 { | |
6318 _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; | |
6319 pSprite->uAreaX = sprite_texture->uAreaX; | |
6320 pSprite->uAreaY = sprite_texture->uAreaY; | |
6321 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
6322 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
6323 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
6324 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6325 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6326 //v7 = v3->pRenderD3D; |
670 | 6327 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
1545 | 6328 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6329 //pSprite = v2->pTextureSurface; |
6330 //pSprite = (Sprite *)pSprite->pName; | |
6331 //v8 = pSprite; | |
670 | 6332 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 6333 Dst.dwSize = 124; |
670 | 6334 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
6335 { | |
6336 v9 = sprite_texture->pPixels; | |
6337 v10 = Dst.lpSurface; | |
6338 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 6339 { |
670 | 6340 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
6341 { | |
0 | 6342 *(int *)v10 = *(int *)v9; |
6343 v9 += 2; | |
6344 v10 = (char *)v10 + 4; | |
670 | 6345 } |
6346 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 6347 } |
670 | 6348 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
6349 } | |
6350 free(sprite_texture->pPixels); | |
6351 free(sprite_texture); | |
6352 return true; | |
6353 } | |
6354 return false; | |
0 | 6355 } |
6356 | |
6357 //----- (004A51CB) -------------------------------------------------------- | |
6358 void Render::BeginScene() | |
6359 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6360 //Render *v1; // esi@1 |
0 | 6361 unsigned int v2; // eax@1 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6362 /*int v3; // eax@5 |
0 | 6363 unsigned __int16 **v4; // edi@6 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6364 char *v5; // ebx@7*/ |
0 | 6365 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 |
6366 | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6367 //v1 = this; |
0 | 6368 v2 = this->uNumSceneBegins; |
6369 this->uNumSceneBegins = v2 + 1; | |
6370 if ( !v2 ) | |
6371 { | |
6372 if ( this->pRenderD3D ) | |
6373 { | |
2069 | 6374 /*if ( this->bColorKeySupported ) |
0 | 6375 { |
6376 memset(&Dst, 0, 0x7Cu); | |
6377 Dst.dwSize = 124; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6378 if ( LockSurface_DDraw4(this->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6379 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6380 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6381 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6382 this->field_18_locked_pitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6383 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6384 --this->uNumSceneBegins; |
2069 | 6385 }*/ |
0 | 6386 } |
6387 else | |
6388 { | |
6389 if ( !this->pTargetSurface ) | |
6390 { | |
6391 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6392 if ( this->pTargetSurface ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6393 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6394 this->field_18_locked_pitch = this->uTargetSurfacePitch; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6395 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6396 --this->uNumSceneBegins; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6397 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6398 } |
0 | 6399 RestoreFrontBuffer(); |
6400 } | |
6401 } | |
6402 | |
6403 //----- (004A527D) -------------------------------------------------------- | |
6404 void Render::EndScene() | |
6405 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6406 if ( this->uNumSceneBegins ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6407 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6408 this->uNumSceneBegins--; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6409 if ( !this->uNumSceneBegins ) |
0 | 6410 { |
6411 if ( this->pRenderD3D ) | |
6412 { | |
2069 | 6413 /*if ( this->bColorKeySupported ) |
0 | 6414 { |
6415 this->pTargetSurface = 0; | |
6416 this->uTargetSurfacePitch = 0; | |
6417 this->field_18_locked_pitch = 0; | |
6418 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
2069 | 6419 }*/ |
0 | 6420 } |
6421 else | |
6422 { | |
6423 this->pTargetSurface = 0; | |
6424 this->uTargetSurfacePitch = 0; | |
6425 this->field_18_locked_pitch = 0; | |
6426 UnlockBackBuffer(); | |
6427 } | |
6428 } | |
6429 } | |
6430 } | |
6431 | |
6432 //----- ( ) -------------------------------------------------------- | |
6433 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
6434 { | |
6435 unsigned int v3; // esi@1 | |
6436 double v4; // st7@2 | |
6437 double v5; // st7@6 | |
6438 double v6; // st6@6 | |
6439 unsigned int v7; // eax@6 | |
6440 double v8; // st5@6 | |
6441 double v9; // st4@6 | |
6442 HRESULT v10; // eax@6 | |
6443 HRESULT v11; // eax@6 | |
6444 unsigned int result; // eax@6 | |
6445 unsigned int v13; // eax@7 | |
6446 unsigned __int16 *v14; // ecx@7 | |
6447 int *v15; // eax@7 | |
6448 unsigned int v16; // ecx@8 | |
6449 __int16 v17; // ax@10 | |
6450 int v18; // esi@10 | |
6451 float v19; // edi@10 | |
6452 void *v20; // esi@10 | |
6453 int v21; // edx@10 | |
6454 int v22; // ecx@11 | |
6455 int v23; // edx@12 | |
6456 __int16 v24; // ax@15 | |
6457 int v25; // esi@15 | |
6458 float v26; // edi@15 | |
6459 char *v27; // esi@15 | |
6460 int v28; // edx@15 | |
6461 int v29; // ecx@16 | |
6462 int v30; // edx@17 | |
6463 int v31; // [sp-Ch] [bp-ACh]@11 | |
6464 int v32; // [sp-Ch] [bp-ACh]@16 | |
6465 const char *v33; // [sp+0h] [bp-A0h]@0 | |
6466 int v34; // [sp+4h] [bp-9Ch]@0 | |
6467 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
6468 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
6469 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
6470 int v38; // [sp+90h] [bp-10h]@7 | |
6471 double v39; // [sp+94h] [bp-Ch]@6 | |
6472 float v40; // [sp+9Ch] [bp-4h]@6 | |
6473 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6474 __debugbreak(); |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6475 |
1980 | 6476 Render* ecx0 = this; |
0 | 6477 v3 = 0; |
1574 | 6478 |
6479 if (!this->pRenderD3D) | |
6480 __debugbreak(); // sw render | |
6481 | |
6482 //{ | |
0 | 6483 v4 = a3; |
6484 if ( a3 <= 1.0 ) | |
6485 { | |
6486 if ( v4 < 0.0 ) | |
6487 v4 = 0.0; | |
6488 } | |
6489 else | |
6490 { | |
6491 v4 = 1.0; | |
6492 } | |
1574 | 6493 __debugbreak(); // banker's rounding again |
0 | 6494 a3 = v4 * 255.0; |
6495 v39 = a3 + 6.7553994e15; | |
6496 LODWORD(v40) = LODWORD(v39); | |
693 | 6497 v5 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 6498 v36[0].pos.x = v5; |
693 | 6499 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 6500 v7 = this_ | (LODWORD(v39) << 24); |
693 | 6501 this_ = pViewport->uViewportBR_Y + 1; |
0 | 6502 v36[0].specular = 0; |
6503 v36[0].pos.y = v6; | |
6504 v36[0].diffuse = v7; | |
6505 v36[1].diffuse = v7; | |
6506 v36[0].pos.z = 0.0; | |
6507 v36[2].diffuse = v7; | |
6508 v36[3].diffuse = v7; | |
6509 v36[0].rhw = 1.0; | |
6510 v36[1].specular = 0; | |
6511 v36[0].texcoord.x = 0.0; | |
6512 v36[2].specular = 0; | |
6513 v36[3].specular = 0; | |
6514 v36[0].texcoord.y = 0.0; | |
6515 v36[1].pos.x = v5; | |
693 | 6516 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 6517 v36[1].pos.y = v8; |
6518 v36[1].pos.z = 0.0; | |
6519 v36[1].rhw = 1.0; | |
6520 v36[1].texcoord.x = 0.0; | |
6521 v36[1].texcoord.y = 0.0; | |
693 | 6522 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 6523 v36[2].pos.x = v9; |
6524 v36[2].pos.y = v8; | |
6525 v36[2].pos.z = 0.0; | |
6526 v36[2].rhw = 1.0; | |
6527 v36[2].texcoord.x = 0.0; | |
6528 v36[2].texcoord.y = 0.0; | |
6529 v36[3].pos.x = v9; | |
6530 v36[3].pos.y = v6; | |
6531 v36[3].pos.z = 0.0; | |
6532 v36[3].rhw = 1.0; | |
6533 v36[3].texcoord.x = 0.0; | |
6534 v36[3].texcoord.y = 0.0; | |
6535 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 6536 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
6537 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6538 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6539 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
6540 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
6541 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6542 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 6543 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
6544 D3DPT_TRIANGLEFAN, | |
6545 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6546 v36, | |
6547 4, | |
6548 28)); | |
186 | 6549 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
6550 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6551 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
6552 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6553 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6554 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
1574 | 6555 /*} |
0 | 6556 else |
6557 { | |
6558 v40 = (1.0 - a3) * 65536.0; | |
6559 v39 = v40 + 6.7553994e15; | |
6560 LODWORD(a3) = LODWORD(v39); | |
693 | 6561 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
6562 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
6563 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
6564 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 6565 v37 = 2 * v13; |
6566 LODWORD(v40) = (int)v14; | |
6567 | |
6568 int __i = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
6569 v15 = dword_F1B430.data(); |
0 | 6570 do |
6571 { | |
6572 v16 = v3; | |
6573 v3 += LODWORD(a3); | |
6574 dword_F1B430[__i++] = v16 >> 16; | |
6575 } | |
6576 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
6577 while (__i < 32); | |
6578 | |
6579 if ( pRenderer->uTargetGBits == 6 ) | |
6580 { | |
1574 | 6581 v17 = sr_42690D_colors_cvt(this_); |
0 | 6582 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); |
6583 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); | |
6584 v19 = v40; | |
6585 v20 = off_4EFDB0; | |
6586 v21 = HIDWORD(v39); | |
6587 do | |
6588 { | |
6589 v22 = v38; | |
6590 v31 = v21; | |
6591 do | |
6592 { | |
6593 v23 = (*(int *)((char *)v20 | |
6594 + ((((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; | |
6595 result = this_ | |
6596 + (*((int *)v20 | |
6597 + (((unsigned __int8)(*((char *)v20 | |
6598 + ((((unsigned __int16)(*(short *)((char *)v20 | |
6599 + ((*(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); | |
6600 *(unsigned int *)LODWORD(v19) = result; | |
6601 LODWORD(v19) += 4; | |
6602 --v22; | |
6603 } | |
6604 while ( v22 ); | |
6605 LODWORD(v19) += v37; | |
6606 v21 = v31 - 1; | |
6607 } | |
6608 while ( v31 != 1 ); | |
6609 } | |
6610 else | |
6611 { | |
1574 | 6612 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_); |
0 | 6613 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); |
6614 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
6615 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
6616 v26 = v40; | |
6617 v27 = (char *)off_4EFDB0; | |
6618 v28 = HIDWORD(v39); | |
6619 do | |
6620 { | |
6621 v29 = v38; | |
6622 v32 = v28; | |
6623 do | |
6624 { | |
6625 v30 = 32 | |
6626 * *(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; | |
6627 result = this_ | |
6628 + (*(int *)&v27[4 | |
6629 * (((unsigned __int8)(32 | |
6630 * 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); | |
6631 *(unsigned int *)LODWORD(v26) = result; | |
6632 LODWORD(v26) += 4; | |
6633 --v29; | |
6634 } | |
6635 while ( v29 ); | |
6636 LODWORD(v26) += v37; | |
6637 v28 = v32 - 1; | |
6638 } | |
6639 while ( v32 != 1 ); | |
6640 } | |
1574 | 6641 }*/ |
0 | 6642 return result; |
6643 } | |
6644 | |
6645 //----- (004A5B81) -------------------------------------------------------- | |
727 | 6646 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 6647 { |
6648 this->bClip = 1; | |
6649 this->uClipY = uY; | |
6650 this->uClipX = uX; | |
6651 this->uClipW = uW; | |
6652 this->uClipZ = uZ; | |
6653 } | |
6654 | |
6655 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 6656 void Render::ResetTextureClipRect() |
0 | 6657 { |
6658 this->uClipY = 0; | |
6659 this->uClipX = 0; | |
6660 this->bClip = 1; | |
6661 this->uClipW = 480; | |
6662 this->uClipZ = 640; | |
6663 } | |
6664 | |
2069 | 6665 unsigned __int32 Color32(unsigned __int16 color16) |
6666 { | |
6667 unsigned __int32 c = color16; | |
6668 unsigned int b = (c & 31) * 8; | |
6669 unsigned int g = ((c >> 5) & 63) * 4; | |
6670 unsigned int r = ((c >> 11) & 31) * 8; | |
6671 | |
2078 | 6672 return (r << 16) | (g << 8) | b;// |
2069 | 6673 } |
6674 | |
6675 //----- (0040DEF3) -------------------------------------------------------- | |
6676 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b) | |
6677 { | |
6678 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + | |
6679 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + | |
6680 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
6681 return (b >> (8 - 5)) | | |
6682 0x7E0 & (g << (6 + 5 - 8)) | | |
6683 0xF800 & (r << (6 + 5 + 5 - 8)); | |
6684 } | |
6685 | |
6686 | |
0 | 6687 //----- (004A5BE3) -------------------------------------------------------- |
6688 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
6689 { | |
6690 int v4; // edi@3 | |
2069 | 6691 //unsigned __int16 *v5; // edx@3 |
0 | 6692 unsigned __int16 *v6; // esi@3 |
6693 unsigned int v8; // eax@5 | |
6694 unsigned int v9; // ebx@5 | |
6695 unsigned int v11; // eax@7 | |
6696 unsigned int v12; // ebx@8 | |
6697 unsigned int v15; // eax@14 | |
6698 int v19; // [sp+10h] [bp-8h]@3 | |
6699 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
6700 int v23; // [sp+28h] [bp+10h]@3 | |
6701 | |
6702 if ( this->uNumSceneBegins && a4 ) | |
6703 { | |
6704 v4 = a4->uWidth; | |
2069 | 6705 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6706 v6 = a4->pPixels; |
6707 v23 = a4->uHeight; | |
6708 v19 = v4; | |
6709 if ( this->bClip ) | |
6710 { | |
1152 | 6711 if ( (signed int)uOutX < (signed int)this->uClipX ) |
6712 { | |
6713 v8 = this->uClipX - uOutX; | |
6714 v9 = uOutX - this->uClipX; | |
0 | 6715 v8 *= 2; |
6716 v4 += v9; | |
6717 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
2069 | 6718 //v5 = (unsigned __int16 *)((char *)v5 + v8); |
0 | 6719 } |
1152 | 6720 if ( (signed int)uOutY < (signed int)this->uClipY ) |
6721 { | |
6722 v11 = this->uClipY - uOutY; | |
0 | 6723 v6 += v19 * v11; |
6724 v23 += uOutY - this->uClipY; | |
2069 | 6725 //v5 += this->uTargetSurfacePitch * v11; |
0 | 6726 } |
1152 | 6727 v12 = max(this->uClipX, uOutX); |
6728 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | |
6729 { | |
6730 v4 = this->uClipZ - max(this->uClipX, uOutX); | |
6731 } | |
6732 v15 = max(this->uClipY, uOutY); | |
6733 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) | |
6734 { | |
6735 v23 = this->uClipW - max(this->uClipY, uOutY); | |
6736 } | |
6737 } | |
6738 | |
2069 | 6739 for (int y = 0; y < v23; y++) |
6740 { | |
6741 for (int x = 0; x < v4; x++) | |
6742 { | |
6743 WritePixel16(uOutX + x, uOutY + y, *v6); | |
6744 //*v5 = *v6; | |
6745 //++v5; | |
1152 | 6746 ++v6; |
6747 } | |
6748 v6 += v19 - v4; | |
2069 | 6749 //v5 += this->uTargetSurfacePitch - v4; |
0 | 6750 } |
6751 } | |
6752 } | |
6753 | |
6754 //----- (004A5D33) -------------------------------------------------------- | |
1675 | 6755 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) |
0 | 6756 { |
2069 | 6757 //unsigned __int16 *v7; // ebx@3 |
1675 | 6758 int full_width; // ecx@3 |
6759 int full_height; // edi@3 | |
2069 | 6760 //int v23; // edi@23 |
0 | 6761 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 |
6762 | |
6763 if ( this->uNumSceneBegins && pTexture ) | |
6764 { | |
2069 | 6765 /*auto v7 = this->pTargetSurface; |
6766 if (FORCE_16_BITS) | |
6767 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2); | |
6768 else | |
6769 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/ | |
1675 | 6770 full_width = pTexture->uWidth - move_X; |
6771 full_height = pTexture->uHeight - move_Y; | |
6772 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth]; | |
6773 if ( this->bClip ) | |
6774 { | |
6775 if ( pX < this->uClipX )//если кадр выходит за правую границу | |
6776 { | |
6777 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX))); | |
6778 full_width += pX - this->uClipX; | |
2069 | 6779 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX))); |
1675 | 6780 } |
6781 if ( pY < this->uClipY )//если кадр выходит за верхнюю границу | |
6782 { | |
6783 pTexturea += pTexture->uWidth * (this->uClipY - pY); | |
6784 full_height += pY - this->uClipY; | |
2069 | 6785 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY)); |
1675 | 6786 } |
6787 if ( this->uClipX < pX )//если правая граница окна меньше х координаты кадра | |
6788 this->uClipX = pX; | |
6789 if ( this->uClipY < pY )//если верхняя граница окна меньше y координаты кадра | |
6790 this->uClipY = pY; | |
6791 if ( (full_width + this->uClipX) > this->uClipZ )//если ширина кадра выходит за правую границу | |
6792 { | |
6793 if ( this->uClipX < pX ) | |
6794 this->uClipX = pX; | |
6795 full_width = this->uClipZ - this->uClipX; | |
6796 } | |
6797 if ( (full_height + this->uClipY) > this->uClipW )//если высота кадра выходит за нижнюю границу | |
6798 { | |
6799 if ( this->uClipY < pY ) | |
6800 this->uClipY = pY; | |
6801 full_height = this->uClipW - this->uClipY; | |
6802 } | |
6803 } | |
2069 | 6804 |
6805 for (int y = 0; y < full_height; ++y) | |
6806 { | |
6807 for (int x = 0; x < full_width; ++x) | |
6808 { | |
6809 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) ) | |
6810 { | |
6811 WritePixel16(pX + x, pY + y, *pTexturea); | |
6812 /*if (FORCE_16_BITS) | |
6813 *(unsigned __int16 *)v7 = *pTexturea; | |
6814 else | |
6815 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/ | |
6816 } | |
0 | 6817 ++pTexturea; |
2069 | 6818 //++v7; |
0 | 6819 } |
2069 | 6820 //v7 += this->uTargetSurfacePitch - full_width; |
1675 | 6821 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width)); |
2069 | 6822 } |
0 | 6823 } |
6824 } | |
6825 | |
6826 //----- (004A6E7E) -------------------------------------------------------- | |
6827 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
6828 { | |
2069 | 6829 //unsigned __int16 *v4; // eax@4 |
0 | 6830 int v5; // edx@4 |
6831 unsigned int v6; // edi@4 | |
6832 unsigned int v7; // edx@5 | |
6833 unsigned int v8; // edx@6 | |
6834 unsigned int v9; // edx@7 | |
6835 unsigned int v10; // edx@8 | |
6836 unsigned int v11; // ebx@9 | |
6837 unsigned int v12; // esi@11 | |
6838 unsigned int v13; // edx@12 | |
6839 unsigned int v14; // ebx@15 | |
6840 unsigned int v15; // esi@17 | |
6841 unsigned int v16; // edi@18 | |
6842 char v17; // zf@29 | |
6843 int v18; // [sp+14h] [bp-Ch]@4 | |
6844 int v19; // [sp+18h] [bp-8h]@4 | |
6845 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
6846 int v21; // [sp+28h] [bp+8h]@25 | |
6847 int v22; // [sp+28h] [bp+8h]@34 | |
6848 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
6849 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
6850 | |
6851 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
6852 { | |
2069 | 6853 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
710 | 6854 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 6855 v5 = a4->uTextureWidth; |
6856 v6 = a4->uTextureHeight; | |
6857 v19 = a4->uTextureWidth; | |
6858 v18 = a4->uTextureWidth; | |
2069 | 6859 int clipped_out_x = a2; |
6860 int clipped_out_y = a3; | |
0 | 6861 if ( this->bClip ) |
6862 { | |
6863 v7 = this->uClipX; | |
6864 if ( (signed int)a2 < (signed int)v7 ) | |
6865 { | |
6866 v8 = v7 - a2; | |
6867 v20 += v8; | |
6868 v19 += a2 - this->uClipX; | |
2069 | 6869 //v4 += v8; |
6870 clipped_out_x = uClipX; | |
0 | 6871 } |
6872 v9 = this->uClipY; | |
6873 if ( (signed int)a3 < (signed int)v9 ) | |
6874 { | |
6875 v10 = v9 - a3; | |
6876 v20 += v18 * v10; | |
6877 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
2069 | 6878 //v4 += this->uTargetSurfacePitch * v10; |
6879 clipped_out_y = uClipY; | |
0 | 6880 } |
6881 v11 = this->uClipX; | |
6882 v5 = v19; | |
6883 if ( (signed int)v11 < (signed int)a2 ) | |
6884 v11 = a2; | |
6885 v12 = this->uClipZ; | |
6886 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
6887 { | |
6888 v13 = this->uClipX; | |
6889 if ( (signed int)v13 < (signed int)a2 ) | |
6890 v13 = a2; | |
6891 v5 = v12 - v13; | |
6892 } | |
6893 v14 = this->uClipY; | |
6894 if ( (signed int)v14 < (signed int)a3 ) | |
6895 v14 = a3; | |
6896 v15 = this->uClipW; | |
6897 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
6898 { | |
6899 v16 = this->uClipY; | |
6900 if ( (signed int)v16 < (signed int)a3 ) | |
6901 v16 = a3; | |
6902 v6 = v15 - v16; | |
6903 } | |
6904 } | |
2069 | 6905 |
6906 for (int y = 0; y < v6; ++y) | |
6907 { | |
6908 for (int x = 0; x < v5; ++x) | |
6909 { | |
6910 if ( *v20 ) | |
6911 WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF); | |
6912 ++v20; | |
6913 } | |
6914 v20 += v18 - v5; | |
6915 } | |
6916 | |
6917 /*if ( pRenderer->uTargetGBits == 5 ) | |
0 | 6918 { |
6919 if ( (signed int)v6 > 0 ) | |
6920 { | |
6921 v23 = v6; | |
6922 do | |
6923 { | |
6924 if ( v5 > 0 ) | |
6925 { | |
6926 v21 = v5; | |
6927 do | |
6928 { | |
6929 if ( *v20 ) | |
6930 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
6931 ++v4; | |
6932 ++v20; | |
6933 --v21; | |
6934 } | |
6935 while ( v21 ); | |
6936 } | |
6937 v20 += v18 - v5; | |
6938 v17 = v23-- == 1; | |
6939 v4 += this->uTargetSurfacePitch - v5; | |
6940 } | |
6941 while ( !v17 ); | |
6942 } | |
6943 } | |
6944 else | |
6945 { | |
6946 if ( (signed int)v6 > 0 ) | |
6947 { | |
6948 v24 = v6; | |
6949 do | |
6950 { | |
6951 if ( v5 > 0 ) | |
6952 { | |
6953 v22 = v5; | |
6954 do | |
6955 { | |
6956 if ( *v20 ) | |
6957 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
6958 ++v4; | |
6959 ++v20; | |
6960 --v22; | |
6961 } | |
6962 while ( v22 ); | |
6963 } | |
6964 v20 += v18 - v5; | |
6965 v17 = v24-- == 1; | |
6966 v4 += this->uTargetSurfacePitch - v5; | |
6967 } | |
6968 while ( !v17 ); | |
6969 } | |
2069 | 6970 }*/ |
0 | 6971 } |
6972 } | |
6973 | |
6974 //----- (004A6DF5) -------------------------------------------------------- | |
2069 | 6975 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) |
0 | 6976 { |
6977 int v8; // ecx@3 | |
6978 unsigned __int16 *v10; // ebx@4 | |
6979 int v11; // esi@4 | |
6980 | |
2069 | 6981 if ( !pBitmap || !pTarget) |
6982 return; | |
6983 | |
2093 | 6984 v8 = a7->z - a7->x; |
6985 v11 = a7->w - a7->y; | |
6986 v10 = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; | |
6987 for ( int y = 0; y < v11; ++y ) | |
6988 { | |
6989 for ( int x = 0; x < v8; ++x ) | |
6990 { | |
6991 WritePixel16(a7->x + x, a7->y + y, *v10); | |
6992 ++v10; | |
6993 } | |
6994 v10 += uTargetPitch - v8; | |
6995 } | |
0 | 6996 } |
6997 | |
6998 //----- (004A6D87) -------------------------------------------------------- | |
6999 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
7000 { | |
7001 if (!uNumSceneBegins) | |
7002 return; | |
7003 | |
7004 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
7005 for (uint y = 0; y < uHeight; ++y) | |
7006 { | |
2069 | 7007 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch); |
7008 | |
7009 memset32(pDst, | |
2098 | 7010 FORCE_16_BITS ? twoColors : 0xFF000000 | Color32(uColor16), // two colors per int (16bit) or 1 (32bit) |
2069 | 7011 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit) |
7012 | |
7013 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit | |
7014 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16; | |
0 | 7015 } |
7016 } | |
7017 | |
7018 //----- (004A6C4F) -------------------------------------------------------- | |
2073 | 7019 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, |
7020 unsigned int uCharHeight, unsigned __int16 *pFontPalette, | |
7021 unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
0 | 7022 { |
7023 unsigned int v9; // edi@2 | |
7024 unsigned int v10; // esi@2 | |
2069 | 7025 //unsigned __int16 *v11; // eax@2 |
0 | 7026 unsigned int v12; // ebx@3 |
7027 signed int v13; // edx@5 | |
7028 int v14; // edx@6 | |
7029 signed int v15; // ebx@7 | |
7030 unsigned int v16; // edx@9 | |
7031 signed int v17; // edi@10 | |
7032 signed int v18; // ebx@13 | |
7033 unsigned int v19; // edx@15 | |
7034 signed int v20; // esi@16 | |
2069 | 7035 //unsigned int v21; // esi@22 |
0 | 7036 unsigned __int16 v22; // dx@24 |
2069 | 7037 //char v23; // zf@28 |
0 | 7038 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 |
2069 | 7039 //unsigned int uOutXa; // [sp+18h] [bp+8h]@20 |
7040 | |
7041 if (!this->uNumSceneBegins) | |
7042 return; | |
7043 | |
0 | 7044 v9 = uCharWidth; |
7045 v10 = uCharHeight; | |
2069 | 7046 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 7047 v24 = pFontPixels; |
2069 | 7048 |
7049 int clipped_out_x = uOutX, clipped_out_y = uOutY; | |
0 | 7050 if ( this->bClip ) |
7051 { | |
7052 v12 = this->uClipX; | |
7053 if ( uOutX < (signed int)v12 ) | |
7054 { | |
7055 v24 = &pFontPixels[v12 - uOutX]; | |
2069 | 7056 //v11 += v12 - uOutX; |
7057 clipped_out_x = uClipX; | |
0 | 7058 v9 = uCharWidth + uOutX - v12; |
7059 } | |
7060 v13 = this->uClipY; | |
7061 if ( uOutY < v13 ) | |
7062 { | |
7063 v14 = v13 - uOutY; | |
7064 v24 += uCharWidth * v14; | |
7065 v10 = uCharHeight + uOutY - this->uClipY; | |
2069 | 7066 //v11 += this->uTargetSurfacePitch * v14; |
7067 clipped_out_y = uClipY; | |
0 | 7068 } |
7069 v15 = this->uClipX; | |
7070 if ( v15 < uOutX ) | |
7071 v15 = uOutX; | |
7072 v16 = this->uClipZ; | |
7073 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
7074 { | |
7075 v17 = this->uClipX; | |
7076 if ( v17 < uOutX ) | |
7077 v17 = uOutX; | |
7078 v9 = v16 - v17; | |
7079 } | |
7080 v18 = this->uClipY; | |
7081 if ( v18 < uOutY ) | |
7082 v18 = uOutY; | |
7083 v19 = this->uClipW; | |
7084 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
7085 { | |
7086 v20 = this->uClipY; | |
7087 if ( v20 < uOutY ) | |
7088 v20 = uOutY; | |
7089 v10 = v19 - v20; | |
7090 } | |
7091 } | |
2069 | 7092 |
7093 for (int y = 0; y < v10; ++y) | |
7094 { | |
7095 for (int x = 0; x < v9; ++x) | |
7096 { | |
7097 if (*v24) | |
0 | 7098 { |
2069 | 7099 v22 = uShadowColor; |
7100 if ( *v24 != 1 ) | |
7101 v22 = uFaceColor; | |
2073 | 7102 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22); |
0 | 7103 } |
2073 | 7104 ++v24; |
7105 } | |
7106 v24 += uCharWidth - v9; | |
2069 | 7107 //v23 = uOutXa-- == 1; |
7108 //v11 += this->uTargetSurfacePitch - v9; | |
7109 } | |
0 | 7110 } |
7111 | |
7112 //----- (004A6A68) -------------------------------------------------------- | |
1496 | 7113 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) |
7114 { | |
0 | 7115 Texture tex; // [sp+Ch] [bp-48h]@1 |
1496 | 7116 |
0 | 7117 memcpy(&tex, a4, sizeof(tex)); |
1496 | 7118 tex.uTextureHeight = a4->uTextureHeight - height; |
7119 if ( (signed __int16)tex.uTextureHeight > 0 ) | |
0 | 7120 DrawTextureIndexed(a2, a3, &tex); |
7121 } | |
7122 | |
7123 //----- (004A6AB1) -------------------------------------------------------- | |
1268 | 7124 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
7125 { | |
0 | 7126 int v8; // edi@2 |
7127 unsigned int v9; // esi@2 | |
2069 | 7128 //unsigned __int16 *v10; // eax@2 |
0 | 7129 unsigned char *v11; // edx@2 |
7130 unsigned int v12; // ebx@3 | |
7131 signed int v13; // edx@5 | |
7132 int v14; // edx@6 | |
7133 signed int v15; // ebx@7 | |
7134 unsigned int v16; // edx@9 | |
7135 signed int v17; // edi@10 | |
7136 signed int v18; // ebx@13 | |
7137 unsigned int v19; // edx@15 | |
7138 signed int v20; // esi@16 | |
7139 int v21; // ebx@22 | |
7140 char v22; // zf@28 | |
7141 int v23; // ebx@31 | |
7142 unsigned __int16 v24; // si@35 | |
7143 int v25; // [sp+Ch] [bp-4h]@2 | |
7144 int v26; // [sp+1Ch] [bp+Ch]@24 | |
7145 int v27; // [sp+1Ch] [bp+Ch]@33 | |
7146 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
7147 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
7148 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
7149 | |
1980 | 7150 int a2 = x; |
7151 int a3 = y; | |
7152 uint a6 = uFontHeight; | |
2069 | 7153 if (!this->uNumSceneBegins) |
7154 return; | |
7155 | |
0 | 7156 v8 = a5; |
7157 v9 = a6; | |
2069 | 7158 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; |
1268 | 7159 v11 = (unsigned char *)font_pixels; |
7160 v25 = (int)font_pixels; | |
2069 | 7161 int clipped_out_x = x; |
7162 int clipped_out_y = y; | |
0 | 7163 if ( this->bClip ) |
7164 { | |
7165 v12 = this->uClipX; | |
7166 if ( a2 < (signed int)v12 ) | |
7167 { | |
1268 | 7168 v25 = v12 - a2 + (int)font_pixels; |
2069 | 7169 //v10 += v12 - a2; |
0 | 7170 v8 = a5 + a2 - v12; |
2069 | 7171 clipped_out_x = uClipX; |
0 | 7172 } |
7173 v13 = this->uClipY; | |
7174 if ( a3 < v13 ) | |
7175 { | |
7176 v14 = v13 - a3; | |
7177 v25 += a5 * v14; | |
7178 v9 = a6 + a3 - this->uClipY; | |
2069 | 7179 //v10 += this->uTargetSurfacePitch * v14; |
7180 clipped_out_y = uClipY; | |
0 | 7181 } |
7182 v15 = this->uClipX; | |
7183 if ( v15 < a2 ) | |
7184 v15 = a2; | |
7185 v16 = this->uClipZ; | |
7186 if ( v8 + v15 > (signed int)v16 ) | |
7187 { | |
7188 v17 = this->uClipX; | |
7189 if ( v17 < a2 ) | |
7190 v17 = a2; | |
7191 v8 = v16 - v17; | |
7192 } | |
7193 v18 = this->uClipY; | |
7194 if ( v18 < a3 ) | |
7195 v18 = a3; | |
7196 v19 = this->uClipW; | |
7197 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
7198 { | |
7199 v20 = this->uClipY; | |
7200 if ( v20 < a3 ) | |
7201 v20 = a3; | |
7202 v9 = v19 - v20; | |
7203 } | |
7204 v11 = (unsigned char *)v25; | |
7205 } | |
2069 | 7206 |
0 | 7207 if ( a8 ) |
7208 { | |
2069 | 7209 v28 = 0x7FF; // 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask; |
7210 for (int dy = 0; dy < v9; ++dy) | |
7211 { | |
7212 for (int dx = 0; dx < v8; ++dx) | |
7213 { | |
7214 if ( *v11 ) | |
7215 v24 = pPalette[*v11]; | |
7216 else | |
7217 v24 = v28; | |
7218 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24); | |
7219 //*v10 = v24; | |
7220 //++v10; | |
2074 | 7221 ++v11; |
2069 | 7222 //--v27; |
2074 | 7223 |
2069 | 7224 } |
7225 v11 += a5 - v8; | |
7226 } | |
7227 /*if ( (signed int)v9 > 0 ) | |
0 | 7228 { |
7229 v23 = a5; | |
7230 v30 = v9; | |
7231 do | |
7232 { | |
7233 if ( v8 > 0 ) | |
7234 { | |
7235 v27 = v8; | |
7236 do | |
7237 { | |
7238 if ( *v11 ) | |
7239 v24 = pPalette[*v11]; | |
7240 else | |
7241 v24 = v28; | |
7242 *v10 = v24; | |
7243 ++v10; | |
7244 ++v11; | |
7245 --v27; | |
7246 } | |
7247 while ( v27 ); | |
7248 } | |
7249 v11 += v23 - v8; | |
7250 v22 = v30-- == 1; | |
7251 v10 += this->uTargetSurfacePitch - v8; | |
7252 } | |
7253 while ( !v22 ); | |
2069 | 7254 }*/ |
0 | 7255 } |
7256 else | |
7257 { | |
2069 | 7258 for (int dy = 0; dy < v9; ++dy) |
7259 { | |
7260 for (int dx = 0; dx < v8; ++dx) | |
7261 { | |
2074 | 7262 if ( *v11 ) |
2069 | 7263 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]); |
7264 //*v10 = v24; | |
7265 //++v10; | |
2074 | 7266 ++v11; |
2069 | 7267 //--v27; |
7268 } | |
7269 v11 += a5 - v8; | |
7270 } | |
7271 | |
7272 /*if ( (signed int)v9 > 0 ) | |
0 | 7273 { |
7274 v21 = a5; | |
7275 v29 = v9; | |
7276 do | |
7277 { | |
7278 if ( v8 > 0 ) | |
7279 { | |
7280 v26 = v8; | |
7281 do | |
7282 { | |
7283 if ( *v11 ) | |
7284 *v10 = pPalette[*v11]; | |
7285 ++v10; | |
7286 ++v11; | |
7287 --v26; | |
7288 } | |
7289 while ( v26 ); | |
7290 } | |
7291 v11 += v21 - v8; | |
7292 v22 = v29-- == 1; | |
7293 v10 += this->uTargetSurfacePitch - v8; | |
7294 } | |
7295 while ( !v22 ); | |
2069 | 7296 }*/ |
7297 } | |
0 | 7298 } |
7299 | |
7300 //----- (004A68EF) -------------------------------------------------------- | |
7301 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
7302 { | |
2069 | 7303 DrawMasked(a2, a3, pTexture, 0x07E0); |
7304 } | |
7305 | |
0 | 7306 |
7307 //----- (004A6776) -------------------------------------------------------- | |
315 | 7308 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 7309 { |
2069 | 7310 DrawMasked(a2, a3, a4, 0xF800); |
7311 /*Texture *v4; // edi@2 | |
0 | 7312 unsigned int v5; // ebx@4 |
7313 unsigned __int16 *v6; // eax@4 | |
7314 unsigned int v7; // edx@5 | |
7315 unsigned int v8; // edx@6 | |
7316 unsigned int v9; // edx@7 | |
7317 unsigned int v10; // edx@8 | |
7318 unsigned int v11; // edx@9 | |
7319 unsigned int v12; // esi@12 | |
7320 unsigned int v13; // esi@15 | |
7321 unsigned int v14; // edx@17 | |
7322 unsigned int v15; // esi@18 | |
7323 unsigned __int8 *v16; // ebx@22 | |
7324 char v17; // zf@28 | |
7325 int v18; // [sp+10h] [bp-10h]@4 | |
7326 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7327 int v20; // [sp+1Ch] [bp-4h]@4 | |
7328 int a2a; // [sp+28h] [bp+8h]@24 | |
7329 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
7330 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
7331 | |
7332 if ( this->uNumSceneBegins ) | |
7333 { | |
7334 v4 = a4; | |
7335 if ( a4 ) | |
7336 { | |
7337 if ( a4->pPalette16 ) | |
7338 { | |
7339 v5 = a4->uTextureHeight; | |
7340 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7341 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7342 v20 = a4->uTextureWidth; |
7343 v18 = a4->uTextureWidth; | |
7344 if ( this->bClip ) | |
7345 { | |
7346 v7 = this->uClipX; | |
7347 if ( (signed int)a2 < (signed int)v7 ) | |
7348 { | |
7349 v8 = v7 - a2; | |
7350 v19 += v8; | |
7351 v20 += a2 - this->uClipX; | |
7352 v6 += v8; | |
7353 } | |
7354 v9 = this->uClipY; | |
7355 v5 = a4->uTextureHeight; | |
7356 if ( (signed int)a3 < (signed int)v9 ) | |
7357 { | |
7358 v10 = v9 - a3; | |
7359 v19 += v18 * v10; | |
7360 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
7361 v4 = a4; | |
7362 v6 += this->uTargetSurfacePitch * v10; | |
7363 } | |
7364 v11 = this->uClipX; | |
7365 if ( (signed int)v11 < (signed int)a2 ) | |
7366 v11 = a2; | |
7367 a4a = this->uClipZ; | |
7368 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
7369 { | |
7370 v12 = this->uClipX; | |
7371 if ( (signed int)v12 < (signed int)a2 ) | |
7372 v12 = a2; | |
7373 v20 = a4a - v12; | |
7374 } | |
7375 v13 = this->uClipY; | |
7376 if ( (signed int)v13 < (signed int)a3 ) | |
7377 v13 = a3; | |
7378 v14 = this->uClipW; | |
7379 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7380 { | |
7381 v15 = this->uClipY; | |
7382 if ( (signed int)v15 < (signed int)a3 ) | |
7383 v15 = a3; | |
7384 v5 = v14 - v15; | |
7385 } | |
7386 } | |
7387 if ( (signed int)v5 > 0 ) | |
7388 { | |
7389 a3a = v5; | |
7390 v16 = v19; | |
7391 do | |
7392 { | |
7393 if ( v20 > 0 ) | |
7394 { | |
7395 a2a = v20; | |
7396 do | |
7397 { | |
7398 if ( *v16 ) | |
7399 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
7400 ++v6; | |
7401 ++v16; | |
7402 --a2a; | |
7403 } | |
7404 while ( a2a ); | |
7405 } | |
7406 v16 += v18 - v20; | |
7407 v17 = a3a-- == 1; | |
7408 v6 += this->uTargetSurfacePitch - v20; | |
7409 } | |
7410 while ( !v17 ); | |
7411 } | |
7412 } | |
7413 } | |
2069 | 7414 }*/ |
7415 } | |
7416 | |
7417 //----- (004A68EF) -------------------------------------------------------- | |
7418 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask) | |
7419 { | |
7420 Texture *v4; // edi@2 | |
7421 unsigned int v5; // ebx@4 | |
7422 //unsigned __int16 *v6; // eax@4 | |
7423 signed int v7; // edx@5 | |
7424 int v8; // edx@6 | |
7425 signed int v9; // edx@7 | |
7426 int v10; // edx@8 | |
7427 signed int v11; // edx@9 | |
7428 signed int v12; // esi@12 | |
7429 signed int v13; // esi@15 | |
7430 unsigned int v14; // edx@17 | |
7431 signed int v15; // esi@18 | |
7432 unsigned __int8 *v16; // ebx@22 | |
7433 char v17; // zf@28 | |
7434 int v18; // [sp+10h] [bp-10h]@4 | |
7435 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7436 int v20; // [sp+1Ch] [bp-4h]@4 | |
7437 int v21; // [sp+28h] [bp+8h]@24 | |
7438 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
7439 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7440 | |
7441 if (!uNumSceneBegins || !pTexture) | |
7442 return; | |
7443 | |
7444 v4 = pTexture; | |
7445 | |
7446 if ( pTexture->pPalette16 ) | |
7447 { | |
7448 v5 = pTexture->uTextureHeight; | |
7449 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
7450 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; | |
7451 v20 = pTexture->uTextureWidth; | |
7452 v18 = pTexture->uTextureWidth; | |
7453 int clipped_out_x = a2; | |
7454 int clipped_out_y = a3; | |
7455 if ( this->bClip ) | |
7456 { | |
7457 v7 = this->uClipX; | |
7458 if ( a2 < v7 ) | |
7459 { | |
7460 v8 = v7 - a2; | |
7461 v19 += v8; | |
7462 v20 += a2 - this->uClipX; | |
7463 //v6 += v8; | |
7464 clipped_out_x = uClipX; | |
7465 } | |
7466 v9 = this->uClipY; | |
7467 v5 = pTexture->uTextureHeight; | |
7468 if ( a3 < v9 ) | |
7469 { | |
7470 v10 = v9 - a3; | |
7471 v19 += v18 * v10; | |
7472 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7473 v4 = pTexture; | |
7474 //v6 += this->uTargetSurfacePitch * v10; | |
7475 clipped_out_y = uClipY; | |
7476 } | |
7477 v11 = this->uClipX; | |
7478 if ( v11 < a2 ) | |
7479 v11 = a2; | |
7480 pTexturea = this->uClipZ; | |
7481 if ( v11 + v20 > (signed int)pTexturea ) | |
7482 { | |
7483 v12 = this->uClipX; | |
7484 if ( v12 < a2 ) | |
7485 v12 = a2; | |
7486 v20 = pTexturea - v12; | |
7487 } | |
7488 v13 = this->uClipY; | |
7489 if ( v13 < a3 ) | |
7490 v13 = a3; | |
7491 v14 = this->uClipW; | |
7492 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7493 { | |
7494 v15 = this->uClipY; | |
7495 if ( v15 < a3 ) | |
7496 v15 = a3; | |
7497 v5 = v14 - v15; | |
7498 } | |
7499 } | |
7500 | |
7501 v16 = v19; | |
7502 for (int y = 0; y < v5; ++y) | |
7503 { | |
7504 for (int x = 0; x < v20; ++x) | |
7505 { | |
7506 if ( *v16 ) | |
7507 WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16] & mask); | |
7508 ++v16; | |
7509 } | |
7510 v16 += v18 - v20; | |
7511 } | |
7512 | |
7513 /*if ( (signed int)v5 > 0 ) | |
7514 { | |
7515 v22 = v5; | |
7516 v16 = v19; | |
7517 do | |
7518 { | |
7519 if ( v20 > 0 ) | |
7520 { | |
7521 v21 = v20; | |
7522 do | |
7523 { | |
7524 if ( *v16 ) | |
7525 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7526 ++v6; | |
7527 ++v16; | |
7528 --v21; | |
7529 } | |
7530 while ( v21 ); | |
7531 } | |
7532 v16 += v18 - v20; | |
7533 v17 = v22-- == 1; | |
7534 v6 += this->uTargetSurfacePitch - v20; | |
7535 } | |
7536 while ( !v17 ); | |
7537 }*/ | |
7538 } | |
7539 } | |
7540 | |
0 | 7541 |
7542 //----- (004A65CC) -------------------------------------------------------- | |
7543 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
7544 { | |
2069 | 7545 //unsigned __int16 *v8; // esi@6 |
0 | 7546 unsigned int v9; // edi@6 |
7547 unsigned int v10; // eax@7 | |
7548 unsigned int v11; // eax@8 | |
7549 unsigned int v12; // eax@9 | |
7550 unsigned int v13; // eax@10 | |
7551 unsigned int v14; // edx@11 | |
7552 unsigned int v15; // eax@13 | |
7553 unsigned int v16; // edx@14 | |
7554 unsigned int v17; // edx@17 | |
7555 unsigned int v18; // eax@19 | |
7556 unsigned int v19; // edx@20 | |
7557 int v20; // eax@27 | |
7558 int v21; // edx@29 | |
7559 int v22; // [sp+Ch] [bp-Ch]@6 | |
7560 int v23; // [sp+Ch] [bp-Ch]@24 | |
7561 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
7562 int xa; // [sp+20h] [bp+8h]@26 | |
7563 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
7564 int v27; // [sp+2Ch] [bp+14h]@6 | |
7565 | |
7566 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
7567 { | |
2069 | 7568 //v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; |
710 | 7569 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7570 v27 = a4->uTextureWidth; |
7571 v9 = a4->uTextureHeight; | |
7572 v22 = a4->uTextureWidth; | |
2069 | 7573 int clipped_out_x = x; |
7574 int clipped_out_y = y; | |
0 | 7575 if ( this->bClip ) |
7576 { | |
7577 v10 = this->uClipX; | |
7578 if ( (signed int)x < (signed int)v10 ) | |
7579 { | |
7580 v11 = v10 - x; | |
7581 v24 += v11; | |
7582 v27 += x - this->uClipX; | |
2069 | 7583 //v8 += v11; |
7584 clipped_out_x = uClipX; | |
0 | 7585 } |
7586 v12 = this->uClipY; | |
7587 if ( (signed int)y < (signed int)v12 ) | |
7588 { | |
7589 v13 = v12 - y; | |
7590 v24 += v22 * v13; | |
7591 v9 = y - this->uClipY + a4->uTextureHeight; | |
2069 | 7592 //v8 += this->uTargetSurfacePitch * v13; |
7593 clipped_out_y = uClipY; | |
0 | 7594 } |
7595 v14 = this->uClipX; | |
7596 if ( (signed int)v14 < (signed int)x ) | |
7597 v14 = x; | |
7598 v15 = this->uClipZ; | |
7599 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
7600 { | |
7601 v16 = this->uClipX; | |
7602 if ( (signed int)v16 < (signed int)x ) | |
7603 v16 = x; | |
7604 v27 = v15 - v16; | |
7605 } | |
7606 v17 = this->uClipY; | |
7607 if ( (signed int)v17 < (signed int)y ) | |
7608 v17 = y; | |
7609 v18 = this->uClipW; | |
7610 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
7611 { | |
7612 v19 = this->uClipY; | |
7613 if ( (signed int)v19 < (signed int)y ) | |
7614 v19 = y; | |
7615 v9 = v18 - v19; | |
7616 } | |
7617 } | |
2069 | 7618 |
7619 for (int dy = 0; dy < v9; ++dy) | |
7620 { | |
7621 for (int dx = 0; dx < v27; ++dx) | |
7622 { | |
7623 v20 = *v24; | |
7624 if ( v20 >= a7 && v20 <= a8 ) | |
7625 { | |
7626 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7627 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7628 v21 = 2 * a8 - v21 - a7; | |
7629 //*v8 = a4->pPalette16[v21]; | |
7630 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]); | |
7631 } | |
7632 ++v24; | |
7633 } | |
7634 v24 += v22 - v27; | |
7635 } | |
7636 /*if ( (signed int)v9 > 0 ) | |
0 | 7637 { |
7638 ya = v9; | |
7639 v23 = v22 - v27; | |
7640 do | |
7641 { | |
7642 if ( v27 > 0 ) | |
7643 { | |
7644 xa = v27; | |
7645 do | |
7646 { | |
7647 v20 = *v24; | |
7648 if ( v20 >= a7 && v20 <= a8 ) | |
7649 { | |
7650 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7651 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7652 v21 = 2 * a8 - v21 - a7; | |
7653 *v8 = a4->pPalette16[v21]; | |
7654 } | |
7655 ++v8; | |
7656 ++v24; | |
7657 --xa; | |
7658 } | |
7659 while ( xa ); | |
7660 } | |
7661 v8 += this->uTargetSurfacePitch - v27; | |
7662 v24 += v23; | |
7663 --ya; | |
7664 } | |
7665 while ( ya ); | |
2069 | 7666 }*/ |
0 | 7667 } |
7668 } | |
7669 | |
7670 //----- (004A63E6) -------------------------------------------------------- | |
1455 | 7671 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) |
0 | 7672 { |
7673 Texture *v8; // eax@2 | |
2069 | 7674 //Texture *v9; // ebx@4 |
7675 //unsigned __int16 *v10; // esi@6 | |
0 | 7676 unsigned int v11; // edi@7 |
7677 unsigned int v12; // eax@9 | |
7678 unsigned int v13; // eax@10 | |
7679 unsigned int v14; // edx@11 | |
7680 unsigned int v15; // eax@13 | |
7681 unsigned int v16; // edx@14 | |
7682 unsigned int v17; // edx@17 | |
7683 unsigned int v18; // eax@19 | |
7684 unsigned int v19; // edx@20 | |
7685 int v20; // eax@27 | |
7686 int v21; // edx@29 | |
7687 int v22; // [sp+Ch] [bp-Ch]@6 | |
7688 int v23; // [sp+Ch] [bp-Ch]@24 | |
7689 int v24; // [sp+10h] [bp-8h]@6 | |
7690 int v25; // [sp+14h] [bp-4h]@6 | |
7691 int i; // [sp+20h] [bp+8h]@25 | |
7692 int v27; // [sp+24h] [bp+Ch]@23 | |
7693 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
7694 | |
7695 if ( this->uNumSceneBegins ) | |
7696 { | |
7697 v8 = a4; | |
7698 if ( a4 ) | |
7699 { | |
7700 if ( a4->pPalette16 ) | |
7701 { | |
7702 if ( a5 ) | |
7703 { | |
7704 if ( a5->pPalette16 ) | |
7705 { | |
2069 | 7706 //v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
710 | 7707 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7708 v25 = v8->uTextureWidth; |
7709 v24 = v8->uTextureHeight; | |
7710 v22 = v8->uTextureWidth; | |
2069 | 7711 |
7712 int clipped_out_x = a2; | |
7713 int clipped_out_y = a3; | |
0 | 7714 if ( this->bClip ) |
7715 { | |
7716 v11 = this->uClipX; | |
7717 if ( (signed int)a2 < (signed int)v11 ) | |
7718 { | |
7719 v28 += v11 - a2; | |
7720 v25 += a2 - v11; | |
2069 | 7721 //v10 += v11 - a2; |
7722 clipped_out_x = uClipX; | |
0 | 7723 } |
7724 v12 = this->uClipY; | |
7725 if ( (signed int)a3 < (signed int)v12 ) | |
7726 { | |
7727 v13 = v12 - a3; | |
7728 v28 += v22 * v13; | |
7729 v24 += a3 - this->uClipY; | |
2069 | 7730 //v10 += this->uTargetSurfacePitch * v13; |
7731 clipped_out_y = uClipY; | |
0 | 7732 } |
7733 v14 = this->uClipX; | |
7734 if ( (signed int)v14 < (signed int)a2 ) | |
7735 v14 = a2; | |
7736 v15 = this->uClipZ; | |
7737 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
7738 { | |
7739 v16 = this->uClipX; | |
7740 if ( (signed int)v16 < (signed int)a2 ) | |
7741 v16 = a2; | |
7742 v25 = v15 - v16; | |
7743 } | |
7744 v17 = this->uClipY; | |
7745 if ( (signed int)v17 < (signed int)a3 ) | |
7746 v17 = a3; | |
7747 v18 = this->uClipW; | |
7748 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
7749 { | |
7750 v19 = this->uClipY; | |
7751 if ( (signed int)v19 < (signed int)a3 ) | |
7752 v19 = a3; | |
7753 v24 = v18 - v19; | |
7754 } | |
7755 } | |
2069 | 7756 |
0 | 7757 v27 = 0; |
2069 | 7758 for (int y = 0; y < v24; ++y) |
7759 { | |
7760 for (int x = 0; x < v25; ++x) | |
7761 { | |
7762 if ( *v28 ) | |
7763 { | |
2101 | 7764 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); |
2069 | 7765 if ( v20 >= a7 ) |
7766 { | |
7767 if ( v20 <= a8 ) | |
7768 { | |
7769 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7770 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7771 v21 = 2 * a8 - v21 - a7; | |
7772 //v9 = a5; | |
7773 //*v10 = a5->pPalette16[v21]; | |
7774 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]); | |
7775 } | |
7776 } | |
7777 } | |
7778 v28++; | |
7779 } | |
7780 v28 += v22 - v25; | |
7781 } | |
7782 | |
7783 /*if ( v24 > 0 ) | |
0 | 7784 { |
7785 v23 = v22 - v25; | |
7786 do | |
7787 { | |
7788 for ( i = 0; i < v25; ++v28 ) | |
7789 { | |
7790 if ( *v28 ) | |
7791 { | |
710 | 7792 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 7793 if ( v20 >= a7 ) |
7794 { | |
7795 if ( v20 <= a8 ) | |
7796 { | |
7797 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7798 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7799 v21 = 2 * a8 - v21 - a7; | |
7800 v9 = a5; | |
7801 *v10 = a5->pPalette16[v21]; | |
7802 } | |
7803 } | |
7804 } | |
7805 ++i; | |
7806 ++v10; | |
7807 } | |
7808 ++v27; | |
7809 v10 += this->uTargetSurfacePitch - v25; | |
7810 v28 += v23; | |
7811 } | |
7812 while ( v27 < v24 ); | |
2069 | 7813 }*/ |
7814 | |
7815 | |
7816 | |
0 | 7817 } |
7818 } | |
7819 } | |
7820 } | |
7821 } | |
7822 } | |
7823 | |
7824 //----- (004A6274) -------------------------------------------------------- | |
7825 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
7826 { | |
7827 Texture *pCurrentTexture; // edi@2 | |
7828 int uHeight; // ebx@4 | |
2069 | 7829 //unsigned __int16 *v6; // eax@4 |
0 | 7830 unsigned int v7; // edx@5 |
7831 unsigned int v8; // edx@6 | |
7832 unsigned int v9; // edx@7 | |
7833 unsigned int v10; // edx@8 | |
7834 unsigned int v11; // edx@9 | |
7835 unsigned int v12; // esi@12 | |
7836 unsigned int v13; // esi@15 | |
7837 unsigned int v14; // edx@17 | |
7838 unsigned int v15; // esi@18 | |
7839 unsigned __int8 *v16; // ebx@22 | |
7840 char uFlag; // zf@28 | |
7841 int v18; // [sp+10h] [bp-10h]@4 | |
7842 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7843 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
7844 int uXa; // [sp+28h] [bp+8h]@24 | |
7845 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
7846 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7847 | |
7848 if ( this->uNumSceneBegins ) | |
7849 { | |
7850 pCurrentTexture = pTexture; | |
7851 if ( pTexture ) | |
7852 { | |
7853 if ( pTexture->pPalette16 ) | |
7854 { | |
7855 uHeight = pTexture->uTextureHeight; | |
2069 | 7856 //v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
710 | 7857 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7858 uWidth = pTexture->uTextureWidth; |
7859 v18 = pTexture->uTextureWidth; | |
2069 | 7860 |
7861 int clipped_out_x = uX; | |
7862 int clipped_out_y = uY; | |
0 | 7863 if ( this->bClip ) |
7864 { | |
7865 v7 = this->uClipX; | |
7866 if ( (signed int)uX < (signed int)v7 ) | |
7867 { | |
7868 v8 = v7 - uX; | |
7869 v19 += v8; | |
7870 uWidth += uX - this->uClipX; | |
2069 | 7871 //v6 += v8; |
7872 clipped_out_x = uClipX; | |
0 | 7873 } |
7874 v9 = this->uClipY; | |
7875 uHeight = pTexture->uTextureHeight; | |
7876 if ( (signed int)uY < (signed int)v9 ) | |
7877 { | |
7878 v10 = v9 - uY; | |
7879 v19 += v18 * v10; | |
7880 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
7881 pCurrentTexture = pTexture; | |
2069 | 7882 //v6 += this->uTargetSurfacePitch * v10; |
7883 clipped_out_y = uClipY; | |
0 | 7884 } |
7885 v11 = this->uClipX; | |
7886 if ( (signed int)v11 < (signed int)uX ) | |
7887 v11 = uX; | |
7888 pTexturea = this->uClipZ; | |
7889 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
7890 { | |
7891 v12 = this->uClipX; | |
7892 if ( (signed int)v12 < (signed int)uX ) | |
7893 v12 = uX; | |
7894 uWidth = pTexturea - v12; | |
7895 } | |
7896 v13 = this->uClipY; | |
7897 if ( (signed int)v13 < (signed int)uY ) | |
7898 v13 = uY; | |
7899 v14 = this->uClipW; | |
7900 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
7901 { | |
7902 v15 = this->uClipY; | |
7903 if ( (signed int)v15 < (signed int)uY ) | |
7904 v15 = uY; | |
7905 uHeight = v14 - v15; | |
7906 } | |
7907 } | |
2069 | 7908 |
7909 v16 = v19; | |
7910 for (int y = 0; y < uHeight; ++y) | |
7911 { | |
7912 for (int x = 0; x < uWidth; ++x) | |
7913 { | |
7914 if ( *v16 ) | |
7915 WritePixel16(clipped_out_x + x, clipped_out_y + y, pCurrentTexture->pPalette16[*v16]); | |
7916 ++v16; | |
7917 } | |
7918 v16 += v18 - uWidth; | |
7919 } | |
7920 /*if ( (signed int)uHeight > 0 ) | |
0 | 7921 { |
7922 uYa = uHeight; | |
7923 v16 = v19; | |
7924 do | |
7925 { | |
7926 if ( uWidth > 0 ) | |
7927 { | |
7928 uXa = uWidth; | |
7929 do | |
7930 { | |
7931 if ( *v16 ) | |
7932 *v6 = pCurrentTexture->pPalette16[*v16]; | |
7933 ++v6; | |
7934 ++v16; | |
7935 } | |
7936 while ( uXa-- !=1 ); | |
7937 } | |
7938 v16 += v18 - uWidth; | |
7939 uFlag = uYa-- == 1; | |
7940 v6 += this->uTargetSurfacePitch - uWidth; | |
7941 } | |
7942 while ( !uFlag ); | |
2069 | 7943 }*/ |
0 | 7944 } |
7945 } | |
7946 } | |
7947 } | |
7948 | |
7949 //----- (004A612A) -------------------------------------------------------- | |
710 | 7950 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 7951 { |
7952 Texture *v5; // eax@2 | |
7953 unsigned int v6; // edx@3 | |
7954 int v7; // ebx@3 | |
7955 int v8; // edi@3 | |
7956 signed int v9; // eax@4 | |
7957 int v10; // eax@5 | |
7958 unsigned int v11; // esi@6 | |
7959 signed int v12; // esi@8 | |
7960 unsigned int v13; // eax@10 | |
7961 signed int v14; // esi@11 | |
7962 unsigned int v15; // esi@14 | |
7963 unsigned int v16; // eax@16 | |
7964 unsigned int v17; // ecx@17 | |
7965 int v18; // edx@23 | |
7966 int v19; // [sp+Ch] [bp-Ch]@3 | |
7967 int v20; // [sp+10h] [bp-8h]@3 | |
7968 int uOutXa; // [sp+20h] [bp+8h]@21 | |
7969 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
7970 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
7971 | |
7972 if ( this->uNumSceneBegins ) | |
7973 { | |
7974 v5 = pTexture; | |
7975 if ( pTexture ) | |
7976 { | |
7977 v6 = uOutY; | |
7978 v7 = pTexture->uTextureHeight; | |
7979 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
710 | 7980 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7981 v8 = v5->uTextureWidth; |
7982 v20 = v5->uTextureWidth; | |
7983 v19 = v5->uTextureWidth; | |
7984 if ( this->bClip ) | |
7985 { | |
7986 v9 = this->uClipX; | |
7987 if ( uOutX < v9 ) | |
7988 { | |
7989 v10 = v9 - uOutX; | |
7990 uOutYa += v10; | |
7991 v8 += uOutX - this->uClipX; | |
7992 v20 = v8; | |
7993 pZBuffer += v10; | |
7994 } | |
7995 v11 = this->uClipY; | |
7996 if ( (signed int)v6 < (signed int)v11 ) | |
7997 { | |
7998 uOutYa += v19 * (v11 - v6); | |
7999 v7 += v6 - v11; | |
8000 pZBuffer += 640 * (v11 - v6); | |
8001 v8 = v20; | |
8002 } | |
8003 v12 = this->uClipX; | |
8004 if ( v12 < uOutX ) | |
8005 v12 = uOutX; | |
8006 v13 = this->uClipZ; | |
8007 if ( v8 + v12 > (signed int)v13 ) | |
8008 { | |
8009 v14 = this->uClipX; | |
8010 if ( v14 < uOutX ) | |
8011 v14 = uOutX; | |
8012 v8 = v13 - v14; | |
8013 } | |
8014 v15 = this->uClipY; | |
8015 if ( (signed int)v15 < (signed int)v6 ) | |
8016 v15 = v6; | |
8017 v16 = this->uClipW; | |
8018 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
8019 { | |
8020 v17 = this->uClipY; | |
8021 if ( (signed int)v17 >= (signed int)v6 ) | |
8022 v6 = v17; | |
8023 v7 = v16 - v6; | |
8024 } | |
8025 } | |
8026 if ( v7 > 0 ) | |
8027 { | |
8028 uOutXa = v7; | |
8029 do | |
8030 { | |
8031 if ( v8 > 0 ) | |
8032 { | |
8033 v18 = v8; | |
8034 do | |
8035 { | |
8036 if ( *uOutYa ) | |
8037 *pZBuffer = zVal; | |
8038 ++pZBuffer; | |
8039 ++uOutYa; | |
8040 --v18; | |
8041 } | |
8042 while ( v18 ); | |
8043 } | |
8044 pZBuffer += 640 - v8; | |
8045 uOutYa += v19 - v8; | |
8046 --uOutXa; | |
8047 } | |
8048 while ( uOutXa ); | |
8049 } | |
8050 } | |
8051 } | |
8052 } | |
8053 | |
8054 //----- (004A601E) -------------------------------------------------------- | |
991 | 8055 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 8056 { |
8057 signed int v5; // edx@3 | |
8058 int v6; // ebx@3 | |
8059 int v7; // esi@3 | |
8060 void *v8; // esi@3 | |
8061 unsigned int v9; // eax@4 | |
8062 unsigned int v10; // eax@6 | |
8063 signed int v11; // edi@8 | |
8064 unsigned int v12; // eax@10 | |
8065 signed int v13; // edi@11 | |
8066 unsigned int v14; // edi@14 | |
8067 unsigned int v15; // eax@16 | |
8068 unsigned int v16; // ecx@17 | |
8069 int v17; // [sp+18h] [bp+Ch]@3 | |
8070 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
8071 | |
8072 if ( this->uNumSceneBegins && pTexture ) | |
8073 { | |
8074 v5 = a3; | |
8075 v6 = pTexture->uTextureHeight; | |
8076 v7 = 5 * a3; | |
8077 v17 = pTexture->uTextureHeight; | |
8078 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
8079 pTexturea = pTexture->uTextureWidth; | |
8080 if ( this->bClip ) | |
8081 { | |
8082 v9 = this->uClipX; | |
8083 if ( a2 < (signed int)v9 ) | |
8084 { | |
8085 pTexturea += a2 - v9; | |
8086 v8 = (char *)v8 + 4 * (v9 - a2); | |
8087 } | |
8088 v10 = this->uClipY; | |
8089 if ( v5 < (signed int)v10 ) | |
8090 { | |
8091 v17 += v5 - v10; | |
8092 v8 = (char *)v8 + 2560 * (v10 - v5); | |
8093 } | |
8094 v11 = this->uClipX; | |
8095 if ( v11 < a2 ) | |
8096 v11 = a2; | |
8097 v12 = this->uClipZ; | |
8098 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
8099 { | |
8100 v13 = this->uClipX; | |
8101 if ( v13 < a2 ) | |
8102 v13 = a2; | |
8103 pTexturea = v12 - v13; | |
8104 } | |
8105 v14 = this->uClipY; | |
8106 if ( (signed int)v14 < v5 ) | |
8107 v14 = v5; | |
8108 v6 = v17; | |
8109 v15 = this->uClipW; | |
8110 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
8111 { | |
8112 v16 = this->uClipY; | |
8113 if ( (signed int)v16 < v5 ) | |
8114 v16 = v5; | |
8115 v6 = v15 - v16; | |
8116 } | |
8117 } | |
8118 if ( v6 > 0 ) | |
8119 { | |
8120 do | |
8121 { | |
8122 if ( (signed int)pTexturea > 0 ) | |
8123 { | |
8124 memset32(v8, a5, pTexturea); | |
8125 v8 = (char *)v8 + 4 * pTexturea; | |
8126 } | |
8127 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
8128 --v6; | |
8129 } | |
8130 while ( v6 ); | |
8131 } | |
8132 } | |
8133 } | |
8134 | |
8135 //----- (004A5EB2) -------------------------------------------------------- | |
8136 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
8137 { | |
8138 Texture *v4; // edi@2 | |
2069 | 8139 int v5; // ebx@4 |
8140 //unsigned __int16 *pTarget; // eax@4 | |
0 | 8141 unsigned int v7; // edx@5 |
8142 unsigned int v8; // edx@6 | |
8143 unsigned int v9; // edx@7 | |
8144 unsigned int v10; // edx@8 | |
8145 unsigned int v11; // edx@9 | |
8146 unsigned int v12; // esi@12 | |
8147 unsigned int v13; // esi@15 | |
2069 | 8148 //unsigned int v14; // edx@17 |
0 | 8149 unsigned int v15; // esi@18 |
8150 unsigned __int8 *v16; // edx@22 | |
8151 char v17; // zf@26 | |
8152 int v18; // [sp+10h] [bp-10h]@4 | |
8153 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
8154 int v20; // [sp+1Ch] [bp-4h]@4 | |
8155 int uXa; // [sp+28h] [bp+8h]@24 | |
8156 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
8157 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
8158 | |
8159 if ( this->uNumSceneBegins ) | |
8160 { | |
8161 v4 = a4; | |
8162 if ( a4 ) | |
8163 { | |
8164 if ( a4->pPalette16 ) | |
8165 { | |
8166 v5 = a4->uTextureHeight; | |
2069 | 8167 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
710 | 8168 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8169 v20 = a4->uTextureWidth; |
8170 v18 = a4->uTextureWidth; | |
2069 | 8171 |
8172 int clipped_out_x = uX; | |
8173 int clipped_out_y = uY; | |
0 | 8174 if ( this->bClip ) |
8175 { | |
8176 v7 = this->uClipX; | |
8177 if ( (signed int)uX < (signed int)v7 ) | |
8178 { | |
8179 v8 = v7 - uX; | |
8180 v19 += v8; | |
8181 v20 += uX - this->uClipX; | |
2069 | 8182 //pTarget += v8; |
8183 clipped_out_x = uClipX; | |
0 | 8184 } |
8185 v9 = this->uClipY; | |
8186 v5 = a4->uTextureHeight; | |
8187 if ( (signed int)uY < (signed int)v9 ) | |
8188 { | |
8189 v10 = v9 - uY; | |
8190 v19 += v18 * v10; | |
8191 v5 = uY - this->uClipY + a4->uTextureHeight; | |
8192 v4 = a4; | |
2069 | 8193 //pTarget += this->uTargetSurfacePitch * v10; |
8194 clipped_out_y = uClipY; | |
0 | 8195 } |
8196 v11 = this->uClipX; | |
8197 if ( (signed int)v11 < (signed int)uX ) | |
8198 v11 = uX; | |
8199 v23 = this->uClipZ; | |
8200 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
8201 { | |
8202 v12 = this->uClipX; | |
8203 if ( (signed int)v12 < (signed int)uX ) | |
8204 v12 = uX; | |
8205 v20 = v23 - v12; | |
8206 } | |
8207 v13 = this->uClipY; | |
8208 if ( (signed int)v13 < (signed int)uY ) | |
8209 v13 = uY; | |
2069 | 8210 |
8211 if ( (signed int)(v5 + v13) > (signed int)uClipW ) | |
0 | 8212 { |
8213 v15 = this->uClipY; | |
8214 if ( (signed int)v15 < (signed int)uY ) | |
8215 v15 = uY; | |
2069 | 8216 v5 = uClipW - v15; |
0 | 8217 } |
8218 } | |
2069 | 8219 |
8220 v16 = v19; | |
8221 for (int y = 0; y < v5; ++y) | |
8222 { | |
8223 for (int x = 0; x < v20; ++x) | |
8224 { | |
8225 WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16]); | |
8226 ++v16; | |
8227 } | |
8228 v16 += v18 - v20; | |
8229 } | |
8230 /*if ( (signed int)v5 > 0 ) | |
0 | 8231 { |
8232 uYa = v5; | |
8233 v16 = v19; | |
8234 do | |
8235 { | |
8236 if ( v20 > 0 ) | |
8237 { | |
8238 uXa = v20; | |
8239 do | |
8240 { | |
8241 *pTarget = v4->pPalette16[*v16]; | |
8242 ++pTarget; | |
8243 ++v16; | |
8244 --uXa; | |
8245 } | |
8246 while ( uXa ); | |
8247 } | |
8248 v16 += v18 - v20; | |
8249 v17 = uYa-- == 1; | |
8250 pTarget += this->uTargetSurfacePitch - v20; | |
8251 } | |
8252 while ( !v17 ); | |
2069 | 8253 }*/ |
0 | 8254 } |
8255 } | |
8256 } | |
8257 } | |
8258 | |
8259 //----- (004667E9) -------------------------------------------------------- | |
8260 void Render::ChangeBetweenWinFullscreenModes() | |
8261 { | |
8262 float v0; // ST14_4@17 | |
8263 int v4; // edx@26 | |
8264 ObjectDesc *v5; // eax@26 | |
8265 RGBTexture *v6; // esi@33 | |
8266 const char *v8; // [sp-4h] [bp-28h]@33 | |
8267 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
8268 | |
2061 | 8269 /*if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) |
0 | 8270 { |
1458 | 8271 ModalWindow(pGlobalTXT_LocalizationStrings[62], UIMSG_0);// "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window." |
0 | 8272 return; |
2061 | 8273 }*/ |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8274 if ( pRenderer->bWindowMode || !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8275 { |
0 | 8276 if ( pEventTimer->bPaused ) |
2061 | 8277 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0800; |
0 | 8278 else |
8279 pEventTimer->Pause(); | |
8280 if ( pMiscTimer->bPaused ) | |
2061 | 8281 dword_6BE364_game_settings_1 |= GAME_SETTINGS_1000; |
0 | 8282 else |
8283 pMiscTimer->Pause(); | |
8284 pMouse->bActive = 0; | |
8285 if ( pRenderer->pRenderD3D ) | |
8286 { | |
8287 pBitmaps_LOD->ReleaseHardwareTextures(); | |
8288 pSprites_LOD->ReleaseAll(); | |
8289 } | |
8290 if ( pRenderer->bWindowMode ) | |
8291 { | |
1802 | 8292 //SetMenu(hWnd, 0); |
8293 //SetWindowLongA(hWnd, -20, 0); | |
8294 //SetWindowLongA(hWnd, -16, 0x10000000u); | |
8295 window->SetFullscreenMode(); | |
8296 pRenderer->InitializeFullscreen(); | |
0 | 8297 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; |
8298 pGame->pGammaController->Initialize(v0); | |
8299 } | |
8300 else | |
8301 { | |
1802 | 8302 //ClipCursor(0); |
8303 window->SetWindowedMode(window->GetWidth(), window->GetHeight()); | |
8304 pRenderer->SwitchToWindow(); | |
0 | 8305 } |
8306 if ( pRenderer->pRenderD3D ) | |
8307 { | |
8308 pBitmaps_LOD->_410423_move_textures_to_device(); | |
8309 pSprites_LOD->MoveSpritesToVideoMemory(); | |
8310 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8311 if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits |
0 | 8312 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8313 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8314 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8315 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8316 pPaletteManager->RecalculateAll(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8317 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8318 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8319 for (int i = 0; i < pObjectList->uNumObjects; i++) |
0 | 8320 { |
8321 BYTE3(v4) = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8322 v5 = &pObjectList->pObjects[i]; |
0 | 8323 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; |
8324 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
8325 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8326 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8327 SetUserInterface(pParty->alignment, true); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8328 if ( pVideoPlayer->pVideoFrame.pPixels ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8329 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); |
2006 | 8330 if ( sCurrentMenuID != MENU_CREATEPARTY ) |
8331 { | |
8332 if ( sCurrentMenuID == MENU_CREDITSPROC ) | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8333 dword_A74C88 = 1; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8334 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8335 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8336 { |
2006 | 8337 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8338 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8339 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8340 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8341 v8 = "makeme.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8342 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8343 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8344 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8345 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8346 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8347 v8 = "title.pcx"; |
2006 | 8348 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8349 v8 = "lsave640.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8350 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8351 v6->Load(v8, 0); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8352 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8353 } |
0 | 8354 viewparams->bRedrawGameUI = 1; |
688 | 8355 viewparams->InitGrayPalette(); |
0 | 8356 pMouse->SetCurrentCursorBitmap(); |
1802 | 8357 /*if ( pRenderer->bWindowMode ) |
0 | 8358 { |
1655 | 8359 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); |
8360 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); | |
1586 | 8361 ShowWindow(hWnd, SW_SHOWNORMAL); |
1802 | 8362 }*/ |
8363 pMouse->bActive = true; | |
0 | 8364 if ( pVideoPlayer->AnyMovieLoaded() ) |
898 | 8365 pVideoPlayer->SelectMovieType(); |
2061 | 8366 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0800) |
8367 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0800; | |
0 | 8368 else |
8369 pEventTimer->Resume(); | |
2061 | 8370 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_1000) |
8371 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_1000; | |
0 | 8372 else |
8373 pMiscTimer->Resume(); | |
8374 } | |
8375 } | |
8376 | |
8377 | |
8378 //----- (004524D8) -------------------------------------------------------- | |
8379 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
8380 { | |
1583 | 8381 //int v11; // eax@13 |
8382 //int v12; // ecx@13 | |
0 | 8383 void *v13; // eax@13 |
1583 | 8384 //unsigned __int8 v14; // zf@13 |
8385 //unsigned __int8 v15; // sf@13 | |
0 | 8386 int v16; // esi@14 |
8387 int v17; // ecx@16 | |
8388 int v18; // esi@16 | |
8389 unsigned __int16 *v19; // eax@16 | |
8390 int v20; // edx@16 | |
8391 int v21; // ecx@16 | |
8392 int v22; // eax@16 | |
8393 int v23; // esi@16 | |
8394 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
8395 int v27; // [sp+28h] [bp-Ch]@14 | |
8396 int v28; // [sp+2Ch] [bp-8h]@13 | |
8397 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
8398 | |
8399 //v3 = this; | |
8400 //sprintf(Str1, "%s", pName); | |
8401 //v4 = uNumItems; | |
8402 if (!uNumItems) | |
8403 return nullptr; | |
8404 | |
8405 //{ | |
8406 //v5 = 0, pDesta = uNumItems; | |
8407 uint idx1 = 0, | |
8408 idx2 = uNumItems; | |
8409 while (true) | |
8410 { | |
1980 | 8411 uint i = idx1 + (idx2 - idx1) / 2; |
8412 | |
8413 int res = _stricmp(pName, pSpriteNames[i]); | |
0 | 8414 if (!res) |
8415 { | |
8416 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
8417 break; | |
8418 } | |
8419 else if (res < 0) | |
8420 idx2 = idx1 + (idx2 - idx1) / 2; | |
8421 else | |
8422 idx1 = i + 1; | |
8423 | |
8424 if ( idx1 >= idx2 ) | |
8425 return false; | |
8426 } | |
8427 | |
8428 | |
8429 uint uCompressedSize = 0; | |
8430 fread(&uCompressedSize, 4, 1, pFile); | |
8431 | |
1980 | 8432 HWLTexture* pTex = new HWLTexture; |
670 | 8433 fread(&pTex->uBufferWidth, 4, 1, pFile); |
8434 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
8435 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
8436 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 8437 fread(&pTex->uWidth, 4, 1, pFile); |
8438 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 8439 fread(&pTex->uAreaX, 4, 1, pFile); |
8440 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 8441 |
8442 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
8443 if (uCompressedSize) | |
8444 { | |
1980 | 8445 char* pCompressedData = new char[uCompressedSize]; |
0 | 8446 { |
8447 fread(pCompressedData, 1, uCompressedSize, pFile); | |
1980 | 8448 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); |
0 | 8449 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); |
8450 } | |
8451 delete [] pCompressedData; | |
8452 } | |
8453 else | |
8454 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
8455 | |
1583 | 8456 if ( scale_hwls_to_half ) |
8457 { | |
8458 pTex->uHeight /= 2; | |
8459 pTex->uWidth /= 2; | |
8460 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
0 | 8461 v28 = 0; |
8462 v26 = (unsigned __int16 *)v13; | |
1583 | 8463 if ( pTex->uHeight > 0 ) |
0 | 8464 { |
8465 v16 = pTex->uWidth; | |
8466 v27 = 1; | |
8467 do | |
8468 { | |
8469 pDestb = 0; | |
8470 if ( v16 > 0 ) | |
8471 { | |
8472 do | |
8473 { | |
8474 v17 = v16 * v27; | |
8475 v18 = v28 * v16; | |
8476 v19 = pTex->pPixels; | |
8477 v20 = pDestb + 2 * v18; | |
8478 v21 = (int)&v19[2 * (pDestb + v17)]; | |
8479 v22 = (int)&v19[2 * v20]; | |
8480 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
8481 LOWORD(v21) = *(unsigned short *)v21; | |
8482 v23 = pDestb++ + v18; | |
1583 | 8483 extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); |
8484 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
0 | 8485 v16 = pTex->uWidth; |
8486 } | |
8487 while (pDestb < pTex->uWidth); | |
8488 } | |
8489 ++v28; | |
8490 v27 += 2; | |
8491 } | |
8492 while ( v28 < (signed int)pTex->uHeight ); | |
8493 } | |
8494 delete [] pTex->pPixels; | |
8495 pTex->pPixels = v26; | |
8496 } | |
8497 return pTex; | |
8498 } | |
8499 | |
8500 //----- (0045271F) -------------------------------------------------------- | |
8501 bool RenderHWLContainer::Release() | |
8502 { | |
8503 __int32 v4; // eax@6 | |
8504 FILE *v5; // ST24_4@6 | |
8505 FILE *File; // [sp+4h] [bp-4h]@6 | |
8506 | |
1162 | 8507 if ( this->bDumpDebug) |
0 | 8508 { |
8509 File = fopen("logd3d.txt", "w"); | |
1162 | 8510 v4 = ftell(this->pFile); |
8511 v5 = this->pFile; | |
8512 this->uDataOffset = v4; | |
8513 fwrite(&this->uNumItems, 4u, 1u, v5); | |
8514 for (int i = 0; i < this->uNumItems; i++) | |
8515 { | |
8516 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
8517 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
8518 } | |
8519 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
8520 fseek(this->pFile, 4, 0); | |
8521 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
8522 fclose(this->pFile); | |
0 | 8523 fclose(File); |
8524 } | |
8525 else | |
8526 { | |
8527 fclose(this->pFile); | |
1162 | 8528 for (int i = 0; i < this->uNumItems; i++) |
8529 { | |
8530 free(this->pSpriteNames[i]); | |
0 | 8531 } |
8532 } | |
1093 | 8533 return true; |
0 | 8534 } |
8535 | |
8536 //----- (00452347) -------------------------------------------------------- | |
8537 RenderHWLContainer::RenderHWLContainer(): | |
8538 bDumpDebug(false) | |
8539 { | |
8540 this->pFile = 0; | |
8541 uSignature = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8542 this->uDataOffset = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8543 memset(&this->uNumItems, 0, 0x61A84u); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8544 this->uNumItems = 0; |
1583 | 8545 this->scale_hwls_to_half = false; |
0 | 8546 } |
8547 | |
8548 //----- (0045237F) -------------------------------------------------------- | |
8549 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
8550 { | |
8551 pFile = _wfopen(pFilename, L"rb"); | |
8552 if (!pFile) | |
8553 { | |
8554 Log::Warning(L"Failed to open file: %s", pFilename); | |
8555 return false; | |
8556 } | |
8557 | |
8558 fread(&uSignature, 1, 4, pFile); | |
8559 if (uSignature != 'TD3D') | |
8560 { | |
8561 Log::Warning(L"Invalid format: %s", pFilename); | |
8562 return false; | |
8563 } | |
8564 | |
8565 fread(&uDataOffset, 4, 1, pFile); | |
8566 fseek(pFile, uDataOffset, SEEK_SET); | |
8567 fread(&uNumItems, 4, 1, pFile); | |
8568 | |
8569 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
8570 for (uint i = 0; i < uNumItems; ++i) | |
8571 { | |
8572 pSpriteNames[i] = new char[20]; | |
8573 fread(pSpriteNames[i], 1, 20, pFile); | |
8574 } | |
8575 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
8576 | |
8577 return true; | |
8578 } | |
8579 | |
8580 //----- (004A1C1E) -------------------------------------------------------- | |
8581 void DoRenderBillboards_D3D() | |
8582 { | |
186 | 8583 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
8584 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8585 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8586 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8587 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8588 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8589 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8590 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8591 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8592 { |
1390 | 8593 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; |
8594 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
8595 } | |
8596 p->pQuads[0].pos.x = 10; | |
8597 p->pQuads[0].pos.y = 10; | |
8598 | |
8599 p->pQuads[1].pos.x = 10; | |
8600 p->pQuads[1].pos.y = 200; | |
8601 | |
8602 p->pQuads[2].pos.x = 100; | |
8603 p->pQuads[2].pos.y = 200; | |
8604 | |
8605 p->pQuads[3].pos.x = 100; | |
8606 p->pQuads[3].pos.y = 10; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8607 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8608 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8609 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8610 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8611 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8612 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8613 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8614 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8615 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8616 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8617 }*/ |
0 | 8618 |
2114 | 8619 for (int i = pRenderer->uNumBillboardsToDraw - 1; i >= 0; --i) |
8620 { | |
8621 if((int)pRenderer->pBillboardRenderListD3D[i].pTexture == 0xcdcdcdcd) | |
8622 __debugbreak();//Ritor1: error | |
8623 if (pRenderer->pBillboardRenderListD3D[i].uOpacity != RenderBillboardD3D::NoBlend) | |
8624 SetBillboardBlendOptions(pRenderer->pBillboardRenderListD3D[i].uOpacity); | |
0 | 8625 |
2114 | 8626 |
8627 pRenderer->pRenderD3D->pDevice->SetTexture(0, pRenderer->pBillboardRenderListD3D[i].pTexture); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8628 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8629 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
2114 | 8630 pRenderer->pBillboardRenderListD3D[i].pQuads, pRenderer->pBillboardRenderListD3D[i].uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8631 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 8632 } |
8633 | |
8634 if (pRenderer->bFogEnabled) | |
8635 { | |
8636 pRenderer->bFogEnabled = false; | |
186 | 8637 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 8638 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
8639 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8640 } | |
186 | 8641 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
8642 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8643 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8644 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8645 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8646 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8647 } |
8648 | |
8649 //----- (004A1DA8) -------------------------------------------------------- | |
8650 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
8651 { | |
8652 switch (a1) | |
8653 { | |
8654 case RenderBillboardD3D::Transparent: | |
8655 { | |
8656 if (pRenderer->bFogEnabled) | |
8657 { | |
8658 pRenderer->bFogEnabled = false; | |
186 | 8659 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 8660 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
8661 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8662 } | |
8663 | |
186 | 8664 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); |
8665 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
8666 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8667 } |
8668 break; | |
8669 | |
8670 case RenderBillboardD3D::Opaque_1: | |
8671 case RenderBillboardD3D::Opaque_2: | |
8672 case RenderBillboardD3D::Opaque_3: | |
8673 { | |
8674 if (pRenderer->bUsingSpecular) | |
8675 { | |
8676 if (!pRenderer->bFogEnabled) | |
8677 { | |
8678 pRenderer->bFogEnabled = true; | |
186 | 8679 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
8680 } | |
8681 } | |
8682 | |
8683 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8684 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8685 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 8686 } |
8687 break; | |
8688 | |
8689 default: | |
8690 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8691 assert(false); |
0 | 8692 break; |
8693 } | |
1787 | 8694 } |
1903 | 8695 //----- (00424CD7) -------------------------------------------------------- |
8696 int ODM_NearClip(unsigned int num_vertices) | |
8697 { | |
8698 bool current_vertices_flag; // edi@1 | |
8699 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 | |
8700 double t; // st6@10 | |
8701 int pNextVertices; | |
8702 | |
8703 if (!num_vertices) | |
8704 return 0; | |
8705 | |
8706 memcpy(&array_50AC10[num_vertices], array_50AC10, sizeof(array_50AC10[0])); | |
8707 current_vertices_flag = 0; | |
8708 if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 ) | |
8709 current_vertices_flag = 1; | |
8710 | |
8711 int out_num_vertices = 0; | |
8712 for (int i = 0; i < num_vertices; ++i) | |
8713 { | |
8714 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= 8.0; | |
8715 if ( current_vertices_flag != next_vertices_flag ) | |
8716 { | |
8717 if ( next_vertices_flag ) | |
8718 { | |
8719 //t = neer_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) | |
8720 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); | |
8721 array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; | |
8722 array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; | |
8723 array_507D30[out_num_vertices].u = (array_50AC10[i + 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; | |
8724 array_507D30[out_num_vertices].v = (array_50AC10[i + 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; | |
8725 } | |
8726 else | |
8727 { | |
8728 t = (8.0 - array_50AC10[i + 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); | |
8729 array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t + array_50AC10[i + 1].vWorldViewPosition.y; | |
8730 array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t + array_50AC10[i + 1].vWorldViewPosition.z; | |
8731 array_507D30[out_num_vertices].u = (array_50AC10[i].u - array_50AC10[i + 1].u) * t + array_50AC10[i + 1].u; | |
8732 array_507D30[out_num_vertices].v = (array_50AC10[i].v - array_50AC10[i + 1].v) * t + array_50AC10[i + 1].v; | |
8733 } | |
8734 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; | |
8735 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
1904 | 8736 //array_507D30[out_num_vertices]._rhw = 0x3E000000u; |
1903 | 8737 ++out_num_vertices; |
8738 } | |
8739 if ( next_vertices_flag ) | |
8740 { | |
8741 pNextVertices = out_num_vertices++; | |
8742 memcpy(&array_507D30[pNextVertices], &array_50AC10[i + 1], 0x30); | |
8743 } | |
8744 current_vertices_flag = next_vertices_flag; | |
8745 } | |
8746 return out_num_vertices >= 3 ? out_num_vertices : 0; | |
8747 } | |
1787 | 8748 //----- (00424EE0) -------------------------------------------------------- |
1903 | 8749 int ODM_FarClip(unsigned int uNumVertices) |
1787 | 8750 { |
8751 signed int previous_vertices_flag; // edi@1 | |
8752 double t; // st6@10 | |
8753 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 | |
8754 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 | |
8755 int pNextVertices; | |
8756 //Доп инфо "Программирование трёхмерных игр для windows" Ламот стр 910 | |
8757 | |
8758 memcpy(&array_50AC10[uNumVertices], array_50AC10, sizeof(array_50AC10[uNumVertices])); | |
8759 depth_num_vertices = 0; | |
8760 previous_vertices_flag = 0; | |
8761 if ( array_50AC10[0].vWorldViewPosition.x <= pODMRenderParams->shading_dist_mist ) | |
8762 previous_vertices_flag = 1;//предыдущая грань меньше границы видимости | |
8763 if ( (signed int)uNumVertices <= 0 ) | |
8764 return 0; | |
8765 for ( uint i = 1; i <= uNumVertices; ++i ) | |
8766 { | |
8767 current_vertices_flag = pODMRenderParams->shading_dist_mist >= array_50AC10[i].vWorldViewPosition.x; | |
8768 if ( previous_vertices_flag != current_vertices_flag )//одна из граней за границей видимости | |
8769 { | |
8770 if ( current_vertices_flag )//текущая грань меньше границы видимости(предыдущая грань за пределами видимости) | |
8771 { | |
8772 //t = far_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) | |
8773 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i - 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i - 1].vWorldViewPosition.x); | |
8774 array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i - 1].vWorldViewPosition.y) * t + array_50AC10[i - 1].vWorldViewPosition.y; | |
8775 array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i - 1].vWorldViewPosition.z) * t + array_50AC10[i - 1].vWorldViewPosition.z; | |
8776 array_507D30[depth_num_vertices].u = (array_50AC10[i].u - array_50AC10[i - 1].u) * t + array_50AC10[i - 1].u; | |
8777 array_507D30[depth_num_vertices].v = (array_50AC10[i].v - array_50AC10[i - 1].v) * t + array_50AC10[i - 1].v; | |
8778 } | |
8779 else//предыдущая грань меньше границы видимости(текущая грань вышла за пределы видимости) | |
8780 { | |
8781 //t = far_clip - v1.x / v0.x - v1.x | |
8782 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i - 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); | |
8783 array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i - 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; | |
8784 array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i - 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; | |
8785 array_507D30[depth_num_vertices].u = (array_50AC10[i - 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; | |
8786 array_507D30[depth_num_vertices].v = (array_50AC10[i - 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; | |
8787 } | |
8788 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; | |
8789 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; | |
8790 ++depth_num_vertices; | |
8791 } | |
8792 if ( current_vertices_flag )//оба в границе видимости | |
8793 { | |
8794 pNextVertices = depth_num_vertices++; | |
8795 memcpy(&array_507D30[pNextVertices], &array_50AC10[i], 0x30); | |
1799 | 8796 //array_507D30[pNextVertices]._rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
8797 //array_507D30[pNextVertices].flt_2C = array_50AC10[i].flt_2C; | |
1787 | 8798 } |
8799 previous_vertices_flag = current_vertices_flag; | |
8800 } | |
8801 if ( depth_num_vertices < 3 ) | |
8802 return 0; | |
8803 return depth_num_vertices; | |
8804 } | |
8805 | |
8806 //----- (0047840D) -------------------------------------------------------- | |
8807 void Render::DrawBuildingsD3D() | |
8808 { | |
8809 int v9; // ecx@8 | |
8810 Texture *pFaceTexture; // eax@10 | |
8811 unsigned int v16; // edi@22 | |
8812 int v27; // eax@57 | |
8813 int vertex_id; // eax@58 | |
8814 unsigned int v34; // eax@80 | |
8815 int v40; // [sp-4h] [bp-5Ch]@2 | |
8816 int v49; // [sp+2Ch] [bp-2Ch]@10 | |
8817 int v50; // [sp+30h] [bp-28h]@34 | |
8818 int v51; // [sp+34h] [bp-24h]@35 | |
8819 int v52; // [sp+38h] [bp-20h]@36 | |
8820 int v53; // [sp+3Ch] [bp-1Ch]@8 | |
8821 int uNumVertices; // [sp+4Ch] [bp-Ch]@34 | |
8822 int unused; // [sp+50h] [bp-8h]@3 | |
8823 | |
8824 if ( !pRenderer->pRenderD3D ) | |
8825 { | |
8826 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); | |
8827 } | |
8828 | |
8829 unused = 0; | |
8830 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
8831 { | |
8832 for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++ ) | |
8833 { | |
8834 if ( IsBModelVisible(model_id, &unused) ) | |
8835 { | |
8836 pOutdoor->pBModels[model_id].field_40 |= 1; | |
8837 if ( pOutdoor->pBModels[model_id].uNumFaces > 0 ) | |
8838 { | |
8839 for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ ) | |
8840 { | |
8841 if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible()) | |
8842 { | |
8843 v53 = 0; | |
8844 array_77EC08[pODMRenderParams->uNumPolygons].flags = 0; | |
8845 array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0; | |
8846 v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID; | |
8847 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME) | |
8848 v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); | |
8849 pFaceTexture = pBitmaps_LOD->GetTexture(v9); | |
8850 array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture; | |
8851 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID) | |
8852 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2; | |
1922 | 8853 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_INDOOR_SKY ) |
1787 | 8854 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
8855 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & 4 ) | |
8856 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; | |
8857 else | |
8858 { | |
8859 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & 0x20 ) | |
8860 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8; | |
8861 } | |
8862 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & 0x0800) | |
8863 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000; | |
8864 else | |
8865 { | |
8866 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE) | |
8867 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10u; | |
8868 } | |
8869 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU; | |
8870 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV; | |
8871 v16 = GetTickCount() >> 4; | |
8872 if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 ) | |
8873 { | |
8874 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8875 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8876 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8877 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8878 } | |
8879 else | |
8880 { | |
8881 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8882 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8883 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8884 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8885 } | |
8886 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 ) | |
8887 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8888 else | |
8889 { | |
8890 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 ) | |
8891 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8892 } | |
8893 v50 = 0; | |
8894 v49 = 0; | |
8895 uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8896 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 ) | |
8897 { | |
8898 for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ ) | |
8899 { | |
8900 array_73D150[vertex_id - 1].vWorldPosition.x = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].x; | |
8901 array_73D150[vertex_id - 1].vWorldPosition.y = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].y; | |
8902 array_73D150[vertex_id - 1].vWorldPosition.z = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].z; | |
8903 array_73D150[vertex_id - 1].u = (array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU + (signed __int16)pOutdoor->pBModels[model_id].pFaces[face_id].pTextureUIDs[vertex_id - 1]) * (1.0 / (double)pFaceTexture->uTextureWidth); | |
8904 array_73D150[vertex_id - 1].v = (array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV + (signed __int16)pOutdoor->pBModels[model_id].pFaces[face_id].pTextureVIDs[vertex_id - 1]) * (1.0 / (double)pFaceTexture->uTextureHeight); | |
8905 } | |
8906 for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ ) | |
8907 { | |
8908 if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z ) | |
8909 ++v53; | |
8910 pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); | |
8911 if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) | |
8912 { | |
8913 if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 ) | |
8914 v49 = 1; | |
8915 else | |
8916 v50 = 1; | |
8917 } | |
8918 else | |
8919 pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); | |
8920 } | |
8921 } | |
8922 if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices ) | |
8923 LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1; | |
8924 array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8925 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8926 array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5; | |
8927 v51 = (unsigned __int64)(-pOutdoor->vSunlight.x * (signed __int64)pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x) >> 16; | |
8928 v53 = (unsigned __int64)(-pOutdoor->vSunlight.y * (signed __int64)pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y) >> 16; | |
8929 v52 = (unsigned __int64)(-pOutdoor->vSunlight.z * (signed __int64)pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >> 16; | |
8930 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - (20 * (signed int)(v51 + v53 + v52) >> 16); | |
8931 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 ) | |
8932 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0; | |
8933 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 ) | |
8934 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31; | |
8935 if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) | |
8936 return; | |
8937 if ( ODMFace::IsBackfaceCulled(&pOutdoor->pBModels[model_id].pFaces[face_id], array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) | |
8938 { | |
8939 pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1; | |
8940 array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id; | |
8941 array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id; | |
8942 v27 = 8 * (face_id | (model_id << 6)); | |
8943 LOBYTE(v27) = v27 | 6; | |
8944 array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27; | |
8945 for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id) | |
8946 { | |
8947 memcpy(&array_50AC10[vertex_id], &array_73D150[vertex_id], sizeof(array_50AC10[vertex_id])); | |
8948 array_50AC10[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001); | |
8949 } | |
8950 static stru154 static_RenderBuildingsD3D_stru_73C834; | |
8951 /*static bool __init_flag = false; | |
8952 if (!__init_flag) | |
8953 { | |
8954 __init_flag = true; | |
8955 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; | |
8956 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); | |
8957 atexit(loc_4789D4); | |
8958 }*/ | |
8959 | |
8960 v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8961 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8962 pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8963 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
8964 int v31 = 0; | |
8965 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
8966 { | |
8967 v31 = v50 ? 3 : v49 != 0 ? 5 : 0; | |
8968 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices); | |
8969 if ( pDecalBuilder->uNumDecals > 0 ) | |
8970 { | |
8971 v40 = -1; | |
8972 pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834, | |
8973 pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, array_50AC10, 0, (char)v31, -1); | |
8974 } | |
8975 } | |
8976 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
8977 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); | |
8978 if ( v50 ) | |
8979 { | |
1903 | 8980 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8981 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8982 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8983 } | |
8984 if ( v49 ) | |
8985 { | |
1903 | 8986 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8987 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8988 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8989 } | |
8990 if ( uNumVertices ) | |
8991 { | |
8992 if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 ) | |
8993 { | |
8994 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C ) | |
8995 v34 = pRenderer->pHDWaterBitmapIDs[0]; | |
8996 else | |
8997 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
8998 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; | |
8999 } | |
9000 else | |
9001 v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; | |
9002 pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40); | |
9003 } | |
9004 } | |
9005 } | |
9006 } | |
9007 } | |
9008 } | |
9009 } | |
9010 } | |
9011 return; | |
1911 | 9012 } |
9013 //----- (00479543) -------------------------------------------------------- | |
1923 | 9014 void Render::DrawOutdoorSkyD3D() |
1911 | 9015 { |
9016 int v9; // eax@4 | |
9017 int v10; // ebx@4 | |
9018 int v13; // edi@6 | |
9019 int v14; // ecx@6 | |
9020 int v15; // eax@8 | |
9021 int v16; // eax@12 | |
9022 signed __int64 v17; // qtt@13 | |
9023 signed int v18; // ecx@13 | |
9024 struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1 | |
9025 int v30; // [sp+134h] [bp-30h]@1 | |
9026 int v32; // [sp+13Ch] [bp-28h]@6 | |
9027 int v33; // [sp+140h] [bp-24h]@2 | |
9028 signed __int64 v34; // [sp+144h] [bp-20h]@1 | |
9029 int v35; // [sp+148h] [bp-1Ch]@4 | |
9030 int v36; // [sp+14Ch] [bp-18h]@2 | |
9031 int v37; // [sp+154h] [bp-10h]@8 | |
9032 int v38; // [sp+158h] [bp-Ch]@1 | |
9033 int v39; // [sp+15Ch] [bp-8h]@4 | |
2120 | 9034 |
9035 v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z) | |
1911 | 9036 / ((double)pODMRenderParams->int_fov_rad + 8192.0) |
2119 | 9037 + (double)(pViewport->uScreenCenterY)); |
9038 v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192 | |
2120 | 9039 v38 = (signed __int64)((double)(pViewport->uScreenCenterY) |
1911 | 9040 - (double)pODMRenderParams->int_fov_rad |
9041 / (v34 + 0.0000001) | |
9042 * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) | |
9043 * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist | |
9044 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); | |
9045 pSkyPolygon.Create_48607B(&stru_8019C8);//заполняется ptr_38 | |
9046 pSkyPolygon.ptr_38->_48694B_frustum_sky(); | |
2006 | 9047 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166) |
9048 pSkyPolygon.pTexture = (Texture *)(SLOWORD(pOutdoor->sSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->sSky_TextureID)] : 0); | |
1911 | 9049 if ( pSkyPolygon.pTexture ) |
9050 { | |
9051 pSkyPolygon.dimming_level = 0; | |
9052 pSkyPolygon.uNumVertices = 4; | |
2119 | 9053 //centering(центруем)----------------------------------------------------------------- |
2120 | 9054 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 9055 pSkyPolygon.v_18.y = 0; |
2120 | 9056 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 9057 |
9058 //sky wiew position(положение неба на экране)------------------------------------------ | |
9059 // X | |
9060 // 0._____________________________.3 | |
9061 // |8,8 468,8 | | |
9062 // | | | |
9063 // | | | |
9064 // Y| | | |
9065 // | | | |
9066 // |8,351 468,351 | | |
9067 // 1._____________________________.2 | |
9068 // | |
2119 | 9069 array_50AC10[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 |
9070 array_50AC10[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
9071 | |
9072 array_50AC10[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 | |
9073 array_50AC10[1].vWorldViewProjY = (double)v38;//247 | |
9074 | |
9075 array_50AC10[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
9076 array_50AC10[2].vWorldViewProjY = (double)v38;//247 | |
9077 | |
9078 array_50AC10[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
9079 array_50AC10[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
9080 | |
9081 pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
9082 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
9083 | |
9084 pSkyPolygon.field_24 = 0x2000000u;//maybe attributes | |
2120 | 9085 v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2) / tan(0.6457717418670654) + 0.5); |
1911 | 9086 for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i ) |
9087 { | |
9088 //rotate skydome(вращение купола неба)-------------------------------------- | |
9089 // В игре принята своя система измерения углов. Полный угол (180). Значению угла 0 соответствует | |
9090 // направление на север и/или юг (либо на восток и/или запад), значению 65536 еденицам(0х10000) соответствует угол 90. | |
2119 | 9091 // две переменные хранят данные по углу обзора. field_14 по западу и востоку. field_20 по югу и северу |
1911 | 9092 // от -25080 до 25080 |
2120 | 9093 v39 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_west_east * (signed __int64)(v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5)))) >> 16; |
9094 v35 = v39 + pSkyPolygon.ptr_38->angle_from_north; | |
9095 | |
9096 v39 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_north_south * (signed __int64)(v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f)))) >> 16; | |
9097 v36 = v39 + pSkyPolygon.ptr_38->angle_from_east; | |
9098 | |
9099 v9 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5)))) >> 16; | |
9100 v10 = pSkyPolygon.v_18.x + v9; | |
2119 | 9101 if ( v10 > 0 ) |
1911 | 9102 v10 = 0; |
2120 | 9103 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX); |
9104 v34 = -pSkyPolygon.field_24; | |
9105 v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0; | |
9106 v14 = v33 * (v30 - v32); | |
1911 | 9107 while ( 1 ) |
9108 { | |
2120 | 9109 if ( v10 ) |
1911 | 9110 { |
2120 | 9111 v37 = abs((int)v34 >> 14); |
9112 v15 = abs(v10); | |
9113 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportTL_Y ) | |
9114 { | |
9115 if ( v10 <= 0 ) | |
9116 break; | |
9117 } | |
1911 | 9118 } |
9119 v16 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v14) >> 16; | |
9120 --v32; | |
9121 v14 += v33; | |
9122 v10 = pSkyPolygon.v_18.x + v16; | |
9123 } | |
9124 LODWORD(v17) = LODWORD(v34) << 16; | |
2120 | 9125 HIDWORD(v17) = v34 >> 16; |
9126 v18 = v17 / v10; | |
1911 | 9127 if ( v18 < 0 ) |
9128 v18 = pODMRenderParams->shading_dist_mist; | |
2120 | 9129 v37 = v35 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_west * (signed __int64)v13) >> 16); |
9130 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed | |
1911 | 9131 + ((signed int)((unsigned __int64)(v37 * (signed __int64)v18) >> 16) >> 3); |
2120 | 9132 array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0); |
9133 | |
9134 v36 = v36 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)v13) >> 16); | |
9135 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed | |
1911 | 9136 + ((signed int)((unsigned __int64)(v36 * (signed __int64)v18) >> 16) >> 3); |
2120 | 9137 array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0); |
2119 | 9138 |
9139 array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192 | |
2120 | 9140 array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16); |
1911 | 9141 } |
1923 | 9142 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
2120 | 9143 array_50AC10[0].vWorldViewProjY = (double)v10; |
1911 | 9144 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; |
9145 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; | |
2120 | 9146 array_50AC10[3].vWorldViewProjY = (double)v10; |
1923 | 9147 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
1911 | 9148 return; |
9149 } | |
1913 | 9150 } |
9151 //----- (004226C2) -------------------------------------------------------- | |
9152 bool PauseGameDrawing() | |
9153 { | |
9154 if ( pCurrentScreen != SCREEN_GAME | |
9155 && pCurrentScreen != SCREEN_NPC_DIALOGUE | |
9156 && pCurrentScreen != SCREEN_CHANGE_LOCATION ) | |
9157 { | |
9158 if ( pCurrentScreen == SCREEN_INPUT_BLV ) | |
9159 return pVideoPlayer->pSmackerMovie != 0; | |
9160 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) | |
9161 return true; | |
9162 } | |
9163 return false; | |
1679 | 9164 } |