Mercurial > mm7
annotate Render.cpp @ 1443:a8b1bbac95d4
Слияние
author | Ritor1 |
---|---|
date | Fri, 02 Aug 2013 23:59:25 +0600 |
parents | b67a3e0d6fc3 3881d2f94eb1 |
children | 6de9c1316852 |
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 |
140 | 5 #include <assert.h> |
6 | |
1277 | 7 #include "Outdoor_stuff.h" |
1016 | 8 #include "VideoPlayer.h" |
9 #include "Sprites.h" | |
10 #include "Mouse.h" | |
11 #include "GammaControl.h" | |
12 #include "stru6.h" | |
1183 | 13 #include "GUIWindow.h" |
1016 | 14 #include "DecalBuilder.h" |
15 #include "ParticleEngine.h" | |
0 | 16 #include "Render.h" |
17 #include "OutdoorCamera.h" | |
18 #include "IndoorCamera.h" | |
19 #include "Outdoor.h" | |
20 #include "Party.h" | |
21 #include "LOD.h" | |
22 #include "Viewport.h" | |
23 #include "Math.h" | |
24 #include "PaletteManager.h" | |
25 #include "Time.h" | |
26 #include "Game.h" | |
27 #include "LightmapBuilder.h" | |
28 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
29 #include "SpriteObject.h" |
0 | 30 #include "DecorationList.h" |
31 #include "Allocator.h" | |
32 #include "OSInfo.h" | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
33 #include "Actor.h" |
0 | 34 #include "Log.h" |
179 | 35 #include "TileFrameTable.h" |
189 | 36 #include "texts.h" |
0 | 37 #include "mm7_data.h" |
860 | 38 #include "MM7.h" |
1262 | 39 #include "Lights.h" |
0 | 40 |
41 #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | |
42 #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | |
43 | |
44 struct IDirectDrawClipper *pDDrawClipper; | |
45 struct Render *pRenderer; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
46 struct RenderVertexD3D3 pVertices[50]; |
0 | 47 int uNumDecorationsDrawnThisFrame; // weak |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
48 RenderBillboard pBillboardRenderList[500]; |
0 | 49 unsigned int uNumBillboardsToDraw; |
50 int uNumSpritesDrawnThisFrame; // weak | |
51 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
52 RenderVertexSoft array_507D30[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
53 RenderVertexSoft array_50AC10[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
54 RenderVertexSoft array_73D150[20]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
55 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
56 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 57 |
58 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
59 | |
60 /* 384 */ | |
61 #pragma pack(push, 1) | |
62 struct PCXHeader_1 | |
63 { | |
64 char manufacturer; | |
65 char version; | |
66 char encoding; | |
67 char bpp; | |
68 __int16 left; | |
69 __int16 up; | |
70 __int16 right; | |
71 __int16 bottom; | |
72 __int16 hdpi; | |
73 __int16 vdpi; | |
74 }; | |
75 #pragma pack(pop) | |
76 | |
77 /* 385 */ | |
78 #pragma pack(push, 1) | |
79 struct PCXHeader_2 | |
80 { | |
81 char reserved; | |
82 char planes; | |
83 __int16 pitch; | |
84 __int16 palette_info; | |
85 }; | |
86 #pragma pack(pop) | |
87 | |
88 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
89 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
90 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
91 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
92 | |
93 //----- (0049E79F) -------------------------------------------------------- | |
94 bool __cdecl CheckTextureStages() | |
95 { | |
96 bool v0; // edi@1 | |
97 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
98 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
99 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
100 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
101 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
102 | |
103 v0 = false; | |
104 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); | |
105 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
106 | |
107 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
186 | 108 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 109 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u)); |
110 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
111 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
112 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
113 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u)); | |
114 | |
115 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
186 | 116 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
0 | 117 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u)); |
118 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u)); | |
119 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u)); | |
120 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u)); | |
121 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u)); | |
122 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u)); | |
123 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u)); | |
124 | |
125 if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
126 v0 = true; | |
127 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); | |
128 pTexture1->Release(); | |
129 pTexture2->Release(); | |
130 pSurface1->Release(); | |
131 pSurface2->Release(); | |
132 return v0; | |
133 } | |
134 | |
135 //----- (00440CB8) -------------------------------------------------------- | |
136 void Render::DrawBillboardList_BLV() | |
137 { | |
138 __int16 v2; // ax@3 | |
139 int v5; // eax@11 | |
140 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
141 | |
142 soft_billboard.uParentBillboardID = -1; | |
143 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; | |
144 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
145 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
146 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
147 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
148 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
149 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
150 | |
617 | 151 pOutdoorCamera->uNumBillboards = ::uNumBillboardsToDraw; |
152 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) | |
0 | 153 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
154 auto p = pBillboardRenderList + i; |
0 | 155 |
156 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
157 soft_billboard.uParentBillboardID = i; | |
158 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
159 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
|
160 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 161 soft_billboard.sZValue = p->sZValue; |
162 soft_billboard.uFlags = p->field_1E; | |
163 soft_billboard.uTintColor = p->uTintColor; | |
164 v2 = p->uHwSpriteID; | |
165 if ( v2 != -1 ) | |
166 { | |
167 if ( pRenderer->pRenderD3D ) | |
657 | 168 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 169 else |
170 { | |
657 | 171 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 172 if (p->field_1E & 0x0100) |
173 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
174 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
175 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
176 v5 = p->uHwSpriteID; | |
177 if ( v5 >= 0 ) | |
733 | 178 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 179 } |
180 } | |
181 } | |
182 } | |
183 | |
184 //----- (004A16A5) -------------------------------------------------------- | |
185 bool __cdecl AreRenderSurfacesOk() | |
186 { | |
187 char v0; // zf@4 | |
188 bool result; // eax@8 | |
189 | |
190 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
191 { | |
192 if ( !pRenderer->pBackBuffer4 ) | |
193 goto LABEL_9; | |
194 v0 = pRenderer->pFrontBuffer4 == 0; | |
195 } | |
196 else | |
197 { | |
198 if ( !pRenderer->pBackBuffer2 ) | |
199 goto LABEL_9; | |
200 v0 = pRenderer->pFrontBuffer2 == 0; | |
201 } | |
202 if ( !v0 ) | |
203 { | |
204 LOBYTE(result) = 1; | |
205 return result; | |
206 } | |
207 LABEL_9: | |
208 LOBYTE(result) = 0; | |
209 return result; | |
210 } | |
211 | |
988 | 212 |
1338 | 213 void Render::RenderTerrainD3D() // New function |
86 | 214 { |
215 char result; // al@3 | |
216 int v6; // ecx@8 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
217 struct Polygon *pTile; // ebx@8 |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
218 struct Polygon *v16; |
86 | 219 unsigned int v18; // edi@22 |
220 int v35; // edi@63 | |
221 int v37; // eax@73 | |
222 int v39; // eax@80 | |
223 char v40; // [sp-18h] [bp-70h]@2 | |
224 int v41; // [sp-14h] [bp-6Ch]@2 | |
225 int v42; // [sp-10h] [bp-68h]@2 | |
226 int v43; // [sp-Ch] [bp-64h]@2 | |
227 const char *v44; // [sp-8h] [bp-60h]@2 | |
228 int v45; // [sp-4h] [bp-5Ch]@2 | |
229 int v56; | |
230 int v57; // [sp+38h] [bp-20h]@36 | |
231 int v64; // [sp+57h] [bp-1h]@2 | |
232 int v62; | |
186 | 233 |
234 //warning: the game uses CW culling by default, ccw is incosistent | |
235 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
236 | |
1338 | 237 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ |
238 | |
239 // ------------------------------------------------------------------------- | |
240 // -64 0 0 64 | |
241 // | |
242 // -64 X 0 64 | |
243 // --------------- 64 | |
244 // | | | | |
245 // | | | | |
246 // | | | | |
247 // 0|------+------| Z | |
248 // | | | | |
249 // | | | | |
250 // | | | | |
251 // --------------- | |
252 // -64 | |
253 | |
254 int blockScale = 512; | |
255 int heightScale = 32; | |
256 for (unsigned int z = 0; z < 128; ++z) | |
257 { | |
258 for (unsigned int x = 0; x < 128; ++x) | |
259 { | |
260 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
261 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
262 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 263 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
264 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 265 } |
266 } | |
1338 | 267 //-------------------------------------------------------------------------------------------------------------------- |
268 | |
269 // | |
1344 | 270 for (unsigned int z = 0; z < 127; ++z) |
271 { | |
272 for (unsigned int x = 0; x < 127; ++x) | |
1338 | 273 { |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
274 pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; |
1338 | 275 pTile->flags = 0; |
276 pTile->field_32 = 0; | |
277 pTile->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
278 pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTile->uTileBitmapID]; | |
279 if (pTile->uTileBitmapID == 0xFFFF) | |
106 | 280 continue; |
186 | 281 |
1338 | 282 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
283 pTile->flags = pOutdoor->GetSomeOtherTileInfo(x, z); | |
284 pTile->field_32 = 0; | |
285 pTile->field_59 = 1; | |
286 pTile->sTextureDeltaU = 0; | |
287 pTile->sTextureDeltaV = 0; | |
288 // x,z x+1,z | |
289 // .____________. | |
290 // | | | |
291 // | | | |
292 // | | | |
293 // | | | |
294 // | | | |
295 // .____________. | |
296 // x,z+1 x+1,z+1 | |
297 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
106 | 298 array_73D150[0].u = 0; |
299 array_73D150[0].v = 0; | |
1338 | 300 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z |
106 | 301 array_73D150[1].u = 1; |
302 array_73D150[1].v = 0; | |
1338 | 303 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 |
106 | 304 array_73D150[2].u = 1; |
305 array_73D150[2].v = 1; | |
1338 | 306 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 |
106 | 307 array_73D150[3].u = 0; |
308 array_73D150[3].v = 1; | |
1338 | 309 //v58 = 0; |
310 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
311 //pTile->field_32 |= 0x0001; | |
312 pTile->pODMFace = nullptr; | |
313 pTile->uNumVertices = 4; | |
314 pTile->field_59 = 5; | |
315 | |
316 //shading ()---------------------------------------------------------------------------- | |
317 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
318 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1];// 1 , 1 | |
638 | 319 assert(norm_idx < uNumTerrainNormals); |
320 | |
321 auto norm = pTerrainNormals + norm_idx; | |
1338 | 322 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
323 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
324 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
325 pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); | |
326 //----------------------------------------------------------------------------------------------- | |
638 | 327 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
328 ++pOutdoorCamera->uNumPolygons; |
86 | 329 ++pOutdoorCamera->field_44; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
330 assert(pOutdoorCamera->uNumPolygons < 20000); |
265 | 331 |
1338 | 332 pTile->uBModelID = 0; |
333 pTile->uBModelFaceID = 0; | |
334 pTile->field_50 = (8 * (0 | (0 << 6))) | 6; | |
335 for (unsigned int k = 0; k < pTile->uNumVertices; ++k) | |
106 | 336 { |
337 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 338 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 339 } |
140 | 340 |
1338 | 341 // check the transparency and texture (tiles) mapping ( ())---------------------- |
186 | 342 bool transparent = false; |
1338 | 343 if ( !( pTile->flags & 1 ) ) // TextureFrameTable |
344 { | |
345 if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id) | |
346 { | |
347 //transparent = false; | |
348 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
349 } | |
350 else | |
351 { | |
352 v6 = pTile->uTileBitmapID; | |
353 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5) ) | |
354 transparent = true; | |
355 } | |
179 | 356 |
140 | 357 assert(v6 < 1000); // many random crashes here |
186 | 358 |
359 // for all shore tiles - draw a tile water under them since they're half-empty | |
1338 | 360 if (!_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX |
361 pTile->DrawBorderTiles(); | |
362 | |
363 pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
364 } | |
365 //else // | |
366 //pTile->DrawBorderTiles(); | |
367 //-------------------------------------------------------------------------------------------------------------------------------- | |
186 | 368 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
369 --pOutdoorCamera->uNumPolygons; |
86 | 370 --pOutdoorCamera->field_44; |
106 | 371 } |
372 } | |
373 } | |
0 | 374 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
375 |
0 | 376 |
377 //----- (0047BACF) -------------------------------------------------------- | |
378 void Render::TransformBillboardsAndSetPalettesODM() | |
379 { | |
142 | 380 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
381 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
382 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
383 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
384 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
385 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
386 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
387 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
388 //int v8; // ebx@4 |
0 | 389 unsigned __int16 *v9; // eax@7 |
390 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
391 //DWORD v11; // eax@13 |
0 | 392 int v12; // eax@13 |
393 int v13; // eax@14 | |
394 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
395 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 396 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
397 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 398 int v18; // [sp+60h] [bp-4h]@13 |
399 | |
400 billboard.uParentBillboardID = -1; | |
401 billboard.pTarget = pRenderer->pTargetSurface; | |
402 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
403 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 404 billboard.uViewportX = pViewport->uViewportTL_X; |
405 billboard.uViewportY = pViewport->uViewportTL_Y; | |
406 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
407 billboard.uViewportW = pViewport->uViewportBR_Y; | |
0 | 408 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; |
142 | 409 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
410 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 411 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
412 auto pBillboard = pBillboardRenderList + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
413 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
414 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
415 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
416 billboard.uParentBillboardID = i; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
417 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
418 billboard.uTintColor = pBillboard->uTintColor; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
419 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
420 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
421 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
422 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
423 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
424 if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
425 //if (pRenderer->pRenderD3D) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
426 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
427 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
657 | 428 pBillboard->dimming_level, pBillboard); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
429 /*else |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
430 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
431 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
432 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
433 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 434 if ( *(v1 - 10) & 2 ) |
435 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
436 else | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
437 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 438 v10 = (*(v1 - 9) & 1) == 0; |
439 billboard.pPalette = v9; | |
440 if ( !v10 ) | |
441 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
442 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
443 { | |
323 | 444 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 445 v15 = abs(v12); |
446 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
447 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
448 } | |
449 v13 = *((short *)v1 - 8); | |
450 if ( v13 >= 0 ) | |
733 | 451 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
452 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
453 } |
0 | 454 } |
455 } | |
456 | |
457 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
458 void Render::DrawSpriteObjects_ODM() |
0 | 459 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
460 //char *v0; // edi@2 |
430 | 461 //ObjectDesc *v1; // ebx@4 |
0 | 462 __int16 v2; // cx@5 |
463 RenderBillboard *v3; // esi@10 | |
464 SpriteFrame *v4; // eax@10 | |
430 | 465 //SpriteFrame *v5; // ebx@10 |
0 | 466 unsigned int v6; // eax@10 |
430 | 467 //int v7; // ecx@10 |
468 //int v8; // edx@10 | |
0 | 469 int v9; // ecx@10 |
470 unsigned __int16 v10; // ax@10 | |
430 | 471 //int *v11; // eax@14 |
0 | 472 int v12; // eax@22 |
473 int v13; // ST3C_4@23 | |
474 int v14; // eax@23 | |
475 int v15; // ecx@23 | |
476 int v16; // ebx@23 | |
477 int v17; // ecx@25 | |
478 int v18; // eax@25 | |
479 int v19; // ST40_4@26 | |
480 int v20; // ecx@26 | |
481 int v21; // ST44_4@28 | |
482 int v22; // ST3C_4@29 | |
483 signed __int64 v23; // qtt@30 | |
484 int v24; // ebx@30 | |
485 int v25; // ST3C_4@30 | |
486 int v26; // eax@31 | |
487 char v27; // zf@31 | |
430 | 488 //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 |
489 //__int16 a5; // [sp+10h] [bp-30h]@10 | |
0 | 490 int v30; // [sp+14h] [bp-2Ch]@23 |
491 int v31; // [sp+14h] [bp-2Ch]@29 | |
492 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
493 int v33; // [sp+18h] [bp-28h]@23 | |
494 int v34; // [sp+18h] [bp-28h]@26 | |
495 int v35; // [sp+18h] [bp-28h]@30 | |
496 int v36; // [sp+1Ch] [bp-24h]@10 | |
497 int v37; // [sp+1Ch] [bp-24h]@23 | |
498 int a6; // [sp+20h] [bp-20h]@10 | |
499 int a6a; // [sp+20h] [bp-20h]@23 | |
500 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
501 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 502 int v42; // [sp+2Ch] [bp-14h]@23 |
503 int y; // [sp+30h] [bp-10h]@10 | |
504 int x; // [sp+34h] [bp-Ch]@10 | |
505 int z; // [sp+38h] [bp-8h]@10 | |
506 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
507 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
508 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
509 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
|
510 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
511 auto object = &pSpriteObjects[i]; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
512 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
513 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
514 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
515 //{ |
430 | 516 if (!object->uObjectDescID) // item probably pciked up |
517 continue; | |
518 | |
519 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
520 auto object_desc = pObjectList->pObjects + object->uObjectDescID; | |
521 if (object_desc->NoSprite()) | |
522 continue; | |
523 | |
524 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
525 //if ( !(v1->uFlags & 1) ) | |
526 //{ | |
527 //v2 = *((short *)v0 - 14) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
528 v2 = object->uType; |
430 | 529 if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) |
530 { | |
531 //a5 = *(short *)v0; | |
532 x = object->vPosition.x; | |
533 y = object->vPosition.y; | |
534 z = object->vPosition.z; | |
535 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; | |
536 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
537 //v5 = v4; | |
538 //v28 = v4; | |
539 v36 = v4->uFlags; | |
540 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; | |
541 v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCamera->pos.x, object->vPosition.y - pIndoorCamera->pos.y); | |
542 //LOWORD(v7) = object->uFacing; | |
543 //v8 = v36; | |
544 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
545 v10 = v4->pHwSpriteIDs[v9]; | |
0 | 546 v3->uHwSpriteID = v10; |
547 if ( v36 & 0x20 ) | |
548 { | |
430 | 549 //v8 = v36; |
550 z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
0 | 551 } |
552 v46 = 0; | |
430 | 553 if ( v36 & 2 ) |
0 | 554 v46 = 2; |
430 | 555 //v11 = (int *)(256 << v9); |
556 if ( (256 << v9) & v36 ) | |
0 | 557 v46 |= 4u; |
430 | 558 if ( v36 & 0x40000 ) |
0 | 559 v46 |= 0x40u; |
430 | 560 if ( v36 & 0x20000 ) |
0 | 561 LOBYTE(v46) = v46 | 0x80; |
562 if ( a6 ) | |
563 { | |
430 | 564 //LOBYTE(v11) = byte_4E94D3; |
565 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
0 | 566 } |
567 v12 = (x - pIndoorCamera->pos.x) << 16; | |
568 if ( pIndoorCamera->sRotationX ) | |
569 { | |
570 v13 = (y - pIndoorCamera->pos.y) << 16; | |
571 v30 = ((unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
572 + ((unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
573 v37 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
574 a6a = (unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
575 v33 = (z - pIndoorCamera->pos.z) << 16; | |
576 v14 = (unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
577 v15 = (unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
578 v16 = v15 + v14; | |
579 v42 = v15 + v14; | |
580 if ( v15 + v14 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
581 { | |
582 v17 = a6a - v37; | |
583 v40 = a6a - v37; | |
584 v18 = ((unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | |
585 - ((unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
586 goto LABEL_29; | |
587 } | |
588 } | |
589 else | |
590 { | |
591 v34 = (y - pIndoorCamera->pos.y) << 16; | |
592 v19 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
593 v20 = (unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
594 v16 = v20 + v19; | |
595 v42 = v20 + v19; | |
596 if ( v20 + v19 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
597 { | |
430 | 598 v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; |
599 v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
600 v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
0 | 601 v18 = (z - pIndoorCamera->pos.z) << 16; |
602 LABEL_29: | |
603 v31 = v18; | |
604 v22 = abs(v17); | |
605 if ( abs(v16) >= v22 ) | |
606 { | |
607 LODWORD(v23) = 0; | |
608 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
609 v24 = v23 / v42; | |
610 v25 = v23 / v42; | |
611 LODWORD(v23) = 0; | |
612 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
430 | 613 v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); |
614 v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
615 | |
616 //if (::uNumBillboardsToDraw >= 500) | |
617 // return; | |
618 assert(::uNumBillboardsToDraw < 500); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
619 ++::uNumBillboardsToDraw; |
0 | 620 ++uNumSpritesDrawnThisFrame; |
430 | 621 |
622 object->uAttributes |= 1; | |
623 v3->uPalette = v4->uPaletteIndex; | |
624 v3->uIndoorSectorID = object->uSectorID; | |
625 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
626 v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
627 v3->pSpriteFrame = v4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
628 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 629 v3->field_1E = v46; |
430 | 630 v3->world_x = x; |
631 v3->world_y = y; | |
632 v3->world_z = z; | |
0 | 633 v3->uScreenSpaceX = v35; |
634 v3->uScreenSpaceY = v32; | |
635 HIWORD(v26) = HIWORD(v42); | |
636 LOWORD(v26) = 0; | |
430 | 637 v27 = (object->uAttributes & 0x20) == 0; |
862 | 638 v3->sZValue = v26 + (PID(OBJECT_Item,i)); |
657 | 639 v3->dimming_level = 0; |
0 | 640 v3->uTintColor = 0; |
641 if ( !v27 ) | |
642 { | |
643 if ( !pRenderer->pRenderD3D ) | |
644 v3->sZValue = 0; | |
645 } | |
646 } | |
647 goto LABEL_34; | |
648 } | |
649 } | |
650 } | |
430 | 651 //} |
0 | 652 LABEL_34: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
653 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
654 //++v41; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
655 //v0 += 112; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
656 //} |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
657 //while ( v41 < (signed int)uNumSpriteObjects ); |
0 | 658 } |
659 } | |
660 // 4E94D3: using guessed type char byte_4E94D3; | |
661 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; | |
662 | |
663 //----- (0049D9BC) -------------------------------------------------------- | |
664 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
665 { | |
666 size_t v4; // eax@1 | |
667 size_t v5; // eax@1 | |
668 IUnknown *v6; // eax@10 | |
669 size_t v7; // eax@13 | |
670 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
671 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
672 int v11; // [sp+430h] [bp-CCh]@16 | |
673 int v12; // [sp+434h] [bp-C8h]@16 | |
674 int v13; // [sp+438h] [bp-C4h]@16 | |
675 int v14; // [sp+474h] [bp-88h]@16*/ | |
676 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
677 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
678 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
679 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
680 int v19; // [sp+4C8h] [bp-34h]@16 | |
681 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
682 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
683 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
684 | |
685 v4 = strlen(lpDriverName); | |
686 v20.pDriverName = new char[v4 + 1]; | |
687 v5 = strlen(lpDevDesc); | |
688 v20.pDeviceDesc = new char[v5 + 1]; | |
689 strcpy(v20.pDriverName, lpDriverName); | |
690 strcpy(v20.pDeviceDesc, lpDevDesc); | |
691 if ( lpGUID ) | |
692 { | |
693 v20.pGUID = new GUID; | |
694 memcpy(v20.pGUID, lpGUID, 0x10u); | |
695 } | |
696 else | |
697 { | |
698 v20.pGUID = 0; | |
699 } | |
700 | |
701 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
702 { | |
703 delete [] v20.pDriverName; | |
704 delete [] v20.pDeviceDesc; | |
705 if ( v20.pGUID ) | |
706 delete v20.pGUID; | |
707 } | |
708 else | |
709 { | |
710 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
711 { | |
712 delete [] v20.pDriverName; | |
713 delete [] v20.pDeviceDesc; | |
714 if ( v20.pGUID ) | |
715 delete v20.pGUID; | |
716 v6 = (IUnknown *)pDirectDraw; | |
717 } | |
718 else | |
719 { | |
720 pDirectDraw->Release(); | |
721 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
722 { | |
723 v20.pDDraw4DevDesc = 0; | |
724 } | |
725 else | |
726 { | |
727 v7 = strlen(ddDevId.szDescription); | |
728 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
729 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
730 } | |
731 memset(&ddsCaps, 0, 0x10u); | |
732 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
733 &ddsCaps, | |
734 (LPDWORD)&v20.uVideoMem, | |
735 (LPDWORD)&uFreeVideoMem))) | |
736 v20.uVideoMem = 0; | |
737 memset(&v10, 0, 0x7Cu); | |
738 v10.dwSize = 124; | |
739 v10.dwFlags = 6; | |
740 v10.dwHeight = 640; | |
741 v10.dwWidth = 480; | |
742 v10.ddpfPixelFormat.dwSize = 32; | |
743 | |
744 v19 = 0; | |
745 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
746 0, | |
747 0, | |
748 &v19, | |
749 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
750 || !v19 | |
751 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
752 { | |
753 delete [] v20.pDriverName; | |
754 delete [] v20.pDeviceDesc; | |
755 if ( v20.pDDraw4DevDesc ) | |
756 free(v20.pDDraw4DevDesc); | |
757 if ( v20.pGUID ) | |
758 delete v20.pGUID; | |
759 v6 = (IUnknown *)pDirectDraw4; | |
760 } | |
761 else | |
762 { | |
763 aux.pInfo = pOut; | |
764 aux.ptr_4 = &v20; | |
765 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
766 delete [] v20.pDriverName; | |
767 delete [] v20.pDeviceDesc; | |
768 if ( v20.pDDraw4DevDesc ) | |
769 free(v20.pDDraw4DevDesc); | |
770 if ( v20.pGUID ) | |
771 delete v20.pGUID; | |
772 pDirectDraw4->Release(); | |
773 v6 = (IUnknown *)pDirect3D3; | |
774 pDirectDraw4 = 0; | |
775 } | |
776 } | |
777 v6->Release(); | |
778 } | |
779 return 1; | |
780 } | |
781 | |
782 //----- (0049D784) -------------------------------------------------------- | |
783 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
784 { | |
785 int v6; // eax@1 | |
786 signed int v7; // edi@1 | |
787 signed int v8; // edi@14 | |
788 size_t v9; // eax@30 | |
789 size_t v10; // eax@30 | |
790 size_t v11; // eax@30 | |
791 size_t v12; // eax@30 | |
792 size_t v13; // eax@30 | |
793 | |
794 v6 = pHWDesc->dwFlags; | |
795 v7 = -1; | |
796 if ( v6 ) | |
797 { | |
798 if ( !a6->ptr_4->pGUID ) | |
799 v7 = 0; | |
800 if ( v6 && a6->ptr_4->pGUID ) | |
801 v7 = 1; | |
802 } | |
803 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
804 v7 = 2; | |
805 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
806 v7 = 3; | |
807 if ( v7 != -1 ) | |
808 { | |
809 v8 = v7; | |
810 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
811 a6->pInfo[v8].uCaps = 0; | |
812 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
813 a6->pInfo[v8].uCaps |= 2u; | |
814 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
815 a6->pInfo[v8].uCaps |= 4u; | |
816 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
817 a6->pInfo[v8].uCaps |= 8u; | |
818 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
819 a6->pInfo[v8].uCaps |= 0x10u; | |
820 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
821 a6->pInfo[v8].uCaps |= 0x20u; | |
822 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
823 a6->pInfo[v8].uCaps |= 0x40u; | |
824 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
825 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
826 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
827 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
828 v9 = strlen(lpDeviceName); | |
829 a6->pInfo[v8].pName = new char[v9 + 1]; | |
830 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
831 v10 = strlen(lpDeviceDesc); | |
832 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
833 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
834 a6->pInfo[v8].pGUID = (GUID *)operator new(0x10u); | |
835 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); | |
836 v11 = strlen(a6->ptr_4->pDriverName); | |
837 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
838 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
839 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
840 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
841 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
842 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
843 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
844 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
845 if ( a6->ptr_4->pGUID ) | |
846 { | |
847 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
848 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
849 } | |
850 else | |
851 { | |
852 a6->pInfo[v8].pDirectDrawGUID = 0; | |
853 } | |
854 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
855 } | |
856 return 1; | |
857 } | |
858 | |
859 //----- (0049D75C) -------------------------------------------------------- | |
860 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
861 { | |
862 HRESULT result; // eax@3 | |
863 | |
864 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
865 { | |
866 *a2 = 1; | |
867 result = 0; | |
868 } | |
869 else | |
870 { | |
871 result = 1; | |
872 } | |
873 return result; | |
874 } | |
875 | |
876 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
877 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
878 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
879 //char *v0; // esi@2 |
639 | 880 //DecorationDesc *v1; // ebx@6 |
0 | 881 __int16 v2; // ax@6 |
882 double v3; // st7@7 | |
639 | 883 //int v4; // eax@9 |
884 //int v5; // edx@9 | |
0 | 885 unsigned int v6; // edi@9 |
886 int v7; // eax@9 | |
887 SpriteFrame *v8; // eax@9 | |
635 | 888 //SpriteFrame *v9; // edi@9 |
0 | 889 unsigned __int16 *v10; // eax@9 |
890 int v11; // ecx@9 | |
891 int v12; // eax@9 | |
892 int v13; // ecx@9 | |
893 int v14; // ecx@20 | |
894 char v15; // dl@20 | |
895 signed int v16; // eax@20 | |
896 int v17; // eax@23 | |
897 int v18; // ecx@24 | |
898 int v19; // eax@24 | |
899 int v20; // ecx@24 | |
900 int v21; // ebx@26 | |
901 int v22; // eax@26 | |
902 int v23; // eax@30 | |
903 signed __int64 v24; // qtt@31 | |
904 int v25; // ebx@31 | |
905 int v26; // ecx@32 | |
906 RenderBillboard *v27; // eax@37 | |
907 __int16 v28; // dx@37 | |
908 __int16 v29; // cx@37 | |
909 int v30; // ecx@37 | |
910 int v31; // ebx@37 | |
619 | 911 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
639 | 912 //int x; // [sp+74h] [bp-30h]@9 |
913 //int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
914 //int v35; // [sp+7Ch] [bp-28h]@1 |
639 | 915 //int v36; // [sp+80h] [bp-24h]@9 |
0 | 916 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
917 int v38; // [sp+88h] [bp-1Ch]@9 | |
918 int v39; // [sp+8Ch] [bp-18h]@24 | |
919 int v40; // [sp+90h] [bp-14h]@24 | |
920 int v41; // [sp+94h] [bp-10h]@24 | |
921 int v42; // [sp+98h] [bp-Ch]@9 | |
922 int a5; // [sp+9Ch] [bp-8h]@9 | |
923 int b; // [sp+A0h] [bp-4h]@22 | |
924 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
925 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
926 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
927 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
928 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
929 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
930 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
931 { |
1202 | 932 auto decor = &pLevelDecorations[i]; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
933 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
934 |
639 | 935 if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) ) |
936 { | |
937 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
938 auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; | |
939 v2 = decor_desc->uFlags; | |
0 | 940 if ( (char)v2 >= 0 ) |
941 { | |
942 if ( !(v2 & 0x22) ) | |
943 { | |
639 | 944 //v4 = decor->vPosition.x; |
945 //v5 = decor->vPosition.z; | |
0 | 946 v6 = pMiscTimer->uTotalGameTimeElapsed; |
639 | 947 //y = decor->vPosition.y; |
948 //x = decor->vPosition.x; | |
949 //v36 = decor->vPosition.z; | |
950 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
635 | 951 |
952 | |
953 #pragma region "New: seasons change" | |
954 extern bool change_seasons; | |
955 if (change_seasons) | |
956 switch (pParty->uCurrentMonth) | |
957 { | |
958 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
959 case 11: case 0: case 1: // winter | |
639 | 960 switch (decor_desc->uSpriteID) |
635 | 961 { |
962 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
963 case 548: // flower10 | |
964 case 547: // flower09 | |
965 case 541: // flower03 | |
966 case 539: continue; // flower01 | |
967 | |
968 case 483: // tree01 | |
969 case 486: // tree04 | |
970 case 492: // tree10 | |
639 | 971 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); |
972 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
635 | 973 break; |
974 | |
975 default: | |
639 | 976 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 977 } |
978 break; | |
979 | |
980 case 2: case 3: case 4: // spring | |
639 | 981 switch (decor_desc->uSpriteID) |
635 | 982 { |
983 } | |
639 | 984 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 985 break; |
986 | |
987 case 8: case 9: case 10: // autumn | |
639 | 988 switch (decor_desc->uSpriteID) |
635 | 989 { |
990 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
991 case 548: // flower10 | |
992 case 547: // flower09 | |
993 case 541: // flower03 | |
994 case 539: continue; // flower01 | |
995 | |
996 case 483: // tree01 | |
997 case 486: // tree04 | |
998 case 492: // tree10 | |
639 | 999 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); |
1000 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
635 | 1001 break; |
1002 | |
1003 default: | |
639 | 1004 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1005 } |
1006 break; | |
1007 | |
1008 case 5: case 6: case 7: // summer | |
1009 //all green by default | |
639 | 1010 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1011 break; |
1012 | |
1013 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
1014 } | |
637 | 1015 else |
639 | 1016 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1017 #pragma endregion |
639 | 1018 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1019 |
1020 //v9 = v8; | |
0 | 1021 v42 = v8->uFlags; |
1022 a5 = v8->uGlowRadius; | |
639 | 1023 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, |
1024 decor->vPosition.y - pIndoorCamera->pos.y); | |
0 | 1025 v11 = *((int *)v0 + 2); |
1026 v37 = v10; | |
1027 v12 = v42; | |
1028 v38 = 0; | |
1029 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
1030 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
1031 + v11 | |
1032 - (signed int)v37) >> 8) & 7; | |
1033 v37 = (unsigned __int16 *)v13; | |
1034 if ( v42 & 2 ) | |
1035 v38 = 2; | |
1036 if ( (256 << v13) & v42 ) | |
1037 v38 |= 4u; | |
1038 if ( v12 & 0x40000 ) | |
1039 v38 |= 0x40u; | |
1040 if ( v12 & 0x20000 ) | |
1041 LOBYTE(v38) = v38 | 0x80; | |
1042 if ( a5 ) | |
1043 { | |
1044 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) | |
1045 { | |
639 | 1046 v14 = decor_desc->uColoredLightRed; |
1047 v15 = decor_desc->uColoredLightGreen; | |
1048 v16 = decor_desc->uColoredLightBlue; | |
0 | 1049 } |
1050 else | |
1051 { | |
1052 v16 = 255; | |
1053 v14 = 255; | |
1054 v15 = 255; | |
1055 } | |
1056 b = v16; | |
1057 pStationaryLightsStack->AddLight( | |
639 | 1058 decor->vPosition.x, |
1059 decor->vPosition.y, | |
1060 decor->vPosition.z + decor_desc->uDecorationHeight / 2, | |
0 | 1061 a5, |
1062 v14, | |
1063 v15, | |
1064 v16, | |
1065 byte_4E94D0); | |
1066 } | |
639 | 1067 v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
0 | 1068 if ( pIndoorCamera->sRotationX ) |
1069 { | |
639 | 1070 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; |
0 | 1071 v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) |
1072 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
1073 v42 = v18; | |
1074 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
1075 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
639 | 1076 v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 1077 v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; |
1078 v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
1079 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
1080 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
1081 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
1082 { | |
1083 v21 = a5 - b; | |
1084 v41 = a5 - b; | |
1085 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
1086 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
1087 v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; | |
1088 LABEL_30: | |
1089 v42 = v22; | |
1090 v40 = 2 * abs(v20); | |
1091 v23 = abs(v21); | |
1092 if ( v40 >= v23 ) | |
1093 { | |
1094 LODWORD(v24) = 0; | |
1095 HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
1096 a5 = v24 / v39; | |
1097 v25 = pViewport->uScreenCenterX | |
1098 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
1099 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
1100 v41 = v24 / v39; | |
1101 v40 = pViewport->uScreenCenterY | |
1102 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
635 | 1103 v42 = v8->scale; |
0 | 1104 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; |
635 | 1105 v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; |
0 | 1106 if ( pRenderer->pRenderD3D ) |
1107 { | |
1108 v26 = v41; | |
1109 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
1110 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
1111 } | |
1112 else | |
1113 { | |
1114 v26 = v41; | |
1115 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
1116 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
1117 } | |
693 | 1118 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
0 | 1119 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1120 if (::uNumBillboardsToDraw >= 500) |
0 | 1121 return; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1122 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; |
0 | 1123 ++uNumDecorationsDrawnThisFrame; |
1124 v27->uHwSpriteID = *v37; | |
635 | 1125 v28 = v8->uPaletteIndex; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1126 v27->_screenspace_x_scaler_packedfloat = v26; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1127 v27->_screenspace_y_scaler_packedfloat = v26; |
0 | 1128 v29 = v38; |
1129 v27->uScreenSpaceX = v25; | |
1130 HIBYTE(v29) |= 2u; | |
1131 v27->uPalette = v28; | |
1132 v27->field_1E = v29; | |
639 | 1133 v27->world_x = decor->vPosition.x; |
1134 v27->world_y = decor->vPosition.y; | |
1135 v27->world_z = decor->vPosition.z; | |
0 | 1136 v27->uScreenSpaceY = v40; |
1137 HIWORD(v30) = HIWORD(v39); | |
862 | 1138 v31 = PID(OBJECT_Decoration,i); |
0 | 1139 LOWORD(v30) = 0; |
1140 v27->uIndoorSectorID = 0; | |
1141 v27->sZValue = v30 + v31; | |
657 | 1142 v27->dimming_level = 0; |
635 | 1143 v27->pSpriteFrame = v8; |
0 | 1144 v27->uTintColor = 0; |
1145 } | |
1146 } | |
1147 goto LABEL_38; | |
1148 } | |
1149 } | |
1150 else | |
1151 { | |
639 | 1152 v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
1153 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; | |
0 | 1154 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; |
1155 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
1156 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
1157 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
1158 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
1159 { | |
1160 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
1161 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
1162 v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
1163 v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
639 | 1164 v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 1165 goto LABEL_30; |
1166 } | |
1167 } | |
1168 } | |
1169 } | |
1170 else | |
1171 { | |
1172 memset(&local_0, 0, 0x68u); | |
1173 v3 = (double)*((signed int *)v0 - 1); | |
619 | 1174 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
1175 local_0.uDiffuse = 0xFF3C1E; | |
0 | 1176 local_0.x = v3; |
1177 local_0.y = (double)*(signed int *)v0; | |
1178 local_0.z = (double)*((signed int *)v0 + 1); | |
1390 | 1179 local_0.r = 0.0; |
1180 local_0.g = 0.0; | |
1181 local_0.b = 0.0; | |
0 | 1182 local_0.flt_28 = 1.0; |
1183 local_0.timeToLive = (rand() & 0x80) + 128; | |
1184 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
1185 pGame->pParticleEngine->AddParticle(&local_0); | |
1186 } | |
1187 } | |
1188 LABEL_38: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1189 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1190 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1191 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1192 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1193 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 1194 } |
1195 // 4E94D0: using guessed type char byte_4E94D0; | |
1196 // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; | |
1197 | |
1198 //----- (0049D717) -------------------------------------------------------- | |
1199 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1200 { | |
1201 HRESULT v2; // esi@2 | |
1202 | |
1203 if ( Src->dwFlags & 0x400 | 0x2000 ) | |
1204 { | |
1205 v2 = 0; | |
1206 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
1207 goto LABEL_6; | |
1208 if ( !Dst->dwSize ) | |
1209 { | |
1210 v2 = 1; | |
1211 LABEL_6: | |
1212 memcpy(Dst, Src, 0x20u); | |
1213 return v2; | |
1214 } | |
1215 } | |
1216 return 1; | |
1217 } | |
1218 | |
1219 //----- (0049DC28) -------------------------------------------------------- | |
1220 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1221 { | |
1222 RenderD3D__DevInfo *v2; // eax@1 | |
1223 | |
1224 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1225 *pOutDevices = v2; | |
1226 memset(v2, 0, 0xA0u); | |
1227 DirectDrawEnumerateA((LPDDENUMCALLBACKA)RenderD3D__DeviceEnumerator, *pOutDevices); | |
1228 } | |
1229 | |
1230 //----- (0049DC58) -------------------------------------------------------- | |
1231 RenderD3D::RenderD3D() | |
1232 { | |
1233 RenderD3D *v1; // esi@1 | |
1234 | |
1235 v1 = this; | |
1236 this->pHost = 0; | |
1237 this->pDirect3D = 0; | |
1238 this->pUnk = 0; | |
1239 this->pBackBuffer = 0; | |
1240 this->pFrontBuffer = 0; | |
1241 this->pZBuffer = 0; | |
1242 this->pDevice = 0; | |
1243 this->pViewport = 0; | |
1244 this->field_40 = 1; | |
1245 this->field_44 = 10; | |
1246 GetAvailableDevices(&this->pAvailableDevices); | |
1247 } | |
1248 | |
1249 //----- (0049DC90) -------------------------------------------------------- | |
1250 void RenderD3D::Release() | |
1251 { | |
1252 RenderD3D *v1; // esi@1 | |
1253 IDirectDraw4 *v2; // eax@2 | |
1254 signed int v3; // edi@4 | |
1255 IDirect3DViewport3 *v4; // eax@22 | |
1256 IUnknown *v5; // eax@24 | |
1257 IDirectDrawSurface4 *v6; // eax@26 | |
1258 IDirect3DDevice3 *v7; // eax@28 | |
1259 IDirect3D3 *v8; // eax@30 | |
1260 IDirectDrawSurface4 *v9; // eax@32 | |
1261 IDirectDrawSurface4 *v10; // eax@34 | |
1262 IDirectDraw4 *v11; // eax@36 | |
1263 | |
1264 v1 = this; | |
1265 if ( !this->bWindowed ) | |
1266 { | |
1267 v2 = this->pHost; | |
1268 if ( v2 ) | |
1269 { | |
1270 v2->RestoreDisplayMode(); | |
1271 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
1272 v1->pHost->FlipToGDISurface(); | |
1273 } | |
1274 } | |
1275 v3 = 0; | |
1276 do | |
1277 { | |
1278 if ( v1->pAvailableDevices[v3].pDriverName ) | |
1279 { | |
1280 free(v1->pAvailableDevices[v3].pDriverName); | |
1281 v1->pAvailableDevices[v3].pDriverName = 0; | |
1282 } | |
1283 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
1284 { | |
1285 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
1286 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
1287 } | |
1288 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
1289 { | |
1290 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
1291 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
1292 } | |
1293 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
1294 { | |
1295 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
1296 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
1297 } | |
1298 if ( v1->pAvailableDevices[v3].pName ) | |
1299 { | |
1300 free(v1->pAvailableDevices[v3].pName); | |
1301 v1->pAvailableDevices[v3].pName = 0; | |
1302 } | |
1303 if ( v1->pAvailableDevices[v3].pDescription ) | |
1304 { | |
1305 free(v1->pAvailableDevices[v3].pDescription); | |
1306 v1->pAvailableDevices[v3].pDescription = 0; | |
1307 } | |
1308 if ( v1->pAvailableDevices[v3].pGUID ) | |
1309 { | |
1310 free(v1->pAvailableDevices[v3].pGUID); | |
1311 v1->pAvailableDevices[v3].pGUID = 0; | |
1312 } | |
1313 ++v3; | |
1314 } | |
1315 while ( v3 < 4 ); | |
1316 if ( v1->pAvailableDevices ) | |
1317 { | |
1318 free(v1->pAvailableDevices); | |
1319 v1->pAvailableDevices = 0; | |
1320 } | |
1321 v4 = v1->pViewport; | |
1322 if ( v4 ) | |
1323 { | |
1324 v4->Release(); | |
1325 v1->pViewport = 0; | |
1326 } | |
1327 v5 = v1->pUnk; | |
1328 if ( v5 ) | |
1329 { | |
1330 v5->Release(); | |
1331 v1->pUnk = 0; | |
1332 } | |
1333 v6 = v1->pZBuffer; | |
1334 if ( v6 ) | |
1335 { | |
1336 v6->Release(); | |
1337 v1->pZBuffer = 0; | |
1338 } | |
1339 v7 = v1->pDevice; | |
1340 if ( v7 ) | |
1341 { | |
1342 v7->Release(); | |
1343 v1->pDevice = 0; | |
1344 } | |
1345 v8 = v1->pDirect3D; | |
1346 if ( v8 ) | |
1347 { | |
1348 v8->Release(); | |
1349 v1->pDirect3D = 0; | |
1350 } | |
1351 v9 = v1->pBackBuffer; | |
1352 if ( v9 ) | |
1353 { | |
1354 v9->Release(); | |
1355 v1->pBackBuffer = 0; | |
1356 } | |
1357 v10 = v1->pFrontBuffer; | |
1358 if ( v10 ) | |
1359 { | |
1360 v10->Release(); | |
1361 v1->pFrontBuffer = 0; | |
1362 } | |
1363 v11 = v1->pHost; | |
1364 if ( v11 ) | |
1365 { | |
1366 v11->Release(); | |
1367 v1->pHost = 0; | |
1368 } | |
1369 } | |
1370 | |
1371 //----- (0049DE14) -------------------------------------------------------- | |
1372 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | |
1373 { | |
1374 //IDirectDraw4 *v8; // eax@12 | |
1375 //IDirectDraw4 *v9; // eax@16 | |
1376 //IDirectDraw4 *v10; // eax@20 | |
1377 //IDirectDraw4 *v13; // eax@35 | |
1378 const char *v23; // [sp-4h] [bp-DCh]@9 | |
1379 const char *v24; // [sp-4h] [bp-DCh]@13 | |
1380 const char *v25; // [sp-4h] [bp-DCh]@19 | |
1381 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1382 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1383 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1384 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1385 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
1386 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1387 | |
1388 this->bWindowed = bWindowed; | |
1389 this->hWindow = hWnd; | |
1390 | |
1391 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
1392 { | |
1393 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1394 return 0; | |
1395 } | |
1396 | |
1397 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1398 { | |
1399 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1400 if (lpDD) | |
1401 lpDD->Release(); | |
1402 return 0; | |
1403 } | |
1404 lpDD->Release(); | |
1405 lpDD = 0; | |
1406 | |
1407 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1408 { | |
1409 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
1410 { | |
1411 v23 = "Init - Failed to set cooperative level.\n"; | |
1412 sprintf(pErrorMessage, v23); | |
1413 LABEL_65: | |
1414 if (pHost) | |
1415 { | |
1416 pHost->Release(); | |
1417 pHost = 0; | |
1418 } | |
1419 return 0; | |
1420 } | |
1421 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1422 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1423 ddsd2.dwFlags = DDSD_CAPS; | |
1424 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
1425 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1426 { | |
1427 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1428 pHost->GetDisplayMode(&ddsd2); | |
1429 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
1430 { | |
1431 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
1432 goto LABEL_14; | |
1433 } | |
1434 | |
1435 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
1436 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
1437 ddsd2.dwWidth = 640; | |
1438 ddsd2.dwHeight = 480; | |
1439 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | |
1440 { | |
1441 v24 = "Init - Failed to create back buffer.\n"; | |
1442 LABEL_14: | |
1443 sprintf(pErrorMessage, v24); | |
1444 if (pFrontBuffer) | |
1445 { | |
1446 pFrontBuffer->Release(); | |
1447 pFrontBuffer = 0; | |
1448 } | |
1449 goto LABEL_65; | |
1450 } | |
1451 if ( pHost->CreateClipper(0, &v30, 0) ) | |
1452 { | |
1453 v25 = "Init - Failed to create clipper.\n"; | |
1454 goto LABEL_45; | |
1455 } | |
1456 v30->SetHWnd(0, hWnd); | |
1457 pFrontBuffer->SetClipper(v30); | |
1458 | |
1459 v30->Release(); | |
1460 v30 = 0; | |
1461 | |
1462 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1463 | |
1464 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1465 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1466 ddsd2.dwWidth = 640; | |
1467 ddsd2.dwHeight = 480; | |
1468 | |
1469 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1470 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1471 &ddsd2.ddpfPixelFormat) ) | |
1472 goto LABEL_21; | |
1473 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1474 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
1475 | |
1476 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1477 { | |
1478 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
1479 { | |
1480 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1481 pBackBuffer, | |
1482 &pDevice, | |
1483 0) ) | |
1484 { | |
1485 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1486 d3dvp2.dvClipWidth = 2.0; | |
1487 d3dvp2.dvClipY = 1.0; | |
1488 d3dvp2.dvClipHeight = 2.0; | |
1489 d3dvp2.dvMaxZ = 1.0; | |
1490 d3dvp2.dvMinZ = 0.0; | |
1491 goto LABEL_54; | |
1492 } | |
1493 LABEL_51: | |
1494 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1495 if (pDirect3D) | |
1496 { | |
1497 pDirect3D->Release(); | |
1498 pDirect3D = 0; | |
1499 } | |
1500 goto LABEL_59; | |
1501 } | |
1502 LABEL_48: | |
1503 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1504 if (pZBuffer) | |
1505 { | |
1506 pZBuffer->Release(); | |
1507 pZBuffer = 0; | |
1508 } | |
1509 goto LABEL_61; | |
1510 } | |
1511 goto LABEL_44; | |
1512 } | |
1513 LABEL_36: | |
1514 v23 = "Init - Failed to create front buffer.\n"; | |
1515 sprintf(pErrorMessage, v23); | |
1516 goto LABEL_65; | |
1517 } | |
1518 if ( uDeviceID == 1 ) | |
1519 v26 = 1045; | |
1520 else | |
1521 v26 = 1041; | |
1522 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
1523 { | |
1524 v23 = "Init - Failed to set cooperative level.\n"; | |
1525 sprintf(pErrorMessage, v23); | |
1526 goto LABEL_65; | |
1527 } | |
1528 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
1529 { | |
1530 v23 = "Init - Failed to set display mode.\n"; | |
1531 sprintf(pErrorMessage, v23); | |
1532 goto LABEL_65; | |
1533 } | |
1534 | |
1535 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1536 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1537 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
1538 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
1539 ddsd2.dwBackBufferCount = 1; | |
1540 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1541 goto LABEL_36; | |
1542 //a3a = &pBackBuffer; | |
1543 //v14 = *v34; | |
1544 memset(&v27, 0, sizeof(DDSCAPS2)); | |
1545 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
1546 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
1547 //hWnda = &pDirect3D; | |
1548 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1549 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
1550 { | |
1551 v25 = "Init - Failed to get D3D interface.\n"; | |
1552 goto LABEL_45; | |
1553 } | |
1554 | |
1555 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1556 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1557 ddsd2.dwWidth = 640; | |
1558 ddsd2.dwHeight = 480; | |
1559 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1560 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1561 &ddsd2.ddpfPixelFormat) ) | |
1562 { | |
1563 LABEL_21: | |
1564 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
1565 goto LABEL_45; | |
1566 } | |
1567 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1568 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
1569 //uDeviceIDa = &pZBuffer; | |
1570 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1571 { | |
1572 LABEL_44: | |
1573 v25 = "Init - Failed to create z-buffer.\n"; | |
1574 LABEL_45: | |
1575 sprintf(pErrorMessage, v25); | |
1576 if (pBackBuffer) | |
1577 { | |
1578 pBackBuffer->Release(); | |
1579 pBackBuffer = 0; | |
1580 } | |
1581 LABEL_63: | |
1582 //v19 = &pFrontBuffer; | |
1583 if (pFrontBuffer) | |
1584 { | |
1585 pFrontBuffer->Release(); | |
1586 pFrontBuffer= 0; | |
1587 } | |
1588 goto LABEL_65; | |
1589 } | |
1590 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
1591 goto LABEL_48; | |
1592 //v33 = &pDevice; | |
1593 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1594 pBackBuffer, | |
1595 &pDevice, | |
1596 0) ) | |
1597 goto LABEL_51; | |
1598 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1599 d3dvp2.dvClipWidth = 2.0; | |
1600 d3dvp2.dvClipY = 1.0; | |
1601 d3dvp2.dvClipHeight = 2.0; | |
1602 d3dvp2.dvMaxZ = 1.0; | |
1603 | |
1604 LABEL_54: | |
1605 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
1606 //v17 = *hWnda; | |
1607 d3dvp2.dwWidth = 640; | |
1608 d3dvp2.dwHeight = 480; | |
1609 d3dvp2.dvClipX = -1.0; | |
1610 //v18 = v17->lpVtbl; | |
1611 //v32 = &v4->pViewport; | |
1612 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
1613 { | |
1614 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
1615 if (pDevice) | |
1616 { | |
1617 pDevice->Release(); | |
1618 pDevice = 0; | |
1619 } | |
1620 if (pDirect3D) | |
1621 { | |
1622 pDirect3D->Release(); | |
1623 pDirect3D = 0; | |
1624 } | |
1625 LABEL_59: | |
1626 if (pZBuffer) | |
1627 { | |
1628 pZBuffer->Release(); | |
1629 pZBuffer = 0; | |
1630 } | |
1631 LABEL_61: | |
1632 if (pBackBuffer) | |
1633 { | |
1634 pBackBuffer->Release(); | |
1635 pBackBuffer = 0; | |
1636 } | |
1637 goto LABEL_63; | |
1638 } | |
1639 | |
1640 pDevice->AddViewport(pViewport); | |
1641 pViewport->SetViewport2(&d3dvp2); | |
1642 pDevice->SetCurrentViewport(pViewport); | |
1643 return 1; | |
1644 } | |
1645 | |
1646 //----- (0049E444) -------------------------------------------------------- | |
1647 unsigned int RenderD3D::GetDeviceCaps() | |
1648 { | |
1649 unsigned int v1; // ebx@1 | |
1650 RenderD3D *v2; // edi@1 | |
1651 IDirect3DDevice3 *v3; // eax@1 | |
1652 unsigned int result; // eax@2 | |
1653 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
1654 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
1655 | |
1656 v1 = 0; | |
1657 v2 = this; | |
1658 memset(&halCaps, 0, 0xFCu); | |
1659 halCaps.dwSize = 252; | |
1660 memset(&refCaps, 0, 0xFCu); | |
1661 v3 = v2->pDevice; | |
1662 refCaps.dwSize = 252; | |
1663 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
1664 { | |
1665 result = 1; | |
1666 } | |
1667 else | |
1668 { | |
1669 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
1670 v1 = 2; | |
1671 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
1672 v1 |= 4u; | |
1673 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
1674 v1 |= 8u; | |
1675 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
1676 v1 |= 0x10u; | |
1677 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
1678 v1 |= 0x20u; | |
1679 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
1680 v1 |= 0x40u; | |
1681 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
1682 LOBYTE(v1) = v1 | 0x80; | |
1683 result = v1; | |
1684 } | |
1685 return result; | |
1686 } | |
1687 | |
1688 //----- (0049E4FC) -------------------------------------------------------- | |
1689 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
1690 { | |
1691 uint uClearFlags = 0; | |
1692 | |
1693 if (bClearColor) | |
1694 uClearFlags |= D3DCLEAR_TARGET; | |
1695 if (bClearDepth) | |
1696 uClearFlags |= D3DCLEAR_ZBUFFER; | |
1697 | |
1698 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
1699 if (uClearFlags) | |
1700 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
1701 } | |
1702 | |
1703 //----- (0049E54D) -------------------------------------------------------- | |
1704 void RenderD3D::Present(bool bForceBlit) | |
1705 { | |
1706 RECT v5; // [sp+18h] [bp-18h]@1 | |
1707 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
1708 | |
1709 v5.left = 0; | |
1710 v5.top = 0; | |
1711 v5.bottom = 480; | |
1712 v5.right = 640; | |
1713 | |
1714 if (bWindowed || bForceBlit) | |
1715 { | |
1716 RECT rc; | |
1717 GetClientRect(hWindow, &rc); | |
1718 Point.y = 0; | |
1719 Point.x = 0; | |
1720 ClientToScreen(hWindow, &Point); | |
1721 OffsetRect(&rc, Point.x, Point.y); | |
1722 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
1723 } | |
1724 else | |
1725 pFrontBuffer->Flip(0, 1); | |
1726 } | |
1727 | |
1728 //----- (0049E5D4) -------------------------------------------------------- | |
1729 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
1730 { | |
1731 unsigned int v8; // edx@4 | |
1732 unsigned int v9; // ebx@5 | |
1733 unsigned int v10; // eax@5 | |
1734 DWORD v11; // edx@5 | |
1735 //int v12; // edx@7 | |
1736 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
1737 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
1738 | |
1739 //v15 = this; | |
1740 memset(&ddsd2, 0, 0x7Cu); | |
1741 ddsd2.dwSize = 0x7Cu; | |
1742 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1743 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
1744 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
1745 ddsd2.dwHeight = uTextureHeight; | |
1746 ddsd2.dwWidth = uTextureWidth; | |
1747 if ( bMipmaps ) | |
1748 { | |
1749 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
1750 { | |
1751 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
1752 LABEL_8: | |
1753 ddsd2.dwMipMapCount = v8; | |
1754 if ( !v8 ) | |
1755 goto LABEL_12; | |
1756 goto LABEL_11; | |
1757 } | |
1758 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
1759 { | |
1760 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
1761 goto LABEL_8; | |
1762 } | |
1763 v9 = GetMaxMipLevels(uTextureWidth); | |
1764 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
1765 ddsd2.dwMipMapCount = v9 - v10; | |
1766 if ( v9 == v10 ) | |
1767 { | |
1768 ddsd2.dwFlags = 0x1007u; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
1769 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used |
0 | 1770 ddsd2.ddsCaps.dwCaps = v11; |
1771 goto LABEL_12; | |
1772 } | |
1773 } | |
1774 else | |
1775 { | |
1776 ddsd2.dwMipMapCount = 1; | |
1777 } | |
1778 LABEL_11: | |
1779 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1780 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1781 LABEL_12: | |
1782 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
1783 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
1784 if (bAlphaChannel) | |
1785 { | |
1786 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
1787 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
1788 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
1789 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1790 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
1791 } | |
1792 else | |
1793 { | |
1794 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
1795 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
1796 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
1797 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1798 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
1799 } | |
1800 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
1801 return false; | |
1802 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
1803 { | |
1804 (*pOutSurface)->Release(); | |
1805 *pOutSurface = 0; | |
1806 return false; | |
1807 } | |
1808 return true; | |
1809 } | |
1810 | |
1811 //----- (004A5190) -------------------------------------------------------- | |
1812 void RenderD3D::HandleLostResources() | |
1813 { | |
1814 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
1815 pBitmaps_LOD->_410423_move_textures_to_device(); | |
1816 pSprites_LOD->ReleaseLostHardwareSprites(); | |
1817 } | |
1818 | |
1819 //----- (004A2050) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
1820 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) |
0 | 1821 { |
1822 Render *v5; // edi@1 | |
1823 unsigned int v6; // ebx@1 | |
1824 LightmapBuilder *v7; // esi@3 | |
1825 int v8; // eax@7 | |
1826 ODMFace *v9; // eax@12 | |
1827 char *v10; // esi@12 | |
1828 double v11; // st7@14 | |
1829 double v12; // st7@14 | |
1830 int v13; // eax@14 | |
1831 ODMFace *v14; // ecx@14 | |
1832 double v15; // st7@14 | |
1833 float v16; // ST48_4@15 | |
1834 int v17; // eax@15 | |
1835 char v18; // zf@17 | |
1836 HRESULT v19; // eax@18 | |
1837 HRESULT v20; // eax@18 | |
1838 HRESULT v21; // eax@20 | |
1839 HRESULT v22; // eax@20 | |
1840 unsigned int v23; // ecx@20 | |
1841 char *v24; // eax@21 | |
1842 HRESULT v25; // eax@23 | |
1843 HRESULT v26; // eax@23 | |
1844 HRESULT v27; // eax@24 | |
1845 HRESULT v28; // eax@25 | |
1846 HRESULT v29; // eax@25 | |
1847 HRESULT v30; // eax@25 | |
1848 HRESULT v31; // eax@25 | |
1849 HRESULT v32; // eax@26 | |
1850 unsigned int v33; // ecx@26 | |
1851 char *v34; // eax@27 | |
1852 int v35; // edx@28 | |
1853 HRESULT v36; // eax@29 | |
1854 HRESULT v37; // eax@29 | |
1855 HRESULT v38; // eax@29 | |
1856 HRESULT v39; // eax@29 | |
1857 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
1858 unsigned int v41; // eax@29 | |
1859 HRESULT v42; // eax@30 | |
1860 HRESULT v43; // eax@30 | |
1861 HRESULT v44; // eax@30 | |
1862 char *v45; // esi@34 | |
1863 int v46; // ecx@35 | |
1864 double v47; // st6@35 | |
1865 int v48; // eax@36 | |
1866 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
1867 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
1868 int v51; // [sp+50h] [bp-18h]@0 | |
1869 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
1870 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
1871 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
1872 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
1873 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
1874 int v57; // [sp+60h] [bp-8h]@34 | |
638 | 1875 unsigned int a2; // [sp+64h] [bp-4h]@4 |
0 | 1876 |
1877 v5 = this; | |
1878 v6 = 0; | |
1879 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
1880 { | |
1881 v7 = pGame->pLightmapBuilder; | |
1882 v53 = v7; | |
1883 v54 = v7->std__vector_000004_size; | |
1884 if ( v7->std__vector_000004_size) | |
638 | 1885 a2 = 0xFFFFFFFF; |
1886 pGame->AlterGamma_ODM(a4, &a2); | |
1394 | 1887 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) |
0 | 1888 { |
638 | 1889 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 1890 v7->DrawLightmaps(/*v8, 0*/); |
0 | 1891 } |
1892 else | |
1893 { | |
1894 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
1895 { | |
323 | 1896 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1897 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
1898 if (bUsingSpecular) | |
1899 { | |
186 | 1900 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
1901 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1902 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1903 } |
1073 | 1904 for (uint i = 0; i < uNumVertices; ++i) |
1905 { | |
1906 | |
1907 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1908 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1909 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
1910 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
1911 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1912 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
1913 | |
1914 if ( this->bUsingSpecular ) | |
0 | 1915 { |
1073 | 1916 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1917 } |
1073 | 1918 else |
1919 { | |
1920 d3d_vertex_buffer[i].specular = 0; | |
1921 } | |
1922 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1923 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1924 | |
1925 } | |
323 | 1926 |
1927 if (a4->uAttributes & FACE_OUTLINED) | |
1928 { | |
1929 int color; | |
1930 if (GetTickCount() % 300 >= 150) | |
1931 color = 0xFFFF2020; | |
1932 else color = 0xFF901010; | |
1933 | |
1934 for (uint i = 0; i < uNumVertices; ++i) | |
1935 d3d_vertex_buffer[i].diffuse = color; | |
1936 } | |
1937 | |
0 | 1938 pRenderD3D->pDevice->SetTexture(0, pTexture); |
1939 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1940 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1941 d3d_vertex_buffer, |
0 | 1942 uNumVertices, |
1943 D3DDP_DONOTLIGHT); | |
1944 } | |
1945 else | |
1946 { | |
1073 | 1947 for (uint i = 0; i < uNumVertices; ++i) |
1948 { | |
1949 | |
1950 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1951 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1952 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
1953 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
1954 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1955 if ( this->bUsingSpecular ) | |
0 | 1956 { |
1073 | 1957 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1958 } |
1073 | 1959 else |
1960 { | |
1961 d3d_vertex_buffer[i].specular = 0; | |
1962 } | |
1963 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1964 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1965 | |
1966 } | |
1967 | |
186 | 1968 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
1969 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 1970 if (bUsingSpecular) |
186 | 1971 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 1972 |
1973 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
1974 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1975 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1976 d3d_vertex_buffer, |
0 | 1977 uNumVertices, |
1978 D3DDP_DONOTLIGHT)); | |
1979 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
1980 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1981 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
1394 | 1982 v53->DrawLightmaps(/*-1, 0*/); |
1073 | 1983 for (uint i = 0; i < uNumVertices; ++i) |
1984 { | |
1985 d3d_vertex_buffer[i].diffuse = a2; | |
1986 } | |
0 | 1987 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 1988 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1989 if ( !pRenderer->bUsingSpecular ) |
186 | 1990 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
1991 | |
1992 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
1993 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
1994 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 1995 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1996 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1997 d3d_vertex_buffer, |
0 | 1998 uNumVertices, |
1999 D3DDP_DONOTLIGHT)); | |
2000 if (bUsingSpecular) | |
2001 { | |
186 | 2002 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 2003 |
1073 | 2004 for (uint i = 0; i < uNumVertices; ++i) |
2005 { | |
2006 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
2007 d3d_vertex_buffer[i].specular = 0; | |
2008 } | |
2009 | |
0 | 2010 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 2011 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
2012 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 2013 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
2014 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2015 d3d_vertex_buffer, |
0 | 2016 uNumVertices, |
2017 D3DDP_DONOTLIGHT)); | |
186 | 2018 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 2019 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
2020 v41 = GetLevelFogColor(); | |
2021 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
2022 v6 = 0; | |
2023 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
2024 } | |
186 | 2025 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
2026 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 2027 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
2028 } | |
2029 } | |
2030 } | |
2031 } | |
2032 // 4D864C: using guessed type char byte_4D864C; | |
2033 | |
2034 //----- (0049EB79) -------------------------------------------------------- | |
2035 Render::~Render() | |
2036 { | |
2037 Render *v1; // esi@1 | |
2038 | |
2039 v1 = this; | |
2040 pAllocator->FreeChunk(this->pDefaultZBuffer); | |
2041 v1->pD3DBitmaps.Release(); | |
2042 v1->pD3DSprites.Release(); | |
2043 Release(); | |
2044 v1->bWindowMode = 1; | |
2045 //nullsub_1(); | |
2046 //nullsub_1(); | |
2047 } | |
2048 | |
2049 //----- (0049E756) -------------------------------------------------------- | |
2050 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
2051 { | |
2052 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
2053 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
2054 | |
2055 halCaps.dwSize = 380; | |
2056 refCaps.dwSize = 380; | |
2057 this_->GetCaps(&halCaps, &refCaps); | |
2058 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
2059 } | |
2060 | |
2061 //----- (0049E992) -------------------------------------------------------- | |
2062 Render::Render() | |
2063 { | |
2064 Render *v1; // esi@1 | |
2065 int v2; // eax@1 | |
2066 char v3; // zf@1 | |
2067 | |
2068 v1 = this; | |
2069 this->pDirectDraw4 = 0; | |
2070 this->pFrontBuffer4 = 0; | |
2071 this->pBackBuffer4 = 0; | |
2072 this->pColorKeySurface4 = 0; | |
2073 this->pDirectDraw2 = 0; | |
2074 this->pFrontBuffer2 = 0; | |
2075 this->pBackBuffer2 = 0; | |
2076 this->pSomeSurface2 = 0; | |
2077 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
2078 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2079 v1->bWindowMode = 1; | |
2080 v1->field_40054 = 0; | |
2081 v1->field_10 = 640; | |
2082 v1->field_14 = 480; | |
2083 v1->field_40030 = 0; | |
2084 v1->field_4002C = 0; | |
2085 v1->pActiveZBuffer = 0; | |
2086 v1->pDefaultZBuffer = 0; | |
709 | 2087 v1->raster_clip_y = 0; |
2088 v1->raster_clip_x = 0; | |
2089 v1->raster_clip_z = 639; | |
2090 v1->raster_clip_w = 479; | |
0 | 2091 v1->field_4003C = (int)&unk_4EED80; |
2092 v1->field_40040 = dword_4EED78; | |
2093 v1->uClipZ = 640; | |
2094 v1->field_40044 = 2; | |
2095 v1->field_40048 = 6; | |
2096 v1->pFrontBuffer4 = 0; | |
2097 v1->pBackBuffer4 = 0; | |
2098 v1->pColorKeySurface4 = 0; | |
2099 v1->pDirectDraw4 = 0; | |
2100 v1->pRenderD3D = 0; | |
2101 v1->uNumSceneBegins = 0; | |
2102 v1->uNumD3DSceneBegins = 0; | |
2103 v1->field_40110 = 0; | |
2104 v1->pTargetSurface = 0; | |
2105 v1->uTargetSurfacePitch = 0; | |
2106 v1->uClipY = 0; | |
2107 v1->uClipX = 0; | |
2108 v1->uClipW = 480; | |
2109 v1->bClip = 1; | |
2110 v1->bColorKeySupported = 0; | |
2111 v1->bRequiredTextureStagesAvailable = 0; | |
2112 v1->bTinting = 1; | |
2113 LOBYTE(v1->field_103668) = 0; | |
2114 v1->field_1036B8 = 0; | |
2115 v1->_gpu_memory_used = 0; | |
2116 uNumBillboardsToDraw = 0; | |
2117 bFogEnabled = false; | |
265 | 2118 |
2119 hd_water_tile_id = -1; | |
2120 hd_water_current_frame = 0; | |
0 | 2121 } |
2122 | |
781 | 2123 bool Render::Initialize(bool bWindowed, uint uDefaultDevice, bool bColoredLights, uint uDetailLevel, uint bTinting) |
0 | 2124 { |
2125 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
2126 bStartInWindow = bWindowed; | |
2127 | |
2128 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | |
2129 | |
2130 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
2131 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
2132 | |
2133 this->bTinting = bTinting; | |
2134 | |
2135 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
2136 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
2137 | |
2138 return r1 && r2; | |
2139 } | |
2140 | |
2141 //----- (0049EBF1) -------------------------------------------------------- | |
2142 void Render::_49EBF1() | |
2143 { | |
2144 signed int uNumRedBits; // edx@1 | |
2145 signed int uNuGreenBits; // edi@1 | |
2146 signed int uNumBlueBits; // esi@1 | |
2147 unsigned int v4; // edx@4 | |
2148 unsigned int v5; // edi@4 | |
2149 int v6; // ebx@4 | |
2150 int v7; // edx@4 | |
2151 signed int v8; // [sp+8h] [bp-24h]@1 | |
2152 signed int v9; // [sp+Ch] [bp-20h]@1 | |
2153 signed int v10; // [sp+20h] [bp-Ch]@1 | |
2154 signed int i; // [sp+24h] [bp-8h]@2 | |
2155 signed int v12; // [sp+28h] [bp-4h]@3 | |
2156 | |
2157 v10 = 0; | |
2158 uNumRedBits = 1 << this->uTargetRBits; | |
2159 uNuGreenBits = 1 << this->uTargetGBits; | |
2160 uNumBlueBits = 1 << this->uTargetBBits; | |
2161 v9 = 1 << this->uTargetRBits; | |
2162 v8 = 1 << this->uTargetGBits; | |
2163 if ( uNumRedBits > 0 ) | |
2164 { | |
2165 do | |
2166 { | |
2167 for ( i = 0; i < uNuGreenBits; ++i ) | |
2168 { | |
2169 v12 = 0; | |
2170 if ( uNumBlueBits > 0 ) | |
2171 { | |
2172 do | |
2173 { | |
2174 v4 = this->uTargetBBits; | |
2175 v5 = v4 + this->uTargetGBits; | |
2176 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
2177 v7 = (v10 << v5) + v12++ + (i << v4); | |
2178 this->field_2C[v7] = v6; | |
2179 } | |
2180 while ( v12 < uNumBlueBits ); | |
2181 uNumRedBits = v9; | |
2182 uNuGreenBits = v8; | |
2183 } | |
2184 } | |
2185 ++v10; | |
2186 } | |
2187 while ( v10 < uNumRedBits ); | |
2188 } | |
2189 } | |
2190 | |
2191 //----- (0049ECC4) -------------------------------------------------------- | |
2192 void Render::ClearBlack() | |
2193 { | |
2194 if (pRenderD3D) | |
2195 { | |
2196 if (field_40110) | |
2197 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
2198 } | |
2199 else | |
2200 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
2201 } | |
2202 | |
2203 //----- (0049ED18) -------------------------------------------------------- | |
2204 void Render::PresentBlackScreen() | |
2205 { | |
2206 LONG w; // edx@3 | |
2207 IDirectDrawSurface *v2; // eax@3 | |
2208 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
2209 RECT x; // [sp+68h] [bp-10h]@3 | |
2210 | |
2211 memset(&v3, 0, sizeof(DDBLTFX)); | |
2212 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
2213 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
2214 { | |
2215 x.left = uWindowX; | |
2216 x.right = uWindowX + uWindowHeight; | |
2217 x.top = uWindowY; | |
2218 w = uWindowY + uWindowWidth; | |
2219 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
2220 } | |
2221 else | |
2222 { | |
2223 x.left = uWindowX; | |
2224 x.right = uWindowX + uWindowHeight; | |
2225 x.top = uWindowY; | |
2226 w = uWindowY + uWindowWidth; | |
2227 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
2228 } | |
2229 x.bottom = w; | |
2230 v3.dwFillColor = 0; | |
2231 v3.dwSize = 100; | |
2232 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
2233 pRenderer->Present(); | |
2234 } | |
2235 | |
2236 //----- (0049EDB6) -------------------------------------------------------- | |
2237 void Render::SavePCXScreenshot() | |
2238 { | |
2239 Render *v1; // esi@1 | |
2240 __int16 v2; // di@1 | |
2241 int v3; // eax@4 | |
2242 int v4; // ecx@4 | |
2243 int v5; // eax@8 | |
2244 FILE *v6; // edi@10 | |
2245 int v7; // ecx@11 | |
2246 int v8; // eax@11 | |
2247 int v9; // eax@13 | |
2248 int v10; // ecx@15 | |
2249 unsigned __int8 v11; // dl@15 | |
2250 signed int v12; // eax@18 | |
2251 char v13; // zf@27 | |
2252 HRESULT v14; // eax@29 | |
2253 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
2254 __int16 v16; // [sp+44h] [bp-120h]@10 | |
2255 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2256 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2257 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2258 char *v20; // [sp+11Ch] [bp-48h]@14 | |
2259 char *v21; // [sp+120h] [bp-44h]@14 | |
2260 int v24; // [sp+124h] [bp-40h]@11 | |
2261 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
2262 int var38; // [sp+12Ch] [bp-38h]@4 | |
2263 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2264 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2265 void *ptr; // [sp+148h] [bp-1Ch]@10 | |
2266 void *v28; // [sp+14Ch] [bp-18h]@8 | |
2267 int v29; // [sp+150h] [bp-14h]@4 | |
2268 int v30; // [sp+154h] [bp-10h]@4 | |
2269 char v31; // [sp+15Ah] [bp-Ah]@25 | |
2270 unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 | |
2271 int i; // [sp+15Ch] [bp-8h]@10 | |
2272 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | |
2273 | |
2274 v1 = this; | |
2275 v2 = 0; | |
2276 if ( !this->pRenderD3D || this->field_40110 ) | |
2277 { | |
2278 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | |
2279 File = fopen(Filename, "wb"); | |
2280 if ( File ) | |
2281 { | |
2282 v3 = v1->field_10; | |
2283 v4 = v1->field_14; | |
2284 var38 = v3; | |
2285 v29 = v4; | |
2286 v30 = v3; | |
2287 if ( v3 & 1 ) | |
2288 v30 = v3 + 1; | |
2289 if ( v1->pRenderD3D ) | |
2290 { | |
2291 memset(&Dst, 0, 0x7Cu); | |
2292 Dst.dwSize = 124; | |
168 | 2293 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 2294 return; |
2295 v28 = Dst.lpSurface; | |
2296 v5 = Dst.lPitch >> 1; | |
2297 v2 = 0; | |
2298 } | |
2299 else | |
2300 { | |
2301 pRenderer->BeginScene(); | |
2302 v28 = pRenderer->pTargetSurface; | |
2303 v5 = pRenderer->uTargetSurfacePitch; | |
2304 } | |
2305 i = v5; | |
2306 header1.right = var38 - 1; | |
2307 header1.left = v2; | |
2308 header1.bottom = v29 - 1; | |
2309 header1.up = v2; | |
2310 header2.pitch = v30; | |
2311 memset(color_map, 0, sizeof(color_map)); | |
2312 memset(v15, 0, sizeof(v15)); | |
2313 header2.reserved = 0; | |
2314 header1.manufacturer = 10; | |
2315 v16 = 0; | |
2316 v6 = File; | |
2317 header1.version = 5; | |
2318 header1.encoding = 1; | |
2319 header1.bpp = 8; | |
2320 header1.hdpi = 75; | |
2321 header1.vdpi = 75; | |
2322 header2.planes = 3; | |
2323 header2.palette_info = 1; | |
2324 fwrite(&header1, 1u, 1u, File); | |
2325 fwrite(&header1.version, 1u, 1u, v6); | |
2326 fwrite(&header1.encoding, 1u, 1u, v6); | |
2327 fwrite(&header1.bpp, 1u, 1u, v6); | |
2328 fwrite(&header1.left, 2u, 1u, v6); | |
2329 fwrite(&header1.up, 2u, 1u, v6); | |
2330 fwrite(&header1.right, 2u, 1u, v6); | |
2331 fwrite(&header1.bottom, 2u, 1u, v6); | |
2332 fwrite(&header1.hdpi, 2u, 1u, v6); | |
2333 fwrite(&header1.vdpi, 2u, 1u, v6); | |
2334 fwrite(color_map, 0x30u, 1u, v6); | |
2335 fwrite(&header2, 1u, 1u, v6); | |
2336 fwrite(&header2.planes, 1u, 1u, v6); | |
2337 fwrite(&header2.pitch, 2u, 1u, v6); | |
2338 fwrite(&header2.palette_info, 2u, 1u, v6); | |
2339 fwrite(v15, 0x3Au, 1u, v6); | |
2340 ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); | |
2341 if ( v29 > 0 ) | |
2342 { | |
2343 v7 = v30; | |
2344 File = (FILE *)v29; | |
2345 v29 = 3 * v30; | |
2346 v24 = 2 * i; | |
2347 v8 = (int)v28; | |
2348 while ( 1 ) | |
2349 { | |
2350 i = v8; | |
2351 v9 = 0; | |
2352 if ( var38 > 0 ) | |
2353 { | |
2354 v21 = (char *)ptr + v7; | |
2355 v20 = (char *)ptr + 2 * v30; | |
2356 do | |
2357 { | |
2358 *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) | |
2359 + LOBYTE(v1->uTargetBBits) | |
2360 + v1->uTargetRBits | |
2361 - 8); | |
2362 v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) | |
2363 + LOBYTE(v1->uTargetGBits) | |
2364 - 8); | |
2365 v10 = i; | |
2366 v11 = LOBYTE(v1->uTargetBMask); | |
2367 i += 2; | |
2368 v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); | |
2369 } | |
2370 while ( v9 < var38 ); | |
2371 } | |
2372 for ( i = 0; i < v29; i += v34 ) | |
2373 { | |
2374 v34 = 1; | |
2375 v32 = *((char *)ptr + i); | |
2376 do | |
2377 { | |
2378 v12 = i + v34; | |
2379 if ( *((char *)ptr + v12) != v32 ) | |
2380 break; | |
2381 if ( !(v12 % v30) ) | |
2382 break; | |
2383 ++v34; | |
2384 } | |
2385 while ( v34 < 0x3Fu ); | |
2386 if ( i + v34 > v29 ) | |
2387 v34 = 3 * v30 - i; | |
2388 if ( v34 > 1u || v32 >= 0xC0u ) | |
2389 { | |
2390 v31 = v34 | 0xC0; | |
2391 fwrite(&v31, 1u, 1u, v6); | |
2392 } | |
2393 fwrite(&v32, 1u, 1u, v6); | |
2394 } | |
2395 v8 = (int)((char *)v28 + v24); | |
2396 v13 = File == (FILE *)1; | |
2397 File = (FILE *)((char *)File - 1); | |
2398 v28 = (char *)v28 + v24; | |
2399 if ( v13 ) | |
2400 break; | |
2401 v7 = v30; | |
2402 } | |
2403 } | |
2404 if ( v1->pRenderD3D ) | |
2405 { | |
2406 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
2407 } | |
2408 else | |
2409 { | |
2410 pRenderer->EndScene(); | |
2411 } | |
2412 | |
2413 pAllocator->FreeChunk(ptr); | |
2414 fclose(v6); | |
2415 } | |
2416 } | |
2417 } | |
2418 // 4EFA80: using guessed type int dword_4EFA80; | |
2419 | |
2420 //----- (0049F1BC) -------------------------------------------------------- | |
2421 void Render::_49F1BC(const char *a1) | |
2422 { | |
2423 Render *v2; // esi@1 | |
2424 __int16 v3; // di@1 | |
2425 int v4; // eax@4 | |
2426 char *v5; // ecx@4 | |
2427 unsigned int v6; // eax@8 | |
2428 FILE *v7; // edi@10 | |
2429 int v8; // ecx@11 | |
2430 int v9; // eax@11 | |
2431 int v10; // eax@13 | |
2432 const char *v11; // ecx@15 | |
2433 unsigned __int8 v12; // dl@15 | |
2434 signed int v13; // eax@18 | |
2435 char v14; // zf@27 | |
2436 HRESULT v15; // eax@29 | |
2437 char v16; // [sp+Ch] [bp-12Ch]@10 | |
2438 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
2439 int Dst; // [sp+48h] [bp-F0h]@7 | |
2440 int v19; // [sp+58h] [bp-E0h]@8 | |
2441 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
2442 char v21; // [sp+C4h] [bp-74h]@10 | |
2443 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
2444 char *v23; // [sp+F8h] [bp-40h]@14 | |
2445 int v24; // [sp+FCh] [bp-3Ch]@11 | |
2446 int v25; // [sp+100h] [bp-38h]@4 | |
2447 FILE *File; // [sp+104h] [bp-34h]@3 | |
2448 char Str; // [sp+108h] [bp-30h]@10 | |
2449 char v28; // [sp+109h] [bp-2Fh]@10 | |
2450 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
2451 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
2452 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
2453 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
2454 __int16 v33; // [sp+110h] [bp-28h]@10 | |
2455 __int16 v34; // [sp+112h] [bp-26h]@10 | |
2456 __int16 v35; // [sp+114h] [bp-24h]@10 | |
2457 __int16 v36; // [sp+116h] [bp-22h]@10 | |
2458 char v37; // [sp+118h] [bp-20h]@10 | |
2459 char v38; // [sp+119h] [bp-1Fh]@10 | |
2460 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
2461 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
2462 void *ptr; // [sp+120h] [bp-18h]@10 | |
2463 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
2464 int v43; // [sp+128h] [bp-10h]@4 | |
2465 char v44; // [sp+12Fh] [bp-9h]@25 | |
2466 char *i; // [sp+130h] [bp-8h]@10 | |
2467 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
2468 | |
2469 v2 = this; | |
2470 v3 = 0; | |
2471 if ( !this->pRenderD3D || this->field_40110 ) | |
2472 { | |
2473 ++dword_4EFA84; | |
2474 File = fopen(a1, "wb"); | |
2475 if ( File ) | |
2476 { | |
2477 v4 = v2->field_10; | |
2478 v5 = (char *)v2->field_14; | |
2479 v25 = v4; | |
2480 a1 = v5; | |
2481 v43 = v4; | |
2482 if ( v4 & 1 ) | |
2483 v43 = v4 + 1; | |
2484 if ( v2->pRenderD3D ) | |
2485 { | |
2486 memset(&Dst, 0, 0x7Cu); | |
2487 Dst = 124; | |
168 | 2488 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 2489 return; |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
2490 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
0 | 2491 v42 = v20; |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
2492 __debugbreak(); // warning C4700: uninitialized local variable 'v19' used |
0 | 2493 v6 = v19 >> 1; |
2494 v3 = 0; | |
2495 } | |
2496 else | |
2497 { | |
2498 pRenderer->BeginScene(); | |
2499 v42 = pRenderer->pTargetSurface; | |
2500 v6 = pRenderer->uTargetSurfacePitch; | |
2501 } | |
2502 i = (char *)v6; | |
2503 v33 = v25 - 1; | |
2504 v31 = v3; | |
2505 v34 = (short)a1 - 1; | |
2506 v32 = v3; | |
2507 v39 = v43; | |
2508 memset(&v21, 0, 0x30u); | |
2509 memset(&v16, 0, 0x38u); | |
2510 v37 = 0; | |
2511 Str = 10; | |
2512 v17 = 0; | |
2513 v7 = File; | |
2514 v28 = 5; | |
2515 v29 = 1; | |
2516 v30 = 8; | |
2517 v35 = 75; | |
2518 v36 = 75; | |
2519 v38 = 3; | |
2520 v40 = 1; | |
2521 fwrite(&Str, 1u, 1u, File); | |
2522 fwrite(&v28, 1u, 1u, v7); | |
2523 fwrite(&v29, 1u, 1u, v7); | |
2524 fwrite(&v30, 1u, 1u, v7); | |
2525 fwrite(&v31, 2u, 1u, v7); | |
2526 fwrite(&v32, 2u, 1u, v7); | |
2527 fwrite(&v33, 2u, 1u, v7); | |
2528 fwrite(&v34, 2u, 1u, v7); | |
2529 fwrite(&v35, 2u, 1u, v7); | |
2530 fwrite(&v36, 2u, 1u, v7); | |
2531 fwrite(&v21, 0x30u, 1u, v7); | |
2532 fwrite(&v37, 1u, 1u, v7); | |
2533 fwrite(&v38, 1u, 1u, v7); | |
2534 fwrite(&v39, 2u, 1u, v7); | |
2535 fwrite(&v40, 2u, 1u, v7); | |
2536 fwrite(&v16, 0x3Au, 1u, v7); | |
2537 ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); | |
2538 if ( (signed int)a1 > 0 ) | |
2539 { | |
2540 v8 = v43; | |
2541 File = (FILE *)a1; | |
2542 v24 = 3 * v43; | |
2543 v22 = 2 * (int)i; | |
2544 v9 = (int)v42; | |
2545 while ( 1 ) | |
2546 { | |
2547 a1 = (const char *)v9; | |
2548 v10 = 0; | |
2549 if ( v25 > 0 ) | |
2550 { | |
2551 i = (char *)ptr + v8; | |
2552 v23 = (char *)ptr + 2 * v43; | |
2553 do | |
2554 { | |
2555 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
2556 + LOBYTE(v2->uTargetBBits) | |
2557 + v2->uTargetRBits | |
2558 - 8); | |
2559 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
2560 + LOBYTE(v2->uTargetGBits) | |
2561 - 8); | |
2562 v11 = a1; | |
2563 v12 = LOBYTE(v2->uTargetBMask); | |
2564 a1 += 2; | |
2565 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
2566 } | |
2567 while ( v10 < v25 ); | |
2568 } | |
2569 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
2570 { | |
2571 BYTE3(a1) = 1; | |
2572 v46 = *((char *)ptr + (int)i); | |
2573 do | |
2574 { | |
2575 v13 = (signed int)&i[BYTE3(a1)]; | |
2576 if ( *((char *)ptr + v13) != v46 ) | |
2577 break; | |
2578 if ( !(v13 % v43) ) | |
2579 break; | |
2580 ++BYTE3(a1); | |
2581 } | |
2582 while ( BYTE3(a1) < 0x3Fu ); | |
2583 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
2584 BYTE3(a1) = 3 * v43 - (char)i; | |
2585 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
2586 { | |
2587 v44 = BYTE3(a1) | 0xC0; | |
2588 fwrite(&v44, 1u, 1u, v7); | |
2589 } | |
2590 fwrite(&v46, 1u, 1u, v7); | |
2591 } | |
2592 v9 = (int)&v42[v22 / 2]; | |
2593 v14 = File == (FILE *)1; | |
2594 File = (FILE *)((char *)File - 1); | |
2595 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
2596 if ( v14 ) | |
2597 break; | |
2598 v8 = v43; | |
2599 } | |
2600 } | |
2601 if ( v2->pRenderD3D ) | |
2602 { | |
2603 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
2604 } | |
2605 else | |
2606 { | |
2607 pRenderer->EndScene(); | |
2608 } | |
2609 pAllocator->FreeChunk(ptr); | |
2610 fclose(v7); | |
2611 } | |
2612 } | |
2613 } | |
2614 // 4EFA84: using guessed type int dword_4EFA84; | |
2615 | |
2616 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 2617 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
2618 { | |
0 | 2619 Render *v7; // ebx@1 |
2620 void *v8; // esi@3 | |
2621 void *v9; // esi@3 | |
2622 int v10; // ecx@4 | |
810 | 2623 unsigned short* v11; // eax@4 |
0 | 2624 int v12; // eax@6 |
2625 int v13; // eax@8 | |
2626 int v14; // ecx@8 | |
2627 signed int v15; // eax@11 | |
2628 char v16; // zf@20 | |
2629 int result; // eax@21 | |
2630 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
2631 // __int16 v19; // [sp+44h] [bp-74h]@3 | |
2632 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 2633 char *lineG; // [sp+78h] [bp-40h]@7 |
2634 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 2635 int v23; // [sp+80h] [bp-38h]@4 |
2636 int v24; // [sp+84h] [bp-34h]@4 | |
2637 int v25; // [sp+88h] [bp-30h]@4 | |
2638 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 2639 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
2640 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
2641 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
2642 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 2643 char v43; // [sp+B3h] [bp-5h]@18 |
2644 int i; // [sp+B4h] [bp-4h]@6 | |
810 | 2645 unsigned short* line_pictute_data; |
2646 byte test_byte; | |
2647 unsigned char pict_byte; | |
0 | 2648 |
2649 v7 = this; | |
810 | 2650 pitch = wight; |
2651 if ( wight & 1 ) | |
2652 pitch = wight + 1; | |
2653 Src.left = 0; | |
2654 Src.up = 0; | |
2655 Src.right = wight - 1; | |
2656 Src.bottom = heidth - 1; | |
2657 v27.pitch = pitch; | |
0 | 2658 memset(&v20, 0, 0x30u); |
2659 memset(&v18, 0, 0x38u); | |
810 | 2660 v8 = data_buff; |
2661 v27.reserved = 0; | |
0 | 2662 *(_WORD *)&v18[56] = 0; |
810 | 2663 Src.manufacturer = 10; |
2664 Src.version = 5; | |
2665 Src.encoding = 1; | |
2666 Src.bpp = 8; | |
2667 Src.hdpi = 75; | |
2668 Src.vdpi = 75; | |
2669 v27.planes = 3; | |
2670 v27.palette_info = 1; | |
2671 memcpy(data_buff, &Src, 1u); | |
0 | 2672 v8 = (char *)v8 + 1; |
810 | 2673 memcpy(v8, &Src.version, 1u); |
0 | 2674 v8 = (char *)v8 + 1; |
810 | 2675 memcpy(v8, &Src.encoding, 1u); |
0 | 2676 v8 = (char *)v8 + 1; |
810 | 2677 memcpy(v8, &Src.bpp, 1u); |
0 | 2678 v8 = (char *)v8 + 1; |
810 | 2679 memcpy(v8, &Src.left, 2u); |
0 | 2680 v8 = (char *)v8 + 2; |
810 | 2681 memcpy(v8, &Src.up, 2u); |
0 | 2682 v8 = (char *)v8 + 2; |
810 | 2683 memcpy(v8, &Src.right, 2u); |
0 | 2684 v8 = (char *)v8 + 2; |
810 | 2685 memcpy(v8, &Src.bottom, 2u); |
0 | 2686 v8 = (char *)v8 + 2; |
810 | 2687 memcpy(v8, &Src.hdpi, 2u); |
0 | 2688 v8 = (char *)v8 + 2; |
810 | 2689 memcpy(v8, &Src.vdpi, 2u); |
0 | 2690 v8 = (char *)v8 + 2; |
2691 memcpy(v8, &v20, 0x30u); | |
2692 v8 = (char *)v8 + 48; | |
810 | 2693 memcpy(v8, &v27, 1u); |
0 | 2694 v8 = (char *)v8 + 1; |
810 | 2695 memcpy(v8, &v27.planes, 1u); |
0 | 2696 v8 = (char *)v8 + 1; |
810 | 2697 memcpy(v8, &v27.pitch, 2u); |
0 | 2698 v8 = (char *)v8 + 2; |
810 | 2699 memcpy(v8, &v27.palette_info, 2u); |
0 | 2700 v8 = (char *)v8 + 2; |
2701 memcpy(v8, &v18, 0x3Au); | |
2702 v9 = (char *)v8 + 58; | |
810 | 2703 |
2704 lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); | |
2705 if ( heidth > 0 ) | |
2706 { | |
2707 v10 = pitch; | |
2708 v25 = heidth; | |
2709 v26 = 3 * pitch; | |
2710 v23 = 2 * wight; | |
2711 v11 = picture_data; | |
2712 v24 = (int)picture_data; | |
0 | 2713 while ( 1 ) |
2714 { | |
810 | 2715 line_pictute_data = v11; |
0 | 2716 v12 = 0; |
2717 i = 0; | |
810 | 2718 if ( wight > 0 ) |
2719 { | |
2720 lineG = (char *)lineRGB + pitch; | |
2721 lineB = (char *)lineRGB + 2 * pitch; | |
0 | 2722 do |
2723 { | |
810 | 2724 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); |
2725 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); | |
2726 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); | |
2727 | |
2728 v12++; | |
2729 } | |
2730 while ( v12 < wight ); | |
0 | 2731 } |
2732 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
2733 { | |
810 | 2734 test_byte = 1; |
2735 pict_byte = lineRGB [i]; | |
0 | 2736 do |
2737 { | |
810 | 2738 v15 = i + test_byte; |
2739 if ( *((char *)lineRGB + v15) != pict_byte ) | |
0 | 2740 break; |
810 | 2741 if ( !(v15 % pitch) ) |
0 | 2742 break; |
810 | 2743 ++test_byte; |
2744 } | |
2745 while ( test_byte < 0x3Fu ); | |
2746 if ( i + test_byte > v26 ) | |
2747 test_byte = 3 * pitch - i; | |
2748 if ( test_byte > 1u || pict_byte >= 0xC0u ) | |
2749 { | |
2750 v43 = test_byte | 0xC0; | |
0 | 2751 memcpy(v9, &v43, 1u); |
2752 v9 = (char *)v9 + 1; | |
2753 } | |
810 | 2754 memcpy(v9, &pict_byte, 1u); |
2755 i += test_byte; | |
2756 } | |
2757 v11 +=wight ; | |
0 | 2758 v16 = v25-- == 1; |
810 | 2759 |
0 | 2760 if ( v16 ) |
2761 break; | |
810 | 2762 v10 = pitch; |
2763 } | |
2764 } | |
2765 pAllocator->FreeChunk(lineRGB); | |
2766 *(int *)packed_size = (char *)v9 - data_buff; | |
2767 | |
0 | 2768 } |
2769 | |
2770 //----- (0049F8B5) -------------------------------------------------------- | |
2771 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) | |
2772 { | |
2773 Render *v5; // esi@1 | |
2774 FILE *result; // eax@1 | |
2775 FILE *v7; // edi@4 | |
2776 int v8; // ecx@5 | |
2777 int v9; // eax@5 | |
2778 int v10; // eax@7 | |
2779 int v11; // ecx@9 | |
2780 signed int v12; // eax@12 | |
2781 char v13; // zf@21 | |
2782 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
2783 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
2784 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
2785 int v17; // [sp+70h] [bp-34h]@5 | |
2786 int v18; // [sp+74h] [bp-30h]@5 | |
2787 char *v19; // [sp+78h] [bp-2Ch]@5 | |
2788 int v20; // [sp+7Ch] [bp-28h]@5 | |
2789 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
2790 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
2791 void *ptr; // [sp+98h] [bp-Ch]@4 | |
2792 int v24; // [sp+9Ch] [bp-8h]@2 | |
2793 char *i; // [sp+A0h] [bp-4h]@8 | |
2794 | |
2795 v5 = this; | |
2796 result = fopen(Filename, "wb"); | |
2797 Filename = (const char *)result; | |
2798 if ( result ) | |
2799 { | |
2800 v24 = a4; | |
2801 if ( a4 & 1 ) | |
2802 v24 = a4 + 1; | |
2803 header1.left = 0; | |
2804 header1.up = 0; | |
2805 header1.right = a4 - 1; | |
2806 header1.bottom = a5 - 1; | |
2807 header2.pitch = v24; | |
2808 memset(color_map, 0, sizeof(color_map)); | |
2809 header2.reserved = 0; | |
2810 memset(v14, 0, sizeof(v14)); | |
2811 v15 = 0; | |
2812 header1.manufacturer = 10; | |
2813 header1.version = 5; | |
2814 header1.encoding = 1; | |
2815 header1.bpp = 8; | |
2816 header1.hdpi = 75; | |
2817 header1.vdpi = 75; | |
2818 header2.planes = 3; | |
2819 header2.palette_info = 1; | |
2820 fwrite(&header1, 1u, 1u, (FILE *)Filename); | |
2821 v7 = (FILE *)Filename; | |
2822 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); | |
2823 fwrite(&header1.encoding, 1u, 1u, v7); | |
2824 fwrite(&header1.bpp, 1u, 1u, v7); | |
2825 fwrite(&header1.left, 2u, 1u, v7); | |
2826 fwrite(&header1.up, 2u, 1u, v7); | |
2827 fwrite(&header1.right, 2u, 1u, v7); | |
2828 fwrite(&header1.bottom, 2u, 1u, v7); | |
2829 fwrite(&header1.hdpi, 2u, 1u, v7); | |
2830 fwrite(&header1.vdpi, 2u, 1u, v7); | |
2831 fwrite(color_map, 0x30u, 1u, v7); | |
2832 fwrite(&header2, 1u, 1u, v7); | |
2833 fwrite(&header2.planes, 1u, 1u, v7); | |
2834 fwrite(&header2.pitch, 2u, 1u, v7); | |
2835 fwrite(&header2.palette_info, 2u, 1u, v7); | |
2836 fwrite(v14, 0x3Au, 1u, v7); | |
2837 ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); | |
2838 if ( a5 > 0 ) | |
2839 { | |
2840 v8 = v24; | |
2841 v18 = a5; | |
2842 v20 = 3 * v24; | |
2843 v17 = 2 * a4; | |
2844 v9 = (int)a3; | |
2845 v19 = a3; | |
2846 while ( 1 ) | |
2847 { | |
2848 a5 = v9; | |
2849 v10 = 0; | |
2850 if ( a4 > 0 ) | |
2851 { | |
2852 a3 = (char *)ptr + v8; | |
2853 i = (char *)ptr + 2 * v24; | |
2854 do | |
2855 { | |
2856 *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) | |
2857 + LOBYTE(v5->uTargetBBits) | |
2858 + v5->uTargetRBits | |
2859 - 8); | |
2860 a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) | |
2861 + LOBYTE(v5->uTargetGBits) | |
2862 - 8); | |
2863 v11 = a5; | |
2864 a5 += 2; | |
2865 i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); | |
2866 } | |
2867 while ( v10 < a4 ); | |
2868 } | |
2869 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) | |
2870 { | |
2871 BYTE3(a5) = 1; | |
2872 BYTE3(Filename) = *((char *)ptr + (int)i); | |
2873 do | |
2874 { | |
2875 v12 = (signed int)&i[BYTE3(a5)]; | |
2876 if ( *((char *)ptr + v12) != BYTE3(Filename) ) | |
2877 break; | |
2878 if ( !(v12 % v24) ) | |
2879 break; | |
2880 ++BYTE3(a5); | |
2881 } | |
2882 while ( BYTE3(a5) < 0x3Fu ); | |
2883 if ( (signed int)&i[BYTE3(a5)] > v20 ) | |
2884 BYTE3(a5) = 3 * v24 - (char)i; | |
2885 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) | |
2886 { | |
2887 BYTE3(a3) = BYTE3(a5) | 0xC0; | |
2888 fwrite((char *)&a3 + 3, 1u, 1u, v7); | |
2889 } | |
2890 fwrite((char *)&Filename + 3, 1u, 1u, v7); | |
2891 } | |
2892 v9 = (int)&v19[v17]; | |
2893 v13 = v18-- == 1; | |
2894 v19 += v17; | |
2895 if ( v13 ) | |
2896 break; | |
2897 v8 = v24; | |
2898 } | |
2899 } | |
2900 pAllocator->FreeChunk(ptr); | |
2901 result = (FILE *)fclose(v7); | |
2902 } | |
2903 return result; | |
2904 } | |
2905 | |
2906 //----- (0049FBCD) -------------------------------------------------------- | |
2907 void Render::ClearTarget(unsigned int uColor) | |
2908 { | |
2909 if (pRenderD3D) | |
2910 { | |
2911 if (field_40110) | |
2912 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
2913 } | |
2914 else | |
2915 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
2916 } | |
2917 | |
2918 //----- (0049FC23) -------------------------------------------------------- | |
2919 void Render::Release2() | |
2920 { | |
2921 Release(); | |
2922 bWindowMode = 1; | |
2923 } | |
2924 | |
2925 //----- (0049FC37) -------------------------------------------------------- | |
2926 void Render::Present() | |
2927 { | |
2928 Render *v1; // esi@1 | |
2929 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
2930 RECT a4; // [sp+18h] [bp-18h]@11 | |
2931 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
2932 | |
2933 v1 = this; | |
2934 if ( !pRenderer->pRenderD3D || this->field_40110 ) | |
2935 { | |
2936 this->pBeforePresentFunction(); | |
2937 if ( v1->pRenderD3D ) | |
2938 { | |
2939 if ( v1->field_40110 ) | |
2940 { | |
2941 pRenderD3D->Present(false); | |
2942 } | |
2943 } | |
2944 else | |
2945 { | |
2946 if ( v1->bWindowMode ) | |
2947 { | |
2948 RestoreFrontBuffer(); | |
2949 GetClientRect(v1->hWnd, &Rect); | |
2950 Point.y = 0; | |
2951 Point.x = 0; | |
2952 ClientToScreen(v1->hWnd, &Point); | |
2953 OffsetRect(&Rect, Point.x, Point.y); | |
2954 a4.top = 0; | |
2955 a4.bottom = 480; | |
2956 a4.left = 0; | |
2957 a4.right = 640; | |
2958 PresentRect(&Rect, &a4); | |
2959 } | |
2960 else | |
2961 { | |
2962 RestoreFrontBuffer(); | |
2963 a4.top = 0; | |
2964 a4.bottom = 480; | |
2965 a4.left = 0; | |
2966 a4.right = 640; | |
2967 BltBackToFontFast(0, 0, &a4); | |
2968 } | |
2969 } | |
2970 } | |
2971 } | |
2972 | |
2973 //----- (0049FD3A) -------------------------------------------------------- | |
2974 void Render::_49FD3A() | |
2975 { | |
2976 Render *v2; // esi@1 | |
2977 IDirectDrawSurface4 *v3; // eax@6 | |
2978 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
2979 RECT v5; // [sp+8h] [bp-10h]@6 | |
2980 | |
2981 auto a1 = this; | |
2982 v2 = a1; | |
2983 if ( a1->pRenderD3D ) | |
2984 { | |
2985 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
2986 pFrontBuffer4->Restore(); | |
2987 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
2988 pBackBuffer4->Restore(); | |
2989 v3 = v2->pBackBuffer4; | |
2990 v4 = v2->pFrontBuffer4; | |
2991 v5.top = 0; | |
2992 v5.bottom = 480; | |
2993 v5.left = 0; | |
2994 v5.right = 640; | |
2995 v3->BltFast(0, 0, v4, &v5, 16u); | |
2996 } | |
2997 } | |
2998 | |
2999 //----- (0049FDBF) -------------------------------------------------------- | |
3000 void Render::CreateZBuffer() | |
3001 { | |
3002 if (!pDefaultZBuffer) | |
3003 { | |
3004 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
3005 pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); | |
871 | 3006 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 3007 } |
3008 } | |
3009 | |
3010 //----- (0049FE05) -------------------------------------------------------- | |
3011 void Render::Release() | |
3012 { | |
3013 Render *v1; // esi@1 | |
3014 RenderD3D *v2; // ecx@1 | |
3015 char v3; // zf@4 | |
3016 void *v4; // ebx@6 | |
3017 IDirectDraw *v5; // eax@10 | |
3018 IDirectDrawSurface2 *v6; // eax@11 | |
3019 IDirectDrawSurface2 *v7; // eax@13 | |
3020 IDirectDrawSurface2 *v8; // eax@15 | |
3021 IDirectDraw2 *v9; // eax@17 | |
3022 IDirectDraw4 *v10; // eax@19 | |
3023 IDirectDrawSurface4 *v11; // eax@20 | |
3024 IDirectDrawSurface4 *v12; // eax@22 | |
3025 IDirectDrawSurface4 *v13; // eax@24 | |
3026 IDirectDraw4 *v14; // eax@26 | |
3027 unsigned __int16 **v15; // ebx@28 | |
3028 void **v16; // esi@29 | |
3029 | |
3030 v1 = this; | |
3031 v2 = this->pRenderD3D; | |
3032 if ( v2 ) | |
3033 { | |
3034 if ( v1->field_40110 ) | |
3035 { | |
3036 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
3037 pRenderD3D->Present(0); | |
3038 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
3039 } | |
3040 v1->pColorKeySurface4 = 0; | |
3041 v1->pBackBuffer4 = 0; | |
3042 v3 = v1->pTargetSurface == 0; | |
3043 v1->pFrontBuffer4 = 0; | |
3044 v1->pDirectDraw4 = 0; | |
3045 if ( !v3 ) | |
3046 { | |
3047 free(v1->ptr_400E8); | |
3048 v1->pTargetSurface = 0; | |
3049 v1->ptr_400E8 = 0; | |
3050 } | |
3051 v4 = v1->pRenderD3D; | |
3052 if ( v4 ) | |
3053 { | |
3054 pRenderD3D->Release(); | |
3055 free(v4); | |
3056 } | |
3057 v1->pRenderD3D = 0; | |
3058 } | |
3059 else | |
3060 { | |
3061 if ( bWinNT4_0 == 1 ) | |
3062 { | |
3063 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
3064 if ( !v5 ) | |
3065 return; | |
3066 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
3067 v1->pDirectDraw2->FlipToGDISurface(); | |
3068 v6 = v1->pSomeSurface2; | |
3069 if ( v6 ) | |
3070 { | |
3071 v6->Release(); | |
3072 v1->pSomeSurface2 = 0; | |
3073 } | |
3074 v7 = v1->pBackBuffer2; | |
3075 if ( v7 ) | |
3076 { | |
3077 v7->Release(); | |
3078 v1->pBackBuffer2 = 0; | |
3079 } | |
3080 v8 = v1->pFrontBuffer2; | |
3081 if ( v8 ) | |
3082 { | |
3083 v8->Release(); | |
3084 v1->pFrontBuffer2 = 0; | |
3085 } | |
3086 v9 = v1->pDirectDraw2; | |
3087 if ( v9 ) | |
3088 { | |
3089 v9->Release(); | |
3090 v1->pDirectDraw2 = 0; | |
3091 } | |
3092 } | |
3093 else | |
3094 { | |
3095 v10 = v1->pDirectDraw4; | |
3096 if ( !v10 ) | |
3097 return; | |
3098 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
3099 v1->pDirectDraw4->FlipToGDISurface(); | |
3100 v11 = v1->pColorKeySurface4; | |
3101 if ( v11 ) | |
3102 { | |
3103 v11->Release(); | |
3104 v1->pColorKeySurface4 = 0; | |
3105 } | |
3106 v12 = v1->pBackBuffer4; | |
3107 if ( v12 ) | |
3108 { | |
3109 v12->Release(); | |
3110 v1->pBackBuffer4 = 0; | |
3111 } | |
3112 v13 = v1->pFrontBuffer4; | |
3113 if ( v13 ) | |
3114 { | |
3115 v13->Release(); | |
3116 v1->pFrontBuffer4 = 0; | |
3117 } | |
3118 v14 = v1->pDirectDraw4; | |
3119 if ( v14 ) | |
3120 { | |
3121 v14->Release(); | |
3122 v1->pDirectDraw4 = 0; | |
3123 } | |
3124 } | |
3125 v15 = &v1->pTargetSurface; | |
3126 if ( v1->pTargetSurface ) | |
3127 { | |
3128 v16 = (void **)&v1->ptr_400E8; | |
3129 free(*v16); | |
3130 *v15 = 0; | |
3131 *v16 = 0; | |
3132 } | |
3133 } | |
3134 } | |
3135 | |
3136 //----- (0049FFD7) -------------------------------------------------------- | |
3137 void Render::CreateSomeTexture() | |
3138 { | |
3139 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
3140 } | |
3141 | |
3142 //----- (0049FFFB) -------------------------------------------------------- | |
3143 bool Render::InitializeFullscreen(HWND hWnd) | |
3144 { | |
3145 //Render *v2; // esi@1 | |
3146 //HWND v3; // ebx@1 | |
3147 //void *v4; // eax@2 | |
3148 //RenderD3D *v5; // eax@3 | |
3149 unsigned int v6; // edx@5 | |
3150 RenderD3D__DevInfo *v7; // ecx@5 | |
3151 bool v8; // eax@6 | |
3152 RenderD3D *v9; // ecx@13 | |
3153 unsigned int v10; // eax@13 | |
3154 RenderD3D *v11; // eax@25 | |
3155 HRESULT v12; // eax@25 | |
3156 int v13; // ecx@25 | |
3157 int v14; // eax@27 | |
3158 signed int v15; // ebx@31 | |
3159 bool v16; // eax@35 | |
3160 char v17; // zf@35 | |
3161 IDirectDraw4 *v18; // eax@38 | |
3162 HRESULT v19; // eax@38 | |
3163 int *v20; // eax@39 | |
3164 int *v22; // eax@42 | |
3165 int v23; // ecx@42 | |
3166 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3167 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3168 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
3169 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
3170 void *v28; // [sp+2FCh] [bp-10h]@2 | |
3171 int v29; // [sp+308h] [bp-4h]@2 | |
3172 | |
3173 //v2 = this; | |
3174 this->field_40110 = 0; | |
3175 this->pColorKeySurface4 = 0; | |
3176 this->pBackBuffer4 = 0; | |
3177 this->pFrontBuffer4 = 0; | |
3178 this->pDirectDraw4 = 0; | |
3179 this->bColorKeySupported = 0; | |
3180 Release(); | |
3181 //v3 = hWnd; | |
3182 this->hWnd = hWnd; | |
3183 CreateZBuffer(); | |
3184 if ( bUserDirect3D ) | |
3185 { | |
3186 pRenderD3D = new RenderD3D; | |
3187 v28 = pRenderD3D; | |
3188 v6 = uDesiredDirect3DDevice; | |
3189 v29 = -1; | |
3190 v7 = pRenderD3D->pAvailableDevices; | |
3191 if ( v7[v6].bIsDeviceCompatible ) | |
3192 { | |
3193 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | |
3194 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
3195 } | |
3196 else | |
3197 { | |
3198 if ( v7[1].bIsDeviceCompatible ) | |
3199 { | |
3200 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | |
3201 uAcquiredDirect3DDevice = 1; | |
3202 } | |
3203 else | |
3204 { | |
3205 if ( !v7->bIsDeviceCompatible ) | |
3206 Abortf("There aren't any D3D devices to create."); | |
3207 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); | |
3208 uAcquiredDirect3DDevice = 0; | |
3209 } | |
3210 } | |
3211 if ( !v8 ) | |
3212 Abortf("D3Drend->Init failed."); | |
3213 v9 = pRenderD3D; | |
3214 pBackBuffer4 = v9->pBackBuffer; | |
3215 pFrontBuffer4 = v9->pFrontBuffer; | |
3216 pDirectDraw4 = v9->pHost; | |
3217 v10 = pRenderD3D->GetDeviceCaps(); | |
3218 if ( v10 & 1 ) | |
3219 { | |
3220 if ( pRenderD3D ) | |
3221 { | |
3222 pRenderD3D->Release(); | |
3223 delete pRenderD3D; | |
3224 } | |
3225 pRenderD3D = 0; | |
3226 pBackBuffer4 = 0; | |
3227 pFrontBuffer4 = 0; | |
3228 pDirectDraw4 = 0; | |
3229 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
3230 } | |
3231 if ( v10 & 0x3E ) | |
3232 { | |
3233 if ( pRenderD3D ) | |
3234 { | |
3235 pRenderD3D->Release(); | |
3236 delete pRenderD3D; | |
3237 } | |
3238 pColorKeySurface4 = 0; | |
3239 pRenderD3D = 0; | |
3240 pBackBuffer4 = 0; | |
3241 pFrontBuffer4 = 0; | |
3242 pDirectDraw4 = 0; | |
3243 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
3244 } | |
3245 if ( (v10 & 0x80u) != 0 ) | |
3246 { | |
3247 if ( pRenderD3D ) | |
3248 { | |
3249 pRenderD3D->Release(); | |
3250 delete pRenderD3D; | |
3251 } | |
3252 pRenderD3D = 0; | |
3253 pBackBuffer4 = 0; | |
3254 pFrontBuffer4 = 0; | |
3255 pDirectDraw4 = 0; | |
3256 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
3257 } | |
3258 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
3259 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
3260 memset(&halCaps, 0, 0xFCu); | |
3261 halCaps.dwSize = 252; | |
3262 memset(&refCaps, 0, 0xFCu); | |
3263 v11 = pRenderD3D; | |
3264 refCaps.dwSize = 252; | |
3265 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
3266 v13 = halCaps.dwMinTextureWidth; | |
3267 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3268 v13 = halCaps.dwMinTextureHeight; | |
3269 v14 = halCaps.dwMaxTextureWidth; | |
3270 uMinDeviceTextureDim = v13; | |
3271 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
3272 v14 = halCaps.dwMaxTextureHeight; | |
3273 uMaxDeviceTextureDim = v14; | |
3274 if ( (unsigned int)v13 < 4 ) | |
3275 uMinDeviceTextureDim = 4; | |
3276 CreateSomeTexture(); | |
3277 v15 = 1; | |
3278 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3279 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
3280 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3281 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
3282 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3283 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
3284 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3285 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3286 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3287 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3288 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3289 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3290 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3291 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3292 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3293 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
3294 } | |
3295 else | |
3296 { | |
3297 CreateDirectDraw(); | |
3298 SetDirectDrawCooperationMode(hWnd, 1); | |
3299 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3300 CreateDirectDrawPrimarySurface(); | |
3301 v15 = 1; | |
3302 } | |
3303 ddpfPrimareSuface.dwSize = 32; | |
3304 GetTargetPixelFormat(&ddpfPrimareSuface); | |
3305 ParseTargetPixelFormat(); | |
3306 _49EBF1(); | |
3307 if ( pRenderD3D ) | |
3308 { | |
3309 v16 = IsColorKeySupported(pDirectDraw4); | |
3310 v17 = uAcquiredDirect3DDevice == v15; | |
3311 bColorKeySupported = v16; | |
3312 if ( !v17 ) | |
3313 bColorKeySupported = 0; | |
3314 if ( bColorKeySupported ) | |
3315 { | |
3316 memset(&ddsd2, 0, 0x7Cu); | |
3317 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3318 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3319 v18 = pDirectDraw4; | |
3320 ddsd2.dwSize = 124; | |
3321 ddsd2.dwFlags = 65543; | |
3322 ddsd2.ddsCaps.dwCaps = 2112; | |
3323 ddsd2.dwWidth = 640; | |
3324 ddsd2.dwHeight = 480; | |
3325 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3326 pBeforePresentFunction = Present_ColorKey; | |
3327 } | |
3328 else | |
3329 { | |
3330 pTargetSurface = 0; | |
3331 ptr_400E8 = 0; | |
3332 v20 = (int *)operator new(0x96020u); | |
3333 ptr_400E8 = v20; | |
3334 if ( !v20 | |
3335 || (memset(&pDesc, 0, 0x7Cu), | |
3336 pDesc.dwSize = 124, | |
3337 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
3338 return 0; | |
3339 pBackBuffer4->Unlock(0); | |
3340 v22 = ptr_400E8 + 4; | |
3341 v23 = (unsigned int)pDesc.lpSurface & 7; | |
3342 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
3343 uTargetSurfacePitch = 640; | |
3344 pBeforePresentFunction = Present_NoColorKey; | |
3345 v15 = 1; | |
3346 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | |
3347 } | |
3348 field_40110 = v15; | |
3349 } | |
3350 else | |
3351 { | |
3352 pBeforePresentFunction = 0;//nullsub_1; | |
3353 } | |
3354 bWindowMode = 0; | |
3355 pParty->uFlags |= 2u; | |
3356 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; | |
3357 pViewport->_4C02F8(36044); | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
3358 return v15 != 0; |
0 | 3359 } |
3360 // 6BE3A0: using guessed type float flt_6BE3A0; | |
3361 | |
3362 //----- (004A05F3) -------------------------------------------------------- | |
3363 bool Render::SwitchToWindow(HWND hWnd) | |
3364 { | |
3365 //Render *v2; // esi@1 | |
3366 //void *v3; // eax@2 | |
3367 //RenderD3D *v4; // eax@3 | |
3368 //unsigned int v5; // edx@5 | |
3369 //RenderD3D__DevInfo *v6; // ecx@5 | |
3370 bool v7; // eax@7 | |
3371 //RenderD3D *v8; // ecx@12 | |
3372 unsigned int v9; // eax@12 | |
3373 RenderD3D *v10; // eax@24 | |
3374 HRESULT v11; // eax@24 | |
3375 int v12; // eax@24 | |
3376 int v13; // eax@26 | |
3377 bool v14; // eax@32 | |
3378 char v15; // zf@32 | |
3379 IDirectDraw4 *v16; // eax@35 | |
3380 HRESULT v17; // eax@35 | |
3381 int *v18; // eax@36 | |
3382 int *v19; // edx@38 | |
3383 int v20; // eax@38 | |
3384 unsigned int v21; // ecx@38 | |
3385 int v22; // eax@41 | |
3386 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
3387 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3388 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
3389 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
3390 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
3391 int v29; // [sp+308h] [bp-4h]@2 | |
3392 | |
3393 pParty->uFlags |= 2u; | |
3394 //v2 = this; | |
3395 flt_6BE3A0 = 0.55000001f; | |
3396 pViewport->_4C02F8(36044); | |
3397 field_40110 = 0; | |
3398 Release(); | |
3399 pColorKeySurface4 = 0; | |
3400 pBackBuffer4 = 0; | |
3401 pFrontBuffer4 = 0; | |
3402 pDirectDraw4 = 0; | |
3403 bColorKeySupported = 0; | |
3404 CreateZBuffer(); | |
3405 if ( bUserDirect3D ) | |
3406 { | |
3407 /*v3 = operator new(0x148u); | |
3408 thisa = (RenderD3D *)v3; | |
3409 v29 = 0; | |
3410 if ( v3 ) | |
3411 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3412 else | |
3413 v4 = 0;*/ | |
3414 pRenderD3D = new RenderD3D; | |
3415 //v4 = pRenderD3D; | |
3416 //v5 = uDesiredDirect3DDevice; | |
3417 v29 = -1; | |
3418 //v6 = pRenderD3D->pAvailableDevices; | |
3419 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
3420 uDesiredDirect3DDevice != 1 ) | |
3421 { | |
3422 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | |
3423 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
3424 } | |
3425 else | |
3426 { | |
3427 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
3428 Abortf("There aren't any D3D devices to init."); | |
3429 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); | |
3430 uAcquiredDirect3DDevice = 0; | |
3431 } | |
3432 if ( !v7 ) | |
3433 Abortf("D3Drend->Init failed."); | |
3434 | |
3435 //v8 = pRenderD3D; | |
3436 pColorKeySurface4 = 0; | |
3437 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
3438 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3439 pDirectDraw4 = pRenderD3D->pHost; | |
3440 v9 = pRenderD3D->GetDeviceCaps(); | |
3441 if ( v9 & 1 ) | |
3442 { | |
3443 if (pRenderD3D) | |
3444 { | |
3445 pRenderD3D->Release(); | |
3446 delete pRenderD3D; | |
3447 } | |
3448 pRenderD3D = 0; | |
3449 pBackBuffer4 = 0; | |
3450 pFrontBuffer4 = 0; | |
3451 pDirectDraw4 = 0; | |
3452 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
3453 } | |
3454 if ( v9 & 0x3E ) | |
3455 { | |
3456 if (pRenderD3D) | |
3457 { | |
3458 pRenderD3D->Release(); | |
3459 delete pRenderD3D; | |
3460 } | |
3461 pColorKeySurface4 = 0; | |
3462 pRenderD3D = 0; | |
3463 pBackBuffer4 = 0; | |
3464 pFrontBuffer4 = 0; | |
3465 pDirectDraw4 = 0; | |
3466 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
3467 } | |
3468 if ( (v9 & 0x80u) != 0 ) | |
3469 { | |
3470 if (pRenderD3D) | |
3471 { | |
3472 pRenderD3D->Release(); | |
3473 delete pRenderD3D; | |
3474 } | |
3475 pRenderD3D = 0; | |
3476 pBackBuffer4 = 0; | |
3477 pFrontBuffer4 = 0; | |
3478 pDirectDraw4 = 0; | |
3479 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
3480 } | |
3481 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
3482 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
3483 memset(&halCaps, 0, 0xFCu); | |
3484 halCaps.dwSize = 252; | |
3485 memset(&refCaps, 0, 0xFCu); | |
3486 //v10 = v2->pRenderD3D; | |
3487 refCaps.dwSize = 252; | |
3488 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3489 v12 = halCaps.dwMinTextureWidth; | |
3490 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3491 v12 = halCaps.dwMinTextureHeight; | |
3492 uMinDeviceTextureDim = v12; | |
3493 v13 = halCaps.dwMaxTextureWidth; | |
3494 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3495 v13 = halCaps.dwMaxTextureHeight; | |
3496 uMaxDeviceTextureDim = v13; | |
3497 CreateSomeTexture(); | |
3498 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
3499 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
3500 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3501 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
3502 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
3503 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3504 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3505 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3506 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3507 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3508 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3509 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3510 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3511 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3512 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
3513 } | |
3514 else | |
3515 { | |
3516 CreateDirectDraw(); | |
3517 SetDirectDrawCooperationMode(hWnd, 0); | |
3518 field_4004C = 1; | |
3519 CreateFrontBuffer(); | |
3520 CreateClipper(hWnd); | |
3521 CreateBackBuffer(); | |
3522 field_40030 = 0; | |
3523 field_18_locked_pitch = 0; | |
3524 } | |
3525 ddpfPrimareSuface.dwSize = 32; | |
3526 GetTargetPixelFormat(&ddpfPrimareSuface); | |
3527 ParseTargetPixelFormat(); | |
3528 _49EBF1(); | |
3529 if ( !pRenderD3D ) | |
3530 { | |
3531 pBeforePresentFunction = 0;//nullsub_1; | |
3532 goto LABEL_47; | |
3533 } | |
3534 v14 = IsColorKeySupported(pDirectDraw4); | |
3535 v15 = uAcquiredDirect3DDevice == 1; | |
3536 bColorKeySupported = v14; | |
3537 if ( !v15 ) | |
3538 bColorKeySupported = 0; | |
3539 if ( bColorKeySupported ) | |
3540 { | |
3541 memset(&ddsd2, 0, 0x7Cu); | |
3542 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3543 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3544 v16 = pDirectDraw4; | |
3545 ddsd2.dwSize = 124; | |
3546 ddsd2.dwFlags = 65543; | |
3547 ddsd2.ddsCaps.dwCaps = 2112; | |
3548 ddsd2.dwWidth = 640; | |
3549 ddsd2.dwHeight = 480; | |
3550 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3551 pBeforePresentFunction = Present_ColorKey; | |
3552 LABEL_45: | |
3553 field_40110 = 1; | |
3554 LABEL_47: | |
3555 bWindowMode = 1; | |
3556 hWnd = hWnd; | |
3557 return 0; | |
3558 } | |
3559 pTargetSurface = 0; | |
3560 ptr_400E8 = 0; | |
3561 v18 = (int *)new char[0x96020]; | |
3562 memset(v18, -1, 0x96020); | |
3563 ptr_400E8 = v18; | |
3564 if ( v18 ) | |
3565 { | |
3566 memset(&pDesc, 0, 0x7Cu); | |
3567 pDesc.dwSize = 124; | |
168 | 3568 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) |
0 | 3569 { |
3570 pRenderer->pBackBuffer4->Unlock(0); | |
3571 v19 = ptr_400E8; | |
3572 v20 = (unsigned int)pDesc.lpSurface & 7; | |
3573 v21 = (unsigned int)ptr_400E8 & 7; | |
3574 if ( v21 == v20 ) | |
3575 { | |
3576 pTargetSurface = (unsigned __int16 *)v19; | |
3577 } | |
3578 else | |
3579 { | |
3580 if ( (signed int)v21 >= v20 ) | |
3581 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
3582 else | |
3583 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
3584 pTargetSurface = (unsigned __int16 *)v22; | |
3585 } | |
3586 uTargetSurfacePitch = 640; | |
3587 pBeforePresentFunction = Present_NoColorKey; | |
3588 goto LABEL_45; | |
3589 } | |
3590 } | |
3591 return 0; | |
3592 } | |
3593 | |
3594 //----- (004A0BEE) -------------------------------------------------------- | |
709 | 3595 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) |
0 | 3596 { |
3597 int v6; // edi@1 | |
3598 int v7; // edx@5 | |
3599 unsigned int v8; // ebx@5 | |
3600 int v9; // eax@7 | |
3601 unsigned int v10; // ecx@9 | |
3602 unsigned int v11; // esi@13 | |
3603 int v12; // eax@17 | |
3604 int v13; // eax@21 | |
3605 Render *v14; // edi@21 | |
3606 int v15; // eax@25 | |
3607 int v16; // eax@27 | |
3608 signed int v17; // eax@28 | |
3609 signed int v18; // edi@30 | |
3610 signed __int64 v19; // qax@41 | |
3611 int v20; // edi@41 | |
3612 unsigned int v21; // edi@46 | |
3613 int v22; // esi@47 | |
3614 int v23; // ebx@47 | |
3615 signed int v24; // edx@50 | |
3616 signed int v25; // esi@52 | |
3617 unsigned __int16 *v26; // ecx@52 | |
3618 int v27; // ebx@54 | |
3619 int v28; // edi@55 | |
3620 int v29; // edx@55 | |
3621 int v30; // ebx@60 | |
3622 int v31; // edx@61 | |
3623 int v32; // edi@61 | |
3624 int v34; // [sp+Ch] [bp-10h]@3 | |
3625 Render *v35; // [sp+10h] [bp-Ch]@1 | |
3626 __int64 v36; // [sp+14h] [bp-8h]@1 | |
3627 signed int v37; // [sp+18h] [bp-4h]@28 | |
3628 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
3629 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | |
3630 int uYb; // [sp+28h] [bp+Ch]@47 | |
3631 int uZa; // [sp+2Ch] [bp+10h]@38 | |
3632 | |
3633 v36 = 0i64; | |
709 | 3634 v6 = this->raster_clip_x; |
0 | 3635 v35 = this; |
3636 if ( (signed int)uX < v6 ) | |
3637 HIDWORD(v36) = 8; | |
709 | 3638 v34 = this->raster_clip_z; |
3639 if ( (signed int)uX > this->raster_clip_z ) | |
0 | 3640 HIDWORD(v36) |= 4u; |
709 | 3641 v7 = this->raster_clip_y; |
0 | 3642 v8 = uY; |
3643 if ( (signed int)uY < v7 ) | |
3644 HIDWORD(v36) |= 2u; | |
709 | 3645 v9 = this->raster_clip_w; |
0 | 3646 if ( (signed int)uY > v9 ) |
3647 HIDWORD(v36) |= 1u; | |
3648 v10 = uZ; | |
3649 if ( (signed int)uZ < v6 ) | |
3650 LODWORD(v36) = 8; | |
3651 if ( (signed int)uZ > v34 ) | |
3652 LODWORD(v36) = v36 | 4; | |
3653 v11 = uW; | |
3654 if ( (signed int)uW < v7 ) | |
3655 LODWORD(v36) = v36 | 2; | |
3656 if ( (signed int)uW > v9 ) | |
3657 LODWORD(v36) = v36 | 1; | |
3658 LOBYTE(v12) = v36; | |
3659 if ( (unsigned int)v36 & HIDWORD(v36) ) | |
3660 return v12; | |
3661 if ( !v36 ) | |
3662 { | |
3663 LABEL_46: | |
3664 v21 = pRenderer->uTargetSurfacePitch; | |
3665 if ( pRenderer->uTargetSurfacePitch ) | |
3666 { | |
3667 v12 = uX + v8 * pRenderer->uTargetSurfacePitch; | |
3668 v22 = v11 - v8; | |
3669 v23 = v22; | |
3670 uYb = v22; | |
3671 if ( v22 < 0 ) | |
3672 { | |
3673 v23 = -v22; | |
3674 uYb = -v22; | |
3675 v21 = -pRenderer->uTargetSurfacePitch; | |
3676 } | |
3677 uXa = v10 - uX; | |
3678 if ( (uXa & 0x80000000u) == 0 ) | |
3679 { | |
3680 v24 = 1; | |
3681 } | |
3682 else | |
3683 { | |
3684 uXa = -uXa; | |
3685 v24 = -1; | |
3686 } | |
3687 v25 = 0; | |
3688 v26 = v35->pTargetSurface; | |
3689 if ( v26 ) | |
3690 { | |
3691 if ( (signed int)uXa <= v23 ) | |
3692 { | |
3693 v30 = v23 + 1; | |
3694 if ( v30 > 0 ) | |
3695 { | |
3696 v31 = 2 * v24; | |
3697 v32 = 2 * v21; | |
3698 v12 = (int)&v26[v12]; | |
3699 do | |
3700 { | |
3701 v25 += uXa; | |
3702 *(short *)v12 = uColor; | |
3703 v12 += v32; | |
3704 if ( v25 > 0 ) | |
3705 { | |
3706 v25 -= uYb; | |
3707 v12 += v31; | |
3708 } | |
3709 --v30; | |
3710 } | |
3711 while ( v30 ); | |
3712 } | |
3713 } | |
3714 else | |
3715 { | |
3716 v27 = uXa + 1; | |
3717 if ( (signed int)(uXa + 1) > 0 ) | |
3718 { | |
3719 v28 = 2 * v21; | |
3720 v29 = 2 * v24; | |
3721 v12 = (int)&v26[v12]; | |
3722 do | |
3723 { | |
3724 v25 += uYb; | |
3725 *(short *)v12 = uColor; | |
3726 v12 += v29; | |
3727 if ( v25 > (signed int)uXa ) | |
3728 { | |
3729 v25 -= uXa; | |
3730 v12 += v28; | |
3731 } | |
3732 --v27; | |
3733 } | |
3734 while ( v27 ); | |
3735 } | |
3736 } | |
3737 } | |
3738 } | |
3739 return v12; | |
3740 } | |
3741 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | |
3742 { | |
3743 if ( BYTE4(v36) & 8 ) | |
3744 { | |
3745 v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX); | |
3746 v14 = v35; | |
3747 v8 = v13 + uY; | |
709 | 3748 uX = v35->raster_clip_x; |
0 | 3749 goto LABEL_24; |
3750 } | |
3751 v10 = v6; | |
3752 v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW; | |
3753 } | |
3754 v14 = v35; | |
3755 LABEL_24: | |
3756 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
3757 { | |
709 | 3758 v15 = v14->raster_clip_z; |
0 | 3759 if ( BYTE4(v36) & 4 ) |
3760 { | |
3761 v14 = v35; | |
3762 v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX); | |
709 | 3763 uX = v35->raster_clip_z; |
0 | 3764 } |
3765 else | |
3766 { | |
3767 v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10); | |
709 | 3768 v10 = v14->raster_clip_z; |
0 | 3769 v11 += v16; |
3770 } | |
3771 } | |
709 | 3772 v17 = v14->raster_clip_y; |
0 | 3773 v37 = 0; |
709 | 3774 uYa = v14->raster_clip_y; |
0 | 3775 if ( (signed int)v8 < v17 ) |
3776 v37 = 2; | |
709 | 3777 v18 = v14->raster_clip_w; |
0 | 3778 if ( (signed int)v8 > v18 ) |
3779 v37 |= 1u; | |
3780 if ( (signed int)v11 >= v17 ) | |
3781 v12 = 0; | |
3782 else | |
3783 v12 = 2; | |
3784 if ( (signed int)v11 > v18 ) | |
3785 LOBYTE(v12) = v12 | 1; | |
3786 if ( !(v12 & v37) ) | |
3787 { | |
3788 v12 ^= v37; | |
3789 uZa = v12; | |
3790 if ( v12 & 2 ) | |
3791 { | |
3792 if ( v37 & 2 ) | |
3793 { | |
3794 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | |
3795 LOBYTE(v12) = (char)v35; | |
709 | 3796 v8 = v35->raster_clip_y; |
0 | 3797 } |
3798 else | |
3799 { | |
3800 v19 = (signed int)((uX - v10) * (uYa - v11)); | |
3801 v20 = v8 - v11; | |
3802 v11 = uYa; | |
3803 v12 = v19 / v20; | |
3804 v10 += v12; | |
3805 } | |
3806 } | |
3807 if ( uZa & 1 ) | |
3808 { | |
3809 if ( v37 & 1 ) | |
3810 { | |
709 | 3811 uX += (signed int)((v10 - uX) * (v35->raster_clip_w - v8)) / (signed int)(v11 - v8); |
0 | 3812 LOBYTE(v12) = (char)v35; |
709 | 3813 v8 = v35->raster_clip_w; |
0 | 3814 } |
3815 else | |
3816 { | |
709 | 3817 v12 = (signed int)((uX - v10) * (v35->raster_clip_w - v11)) / (signed int)(v8 - v11); |
3818 v11 = v35->raster_clip_w; | |
0 | 3819 v10 += v12; |
3820 } | |
3821 } | |
3822 goto LABEL_46; | |
3823 } | |
3824 return v12; | |
3825 } | |
3826 | |
3827 //----- (004A0E80) -------------------------------------------------------- | |
3828 void Render::ClearZBuffer(int a2, int a3) | |
3829 { | |
3830 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
3831 } | |
3832 | |
3833 //----- (004A0E97) -------------------------------------------------------- | |
709 | 3834 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
3835 { | |
3836 this->raster_clip_x = uX; | |
3837 this->raster_clip_y = uY; | |
3838 this->raster_clip_z = uZ; | |
3839 this->raster_clip_w = uW; | |
0 | 3840 } |
3841 | |
3842 //----- (004A0EB6) -------------------------------------------------------- | |
3843 void Render::ParseTargetPixelFormat() | |
3844 { | |
3845 Render *v1; // eax@1 | |
3846 signed int v2; // ecx@1 | |
3847 DWORD uRedMask; // edx@1 | |
3848 unsigned int uGreenMask; // esi@5 | |
3849 signed int v5; // ecx@5 | |
3850 unsigned int uBlueMask; // edx@9 | |
3851 signed int v7; // ecx@9 | |
3852 unsigned int v8; // ecx@13 | |
3853 | |
3854 v1 = this; | |
3855 v2 = 0; | |
3856 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | |
3857 v1->uTargetBBits = 0; | |
3858 v1->uTargetGBits = 0; | |
3859 v1->uTargetRBits = 0; | |
3860 do | |
3861 { | |
3862 if ( (1 << v2) & uRedMask ) | |
3863 ++v1->uTargetRBits; | |
3864 ++v2; | |
3865 } | |
3866 while ( v2 < 16 ); | |
3867 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | |
3868 v5 = 0; | |
3869 do | |
3870 { | |
3871 if ( (1 << v5) & uGreenMask ) | |
3872 ++v1->uTargetGBits; | |
3873 ++v5; | |
3874 } | |
3875 while ( v5 < 16 ); | |
3876 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | |
3877 v7 = 0; | |
3878 do | |
3879 { | |
3880 if ( (1 << v7) & uBlueMask ) | |
3881 ++v1->uTargetBBits; | |
3882 ++v7; | |
3883 } | |
3884 while ( v7 < 16 ); | |
3885 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
3886 v1->uTargetGMask = uGreenMask; | |
3887 v1->uTargetRMask = v8; | |
3888 v1->uTargetBMask = uBlueMask; | |
3889 } | |
3890 | |
3891 //----- (004A0F40) -------------------------------------------------------- | |
3892 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
3893 { | |
3894 IDirectDrawSurface4 *v4; // esi@1 | |
168 | 3895 HRESULT result; // eax@1 |
0 | 3896 HRESULT v6; // eax@4 |
3897 int v7; // [sp-8h] [bp-14h]@10 | |
3898 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
3899 char v9; // [sp+Bh] [bp-1h]@1 | |
3900 | |
3901 v4 = pSurface; | |
3902 v9 = 1; | |
3903 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
3904 if ( result == DDERR_SURFACELOST ) | |
3905 { | |
3906 v6 = v4->Restore(); | |
3907 if ( v6 ) | |
3908 { | |
3909 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
3910 { | |
3911 LABEL_20: | |
3912 v9 = 0; | |
3913 result = (bool)memset(pDesc, 0, 4u); | |
3914 goto LABEL_21; | |
3915 } | |
3916 pRenderer->pFrontBuffer4->Restore(); | |
3917 v4->Restore(); | |
3918 } | |
3919 result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
3920 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3921 goto LABEL_20; | |
3922 ErrD3D(result); | |
3923 if ( result ) | |
3924 { | |
3925 //v8 = 0; | |
3926 //v7 = 2161; | |
3927 LABEL_19: | |
3928 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
3929 goto LABEL_20; | |
3930 } | |
3931 if ( pRenderer->pRenderD3D ) | |
3932 pRenderD3D->HandleLostResources(); | |
3933 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
3934 } | |
3935 else | |
3936 { | |
3937 if ( result ) | |
3938 { | |
3939 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3940 goto LABEL_20; | |
3941 ErrD3D(result); | |
3942 //v8 = 0; | |
3943 //v7 = 2199; | |
3944 //goto LABEL_19; | |
3945 } | |
3946 } | |
3947 LABEL_21: | |
3948 LOBYTE(result) = v9; | |
3949 return result; | |
3950 } | |
3951 | |
3952 //----- (004A1032) -------------------------------------------------------- | |
3953 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
3954 { | |
3955 IDirectDrawSurface2 *v4; // esi@1 | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
3956 HRESULT v5; // eax@1 |
0 | 3957 HRESULT v6; // eax@2 |
3958 int v7; // [sp-8h] [bp-10h]@8 | |
3959 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
3960 | |
3961 v4 = pSurface; | |
3962 v5 = pSurface->Lock( | |
3963 0, | |
3964 pDesc, | |
3965 uLockFlags, | |
3966 0); | |
3967 BYTE3(pSurface) = 1; | |
3968 if ( v5 == DDERR_SURFACELOST ) | |
3969 { | |
3970 v6 = v4->Restore(); | |
3971 if ( !v6 ) | |
3972 goto LABEL_5; | |
3973 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
3974 { | |
3975 pRenderer->pFrontBuffer2->Restore(); | |
3976 v4->Restore(); | |
3977 LABEL_5: | |
3978 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
3979 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
3980 goto LABEL_14; | |
3981 if ( !v5 ) | |
3982 return true; | |
3983 ErrD3D(v5); | |
3984 //v8 = 0; | |
3985 //v7 = 2247; | |
3986 goto LABEL_13; | |
3987 } | |
3988 else | |
3989 { | |
3990 pDesc->dwSize = 0; | |
3991 return false; | |
3992 } | |
3993 } | |
3994 else | |
3995 { | |
3996 if ( !v5 ) | |
3997 return true; | |
3998 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
3999 { | |
4000 //v8 = 0; | |
4001 //v7 = 2269; | |
4002 ErrD3D(v5); | |
4003 pDesc->dwSize = 0; | |
4004 return false; | |
4005 LABEL_13: | |
4006 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
4007 goto LABEL_14; | |
4008 } | |
4009 } | |
4010 LABEL_14: | |
4011 return true; | |
4012 } | |
4013 | |
4014 //----- (004A10E4) -------------------------------------------------------- | |
4015 void Render::CreateDirectDraw() | |
4016 { | |
4017 Render *v1; // edi@1 | |
4018 HRESULT v2; // eax@1 | |
4019 HRESULT v3; // eax@5 | |
4020 int v6; // [sp-Ch] [bp-20h]@3 | |
4021 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
4022 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
4023 | |
4024 v1 = this; | |
4025 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
4026 | |
4027 pDirectDraw2 = nullptr; | |
4028 pDirectDraw4 = nullptr; | |
4029 | |
4030 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4031 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
4032 else | |
4033 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
4034 | |
4035 lpDD->Release(); | |
4036 lpDD = nullptr; | |
4037 } | |
4038 | |
4039 //----- (004A1169) -------------------------------------------------------- | |
4040 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
4041 { | |
4042 DWORD flags; // eax@1 | |
4043 IDirectDraw *v4; // ecx@3 | |
4044 HRESULT v5; // eax@5 | |
4045 int v6; // [sp-8h] [bp-8h]@3 | |
4046 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
4047 | |
4048 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
4049 DDSCL_NORMAL; | |
4050 | |
4051 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4052 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
4053 else | |
4054 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
4055 } | |
4056 | |
4057 //----- (004A11C6) -------------------------------------------------------- | |
4058 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
4059 { | |
4060 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4061 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
4062 else | |
4063 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
4064 } | |
4065 | |
4066 //----- (004A121C) -------------------------------------------------------- | |
4067 void Render::CreateFrontBuffer() | |
4068 { | |
4069 Render *v1; // esi@1 | |
4070 IDirectDraw *pDD; // eax@3 | |
4071 IDirectDrawSurface **pOutSurf; // esi@3 | |
4072 struct _DDSURFACEDESC *v4; // edx@3 | |
4073 HRESULT v5; // eax@5 | |
4074 int v6; // [sp-8h] [bp-8Ch]@3 | |
4075 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4076 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4077 | |
4078 v1 = this; | |
4079 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4080 { | |
4081 memset(&a2, 0, 0x7Cu); | |
4082 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
4083 a2.dwSize = 124; | |
4084 a2.dwFlags = 1; | |
4085 v7 = 0; | |
4086 a2.ddsCaps.dwCaps = 512; | |
4087 v6 = 2357; | |
4088 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
4089 v4 = (struct _DDSURFACEDESC *)&a2; | |
4090 } | |
4091 else | |
4092 { | |
4093 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
4094 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
4095 a2.lPitch = 108; | |
4096 a2.dwBackBufferCount = 1; | |
4097 v7 = 0; | |
4098 a2.dwTextureStage = 512; | |
4099 v6 = 2346; | |
4100 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
4101 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
4102 } | |
4103 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
4104 } | |
4105 | |
4106 //----- (004A12CD) -------------------------------------------------------- | |
4107 void Render::CreateBackBuffer() | |
4108 { | |
4109 Render *v1; // esi@1 | |
4110 IDirectDraw *v2; // eax@3 | |
4111 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
4112 struct _DDSURFACEDESC *v4; // edx@3 | |
4113 HRESULT v5; // eax@5 | |
4114 int v6; // [sp-8h] [bp-8Ch]@3 | |
4115 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4116 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4117 | |
4118 v1 = this; | |
4119 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4120 { | |
4121 memset(&a2, 0, 0x7Cu); | |
4122 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
4123 a2.dwSize = 124; | |
4124 a2.dwFlags = 7; | |
4125 v7 = 0; | |
4126 a2.ddsCaps.dwCaps = 2112; | |
4127 a2.dwWidth = 640; | |
4128 a2.dwHeight = 480; | |
4129 v6 = 2387; | |
4130 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4131 v4 = (struct _DDSURFACEDESC *)&a2; | |
4132 } | |
4133 else | |
4134 { | |
4135 memset(&a2.lPitch, 0, 0x6Cu); | |
4136 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4137 a2.lPitch = 108; | |
4138 a2.dwBackBufferCount = 7; | |
4139 v7 = 0; | |
4140 a2.dwTextureStage = 2112; | |
4141 a2.dwAlphaBitDepth = 640; | |
4142 a2.dwMipMapCount = 480; | |
4143 v6 = 2374; | |
4144 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4145 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
4146 } | |
4147 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
4148 } | |
4149 | |
4150 //----- (004A139A) -------------------------------------------------------- | |
4151 void Render::CreateDirectDrawPrimarySurface() | |
4152 { | |
4153 Render *v1; // esi@1 | |
4154 int v2; // ebx@3 | |
4155 IDirectDraw2 *v3; // eax@3 | |
4156 HRESULT v4; // eax@3 | |
4157 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
4158 DDSCAPS2 *v6; // edx@3 | |
4159 IDirectDraw4 *v7; // eax@4 | |
4160 HRESULT v8; // eax@4 | |
4161 int v9; // ST14_4@5 | |
4162 IDirectDrawSurface *v10; // ST10_4@5 | |
4163 HRESULT v11; // eax@5 | |
4164 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
4165 const char *v13; // [sp+0h] [bp-A0h]@0 | |
4166 int v14; // [sp+4h] [bp-9Ch]@0 | |
4167 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
4168 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
4169 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
4170 int a4; // [sp+98h] [bp-8h]@3 | |
4171 | |
4172 v1 = this; | |
4173 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4174 { | |
4175 v2 = 0; | |
4176 this->field_4004C = 1; | |
4177 memset(&ddsd2, 0, 0x7Cu); | |
4178 v7 = v1->pDirectDraw4; | |
4179 ddsd2.dwBackBufferCount = 1; | |
4180 ddsd2.dwSize = 0x7Cu; | |
4181 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4182 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4183 ErrD3D(v7->CreateSurface( | |
4184 &ddsd2, | |
4185 &pFrontBuffer4, | |
4186 0)); | |
4187 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
4188 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4189 } | |
4190 else | |
4191 { | |
4192 v2 = 0; | |
4193 this->field_4004C = 1; | |
4194 | |
4195 DDSURFACEDESC ddsd; | |
4196 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4197 | |
4198 ddsd.lpSurface = (LPVOID)1; | |
4199 ddsd.lPitch = 108; | |
4200 ddsd.dwBackBufferCount = 33; | |
4201 ddsd.ddsCaps.dwCaps = 8728; | |
4202 ErrD3D(pDirectDraw2->CreateSurface( | |
4203 &ddsd, | |
4204 (IDirectDrawSurface **)&pFrontBuffer2, | |
4205 0)); | |
4206 | |
4207 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4208 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4209 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4210 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used |
0 | 4211 v9 = (int)v6; |
4212 v10 = pFrontBuffer; // BUG | |
4213 | |
4214 v17.dwCaps = 4; | |
4215 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4216 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
4217 v1->field_40030 = v2; | |
4218 v1->field_18_locked_pitch = v2; | |
4219 } | |
4220 | |
4221 //----- (004A14F4) -------------------------------------------------------- | |
4222 void Render::CreateClipper(HWND a2) | |
4223 { | |
4224 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4225 { | |
4226 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
4227 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4228 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
4229 } | |
4230 else | |
4231 { | |
4232 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
4233 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4234 } | |
4235 } | |
4236 | |
4237 //----- (004A15D8) -------------------------------------------------------- | |
4238 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4239 { | |
4240 IDirectDrawSurface *v2; // eax@3 | |
4241 | |
4242 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4243 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4244 else | |
4245 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4246 v2->GetPixelFormat(pOut); | |
4247 } | |
4248 | |
4249 //----- (004A1605) -------------------------------------------------------- | |
4250 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4251 { | |
4252 Render *v3; // esi@1 | |
4253 signed int v4; // eax@3 | |
4254 | |
4255 v3 = this; | |
4256 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4257 { | |
4258 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4259 memset(&pDesc, 0, 0x7Cu); | |
4260 pDesc.dwSize = 124; | |
168 | 4261 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4262 *pOutSurfacePtr = pDesc.lpSurface; |
4263 v4 = pDesc.lPitch; | |
4264 } | |
4265 else | |
4266 { | |
4267 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4268 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4269 pDesc.lPitch = 108; | |
4270 LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); | |
4271 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
4272 v4 = pDesc.dwReserved; | |
4273 } | |
4274 *pOutPixelsPerRow = v4 >> 1; | |
4275 } | |
4276 | |
4277 //----- (004A169E) -------------------------------------------------------- | |
4278 bool Render::UsingDirect3D() | |
4279 { | |
4280 return bUserDirect3D == 0; | |
4281 } | |
4282 | |
4283 //----- (004A16E1) -------------------------------------------------------- | |
4284 void Render::UnlockBackBuffer() | |
4285 { | |
4286 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4287 ErrD3D(pBackBuffer4->Unlock(0)); | |
4288 else | |
4289 ErrD3D(pBackBuffer2->Unlock(0)); | |
4290 } | |
4291 | |
4292 //----- (004A172E) -------------------------------------------------------- | |
4293 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4294 { | |
4295 Render *v3; // esi@1 | |
4296 signed int v4; // eax@3 | |
4297 | |
4298 v3 = this; | |
4299 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4300 { | |
4301 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4302 memset(&pDesc, 0, 0x7Cu); | |
4303 pDesc.dwSize = 124; | |
168 | 4304 LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4305 *pOutSurface = pDesc.lpSurface; |
4306 v4 = pDesc.lPitch; | |
4307 } | |
4308 else | |
4309 { | |
4310 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4311 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4312 pDesc.lPitch = 108; | |
4313 LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); | |
4314 *pOutSurface = (void *)pDesc.lpSurface; | |
4315 v4 = pDesc.dwReserved; | |
4316 } | |
4317 *pOutPixelsPerRow = v4 >> 1; | |
4318 } | |
4319 | |
4320 //----- (004A17C7) -------------------------------------------------------- | |
4321 void Render::UnlockFrontBuffer() | |
4322 { | |
4323 IDirectDrawSurface *pFront; // eax@3 | |
4324 HRESULT v2; // eax@5 | |
4325 signed int v3; // [sp-8h] [bp-Ch]@3 | |
4326 int v4; // [sp-4h] [bp-8h]@3 | |
4327 | |
4328 auto a5 = this; | |
4329 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4330 { | |
4331 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
4332 v4 = 0; | |
4333 v3 = 2615; | |
4334 } | |
4335 else | |
4336 { | |
4337 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
4338 v4 = 0; | |
4339 v3 = 2611; | |
4340 } | |
4341 ErrD3D(pFront->Unlock(0)); | |
4342 } | |
4343 | |
4344 //----- (004A1814) -------------------------------------------------------- | |
4345 void Render::RestoreFrontBuffer() | |
4346 { | |
4347 IDirectDrawSurface **v1; // esi@2 | |
4348 | |
4349 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
4350 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
4351 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
4352 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
4353 (*v1)->Restore(); | |
4354 } | |
4355 | |
4356 //----- (004A184C) -------------------------------------------------------- | |
4357 HRESULT Render::_4A184C() | |
4358 { | |
4359 IDirectDrawSurface **pBack; // esi@2 | |
4360 HRESULT result; // eax@4 | |
4361 | |
4362 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
4363 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
4364 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
4365 result = (*pBack)->IsLost(); | |
4366 if ( result == DDERR_SURFACELOST ) | |
4367 result = (*pBack)->Restore(); | |
4368 return result; | |
4369 } | |
4370 | |
4371 //----- (004A1884) -------------------------------------------------------- | |
4372 void Render::PresentRect(RECT *a2, RECT *a3) | |
4373 { | |
4374 IDirectDrawSurface *pFront; // eax@3 | |
4375 HRESULT v4; // eax@5 | |
4376 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
4377 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
4378 DWORD v7; // [sp-14h] [bp-14h]@3 | |
4379 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
4380 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
4381 int v10; // [sp-8h] [bp-8h]@3 | |
4382 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
4383 | |
4384 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4385 { | |
4386 v11 = 0; | |
4387 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4388 v10 = 2657; | |
4389 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4390 v8 = 0; | |
4391 v7 = DDBLT_WAIT; | |
4392 v6 = a3; | |
4393 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4394 } | |
4395 else | |
4396 { | |
4397 v11 = 0; | |
4398 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4399 v10 = 2653; | |
4400 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4401 v8 = 0; | |
4402 v7 = DDBLT_WAIT; | |
4403 v6 = a3; | |
4404 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
4405 } | |
4406 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
4407 } | |
4408 | |
4409 //----- (004A18F5) -------------------------------------------------------- | |
4410 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4411 { | |
4412 IDirectDrawSurface *pFront; // eax@3 | |
4413 HRESULT v6; // eax@5 | |
4414 int v7; // [sp-8h] [bp-8h]@3 | |
4415 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
4416 | |
4417 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
4418 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
4419 else | |
4420 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
4421 } | |
4422 | |
4423 //----- (004A194A) -------------------------------------------------------- | |
4424 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
4425 { | |
4426 IDirectDrawSurface *pFront; // eax@3 | |
4427 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
4428 | |
4429 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4430 { | |
4431 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4432 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4433 } | |
4434 else | |
4435 { | |
4436 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4437 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
4438 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4439 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 4440 } |
4441 | |
4442 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4443 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4444 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4445 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4446 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4447 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4448 //int v6; // ecx@5 |
0 | 4449 unsigned int v7; // edx@6 |
4450 char *v8; // ecx@12 | |
4451 void *v9; // edi@16 | |
4452 unsigned int v10; // eax@16 | |
4453 void *v11; // edi@21 | |
4454 unsigned int v12; // eax@21 | |
4455 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4456 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4457 if (uNumBillboardsToDraw >= 999 ) |
0 | 4458 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4459 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4460 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4461 uNumBillboardsToDraw = 1; |
0 | 4462 return 0; |
4463 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4464 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4465 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4466 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4467 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4468 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4469 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4470 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4471 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4472 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4473 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4474 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4475 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4476 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4477 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4478 if (z > *(float *)v8 ) |
0 | 4479 { |
4480 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
4481 { | |
4482 v7 = pRenderer->uNumBillboardsToDraw; | |
4483 } | |
4484 else | |
4485 { | |
4486 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4487 { | |
4488 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
4489 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
4490 do | |
4491 { | |
4492 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
4493 v9 = (char *)v9 - 156; | |
4494 --v10; | |
4495 } | |
4496 while ( v10 ); | |
4497 } | |
4498 ++v7; | |
4499 } | |
717 | 4500 //LABEL_23: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4501 uNumBillboardsToDraw++; |
0 | 4502 return v7; |
4503 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4504 if (z <= *(float *)v8 ) |
0 | 4505 { |
4506 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4507 { | |
4508 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
4509 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
4510 do | |
4511 { | |
4512 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
4513 v11 = (char *)v11 - 156; | |
4514 --v12; | |
4515 } | |
4516 while ( v12 ); | |
4517 } | |
717 | 4518 //goto LABEL_23; |
4519 uNumBillboardsToDraw++; | |
4520 return v7; | |
0 | 4521 } |
4522 return v7; | |
4523 } | |
4524 | |
4525 //----- (004A1E9D) -------------------------------------------------------- | |
4526 unsigned int Render::GetBillboardDrawListSize() | |
4527 { | |
4528 return pRenderer->uNumBillboardsToDraw; | |
4529 } | |
4530 | |
4531 //----- (004A1EA3) -------------------------------------------------------- | |
4532 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
4533 { | |
4534 return pRenderer->pBillboardRenderListD3D[uBillboardID].uParentBillboardID; | |
4535 } | |
4536 | |
4537 //----- (004A1EB6) -------------------------------------------------------- | |
4538 void Render::BeginSceneD3D() | |
4539 { | |
4540 if (!uNumD3DSceneBegins++) | |
4541 { | |
4542 if (pRenderD3D) | |
4543 { | |
4544 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
4545 pRenderer->uNumBillboardsToDraw = 0; | |
4546 pRenderD3D->pDevice->BeginScene(); | |
1390 | 4547 |
0 | 4548 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
4549 uFogColor = GetLevelFogColor(); | |
4550 else | |
4551 uFogColor = 0; | |
4552 | |
4553 if ( uFogColor & 0xFF000000 ) | |
4554 { | |
4555 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
4556 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
4557 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4558 bUsingSpecular = true; | |
4559 } | |
4560 else | |
4561 { | |
4562 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
4563 bUsingSpecular = 0; | |
4564 } | |
4565 } | |
4566 else | |
4567 { | |
4568 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
4569 if (pTargetSurface) | |
4570 field_18_locked_pitch = uTargetSurfacePitch; | |
4571 else | |
4572 --uNumD3DSceneBegins; | |
4573 } | |
4574 } | |
4575 } | |
4576 | |
4577 //----- (004A1FE1) -------------------------------------------------------- | |
4578 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
4579 { | |
4580 --uNumD3DSceneBegins; | |
4581 if (uNumD3DSceneBegins) | |
4582 return; | |
4583 | |
4584 if (pRenderD3D) | |
4585 { | |
4586 pGame->draw_debug_outlines(); | |
161 | 4587 DoRenderBillboards_D3D(); |
0 | 4588 pGame->pStru6Instance->RenderSpecialEffects(); |
4589 pRenderD3D->pDevice->EndScene(); | |
4590 } | |
4591 else | |
4592 pGame->pStru6Instance->RenderSpecialEffects(); | |
4593 } | |
4594 | |
4595 //----- (004A2031) -------------------------------------------------------- | |
349 | 4596 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
4597 { | |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4598 // __debugbreak(); // should not fire outside decal builder |
349 | 4599 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 4600 } |
4601 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4602 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 4603 { |
4604 int v5; // ebx@1 | |
4605 int v6; // edi@1 | |
4606 int v8; // eax@7 | |
4607 float v9; // eax@12 | |
4608 float *v10; // esi@12 | |
4609 float v11; // ecx@14 | |
4610 double v12; // st7@14 | |
4611 double v13; // st7@14 | |
4612 double v14; // st7@14 | |
4613 signed int v15; // eax@14 | |
4614 int v16; // eax@15 | |
4615 float v17; // ST48_4@15 | |
4616 char v18; // zf@17 | |
4617 int v19; // eax@18 | |
4618 int v20; // eax@18 | |
4619 int v21; // edx@20 | |
4620 signed int v22; // ecx@20 | |
4621 int v23; // eax@20 | |
4622 const char *v24; // ST4C_4@20 | |
4623 unsigned int v25; // ST50_4@20 | |
4624 int v26; // ST54_4@20 | |
4625 int v27; // eax@20 | |
4626 _UNKNOWN *v28; // eax@21 | |
4627 int v29; // ecx@23 | |
4628 int v30; // eax@23 | |
4629 int v31; // eax@23 | |
4630 int v32; // eax@24 | |
4631 int v33; // eax@25 | |
4632 int v34; // eax@25 | |
4633 int v35; // eax@25 | |
4634 int v36; // eax@25 | |
4635 signed int v37; // ecx@26 | |
4636 int v38; // eax@26 | |
4637 _UNKNOWN *v39; // eax@27 | |
4638 int v40; // edx@28 | |
4639 int v41; // eax@29 | |
4640 int v42; // eax@29 | |
4641 int v43; // eax@29 | |
4642 int v44; // eax@29 | |
4643 unsigned int v46; // eax@29 | |
4644 int v47; // eax@30 | |
4645 int v48; // eax@30 | |
4646 int v49; // eax@30 | |
4647 double v52; // st6@35 | |
4648 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
4649 int v57; // [sp+5Ch] [bp-Ch]@3 | |
4650 signed int v59; // [sp+60h] [bp-8h]@12 | |
4651 int v61; // [sp+64h] [bp-4h]@4 | |
4652 int i; | |
4653 | |
4654 v6 = (int)this; | |
4655 v5 = 0; | |
4656 if (!this->uNumD3DSceneBegins) | |
4657 return; | |
4658 | |
4659 | |
4660 | |
4661 | |
186 | 4662 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 4663 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
4664 if (this->bUsingSpecular) | |
4665 { | |
186 | 4666 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4667 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4668 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 4669 } |
4670 | |
4671 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
4672 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
4673 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
4674 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); | |
4675 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
4676 pVertices[0].specular = 0; | |
4677 pVertices[0].texcoord.x = array_50AC10[0].u; | |
4678 pVertices[0].texcoord.y = array_50AC10[0].v; | |
4679 | |
4680 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
4681 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
4682 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
4683 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); | |
4684 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
4685 pVertices[1].specular = 0; | |
4686 pVertices[1].texcoord.x = array_50AC10[3].u; | |
4687 pVertices[1].texcoord.y = array_50AC10[3].v; | |
4688 | |
4689 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
4690 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
4691 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
4692 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); | |
4693 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
4694 pVertices[2].specular = 0; | |
4695 pVertices[2].texcoord.x = array_50AC10[1].u; | |
4696 pVertices[2].texcoord.y = array_50AC10[1].v; | |
4697 | |
4698 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
4699 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
4700 | |
4701 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
4702 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
4703 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
4704 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); | |
4705 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
4706 pVertices[5].specular = 0; | |
4707 pVertices[5].texcoord.x = array_50AC10[2].u; | |
4708 pVertices[5].texcoord.y = array_50AC10[2].v; | |
4709 | |
4710 | |
4711 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4712 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
4713 | |
186 | 4714 }*/ |
4715 | |
0 | 4716 //----- (004A26BC) -------------------------------------------------------- |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4717 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
186 | 4718 { |
4719 //RenderVertexSoft *pVertices; // esi@0 | |
4720 //int v7; // edi@1 | |
0 | 4721 unsigned int v8; // ebx@1 |
4722 LightmapBuilder *v9; // esi@3 | |
4723 unsigned int v10; // edx@3 | |
4724 int v11; // eax@5 | |
4725 int v12; // eax@11 | |
4726 char *v13; // esi@11 | |
4727 double v14; // st7@13 | |
4728 double v15; // st7@13 | |
4729 signed int v16; // eax@13 | |
4730 int v17; // ecx@13 | |
4731 double v18; // st7@13 | |
4732 float v19; // ST78_4@14 | |
4733 int v20; // eax@14 | |
4734 char v21; // zf@16 | |
4735 HRESULT v22; // eax@17 | |
4736 HRESULT v23; // eax@17 | |
4737 HRESULT v24; // eax@19 | |
4738 HRESULT v25; // eax@19 | |
4739 unsigned int v26; // ecx@19 | |
4740 char *v27; // eax@20 | |
4741 HRESULT v28; // eax@22 | |
4742 HRESULT v29; // eax@22 | |
4743 HRESULT v30; // eax@23 | |
4744 HRESULT v31; // eax@24 | |
4745 HRESULT v32; // eax@24 | |
4746 HRESULT v33; // eax@24 | |
4747 HRESULT v34; // eax@24 | |
4748 HRESULT v35; // eax@25 | |
4749 HRESULT v36; // eax@25 | |
4750 unsigned int v37; // ecx@25 | |
4751 char *v38; // eax@26 | |
4752 int v39; // edx@27 | |
4753 HRESULT v40; // eax@28 | |
4754 HRESULT v41; // eax@28 | |
4755 HRESULT v42; // eax@28 | |
4756 HRESULT v43; // eax@28 | |
4757 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
4758 unsigned int v45; // eax@28 | |
4759 HRESULT v46; // eax@29 | |
4760 HRESULT v47; // eax@29 | |
4761 HRESULT v48; // eax@29 | |
186 | 4762 //IDirect3DDevice3 *v49; // eax@35 |
0 | 4763 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
4764 int v51; // eax@40 | |
4765 char *v52; // esi@40 | |
4766 double v53; // st7@42 | |
4767 double v54; // st7@42 | |
4768 signed int v55; // eax@42 | |
4769 int v56; // ecx@42 | |
4770 double v57; // st7@42 | |
4771 float v58; // ST7C_4@43 | |
4772 int v59; // eax@43 | |
186 | 4773 //signed int v60; // [sp+78h] [bp-14h]@31 |
4774 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 4775 const char *v62; // [sp+80h] [bp-Ch]@0 |
4776 const char *v63; // [sp+80h] [bp-Ch]@19 | |
4777 int v64; // [sp+84h] [bp-8h]@0 | |
4778 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
4779 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
4780 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 4781 int a7; |
4782 | |
4783 //v7 = (int)this; | |
0 | 4784 v8 = 0; |
186 | 4785 if (!this->uNumD3DSceneBegins) |
75 | 4786 return; |
4787 if ( uNumVertices < 3) | |
4788 return; | |
4789 | |
186 | 4790 //v61 = pVertices; |
4791 | |
75 | 4792 /* v9 = pGame->pLightmapBuilder; |
0 | 4793 v65 = v9; |
75 | 4794 v10 = v9->std__vector_000004_size;*/ |
1394 | 4795 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) |
0 | 4796 { |
638 | 4797 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 4798 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); |
0 | 4799 } |
4800 else | |
4801 { | |
186 | 4802 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 4803 byte_4D864C && pGame->uFlags & 2 ) |
4804 { | |
186 | 4805 if (clampAtTextureBorders) |
4806 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 4807 else |
186 | 4808 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
4809 | |
4810 if (transparent || this->bUsingSpecular) | |
4811 { | |
4812 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4813 if (transparent) | |
0 | 4814 { |
186 | 4815 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
4816 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
4817 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
4818 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 4819 } |
4820 else | |
4821 { | |
186 | 4822 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
4823 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 4824 } |
186 | 4825 } |
1073 | 4826 |
4827 for (uint i = 0; i < uNumVertices; ++i) | |
4828 { | |
4829 | |
4830 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4831 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4832 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
4833 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
4834 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4835 if ( this->bUsingSpecular ) | |
0 | 4836 { |
1073 | 4837 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4838 } |
1073 | 4839 else |
4840 { | |
4841 d3d_vertex_buffer[i].specular = 0; | |
4842 } | |
4843 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4844 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4845 } | |
4846 | |
4847 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4848 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
186 | 4849 if (transparent) |
4850 { | |
4851 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
4852 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4853 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4854 } |
4855 } | |
4856 else | |
4857 { | |
1073 | 4858 for (uint i = 0; i < uNumVertices; ++i) |
4859 { | |
4860 | |
4861 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4862 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4863 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
4864 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
4865 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4866 if ( this->bUsingSpecular ) | |
0 | 4867 { |
1073 | 4868 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4869 } |
1073 | 4870 else |
4871 { | |
4872 d3d_vertex_buffer[i].specular = 0; | |
4873 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4874 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
1073 | 4875 d3d_vertex_buffer[i].specular = v20; |
4876 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4877 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4878 } | |
186 | 4879 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4880 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4881 if (pRenderer->bUsingSpecular) | |
4882 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 4883 |
4884 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 4885 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 4886 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4887 d3d_vertex_buffer, |
0 | 4888 uNumVertices, |
4889 16)); | |
4890 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 4891 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 4892 //(*(void (**)(void))(*(int *)v63 + 88))(); |
1394 | 4893 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
1073 | 4894 for (uint i = 0; i < uNumVertices; ++i) |
4895 { | |
4896 d3d_vertex_buffer[i].diffuse = -1; | |
4897 } | |
0 | 4898 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 4899 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4900 if ( !pRenderer->bUsingSpecular ) |
4901 { | |
186 | 4902 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4903 } | |
4904 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4905 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4906 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
4907 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4908 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4909 d3d_vertex_buffer, |
0 | 4910 uNumVertices, |
4911 16)); | |
4912 if ( pRenderer->bUsingSpecular ) | |
4913 { | |
186 | 4914 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4915 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 4916 for (uint i = 0; i < uNumVertices; ++i) |
4917 { | |
4918 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4919 d3d_vertex_buffer[i].specular = 0; | |
4920 } | |
4921 | |
75 | 4922 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 4923 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4924 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
4925 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4926 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4927 d3d_vertex_buffer, |
0 | 4928 uNumVertices, |
4929 16)); | |
186 | 4930 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4931 //v44 = pRenderer->pRenderD3D->pDevice; |
4932 v45 = GetLevelFogColor(); | |
4933 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
4934 v8 = 0; | |
4935 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
4936 } | |
186 | 4937 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4938 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4939 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
4940 } | |
4941 } | |
186 | 4942 |
791 | 4943 if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4944 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 4945 } |
4946 // 4A26BC: could not find valid save-restore pair for esi | |
4947 // 4D864C: using guessed type char byte_4D864C; | |
4948 | |
4949 //----- (004A2DA3) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4950 void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *a3, IDirect3DTexture2 *pTexture) |
852 | 4951 { |
67 | 4952 int v7; // eax@7 |
0 | 4953 float v13; // ST3C_4@8 |
67 | 4954 int i; |
4955 | |
4956 if ( !this->uNumD3DSceneBegins ) | |
4957 return; | |
4958 if ( uNumVertices >= 3 ) | |
4959 { | |
186 | 4960 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 4961 if ( this->bUsingSpecular ) |
4962 { | |
186 | 4963 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4964 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4965 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 4966 } |
840 | 4967 for ( i = 0; i < uNumVertices; ++i ) |
67 | 4968 { |
4969 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4970 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4971 pVertices[i].pos.z = 0.99989998; | |
168 | 4972 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 4973 |
840 | 4974 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 4975 v7 = 0; |
4976 if (this->bUsingSpecular) | |
4977 { | |
4978 v13 = array_50AC10[i].vWorldViewPosition.x; | |
4979 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); | |
4980 } | |
4981 pVertices[i].specular = v7; | |
4982 pVertices[i].texcoord.x = array_50AC10[i].u; | |
4983 pVertices[i].texcoord.y = array_50AC10[i].v; | |
4984 } | |
4985 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4986 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 4987 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 4988 } |
4989 } | |
4990 | |
4991 //----- (004A2ED5) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4992 void Render::_4A2ED5(signed int a2, struct Polygon *a3, IDirect3DTexture2 *pHwTex) |
0 | 4993 { |
4994 signed int v4; // edi@2 | |
4995 int v5; // eax@3 | |
4996 int v6; // edx@5 | |
1072 | 4997 RenderVertexD3D3 *v7; // eax@6 |
4998 RenderVertexSoft *v8; // ecx@6 | |
4999 //double v9; // st6@7 | |
5000 //int v10; // ebx@7 | |
5001 //int v11; // ebx@7 | |
0 | 5002 |
5003 if ( this->uNumD3DSceneBegins ) | |
5004 { | |
5005 v4 = a2; | |
5006 if ( a2 >= 3 ) | |
5007 { | |
186 | 5008 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
638 | 5009 v5 = 31 - (a3->dimming_level & 0x1F); |
5010 if ( v5 < pOutdoor->max_terrain_dimming_level ) | |
5011 v5 = pOutdoor->max_terrain_dimming_level; | |
0 | 5012 v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); |
1072 | 5013 for (uint i = 0; i < a2; ++i) |
5014 { | |
5015 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5016 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5017 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / array_507D30[i].vWorldViewPosition.y; | |
5018 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; | |
5019 d3d_vertex_buffer[i].diffuse = v6; | |
5020 d3d_vertex_buffer[i].specular = 0; | |
5021 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
5022 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
5023 } | |
5024 | |
0 | 5025 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5026 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5027 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5028 d3d_vertex_buffer, |
0 | 5029 a2, |
5030 28)); | |
5031 } | |
5032 } | |
5033 } | |
5034 | |
1390 | 5035 |
5036 //----- (00479A53) -------------------------------------------------------- | |
5037 void Render::DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID) | |
5038 { | |
5039 BLVFace *pFace; // esi@1 | |
5040 unsigned int v3; // edi@1 | |
5041 PolygonType v4; // al@1 | |
5042 double v5; // st7@3 | |
5043 signed __int64 v6; // qax@3 | |
5044 PolygonType v7; // cl@3 | |
5045 int v8; // esi@7 | |
5046 int v9; // eax@7 | |
5047 unsigned int v10; // eax@7 | |
5048 double v11; // st6@7 | |
5049 int v12; // edx@7 | |
5050 int v13; // eax@7 | |
5051 char *v14; // esi@8 | |
5052 void *v15; // ecx@9 | |
5053 int v16; // eax@9 | |
5054 int v17; // edi@9 | |
5055 double v18; // st7@9 | |
5056 signed int v19; // ebx@9 | |
5057 void *v20; // ecx@9 | |
5058 int v21; // ebx@11 | |
5059 int v22; // eax@14 | |
5060 signed __int64 v23; // qtt@16 | |
5061 double v24; // st7@16 | |
5062 unsigned __int8 v25; // sf@16 | |
5063 unsigned __int8 v26; // of@16 | |
5064 Render *v27; // ecx@17 | |
5065 double v28; // st7@20 | |
5066 char *v29; // ebx@20 | |
5067 char *v30; // edx@20 | |
5068 unsigned __int8 v31; // c0@21 | |
5069 unsigned __int8 v32; // c3@21 | |
5070 double v33; // st6@23 | |
5071 char *v34; // esi@30 | |
5072 const void *v35; // ecx@31 | |
5073 int v36; // eax@31 | |
5074 const void *v37; // edi@31 | |
5075 signed __int64 v38; // qax@31 | |
5076 int v39; // ecx@31 | |
5077 int v40; // ebx@33 | |
5078 int v41; // eax@36 | |
5079 signed __int64 v42; // qtt@39 | |
5080 int v43; // eax@39 | |
5081 char v44; // zf@39 | |
5082 double v45; // st7@39 | |
5083 double v46; // st7@39 | |
5084 unsigned int v47; // edx@40 | |
5085 double v48; // st7@41 | |
5086 RenderVertexSoft *v49; // ebx@41 | |
5087 void *v50; // edi@43 | |
5088 double v51; // st7@46 | |
5089 RenderVertexSoft *v52; // edx@46 | |
5090 void *v53; // edi@48 | |
5091 char *v54; // ebx@52 | |
5092 unsigned int v55; // eax@53 | |
5093 unsigned int v56; // eax@55 | |
5094 int v57; // ST10_4@55 | |
5095 Texture *v58; // eax@55 | |
5096 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
|
5097 struct Polygon *v60; // [sp+0h] [bp-174h]@17 |
1390 | 5098 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
5099 struct Polygon v62; // [sp+14h] [bp-160h]@6 |
1390 | 5100 unsigned int v63; // [sp+120h] [bp-54h]@7 |
5101 double v64; // [sp+124h] [bp-50h]@7 | |
5102 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
5103 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
5104 float v67; // [sp+130h] [bp-44h]@7 | |
5105 __int64 v68; // [sp+134h] [bp-40h]@3 | |
5106 __int64 v69; // [sp+13Ch] [bp-38h]@3 | |
5107 int v70; // [sp+144h] [bp-30h]@3 | |
5108 int X; // [sp+148h] [bp-2Ch]@9 | |
5109 int v72; // [sp+14Ch] [bp-28h]@7 | |
5110 float v73; // [sp+150h] [bp-24h]@16 | |
5111 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
5112 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 | |
5113 float v76; // [sp+15Ch] [bp-18h]@9 | |
5114 int v77; // [sp+160h] [bp-14h]@9 | |
5115 int v78; // [sp+164h] [bp-10h]@7 | |
5116 void *v79; // [sp+168h] [bp-Ch]@9 | |
5117 float v80; // [sp+16Ch] [bp-8h]@3 | |
5118 const void *v81; // [sp+170h] [bp-4h]@7 | |
5119 | |
5120 __debugbreak(); | |
5121 | |
5122 pFace = &pIndoor->pFaces[uFaceID]; | |
5123 v65 = uFaceID; | |
5124 v3 = uNumVertices; | |
5125 v4 = pFace->uPolygonType; | |
5126 if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor ) | |
5127 { | |
5128 if ( (signed int)uNumVertices > 0 ) | |
5129 { | |
5130 v54 = (char *)&array_507D30[0].u; | |
5131 LODWORD(v80) = uNumVertices; | |
5132 do | |
5133 { | |
5134 v69 = (GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x; | |
5135 *(float *)v54 = (double)v69 + *(float *)v54; | |
5136 *(float *)v54 = *(float *)v54 * 0.25; | |
5137 v55 = GetTickCount(); | |
5138 v54 += 48; | |
5139 v44 = LODWORD(v80)-- == 1; | |
5140 v68 = pBLVRenderParams->vPartyPos.y + (v55 >> 5); | |
5141 *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25; | |
5142 } | |
5143 while ( !v44 ); | |
5144 uFaceID = v65; | |
5145 } | |
5146 v56 = 8 * uFaceID; | |
5147 LOBYTE(v56) = PID(OBJECT_BModel,uFaceID); | |
5148 v57 = v56; | |
5149 v58 = pFace->GetTexture(); | |
5150 pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0); | |
5151 return; | |
5152 } | |
5153 HIDWORD(v69) = pIndoorCamera->sRotationX; | |
5154 HIDWORD(v68) = pIndoorCamera->pos.z; | |
5155 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY; | |
5156 v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z) | |
5157 / (((double)pBLVRenderParams->field_40 + 16192.0) | |
5158 * 65536.0) | |
5159 + *(float *)&v74); | |
5160 v5 = (double)pIndoorCamera->sRotationX * 0.0030664064; | |
5161 *(float *)&v75 = v5; | |
5162 v80 = cos(v5) * 16192.0; | |
5163 v6 = (signed __int64)(*(float *)&v74 | |
5164 - (double)pBLVRenderParams->field_40 | |
5165 / ((v80 + 0.0000001) | |
5166 * 65535.0) | |
5167 * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68))); | |
5168 v7 = pFace->uPolygonType; | |
5169 if ( v7 == 4 || v7 == 3 ) | |
5170 v70 = v6; | |
5171 stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0); | |
5172 v62._48607B(&stru_8019C8); | |
5173 v62.uTileBitmapID = pFace->uBitmapID; | |
5174 v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0); | |
5175 if ( !v62.pTexture ) | |
5176 return; | |
5177 v8 = pBLVRenderParams->sPartyRotX; | |
5178 v62.dimming_level = 0; | |
5179 v62.uNumVertices = v3; | |
5180 v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX + 16); | |
5181 v62.v_18.y = 0; | |
5182 v62.v_18.x = -v9; | |
5183 v62.v_18.z = -stru_5C6E00->Cos(v8 + 16); | |
5184 v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX; | |
5185 memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3])); | |
5186 LODWORD(v80) = v10; | |
5187 v62.field_24 = 33554432; | |
5188 v64 = (double)(signed int)v10 * 0.5; | |
5189 v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); | |
5190 LODWORD(v80) = v62.pTexture->uTextureWidth; | |
5191 v11 = 1.0 / (double)SLODWORD(v80); | |
5192 LODWORD(v80) = v62.pTexture->uTextureHeight; | |
5193 v12 = v62.pTexture->uWidthMinus1; | |
5194 v13 = v62.pTexture->uHeightMinus1; | |
5195 v67 = v11; | |
5196 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; | |
5197 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
5198 v78 = 0; | |
5199 v81 = 0; | |
5200 *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80); | |
5201 if ( (signed int)v62.uNumVertices <= 0 ) | |
5202 { | |
5203 LABEL_17: | |
5204 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; | |
5205 v27 = pRenderer; | |
5206 v60 = &v62; | |
5207 v59 = v62.uNumVertices; | |
5208 goto LABEL_18; | |
5209 } | |
5210 v14 = (char *)&array_507D30[0].vWorldViewProjY; | |
5211 while ( 2 ) | |
5212 { | |
5213 v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14)); | |
5214 LODWORD(v80) = v62.ptr_38->field_14; | |
5215 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; | |
5216 v16 = v77 + v62.ptr_38->field_C; | |
5217 v77 = (int)v15; | |
5218 v74 = v16; | |
5219 LODWORD(v80) = v62.ptr_38->field_20; | |
5220 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; | |
5221 v79 = v15; | |
5222 v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18); | |
5223 LODWORD(v80) = v62.v_18.z; | |
5224 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16); | |
5225 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1)); | |
5226 v18 = *(float *)v14 - 1.0; | |
5227 v19 = -v62.field_24; | |
5228 v77 = -v62.field_24; | |
5229 X = (int)((char *)v79 + v62.v_18.x); | |
5230 LODWORD(v76) = (signed __int64)v18; | |
5231 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
5232 while ( 1 ) | |
5233 { | |
5234 v79 = v20; | |
5235 if ( !X ) | |
5236 goto LABEL_14; | |
5237 v21 = abs(v19 >> 14); | |
5238 if ( v21 <= abs(X) ) | |
5239 break; | |
5240 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5241 break; | |
5242 v19 = v77; | |
5243 v20 = v79; | |
5244 LABEL_14: | |
5245 LODWORD(v80) = v62.v_18.z; | |
5246 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16); | |
5247 v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16; | |
5248 --LODWORD(v76); | |
5249 v20 = (char *)v20 + v72; | |
5250 X = v22 + v62.v_18.x; | |
5251 v78 = 1; | |
5252 } | |
5253 if ( !v78 ) | |
5254 { | |
5255 LODWORD(v23) = v77 << 16; | |
5256 HIDWORD(v23) = v77 >> 16; | |
5257 v79 = (void *)(v23 / X); | |
5258 v77 = v17; | |
5259 LODWORD(v80) = v62.ptr_38->field_10; | |
5260 v77 = v17; | |
5261 LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16); | |
5262 LODWORD(v80) = v62.ptr_38->field_1C; | |
5263 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16)); | |
5264 v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16; | |
5265 LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16; | |
5266 v14 += 48; | |
5267 LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4); | |
5268 v81 = (char *)v81 + 1; | |
5269 v24 = (double)SLODWORD(v80) * 0.000015259022; | |
5270 LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4); | |
5271 v26 = __OFSUB__((int)v81, v62.uNumVertices); | |
5272 v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0; | |
5273 *((float *)v14 - 10) = v24 * v67; | |
5274 *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1); | |
5275 *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79; | |
5276 if ( !(v25 ^ v26) ) | |
5277 goto LABEL_17; | |
5278 continue; | |
5279 } | |
5280 break; | |
5281 } | |
5282 LODWORD(v73) = 0; | |
5283 v80 = v76; | |
5284 if ( (signed int)v62.uNumVertices > 0 ) | |
5285 { | |
5286 v28 = (double)SLODWORD(v76); | |
5287 LODWORD(v76) = (int)(char *)array_50AC10 + 28; | |
5288 v29 = (char *)&array_50AC10[0].vWorldViewProjX; | |
5289 v30 = (char *)&array_507D30[1].vWorldViewProjY; | |
5290 v79 = array_50AC10; | |
5291 v81 = array_507D30; | |
5292 v78 = v62.uNumVertices; | |
5293 do | |
5294 { | |
5295 v31 = v28 < *((float *)v30 - 12); | |
5296 v32 = v28 == *((float *)v30 - 12); | |
5297 ++LODWORD(v73); | |
5298 memcpy(v79, v81, 0x30u); | |
5299 v79 = (char *)v79 + 48; | |
5300 LODWORD(v76) += 48; | |
5301 v29 += 48; | |
5302 if ( v31 | v32 || v28 >= *(float *)v30 ) | |
5303 { | |
5304 if ( v28 >= *((float *)v30 - 12) || v28 <= *(float *)v30 ) | |
5305 goto LABEL_28; | |
5306 v33 = (*((float *)v30 - 1) - *((float *)v30 - 13)) * v28 / (*(float *)v30 - *((float *)v30 - 12)) | |
5307 + *((float *)v30 - 1); | |
5308 } | |
5309 else | |
5310 { | |
5311 v33 = (*((float *)v30 - 13) - *((float *)v30 - 1)) * v28 / (*((float *)v30 - 12) - *(float *)v30) | |
5312 + *((float *)v30 - 13); | |
5313 } | |
5314 *(float *)v29 = v33; | |
5315 v79 = (char *)v79 + 48; | |
5316 v29 += 48; | |
5317 ++LODWORD(v73); | |
5318 *(unsigned int *)LODWORD(v76) = v28; | |
5319 LODWORD(v76) += 48; | |
5320 LABEL_28: | |
5321 v81 = (char *)v81 + 48; | |
5322 v30 += 48; | |
5323 --v78; | |
5324 } | |
5325 while ( v78 ); | |
5326 } | |
5327 if ( SLODWORD(v73) <= 0 ) | |
5328 goto LABEL_40; | |
5329 v34 = (char *)&array_50AC10[0].vWorldViewProjY; | |
5330 v65 = v77 >> 14; | |
5331 HIDWORD(v69) = LODWORD(v73); | |
5332 do | |
5333 { | |
5334 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34)); | |
5335 v78 = v62.ptr_38->field_14; | |
5336 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); | |
5337 v36 = (int)((char *)v81 + v62.ptr_38->field_C); | |
5338 v81 = v35; | |
5339 v74 = v36; | |
5340 v78 = v62.ptr_38->field_20; | |
5341 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); | |
5342 v78 = (int)v35; | |
5343 v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18); | |
5344 v81 = (const void *)v62.v_18.z; | |
5345 v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16; | |
5346 v37 = (const void *)(v72 | |
5347 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1))); | |
5348 v38 = (signed __int64)(*(float *)v34 - 1.0); | |
5349 v81 = 0; | |
5350 LODWORD(v76) = v38; | |
5351 v39 = v72 * (v70 - v38); | |
5352 while ( 1 ) | |
5353 { | |
5354 v78 = v39; | |
5355 if ( !X ) | |
5356 goto LABEL_36; | |
5357 v40 = abs(X); | |
5358 if ( abs((signed __int64)v65) <= v40 ) | |
5359 break; | |
5360 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5361 break; | |
5362 v39 = v78; | |
5363 LABEL_36: | |
5364 v78 = v62.v_18.z; | |
5365 v41 = (unsigned __int64)(v62.v_18.z * (signed __int64)v39) >> 16; | |
5366 --LODWORD(v76); | |
5367 v39 += v72; | |
5368 X = v41 + v62.v_18.x; | |
5369 v81 = (const void *)1; | |
5370 } | |
5371 if ( v81 ) | |
5372 { | |
5373 v79 = (void *)v62.v_18.z; | |
5374 v78 = 2 * LODWORD(v76); | |
5375 v81 = (const void *)((unsigned __int64)(v62.v_18.z | |
5376 * (signed __int64)(signed int)(signed __int64)(((double)v70 | |
5377 - ((double)(2 * LODWORD(v76)) | |
5378 - *(float *)v34)) | |
5379 * (double)v72)) >> 16); | |
5380 X = (int)((char *)v81 + v62.v_18.x); | |
5381 } | |
5382 LODWORD(v42) = v77 << 16; | |
5383 HIDWORD(v42) = v77 >> 16; | |
5384 v79 = (void *)(v42 / X); | |
5385 v81 = v37; | |
5386 v78 = v62.ptr_38->field_10; | |
5387 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); | |
5388 v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); | |
5389 v74 = (unsigned int)v37; | |
5390 LODWORD(v76) = v43; | |
5391 v78 = v62.ptr_38->field_1C; | |
5392 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16)); | |
5393 v74 = (unsigned __int64)(v43 * v42 / X) >> 16; | |
5394 v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16); | |
5395 v34 += 48; | |
5396 v78 = v66 + ((signed int)v74 >> 4); | |
5397 v44 = HIDWORD(v69)-- == 1; | |
5398 v45 = (double)v78 * 0.000015259022; | |
5399 v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4); | |
5400 *((float *)v34 - 10) = v45 * v67; | |
5401 *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1); | |
5402 v46 = (double)(signed int)v79; | |
5403 *((float *)v34 - 16) = 0.000015258789 * v46; | |
5404 *((float *)v34 - 11) = 65536.0 / v46; | |
5405 } | |
5406 while ( !v44 ); | |
5407 LABEL_40: | |
5408 v47 = 0; | |
5409 if ( SLODWORD(v73) > 0 ) | |
5410 { | |
5411 v48 = (double)SLODWORD(v80); | |
5412 v75 = array_507D30; | |
5413 v49 = array_50AC10; | |
5414 HIDWORD(v69) = LODWORD(v73); | |
5415 do | |
5416 { | |
5417 if ( v48 >= v49->vWorldViewProjY ) | |
5418 { | |
5419 v50 = v75; | |
5420 ++v47; | |
5421 ++v75; | |
5422 memcpy(v50, v49, 0x30u); | |
5423 } | |
5424 ++v49; | |
5425 --HIDWORD(v69); | |
5426 } | |
5427 while ( HIDWORD(v69) ); | |
5428 } | |
5429 v62.uNumVertices = v47; | |
5430 pRenderer->_4A2ED5(v47, &v62, pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]); | |
5431 *(float *)&v74 = 0.0; | |
5432 if ( SLODWORD(v73) > 0 ) | |
5433 { | |
5434 v51 = (double)SLODWORD(v80); | |
5435 v75 = array_507D30; | |
5436 v52 = array_50AC10; | |
5437 v80 = v73; | |
5438 do | |
5439 { | |
5440 if ( v51 <= v52->vWorldViewProjY ) | |
5441 { | |
5442 v53 = v75; | |
5443 ++v74; | |
5444 ++v75; | |
5445 memcpy(v53, v52, 0x30u); | |
5446 } | |
5447 ++v52; | |
5448 --LODWORD(v80); | |
5449 } | |
5450 while ( v80 != 0.0 ); | |
5451 } | |
5452 v62.uNumVertices = v74; | |
5453 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; | |
5454 v60 = &v62; | |
5455 v59 = v74; | |
5456 v27 = pRenderer; | |
5457 LABEL_18: | |
5458 v27->_4A2ED5(v59, v60, v61); | |
5459 } | |
5460 | |
5461 | |
0 | 5462 //----- (004A2FC0) -------------------------------------------------------- |
5463 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
5464 { | |
5465 //Render *v8; // edi@1 | |
5466 //unsigned int v9; // esi@3 | |
1072 | 5467 RenderVertexSoft *v12; // ecx@9 |
5468 RenderVertexD3D3 *v13; // eax@9 | |
0 | 5469 double v14; // st6@10 |
5470 int v15; // edx@10 | |
5471 Texture *v16; // edx@10 | |
5472 double v17; // st6@10 | |
5473 //char v18; // zf@10 | |
5474 Texture *v19; // edx@10 | |
595 | 5475 //Texture *v23; // edx@16 |
5476 //char *v24; // ecx@16 | |
5477 //char *v25; // eax@16 | |
5478 //double v26; // st6@17 | |
5479 //int v27; // esi@17 | |
5480 //double v28; // st6@17 | |
5481 //unsigned int v33; // ecx@18 | |
5482 //char *v34; // eax@19 | |
0 | 5483 //Texture *v45; // edx@23 |
5484 //char *v46; // ecx@23 | |
5485 //char *v47; // eax@23 | |
5486 //double v48; // st6@24 | |
5487 //int v49; // esi@24 | |
5488 //double v50; // st6@24 | |
5489 const char *v53; // [sp-Ch] [bp-20h]@21 | |
5490 //int v54; // [sp-8h] [bp-1Ch]@21 | |
5491 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
5492 const char *v56; // [sp+0h] [bp-14h]@0 | |
5493 int v57; // [sp+4h] [bp-10h]@0 | |
5494 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
5495 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
5496 //int a3a; // [sp+10h] [bp-4h]@4 | |
5497 | |
5498 //v8 = this; | |
5499 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
5500 return; | |
5501 | |
5502 //auto a3 = pFace; | |
5503 //auto a6 = uPackedID; | |
5504 //v59 = pGame->pLightmapBuilder; | |
5505 //v9 = v59->std__vector_000004_size; | |
5506 | |
5507 auto uCorrectedColor = uColor; | |
5508 if (pGame->pLightmapBuilder->std__vector_000004_size) | |
5509 uCorrectedColor = 0xFFFFFFFF; | |
638 | 5510 pGame->AlterGamma_BLV(pFace, &uCorrectedColor); |
0 | 5511 |
792 | 5512 |
5513 if (pFace->uAttributes & FACE_OUTLINED) | |
5514 { | |
5515 int color; | |
5516 if (GetTickCount() % 300 >= 150) | |
5517 uColor = uCorrectedColor = 0xFF20FF20; | |
5518 else uColor = uCorrectedColor = 0xFF109010; | |
5519 } | |
5520 | |
1394 | 5521 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) |
0 | 5522 { |
5523 __debugbreak(); | |
5524 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 5525 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 5526 for (uint i = 0; i < uNumVertices; ++i) |
5527 { | |
5528 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5529 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5530 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5531 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5532 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
5533 d3d_vertex_buffer[i].specular = 0; | |
5534 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5535 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5536 } | |
5537 | |
186 | 5538 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5539 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
5540 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
5541 D3DPT_TRIANGLEFAN, | |
5542 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5543 d3d_vertex_buffer, |
0 | 5544 uNumVertices, |
5545 28)); | |
1394 | 5546 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
0 | 5547 } |
5548 else | |
5549 { | |
5550 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
5551 byte_4D864C && pGame->uFlags & 2) | |
5552 { | |
5553 for (uint i = 0; i < uNumVertices; ++i) | |
5554 { | |
186 | 5555 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
5556 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5557 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5558 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5559 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
5560 d3d_vertex_buffer[i].specular = 0; | |
5561 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5562 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5563 } | |
5564 | |
5565 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 5566 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
5567 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5568 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5569 d3d_vertex_buffer, |
0 | 5570 uNumVertices, |
5571 28)); | |
5572 } | |
5573 else | |
5574 { | |
595 | 5575 for (uint i = 0; i < uNumVertices; ++i) |
5576 { | |
5577 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5578 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5579 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5580 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5581 d3d_vertex_buffer[i].diffuse = uColor; | |
5582 d3d_vertex_buffer[i].specular = 0; | |
5583 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5584 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5585 } | |
5586 //__debugbreak(); | |
5587 //if ( (signed int)uNumVertices > 0 ) | |
5588 //{ | |
5589 //v23 = pTex; | |
5590 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
5591 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
5592 //pTex = (Texture *)uNumVertices; | |
5593 //uint v18; | |
5594 //do | |
5595 //{ | |
5596 //v26 = *(float *)v24 * 0.061758894; | |
5597 //v27 = *((int *)v24 + 3); | |
5598 //*((int *)v25 + 4) = 0; | |
5599 //*((int *)v25 - 1) = v27; | |
5600 //*(int *)v25 = *((int *)v24 + 4); | |
5601 //*((int *)v25 + 3) = uColor; | |
5602 //v25 += 32; | |
5603 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
5604 //v28 = 1.0 / *(float *)v24; | |
5605 //v24 += 48; | |
5606 //v18 = pTex == (Texture *)1; | |
5607 //pTex = (Texture *)((char *)pTex - 1); | |
5608 //*((float *)v25 - 6) = v28; | |
0 | 5609 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 5610 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 5611 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 5612 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
5613 //} | |
5614 //while ( !v18 ); | |
5615 //} | |
0 | 5616 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 5617 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5618 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 5619 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5620 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5621 d3d_vertex_buffer, |
0 | 5622 uNumVertices, |
5623 28)); | |
595 | 5624 |
5625 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1394 | 5626 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
595 | 5627 |
5628 for (uint i = 0; i < uNumVertices; ++i) | |
5629 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
5630 /*v33 = uNumVertices; | |
0 | 5631 if ( (signed int)uNumVertices > 0 ) |
5632 { | |
186 | 5633 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 5634 do |
5635 { | |
5636 *(int *)v34 = uCorrectedColor; | |
5637 v34 += 32; | |
5638 --v33; | |
5639 } | |
5640 while ( v33 ); | |
595 | 5641 }*/ |
0 | 5642 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5643 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
5644 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5645 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5646 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5647 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
5648 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 5649 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5650 d3d_vertex_buffer, |
0 | 5651 uNumVertices, |
5652 28)); | |
186 | 5653 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
5654 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5655 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 5656 } |
5657 } | |
5658 } | |
5659 // 4D864C: using guessed type char byte_4D864C; | |
5660 | |
5661 //----- (004A43B1) -------------------------------------------------------- | |
717 | 5662 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
5663 { | |
5664 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
5665 //double v5; // st7@2 | |
5666 //float v6; // ST08_4@2 | |
0 | 5667 unsigned int v7; // eax@2 |
717 | 5668 //int v8; // ecx@2 |
5669 //unsigned int v9; // esi@2 | |
5670 //Sprite *v10; // edi@5 | |
0 | 5671 signed int v11; // eax@9 |
5672 signed int v12; // eax@9 | |
717 | 5673 //double v13; // st7@12 |
5674 //double v14; // st6@12 | |
0 | 5675 double v15; // st5@12 |
5676 double v16; // st4@12 | |
5677 double v17; // st3@12 | |
5678 double v18; // st2@12 | |
5679 int v19; // ecx@14 | |
5680 double v20; // st3@14 | |
5681 int v21; // ecx@16 | |
5682 double v22; // st3@16 | |
717 | 5683 //IDirect3DTexture2 *v23; // eax@18 |
5684 //signed int v24; // [sp+18h] [bp-18h]@5 | |
5685 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
5686 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 5687 float v27; // [sp+24h] [bp-Ch]@5 |
5688 int v28; // [sp+28h] [bp-8h]@2 | |
5689 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 5690 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 5691 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 5692 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 5693 float a1; // [sp+40h] [bp+10h]@5 |
5694 | |
717 | 5695 //v26 = this; |
0 | 5696 if ( this->uNumD3DSceneBegins ) |
5697 { | |
717 | 5698 //v4 = pSoftBillboard; |
5699 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
5700 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
5701 //v6 = pSoftBillboard->zbuffer_depth; | |
5702 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
5703 //v8 = dimming_level; | |
5704 //v9 = v7; | |
657 | 5705 v28 = dimming_level & 0xFF000000; |
5706 if ( dimming_level & 0xFF000000 ) | |
717 | 5707 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; |
0 | 5708 else |
717 | 5709 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; |
5710 //v10 = a3; | |
5711 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
5712 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
5713 pBillboardRenderListD3D[v7].uParentBillboardID = pSoftBillboard->uParentBillboardID; | |
5714 //v25 = pSoftBillboard->uScreenSpaceX; | |
5715 //v24 = pSoftBillboard->uScreenSpaceY; | |
5716 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
5717 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
5718 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5719 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
5720 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5721 v31 = v31 * -1.0; |
717 | 5722 if ( pSoftBillboard->uTintColor && this->bTinting ) |
5723 { | |
5724 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
737 | 5725 v12 = BlendColors(pSoftBillboard->uTintColor, v11); |
0 | 5726 if ( v28 ) |
5727 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
5728 } | |
5729 else | |
5730 { | |
717 | 5731 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
5732 } | |
5733 //v13 = (double)v25; | |
1390 | 5734 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; |
5735 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
5736 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
717 | 5737 //v14 = (double)v24; |
5738 //v32 = v14; | |
1390 | 5739 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; |
717 | 5740 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); |
1390 | 5741 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; |
717 | 5742 v16 = 1.0 / pSoftBillboard->zbuffer_depth; |
1390 | 5743 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; |
5744 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
5745 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
717 | 5746 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); |
5747 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
5748 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5749 v17 = v17 * -1.0; |
1390 | 5750 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; |
5751 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
5752 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
5753 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
5754 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
5755 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
5756 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
5757 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
717 | 5758 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; |
5759 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5760 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5761 v20 = v20 * -1.0; |
1390 | 5762 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; |
5763 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
5764 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
5765 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
5766 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
5767 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
5768 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
5769 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
717 | 5770 v21 = pSprite->uBufferHeight - pSprite->uAreaY; |
5771 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5772 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5773 v22 = v22 * -1.0; |
1390 | 5774 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; |
5775 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
5776 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
5777 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
5778 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
5779 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
5780 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
5781 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
717 | 5782 //v23 = pSprite->pTexture; |
5783 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
5784 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
5785 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 5786 } |
5787 } | |
5788 | |
5789 //----- (004A354F) -------------------------------------------------------- | |
5790 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5791 { | |
743 | 5792 //double v5; // st7@3 |
5793 //float v6; // ST20_4@3 | |
5794 //float v7; // ST00_4@3 | |
0 | 5795 unsigned int v8; // esi@3 |
743 | 5796 //int v9; // eax@3 |
5797 //int v10; // ebx@3 | |
0 | 5798 float v11; // ST28_4@3 |
743 | 5799 //double v12; // st7@3 |
5800 //float v13; // ST24_4@3 | |
5801 //double v14; // st6@3 | |
5802 //float v15; // ST1C_4@3 | |
0 | 5803 float v16; // ST2C_4@3 |
5804 float v17; // ST30_4@3 | |
5805 signed int v18; // ST18_4@3 | |
5806 signed int v19; // ST14_4@3 | |
5807 signed int v20; // ST10_4@3 | |
5808 signed int v21; // eax@3 | |
5809 double v22; // st6@3 | |
5810 float v23; // ST2C_4@3 | |
5811 float v24; // ST30_4@3 | |
5812 signed int v25; // ST10_4@3 | |
5813 signed int v26; // ST14_4@3 | |
5814 signed int v27; // ST18_4@3 | |
5815 signed int v28; // eax@3 | |
5816 double v29; // st6@3 | |
5817 float v30; // ecx@3 | |
5818 float v31; // ST2C_4@3 | |
5819 float v32; // ST30_4@3 | |
5820 signed int v33; // ST10_4@3 | |
5821 signed int v34; // ST14_4@3 | |
5822 signed int v35; // ST18_4@3 | |
5823 signed int v36; // eax@3 | |
5824 float v37; // ecx@3 | |
5825 double v38; // st6@3 | |
5826 float v39; // ST2C_4@3 | |
5827 float v40; // ST30_4@3 | |
5828 signed int v41; // ST10_4@3 | |
5829 signed int v42; // ST14_4@3 | |
5830 signed int v43; // ST18_4@3 | |
5831 signed int v44; // eax@3 | |
5832 double v45; // st6@3 | |
5833 float v46; // eax@3 | |
5834 | |
5835 if ( this->uNumD3DSceneBegins ) | |
5836 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5837 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5838 { |
743 | 5839 //v5 = (double)a2->zbuffer_depth; |
5840 //v6 = v5; | |
5841 //v7 = v5; | |
5842 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
0 | 5843 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; |
5844 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
5845 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
5846 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
743 | 5847 //v9 = a2->uScreenSpaceX; |
5848 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5849 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 5850 //v12 = (double) a2->uScreenSpaceX; |
5851 //v13 = v12; | |
5852 //v14 = (double)(a2->uScreenSpaceY - 12); | |
5853 //v15 = v14; | |
5854 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5855 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5856 v18 = stru_5C6E00->Cos(angle); |
5857 v19 = stru_5C6E00->Sin(angle); | |
5858 v20 = stru_5C6E00->Sin(angle); | |
5859 v21 = stru_5C6E00->Cos(angle); | |
1390 | 5860 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5861 + (double)(v18 >> 16)) |
5862 * v16 | |
5863 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
5864 + (double)(v19 >> 16)) | |
5865 * v17) | |
743 | 5866 * v11 + (double) a2->uScreenSpaceX; |
0 | 5867 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
5868 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
5869 - 12.0) | |
5870 * v11 | |
5871 + (double)a2->uScreenSpaceY; | |
1390 | 5872 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5873 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5874 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
5875 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
5876 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5877 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5878 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
743 | 5879 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5880 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5881 v25 = stru_5C6E00->Cos(angle); |
5882 v26 = stru_5C6E00->Sin(angle); | |
5883 v27 = stru_5C6E00->Sin(angle); | |
5884 v28 = stru_5C6E00->Cos(angle); | |
1390 | 5885 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
0 | 5886 + (double)(v25 >> 16)) |
740 | 5887 * v31 |
0 | 5888 - ((double)(unsigned __int16)v26 * 0.000015259022 |
5889 + (double)(v26 >> 16)) | |
740 | 5890 * v32) |
743 | 5891 * v11 + (double) a2->uScreenSpaceX; |
740 | 5892 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
5893 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 5894 - 12.0) |
5895 * v11 | |
5896 + (double)a2->uScreenSpaceY; | |
1390 | 5897 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5898 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5899 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
5900 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5901 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
5902 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5903 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5904 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
743 | 5905 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
5906 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5907 v33 = stru_5C6E00->Cos(angle); |
5908 v34 = stru_5C6E00->Sin(angle); | |
5909 v35 = stru_5C6E00->Sin(angle); | |
5910 v36 = stru_5C6E00->Cos(angle); | |
1390 | 5911 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
0 | 5912 + (double)(v33 >> 16)) |
740 | 5913 * v23 |
0 | 5914 - ((double)(unsigned __int16)v34 * 0.000015259022 |
5915 + (double)(v34 >> 16)) | |
740 | 5916 * v24) |
743 | 5917 * v11 + (double) a2->uScreenSpaceX; |
1390 | 5918 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
740 | 5919 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
5920 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 5921 - 12.0) |
5922 * v11 | |
5923 + (double)a2->uScreenSpaceY; | |
1390 | 5924 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5925 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
5926 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5927 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5928 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
5929 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5930 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
743 | 5931 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5932 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5933 v41 = stru_5C6E00->Cos(angle); |
5934 v42 = stru_5C6E00->Sin(angle); | |
5935 v43 = stru_5C6E00->Sin(angle); | |
5936 v44 = stru_5C6E00->Cos(angle); | |
1390 | 5937 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
0 | 5938 + (double)(v41 >> 16)) |
5939 * v39 | |
5940 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
5941 + (double)(v42 >> 16)) | |
5942 * v40) | |
743 | 5943 * v11 + (double) a2->uScreenSpaceX; |
0 | 5944 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
5945 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
5946 - 12.0) | |
5947 * v11 | |
5948 + (double)a2->uScreenSpaceY; | |
1390 | 5949 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5950 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5951 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
5952 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5953 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5954 pBillboardRenderListD3D[v8].pTexture = a3; |
743 | 5955 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 5956 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5957 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; |
5958 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5959 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5960 } |
5961 } | |
5962 } | |
5963 | |
5964 //----- (004A3AD9) -------------------------------------------------------- | |
5965 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5966 { | |
5967 double v5; // st7@2 | |
5968 float v6; // ST28_4@2 | |
5969 float v7; // ST00_4@2 | |
5970 unsigned int v8; // esi@2 | |
5971 int v9; // eax@2 | |
5972 int v10; // ebx@2 | |
5973 float v11; // ST34_4@2 | |
5974 double v12; // st7@2 | |
5975 float v13; // ST2C_4@2 | |
5976 double v14; // st6@2 | |
5977 float v15; // ST24_4@2 | |
5978 float v16; // ST38_4@2 | |
5979 float v17; // ST3C_4@2 | |
5980 signed int v18; // ST1C_4@2 | |
5981 int v19; // ST30_4@2 | |
5982 signed int v20; // ST20_4@2 | |
5983 signed int v21; // ST18_4@2 | |
5984 signed int v22; // eax@2 | |
5985 double v23; // st6@2 | |
5986 float v24; // ST20_4@2 | |
5987 float v25; // ST1C_4@2 | |
5988 float v26; // ST38_4@2 | |
5989 float v27; // ST3C_4@2 | |
5990 signed int v28; // ST18_4@2 | |
5991 signed int v29; // ST14_4@2 | |
5992 signed int v30; // ST10_4@2 | |
5993 signed int v31; // eax@2 | |
5994 double v32; // st6@2 | |
5995 float v33; // ST38_4@2 | |
5996 float v34; // ST3C_4@2 | |
5997 signed int v35; // ST10_4@2 | |
5998 signed int v36; // ST14_4@2 | |
5999 signed int v37; // ST18_4@2 | |
6000 signed int v38; // eax@2 | |
6001 double v39; // st6@2 | |
6002 float v40; // ST38_4@2 | |
6003 float v41; // ST3C_4@2 | |
6004 signed int v42; // ST10_4@2 | |
6005 signed int v43; // ST14_4@2 | |
6006 signed int v44; // ST18_4@2 | |
6007 signed int v45; // eax@2 | |
6008 double v46; // st6@2 | |
6009 | |
6010 if ( this->uNumD3DSceneBegins ) | |
6011 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6012 v5 = (double)a2->zbuffer_depth; |
0 | 6013 v6 = v5; |
6014 v7 = v5; | |
6015 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
6016 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
6017 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
6018 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
6019 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
6020 v9 = a2->uScreenSpaceX; | |
6021 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6022 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 6023 v12 = (double)v9; |
6024 v13 = v12; | |
6025 v14 = (double)(v10 - 12); | |
6026 v15 = v14; | |
6027 v16 = (double)(v9 - 12) - v12; | |
6028 v17 = (double)(v10 - 25) - v14; | |
323 | 6029 v18 = stru_5C6E00->Cos(angle); |
0 | 6030 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 6031 v20 = stru_5C6E00->Sin(angle); |
6032 v21 = stru_5C6E00->Sin(angle); | |
6033 v22 = stru_5C6E00->Cos(angle); | |
1390 | 6034 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 6035 + (double)(v18 >> 16)) |
6036 * v16 | |
6037 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
6038 + (double)(v20 >> 16)) | |
6039 * v17) | |
6040 * v11 + v13; | |
6041 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
6042 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
6043 - 12.0) | |
6044 * v11 | |
6045 + (double)a2->uScreenSpaceY; | |
1390 | 6046 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
6047 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
6048 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
0 | 6049 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); |
1390 | 6050 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; |
0 | 6051 v25 = 1.0 / v6; |
1390 | 6052 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; |
6053 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
6054 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
0 | 6055 v26 = (double)(a2->uScreenSpaceX - 12) - v13; |
6056 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 6057 v28 = stru_5C6E00->Cos(angle); |
6058 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6059 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6060 v31 = stru_5C6E00->Cos(angle); | |
1390 | 6061 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
0 | 6062 + (double)(v28 >> 16)) |
6063 * v26 | |
6064 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
6065 + (double)(v29 >> 16)) | |
6066 * v27) | |
6067 * v11 + v13; | |
6068 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
6069 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
6070 - 12.0) | |
6071 * v11 | |
6072 + (double)a2->uScreenSpaceY; | |
1390 | 6073 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; |
6074 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
6075 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
6076 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
6077 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
6078 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
6079 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
0 | 6080 v33 = (double)(a2->uScreenSpaceX + 12) - v13; |
6081 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 6082 v35 = stru_5C6E00->Cos(angle); |
6083 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6084 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6085 v38 = stru_5C6E00->Cos(angle); | |
1390 | 6086 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
0 | 6087 + (double)(v35 >> 16)) |
6088 * v33 | |
6089 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
6090 + (double)(v36 >> 16)) | |
6091 * v34) | |
6092 * v11 + v13; | |
6093 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
6094 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
6095 - 12.0) | |
6096 * v11 | |
6097 + (double)a2->uScreenSpaceY; | |
1390 | 6098 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
6099 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
6100 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
6101 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
6102 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
6103 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
6104 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
0 | 6105 v40 = (double)(a2->uScreenSpaceX + 12) - v13; |
6106 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 6107 v42 = stru_5C6E00->Cos(angle); |
6108 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6109 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6110 v45 = stru_5C6E00->Cos(angle); | |
1390 | 6111 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
0 | 6112 + (double)(v42 >> 16)) |
6113 * v40 | |
6114 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
6115 + (double)(v43 >> 16)) | |
6116 * v41) | |
6117 * v11 + v13; | |
6118 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
6119 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
6120 - 12.0) | |
6121 * v11 | |
6122 + (double)a2->uScreenSpaceY; | |
1390 | 6123 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; |
6124 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
6125 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
6126 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 6127 pBillboardRenderListD3D[v8].pTexture = a3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6128 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 6129 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 6130 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; |
6131 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
6132 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 6133 } |
6134 } | |
6135 | |
6136 //----- (004A4023) -------------------------------------------------------- | |
657 | 6137 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
|
6138 { |
0 | 6139 unsigned int v8; // esi@2 |
6140 double v14; // st6@14 | |
6141 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6142 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6143 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6144 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6145 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6146 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6147 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6148 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6149 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6150 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6151 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 6152 float v29; // [sp+28h] [bp-8h]@5 |
6153 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6154 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6155 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6156 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6157 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6158 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6159 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6160 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6161 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
|
6162 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
|
6163 |
657 | 6164 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6165 if (a2->uTintColor & 0x00FFFFFF && bTinting) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6166 { |
737 | 6167 diffuse = BlendColors(a2->uTintColor, diffuse); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6168 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6169 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6170 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6171 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6172 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6173 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6174 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
|
6175 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6176 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6177 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6178 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6179 v14 *= -1.0; |
1390 | 6180 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; |
6181 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
6182 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
6183 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
6184 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
6185 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
6186 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
6187 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6188 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6189 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6190 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6191 if ( a2->uFlags & 4 ) |
0 | 6192 v14 = v14 * -1.0; |
1390 | 6193 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; |
6194 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
6195 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
6196 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
6197 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
6198 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; | |
6199 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
6200 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6201 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6202 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
|
6203 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6204 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6205 v14 *= -1.0; |
1390 | 6206 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; |
6207 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
6208 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
6209 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
6210 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
6211 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; | |
6212 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
6213 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6214 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6215 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
|
6216 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6217 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6218 v14 *= -1.0; |
1390 | 6219 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; |
6220 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
6221 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
6222 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
6223 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
6224 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; | |
6225 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
6226 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6227 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6228 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6229 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6230 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6231 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6232 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6233 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6234 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6235 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6236 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6237 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6238 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 6239 } |
6240 | |
6241 //----- (004A48E4) -------------------------------------------------------- | |
6242 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
6243 { | |
6244 int v6; // ecx@1 | |
6245 int v7; // ebx@1 | |
6246 int v8; // ecx@1 | |
6247 int v9; // edx@1 | |
6248 int v10; // edi@1 | |
6249 unsigned int x; // esi@1 | |
6250 int result; // eax@8 | |
6251 int v13; // [sp+Ch] [bp-10h]@1 | |
6252 int v14; // [sp+10h] [bp-Ch]@1 | |
6253 int v15; // [sp+14h] [bp-8h]@1 | |
6254 int v16; // [sp+18h] [bp-4h]@1 | |
6255 int v17; // [sp+24h] [bp+8h]@1 | |
6256 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
6257 int v19; // [sp+34h] [bp+18h]@1 | |
6258 | |
6259 v6 = screenSpaceX; | |
6260 v7 = (a6 >> 1) + screenSpaceY; | |
6261 v17 = 0; | |
6262 v15 = 0; | |
6263 v8 = (a6 >> 1) + v6; | |
6264 v14 = (a6 >> 1) * (a6 >> 1); | |
6265 v9 = 2 * (a6 >> 1); | |
6266 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
6267 x = v8 - (a6 >> 1); | |
6268 v16 = (a6 >> 1) + screenSpaceY - v8; | |
6269 v19 = a6 >> 1; | |
6270 v13 = v9; | |
6271 v18 = v8; | |
6272 do | |
6273 { | |
6274 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
6275 if ( v15 ) | |
6276 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
6277 v14 -= v15; | |
6278 if ( v14 <= v10 ) | |
6279 { | |
6280 if ( v19 != v17 ) | |
6281 { | |
6282 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
6283 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
6284 } | |
6285 --v19; | |
6286 v13 -= 2; | |
6287 ++x; | |
6288 v10 -= v13; | |
6289 } | |
6290 result = v17++; | |
6291 v15 += 2; | |
6292 --v18; | |
6293 } | |
6294 while ( result < v19 ); | |
6295 return result; | |
6296 } | |
6297 | |
6298 //----- (004A49D0) -------------------------------------------------------- | |
6299 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
6300 { | |
1159 | 6301 int absXDifference; // eax@1 |
6302 int absYDifference; // eax@1 | |
6303 unsigned int smallerabsdiff; // ebx@1 | |
6304 unsigned int largerabsdiff; | |
0 | 6305 double v16; // st7@7 |
6306 double v17; // st7@7 | |
6307 double v18; // st6@7 | |
6308 double v20; // st4@8 | |
6309 double v21; // st4@10 | |
6310 double v22; // st4@10 | |
6311 double v23; // st4@10 | |
6312 double v25; // st4@11 | |
6313 double v26; // st4@13 | |
6314 double v28; // st4@13 | |
6315 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
1159 | 6316 int xDifference; // [sp+88h] [bp-Ch]@1 |
0 | 6317 signed int v32; // [sp+8Ch] [bp-8h]@1 |
1159 | 6318 int yDifference; // [sp+90h] [bp-4h]@1 |
6319 | |
6320 xDifference = bankersRounding(dstX - srcX); | |
6321 yDifference = bankersRounding(dstY - srcY); | |
6322 absYDifference = abs(yDifference); | |
6323 absXDifference = abs(xDifference); | |
6324 smallerabsdiff = min(absXDifference, absYDifference); | |
6325 largerabsdiff = max(absXDifference, absYDifference); | |
6326 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
0 | 6327 v16 = 1.0 / (double)v32; |
1159 | 6328 v17 = (double)yDifference * v16 * a4; |
6329 v18 = (double)xDifference * v16 * a4; | |
6330 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
6331 { | |
6332 v20 = a3 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
6333 v25 = a7 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
6334 } | |
6335 else | |
6336 { | |
6337 v20 = a3 * 0.061758894; | |
6338 v25 = a7 * 0.061758894; | |
6339 } | |
6340 v21 = 1.0 / a3; | |
6341 v22 = (double)yDifference * v16 * a8; | |
6342 v23 = (double)xDifference * v16 * a8; | |
6343 v26 = 1.0 - 1.0 / v25; | |
6344 v28 = 1.0 / a7; | |
0 | 6345 v29[0].pos.x = srcX + v17; |
6346 v29[0].pos.y = srcY - v18; | |
1159 | 6347 v29[0].pos.z = 1.0 - 1.0 / v20; |
6348 v29[0].rhw = v21; | |
0 | 6349 v29[0].diffuse = -1; |
6350 v29[0].specular = 0; | |
6351 v29[0].texcoord.x = 1.0; | |
6352 v29[0].texcoord.y = 0.0; | |
1159 | 6353 |
0 | 6354 v29[1].pos.x = v22 + dstX; |
6355 v29[1].pos.y = dstY - v23; | |
1159 | 6356 v29[1].pos.z = v26; |
6357 v29[1].rhw = v28; | |
0 | 6358 v29[1].diffuse = -16711936; |
6359 v29[1].specular = 0; | |
6360 v29[1].texcoord.x = 1.0; | |
6361 v29[1].texcoord.y = 1.0; | |
1159 | 6362 |
6363 v29[2].pos.x = dstX - v22; | |
6364 v29[2].pos.y = v23 + dstY; | |
6365 v29[2].pos.z = v26; | |
0 | 6366 v29[2].rhw = v28; |
1159 | 6367 v29[2].diffuse = -1; |
6368 v29[2].specular = 0; | |
0 | 6369 v29[2].texcoord.x = 0.0; |
6370 v29[2].texcoord.y = 1.0; | |
1159 | 6371 |
0 | 6372 v29[3].pos.x = srcX - v17; |
6373 v29[3].pos.y = v18 + srcY; | |
1159 | 6374 v29[3].pos.z = v29[0].pos.z; |
6375 v29[3].rhw = v21; | |
6376 v29[3].diffuse = -1; | |
6377 v29[3].specular = 0; | |
0 | 6378 v29[3].texcoord.x = 0.0; |
6379 v29[3].texcoord.y = 0.0; | |
186 | 6380 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
6381 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6382 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
6383 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6384 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6385 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 6386 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
6387 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
6388 D3DPT_TRIANGLEFAN, | |
6389 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6390 v29, | |
6391 4, | |
6392 24)); | |
186 | 6393 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
6394 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6395 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6396 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6397 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6398 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 6399 } |
6400 | |
6401 //----- (004A4CC9) -------------------------------------------------------- | |
1390 | 6402 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) |
6403 { | |
0 | 6404 unsigned int v5; // eax@7 |
6405 char *v7; // edx@8 | |
6406 double v10; // st6@9 | |
6407 double v11; // st6@10 | |
6408 int v12; // ebx@13 | |
1390 | 6409 |
6410 if (a1->uNumVertices < 3) | |
6411 return; | |
6412 | |
6413 float depth = 1000000.0; | |
6414 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6415 { | |
6416 if (a1->field_104[i].z < depth) | |
6417 depth = a1->field_104[i * 4].z; | |
6418 } | |
6419 | |
6420 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
6421 pBillboardRenderListD3D[v5].field_90 = 0; | |
6422 pBillboardRenderListD3D[v5].uParentBillboardID = -1; | |
6423 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | |
6424 pBillboardRenderListD3D[v5].pTexture = 0; | |
6425 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
6426 pBillboardRenderListD3D[v5].z_order = depth; | |
6427 | |
6428 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6429 { | |
6430 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
6431 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
6432 | |
6433 v10 = a1->field_104[i].z; | |
6434 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
6435 v11 = v10 * 0.061758894; | |
6436 else | |
6437 v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
6438 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; | |
6439 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
6440 | |
6441 if (diffuse & 0xFF000000) | |
6442 v12 = a1->field_104[i].diffuse; | |
6443 else | |
6444 v12 = diffuse; | |
6445 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
6446 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
6447 | |
6448 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
6449 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
0 | 6450 } |
6451 } | |
6452 | |
6453 //----- (004A4DE1) -------------------------------------------------------- | |
6454 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
6455 { | |
6456 HRESULT v12; // eax@14 | |
6457 unsigned __int16 *v13; // ecx@19 | |
6458 unsigned __int16 *v14; // eax@19 | |
6459 DWORD v15; // edx@20 | |
6460 HRESULT v16; // eax@23 | |
6461 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
6462 | |
6463 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
6464 if ( pHWLTexture ) | |
6465 { | |
6466 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
6467 if ( !pRenderD3D->CreateTexture( | |
6468 pHWLTexture->uWidth, | |
6469 pHWLTexture->uHeight, | |
6470 pOutSurface, | |
6471 pOutTexture, | |
6472 true, | |
6473 bMipMaps, | |
6474 uMinDeviceTextureDim) ) | |
6475 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
6476 //v10 = *pOutSurface; | |
6477 //v11 = 0; | |
6478 if ( bMipMaps ) | |
6479 { | |
6480 Dst._450DDE(); | |
6481 //v20 = 0; | |
6482 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
6483 | |
6484 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
6485 while ( 1 ) | |
6486 { | |
6487 DDSCAPS2 v19; | |
6488 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6489 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6490 | |
6491 DDSURFACEDESC2 desc; | |
6492 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6493 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6494 | |
168 | 6495 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6496 { |
6497 Dst.sub_451007_scale_image_bicubic( | |
6498 pHWLTexture->pPixels, | |
6499 pHWLTexture->uWidth, | |
6500 pHWLTexture->uHeight, | |
6501 pHWLTexture->uWidth, | |
6502 (unsigned short *)desc.lpSurface, | |
6503 desc.dwWidth, | |
6504 desc.dwHeight, | |
6505 desc.lPitch >> 1, | |
6506 0, | |
6507 0); | |
6508 ErrD3D(pNextSurf->Unlock(0)); | |
6509 //bMipMaps = 0x4D86ACu; | |
6510 } | |
6511 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
6512 break; | |
6513 //v10 = (IDirectDrawSurface4 *)pName; | |
6514 //v11 = 0; | |
6515 } | |
6516 //v20 = -1; | |
6517 //nullsub_1(); | |
6518 } | |
6519 else | |
6520 { | |
6521 DDSCAPS2 v19; | |
6522 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6523 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6524 | |
6525 DDSURFACEDESC2 desc; | |
6526 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6527 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6528 | |
168 | 6529 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6530 { |
6531 bMipMaps = 0; | |
6532 v13 = pHWLTexture->pPixels; | |
6533 v14 = (unsigned __int16 *)desc.lpSurface; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6534 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
|
6535 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6536 for (v15 = 0; v15 < desc.dwWidth; v15++) |
0 | 6537 { |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6538 *v14 = *v13; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6539 ++v14; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6540 ++v13; |
0 | 6541 } |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6542 v14 += (desc.lPitch >> 1) - desc.dwWidth; |
0 | 6543 } |
6544 ErrD3D((*pOutSurface)->Unlock(0)); | |
6545 } | |
6546 } | |
6547 delete [] pHWLTexture->pPixels; | |
6548 delete pHWLTexture; | |
6549 return true; | |
6550 } | |
6551 return false; | |
6552 } | |
6553 | |
6554 //----- (004A5048) -------------------------------------------------------- | |
670 | 6555 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
6556 { | |
6557 | |
6558 HWLTexture *sprite_texture; // eax@1 | |
0 | 6559 unsigned __int16 *v9; // edx@5 |
6560 LPVOID v10; // eax@5 | |
6561 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6562 | |
670 | 6563 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
6564 if ( sprite_texture ) | |
6565 { | |
6566 _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; | |
6567 pSprite->uAreaX = sprite_texture->uAreaX; | |
6568 pSprite->uAreaY = sprite_texture->uAreaY; | |
6569 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
6570 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
6571 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
6572 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6573 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6574 //v7 = v3->pRenderD3D; |
670 | 6575 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
0 | 6576 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
6577 //pSprite = v2->pTextureSurface; | |
6578 //pSprite = (Sprite *)pSprite->pName; | |
6579 //v8 = pSprite; | |
670 | 6580 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 6581 Dst.dwSize = 124; |
670 | 6582 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
6583 { | |
6584 v9 = sprite_texture->pPixels; | |
6585 v10 = Dst.lpSurface; | |
6586 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 6587 { |
670 | 6588 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
6589 { | |
0 | 6590 *(int *)v10 = *(int *)v9; |
6591 v9 += 2; | |
6592 v10 = (char *)v10 + 4; | |
670 | 6593 } |
6594 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 6595 } |
670 | 6596 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
6597 } | |
6598 free(sprite_texture->pPixels); | |
6599 free(sprite_texture); | |
6600 return true; | |
6601 } | |
6602 return false; | |
0 | 6603 } |
6604 | |
6605 //----- (004A51CB) -------------------------------------------------------- | |
6606 void Render::BeginScene() | |
6607 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6608 //Render *v1; // esi@1 |
0 | 6609 unsigned int v2; // eax@1 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6610 /*int v3; // eax@5 |
0 | 6611 unsigned __int16 **v4; // edi@6 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6612 char *v5; // ebx@7*/ |
0 | 6613 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 |
6614 | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6615 //v1 = this; |
0 | 6616 v2 = this->uNumSceneBegins; |
6617 this->uNumSceneBegins = v2 + 1; | |
6618 if ( !v2 ) | |
6619 { | |
6620 if ( this->pRenderD3D ) | |
6621 { | |
6622 if ( this->bColorKeySupported ) | |
6623 { | |
6624 memset(&Dst, 0, 0x7Cu); | |
6625 Dst.dwSize = 124; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6626 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
|
6627 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6628 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6629 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6630 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
|
6631 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6632 --this->uNumSceneBegins; |
0 | 6633 } |
6634 } | |
6635 else | |
6636 { | |
6637 if ( !this->pTargetSurface ) | |
6638 { | |
6639 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
|
6640 if ( this->pTargetSurface ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6641 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6642 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
|
6643 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6644 --this->uNumSceneBegins; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6645 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6646 } |
0 | 6647 RestoreFrontBuffer(); |
6648 } | |
6649 } | |
6650 | |
6651 //----- (004A527D) -------------------------------------------------------- | |
6652 void Render::EndScene() | |
6653 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6654 if ( this->uNumSceneBegins ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6655 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6656 this->uNumSceneBegins--; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6657 if ( !this->uNumSceneBegins ) |
0 | 6658 { |
6659 if ( this->pRenderD3D ) | |
6660 { | |
6661 if ( this->bColorKeySupported ) | |
6662 { | |
6663 this->pTargetSurface = 0; | |
6664 this->uTargetSurfacePitch = 0; | |
6665 this->field_18_locked_pitch = 0; | |
6666 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
6667 } | |
6668 } | |
6669 else | |
6670 { | |
6671 this->pTargetSurface = 0; | |
6672 this->uTargetSurfacePitch = 0; | |
6673 this->field_18_locked_pitch = 0; | |
6674 UnlockBackBuffer(); | |
6675 } | |
6676 } | |
6677 } | |
6678 } | |
6679 | |
6680 //----- ( ) -------------------------------------------------------- | |
6681 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
6682 { | |
6683 unsigned int v3; // esi@1 | |
6684 double v4; // st7@2 | |
6685 double v5; // st7@6 | |
6686 double v6; // st6@6 | |
6687 unsigned int v7; // eax@6 | |
6688 double v8; // st5@6 | |
6689 double v9; // st4@6 | |
6690 HRESULT v10; // eax@6 | |
6691 HRESULT v11; // eax@6 | |
6692 unsigned int result; // eax@6 | |
6693 unsigned int v13; // eax@7 | |
6694 unsigned __int16 *v14; // ecx@7 | |
6695 int *v15; // eax@7 | |
6696 unsigned int v16; // ecx@8 | |
6697 __int16 v17; // ax@10 | |
6698 int v18; // esi@10 | |
6699 float v19; // edi@10 | |
6700 void *v20; // esi@10 | |
6701 int v21; // edx@10 | |
6702 int v22; // ecx@11 | |
6703 int v23; // edx@12 | |
6704 __int16 v24; // ax@15 | |
6705 int v25; // esi@15 | |
6706 float v26; // edi@15 | |
6707 char *v27; // esi@15 | |
6708 int v28; // edx@15 | |
6709 int v29; // ecx@16 | |
6710 int v30; // edx@17 | |
6711 int v31; // [sp-Ch] [bp-ACh]@11 | |
6712 int v32; // [sp-Ch] [bp-ACh]@16 | |
6713 const char *v33; // [sp+0h] [bp-A0h]@0 | |
6714 int v34; // [sp+4h] [bp-9Ch]@0 | |
6715 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
6716 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
6717 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
6718 int v38; // [sp+90h] [bp-10h]@7 | |
6719 double v39; // [sp+94h] [bp-Ch]@6 | |
6720 float v40; // [sp+9Ch] [bp-4h]@6 | |
6721 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6722 __debugbreak(); |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6723 |
0 | 6724 auto ecx0 = this; |
6725 v3 = 0; | |
6726 if ( ecx0->pRenderD3D ) | |
6727 { | |
6728 v4 = a3; | |
6729 if ( a3 <= 1.0 ) | |
6730 { | |
6731 if ( v4 < 0.0 ) | |
6732 v4 = 0.0; | |
6733 } | |
6734 else | |
6735 { | |
6736 v4 = 1.0; | |
6737 } | |
6738 a3 = v4 * 255.0; | |
6739 v39 = a3 + 6.7553994e15; | |
6740 LODWORD(v40) = LODWORD(v39); | |
693 | 6741 v5 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 6742 v36[0].pos.x = v5; |
693 | 6743 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 6744 v7 = this_ | (LODWORD(v39) << 24); |
693 | 6745 this_ = pViewport->uViewportBR_Y + 1; |
0 | 6746 v36[0].specular = 0; |
6747 v36[0].pos.y = v6; | |
6748 v36[0].diffuse = v7; | |
6749 v36[1].diffuse = v7; | |
6750 v36[0].pos.z = 0.0; | |
6751 v36[2].diffuse = v7; | |
6752 v36[3].diffuse = v7; | |
6753 v36[0].rhw = 1.0; | |
6754 v36[1].specular = 0; | |
6755 v36[0].texcoord.x = 0.0; | |
6756 v36[2].specular = 0; | |
6757 v36[3].specular = 0; | |
6758 v36[0].texcoord.y = 0.0; | |
6759 v36[1].pos.x = v5; | |
693 | 6760 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 6761 v36[1].pos.y = v8; |
6762 v36[1].pos.z = 0.0; | |
6763 v36[1].rhw = 1.0; | |
6764 v36[1].texcoord.x = 0.0; | |
6765 v36[1].texcoord.y = 0.0; | |
693 | 6766 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 6767 v36[2].pos.x = v9; |
6768 v36[2].pos.y = v8; | |
6769 v36[2].pos.z = 0.0; | |
6770 v36[2].rhw = 1.0; | |
6771 v36[2].texcoord.x = 0.0; | |
6772 v36[2].texcoord.y = 0.0; | |
6773 v36[3].pos.x = v9; | |
6774 v36[3].pos.y = v6; | |
6775 v36[3].pos.z = 0.0; | |
6776 v36[3].rhw = 1.0; | |
6777 v36[3].texcoord.x = 0.0; | |
6778 v36[3].texcoord.y = 0.0; | |
6779 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 6780 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
6781 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6782 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6783 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
6784 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
6785 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6786 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 6787 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
6788 D3DPT_TRIANGLEFAN, | |
6789 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6790 v36, | |
6791 4, | |
6792 28)); | |
186 | 6793 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
6794 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6795 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
6796 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6797 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6798 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
0 | 6799 } |
6800 else | |
6801 { | |
6802 v40 = (1.0 - a3) * 65536.0; | |
6803 v39 = v40 + 6.7553994e15; | |
6804 LODWORD(a3) = LODWORD(v39); | |
693 | 6805 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
6806 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
6807 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
6808 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 6809 v37 = 2 * v13; |
6810 LODWORD(v40) = (int)v14; | |
6811 | |
6812 int __i = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
6813 v15 = dword_F1B430.data(); |
0 | 6814 do |
6815 { | |
6816 v16 = v3; | |
6817 v3 += LODWORD(a3); | |
6818 dword_F1B430[__i++] = v16 >> 16; | |
6819 } | |
6820 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
6821 while (__i < 32); | |
6822 | |
6823 if ( pRenderer->uTargetGBits == 6 ) | |
6824 { | |
6825 v17 = _42690D_colors_cvt(this_); | |
6826 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); | |
6827 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); | |
6828 v19 = v40; | |
6829 v20 = off_4EFDB0; | |
6830 v21 = HIDWORD(v39); | |
6831 do | |
6832 { | |
6833 v22 = v38; | |
6834 v31 = v21; | |
6835 do | |
6836 { | |
6837 v23 = (*(int *)((char *)v20 | |
6838 + ((((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; | |
6839 result = this_ | |
6840 + (*((int *)v20 | |
6841 + (((unsigned __int8)(*((char *)v20 | |
6842 + ((((unsigned __int16)(*(short *)((char *)v20 | |
6843 + ((*(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); | |
6844 *(unsigned int *)LODWORD(v19) = result; | |
6845 LODWORD(v19) += 4; | |
6846 --v22; | |
6847 } | |
6848 while ( v22 ); | |
6849 LODWORD(v19) += v37; | |
6850 v21 = v31 - 1; | |
6851 } | |
6852 while ( v31 != 1 ); | |
6853 } | |
6854 else | |
6855 { | |
6856 v24 = _4268E3_smthn_to_a1r5g5b5(this_); | |
6857 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); | |
6858 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
6859 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
6860 v26 = v40; | |
6861 v27 = (char *)off_4EFDB0; | |
6862 v28 = HIDWORD(v39); | |
6863 do | |
6864 { | |
6865 v29 = v38; | |
6866 v32 = v28; | |
6867 do | |
6868 { | |
6869 v30 = 32 | |
6870 * *(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; | |
6871 result = this_ | |
6872 + (*(int *)&v27[4 | |
6873 * (((unsigned __int8)(32 | |
6874 * 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); | |
6875 *(unsigned int *)LODWORD(v26) = result; | |
6876 LODWORD(v26) += 4; | |
6877 --v29; | |
6878 } | |
6879 while ( v29 ); | |
6880 LODWORD(v26) += v37; | |
6881 v28 = v32 - 1; | |
6882 } | |
6883 while ( v32 != 1 ); | |
6884 } | |
6885 } | |
6886 return result; | |
6887 } | |
6888 | |
6889 //----- (004A5B81) -------------------------------------------------------- | |
727 | 6890 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 6891 { |
6892 this->bClip = 1; | |
6893 this->uClipY = uY; | |
6894 this->uClipX = uX; | |
6895 this->uClipW = uW; | |
6896 this->uClipZ = uZ; | |
6897 } | |
6898 | |
6899 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 6900 void Render::ResetTextureClipRect() |
0 | 6901 { |
6902 this->uClipY = 0; | |
6903 this->uClipX = 0; | |
6904 this->bClip = 1; | |
6905 this->uClipW = 480; | |
6906 this->uClipZ = 640; | |
6907 } | |
6908 | |
6909 //----- (004A5BE3) -------------------------------------------------------- | |
6910 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
6911 { | |
6912 int v4; // edi@3 | |
6913 unsigned __int16 *v5; // edx@3 | |
6914 unsigned __int16 *v6; // esi@3 | |
6915 unsigned int v8; // eax@5 | |
6916 unsigned int v9; // ebx@5 | |
6917 unsigned int v11; // eax@7 | |
6918 unsigned int v12; // ebx@8 | |
6919 unsigned int v15; // eax@14 | |
6920 int v19; // [sp+10h] [bp-8h]@3 | |
6921 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
6922 int v23; // [sp+28h] [bp+10h]@3 | |
6923 | |
6924 if ( this->uNumSceneBegins && a4 ) | |
6925 { | |
6926 v4 = a4->uWidth; | |
6927 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
6928 v6 = a4->pPixels; | |
6929 v23 = a4->uHeight; | |
6930 v19 = v4; | |
6931 if ( this->bClip ) | |
6932 { | |
1152 | 6933 if ( (signed int)uOutX < (signed int)this->uClipX ) |
6934 { | |
6935 v8 = this->uClipX - uOutX; | |
6936 v9 = uOutX - this->uClipX; | |
0 | 6937 v8 *= 2; |
6938 v4 += v9; | |
6939 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
6940 v5 = (unsigned __int16 *)((char *)v5 + v8); | |
6941 } | |
1152 | 6942 if ( (signed int)uOutY < (signed int)this->uClipY ) |
6943 { | |
6944 v11 = this->uClipY - uOutY; | |
0 | 6945 v6 += v19 * v11; |
6946 v23 += uOutY - this->uClipY; | |
6947 v5 += this->uTargetSurfacePitch * v11; | |
6948 } | |
1152 | 6949 v12 = max(this->uClipX, uOutX); |
6950 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | |
6951 { | |
6952 v4 = this->uClipZ - max(this->uClipX, uOutX); | |
6953 } | |
6954 v15 = max(this->uClipY, uOutY); | |
6955 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) | |
6956 { | |
6957 v23 = this->uClipW - max(this->uClipY, uOutY); | |
6958 } | |
6959 } | |
6960 | |
6961 for (int outerCounter = 0; outerCounter < v23; outerCounter++) | |
6962 { | |
6963 for (int counter = 0; counter < v4; counter++) | |
6964 { | |
6965 *v5 = *v6; | |
6966 ++v5; | |
6967 ++v6; | |
6968 } | |
6969 v6 += v19 - v4; | |
6970 v5 += this->uTargetSurfacePitch - v4; | |
0 | 6971 } |
6972 } | |
6973 } | |
6974 | |
6975 //----- (004A5D33) -------------------------------------------------------- | |
6976 void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture) | |
6977 { | |
6978 Render *v6; // esi@1 | |
6979 unsigned __int16 *v7; // ebx@3 | |
6980 int v8; // ecx@3 | |
6981 int v9; // edx@3 | |
6982 int v10; // ecx@3 | |
6983 int v11; // edi@3 | |
6984 signed int v12; // eax@4 | |
6985 unsigned int v13; // eax@5 | |
6986 signed int v14; // eax@6 | |
6987 unsigned int v15; // eax@7 | |
6988 unsigned int v16; // edx@8 | |
6989 int v17; // eax@10 | |
6990 unsigned int v18; // ecx@11 | |
6991 unsigned int v19; // ecx@14 | |
6992 int v20; // eax@16 | |
6993 unsigned int v21; // ecx@17 | |
6994 int v22; // eax@21 | |
6995 int v23; // edi@23 | |
6996 int v24; // [sp+Ch] [bp-4h]@3 | |
6997 int a2a; // [sp+18h] [bp+8h]@21 | |
6998 unsigned int teal; // [sp+1Ch] [bp+Ch]@20 | |
6999 int a4a; // [sp+20h] [bp+10h]@3 | |
7000 int a4b; // [sp+20h] [bp+10h]@21 | |
7001 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
7002 | |
7003 v6 = this; | |
7004 if ( this->uNumSceneBegins && pTexture ) | |
7005 { | |
7006 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | |
7007 v8 = pTexture->uWidth; | |
7008 v24 = pTexture->uWidth; | |
7009 v9 = a4 + a5 * v8; | |
7010 v10 = v8 - a4; | |
7011 a4a = v10; | |
7012 v11 = pTexture->uHeight - a5; | |
7013 pTexturea = &pTexture->pPixels[v9]; | |
7014 if ( v6->bClip ) | |
7015 { | |
7016 v12 = v6->uClipX; | |
7017 if ( (signed int)pX < v12 ) | |
7018 { | |
7019 v13 = 2 * (v12 - pX); | |
7020 pTexturea = (unsigned __int16 *)((char *)pTexturea + v13); | |
7021 v10 += pX - v6->uClipX; | |
7022 v7 = (unsigned __int16 *)((char *)v7 + v13); | |
7023 a4a = v10; | |
7024 } | |
7025 v14 = v6->uClipY; | |
7026 if ( (signed int)pY < v14 ) | |
7027 { | |
7028 v15 = v14 - pY; | |
7029 pTexturea += v24 * v15; | |
7030 v11 += pY - v6->uClipY; | |
7031 v10 = a4a; | |
7032 v7 += v6->uTargetSurfacePitch * v15; | |
7033 } | |
7034 v16 = v6->uClipX; | |
7035 if ( (signed int)v16 < (signed int)pX ) | |
7036 v16 = pX; | |
7037 v17 = v6->uClipZ; | |
7038 if ( (signed int)(v10 + v16) > v17 ) | |
7039 { | |
7040 v18 = v6->uClipX; | |
7041 if ( (signed int)v18 < (signed int)pX ) | |
7042 v18 = pX; | |
7043 a4a = v17 - v18; | |
7044 } | |
7045 v19 = v6->uClipY; | |
7046 if ( (signed int)v19 < (signed int)pY ) | |
7047 v19 = pY; | |
7048 v20 = v6->uClipW; | |
7049 if ( (signed int)(v11 + v19) > v20 ) | |
7050 { | |
7051 v21 = v6->uClipY; | |
7052 if ( (signed int)v21 < (signed int)pY ) | |
7053 v21 = pY; | |
7054 v11 = v20 - v21; | |
7055 } | |
7056 } | |
949 | 7057 teal = TargetColor(0, 0xFFu, 0xFFu); |
0 | 7058 if ( v11 > 0 ) |
7059 { | |
7060 v22 = a4a; | |
7061 a2a = v11; | |
7062 a4b = 2 * (v24 - a4a); | |
7063 do | |
7064 { | |
7065 if ( v22 > 0 ) | |
7066 { | |
7067 v23 = v22; | |
7068 do | |
7069 { | |
7070 if ( *pTexturea != teal ) | |
7071 *v7 = *pTexturea; | |
7072 ++pTexturea; | |
7073 ++v7; | |
7074 --v23; | |
7075 } | |
7076 while ( v23 ); | |
7077 } | |
7078 v7 += v6->uTargetSurfacePitch - v22; | |
7079 pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b); | |
7080 --a2a; | |
7081 } | |
7082 while ( a2a ); | |
7083 } | |
7084 } | |
7085 } | |
7086 | |
7087 //----- (004A6E7E) -------------------------------------------------------- | |
7088 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
7089 { | |
7090 unsigned __int16 *v4; // eax@4 | |
7091 int v5; // edx@4 | |
7092 unsigned int v6; // edi@4 | |
7093 unsigned int v7; // edx@5 | |
7094 unsigned int v8; // edx@6 | |
7095 unsigned int v9; // edx@7 | |
7096 unsigned int v10; // edx@8 | |
7097 unsigned int v11; // ebx@9 | |
7098 unsigned int v12; // esi@11 | |
7099 unsigned int v13; // edx@12 | |
7100 unsigned int v14; // ebx@15 | |
7101 unsigned int v15; // esi@17 | |
7102 unsigned int v16; // edi@18 | |
7103 char v17; // zf@29 | |
7104 int v18; // [sp+14h] [bp-Ch]@4 | |
7105 int v19; // [sp+18h] [bp-8h]@4 | |
7106 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
7107 int v21; // [sp+28h] [bp+8h]@25 | |
7108 int v22; // [sp+28h] [bp+8h]@34 | |
7109 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
7110 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
7111 | |
7112 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
7113 { | |
7114 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7115 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7116 v5 = a4->uTextureWidth; |
7117 v6 = a4->uTextureHeight; | |
7118 v19 = a4->uTextureWidth; | |
7119 v18 = a4->uTextureWidth; | |
7120 if ( this->bClip ) | |
7121 { | |
7122 v7 = this->uClipX; | |
7123 if ( (signed int)a2 < (signed int)v7 ) | |
7124 { | |
7125 v8 = v7 - a2; | |
7126 v20 += v8; | |
7127 v19 += a2 - this->uClipX; | |
7128 v4 += v8; | |
7129 } | |
7130 v9 = this->uClipY; | |
7131 if ( (signed int)a3 < (signed int)v9 ) | |
7132 { | |
7133 v10 = v9 - a3; | |
7134 v20 += v18 * v10; | |
7135 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
7136 v4 += this->uTargetSurfacePitch * v10; | |
7137 } | |
7138 v11 = this->uClipX; | |
7139 v5 = v19; | |
7140 if ( (signed int)v11 < (signed int)a2 ) | |
7141 v11 = a2; | |
7142 v12 = this->uClipZ; | |
7143 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
7144 { | |
7145 v13 = this->uClipX; | |
7146 if ( (signed int)v13 < (signed int)a2 ) | |
7147 v13 = a2; | |
7148 v5 = v12 - v13; | |
7149 } | |
7150 v14 = this->uClipY; | |
7151 if ( (signed int)v14 < (signed int)a3 ) | |
7152 v14 = a3; | |
7153 v15 = this->uClipW; | |
7154 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
7155 { | |
7156 v16 = this->uClipY; | |
7157 if ( (signed int)v16 < (signed int)a3 ) | |
7158 v16 = a3; | |
7159 v6 = v15 - v16; | |
7160 } | |
7161 } | |
7162 if ( pRenderer->uTargetGBits == 5 ) | |
7163 { | |
7164 if ( (signed int)v6 > 0 ) | |
7165 { | |
7166 v23 = v6; | |
7167 do | |
7168 { | |
7169 if ( v5 > 0 ) | |
7170 { | |
7171 v21 = v5; | |
7172 do | |
7173 { | |
7174 if ( *v20 ) | |
7175 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
7176 ++v4; | |
7177 ++v20; | |
7178 --v21; | |
7179 } | |
7180 while ( v21 ); | |
7181 } | |
7182 v20 += v18 - v5; | |
7183 v17 = v23-- == 1; | |
7184 v4 += this->uTargetSurfacePitch - v5; | |
7185 } | |
7186 while ( !v17 ); | |
7187 } | |
7188 } | |
7189 else | |
7190 { | |
7191 if ( (signed int)v6 > 0 ) | |
7192 { | |
7193 v24 = v6; | |
7194 do | |
7195 { | |
7196 if ( v5 > 0 ) | |
7197 { | |
7198 v22 = v5; | |
7199 do | |
7200 { | |
7201 if ( *v20 ) | |
7202 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
7203 ++v4; | |
7204 ++v20; | |
7205 --v22; | |
7206 } | |
7207 while ( v22 ); | |
7208 } | |
7209 v20 += v18 - v5; | |
7210 v17 = v24-- == 1; | |
7211 v4 += this->uTargetSurfacePitch - v5; | |
7212 } | |
7213 while ( !v17 ); | |
7214 } | |
7215 } | |
7216 } | |
7217 } | |
7218 | |
7219 //----- (004A6DF5) -------------------------------------------------------- | |
7220 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
7221 { | |
7222 int result; // eax@0 | |
7223 int v8; // ecx@3 | |
7224 unsigned __int16 *v9; // edi@4 | |
7225 unsigned __int16 *v10; // ebx@4 | |
7226 int v11; // esi@4 | |
7227 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | |
7228 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | |
7229 | |
7230 if ( pBitmap ) | |
7231 { | |
7232 if ( pTarget ) | |
7233 { | |
7234 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | |
7235 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | |
7236 v8 = a7->z - a7->x; | |
7237 result = a7->w - a7->y; | |
7238 if ( result > 0 ) | |
7239 { | |
7240 v9 = pBitmapa; | |
7241 v10 = pTargeta; | |
7242 v11 = a7->w - a7->y; | |
7243 do | |
7244 { | |
7245 if ( v8 > 0 ) | |
7246 { | |
7247 result = v8; | |
7248 do | |
7249 { | |
7250 *v9 = *v10; | |
7251 ++v9; | |
7252 ++v10; | |
7253 --result; | |
7254 } | |
7255 while ( result ); | |
7256 } | |
7257 v9 += uBitmapPitch - v8; | |
7258 v10 += uTargetPitch - v8; | |
7259 --v11; | |
7260 } | |
7261 while ( v11 ); | |
7262 } | |
7263 } | |
7264 } | |
7265 return result; | |
7266 } | |
7267 | |
7268 //----- (004A6D87) -------------------------------------------------------- | |
7269 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
7270 { | |
7271 if (!uNumSceneBegins) | |
7272 return; | |
7273 | |
7274 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
7275 for (uint y = 0; y < uHeight; ++y) | |
7276 { | |
7277 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | |
7278 | |
7279 memset32(pDst, twoColors, uWidth / 2); | |
7280 if (uWidth & 1) | |
7281 pDst[uWidth - 1] = uColor16; | |
7282 } | |
7283 } | |
7284 | |
7285 //----- (004A6C4F) -------------------------------------------------------- | |
7286 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
7287 { | |
7288 unsigned int v9; // edi@2 | |
7289 unsigned int v10; // esi@2 | |
7290 unsigned __int16 *v11; // eax@2 | |
7291 unsigned int v12; // ebx@3 | |
7292 signed int v13; // edx@5 | |
7293 int v14; // edx@6 | |
7294 signed int v15; // ebx@7 | |
7295 unsigned int v16; // edx@9 | |
7296 signed int v17; // edi@10 | |
7297 signed int v18; // ebx@13 | |
7298 unsigned int v19; // edx@15 | |
7299 signed int v20; // esi@16 | |
7300 unsigned int v21; // esi@22 | |
7301 unsigned __int16 v22; // dx@24 | |
7302 char v23; // zf@28 | |
7303 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
7304 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | |
7305 | |
7306 if ( this->uNumSceneBegins ) | |
7307 { | |
7308 v9 = uCharWidth; | |
7309 v10 = uCharHeight; | |
7310 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
7311 v24 = pFontPixels; | |
7312 if ( this->bClip ) | |
7313 { | |
7314 v12 = this->uClipX; | |
7315 if ( uOutX < (signed int)v12 ) | |
7316 { | |
7317 v24 = &pFontPixels[v12 - uOutX]; | |
7318 v11 += v12 - uOutX; | |
7319 v9 = uCharWidth + uOutX - v12; | |
7320 } | |
7321 v13 = this->uClipY; | |
7322 if ( uOutY < v13 ) | |
7323 { | |
7324 v14 = v13 - uOutY; | |
7325 v24 += uCharWidth * v14; | |
7326 v10 = uCharHeight + uOutY - this->uClipY; | |
7327 v11 += this->uTargetSurfacePitch * v14; | |
7328 } | |
7329 v15 = this->uClipX; | |
7330 if ( v15 < uOutX ) | |
7331 v15 = uOutX; | |
7332 v16 = this->uClipZ; | |
7333 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
7334 { | |
7335 v17 = this->uClipX; | |
7336 if ( v17 < uOutX ) | |
7337 v17 = uOutX; | |
7338 v9 = v16 - v17; | |
7339 } | |
7340 v18 = this->uClipY; | |
7341 if ( v18 < uOutY ) | |
7342 v18 = uOutY; | |
7343 v19 = this->uClipW; | |
7344 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
7345 { | |
7346 v20 = this->uClipY; | |
7347 if ( v20 < uOutY ) | |
7348 v20 = uOutY; | |
7349 v10 = v19 - v20; | |
7350 } | |
7351 } | |
7352 if ( (signed int)v10 > 0 ) | |
7353 { | |
7354 uOutXa = v10; | |
7355 do | |
7356 { | |
7357 if ( (signed int)v9 > 0 ) | |
7358 { | |
7359 v21 = v9; | |
7360 do | |
7361 { | |
7362 if ( *v24 ) | |
7363 { | |
7364 v22 = uShadowColor; | |
7365 if ( *v24 != 1 ) | |
7366 v22 = uFaceColor; | |
7367 *v11 = v22; | |
7368 } | |
7369 ++v11; | |
7370 ++v24; | |
7371 --v21; | |
7372 } | |
7373 while ( v21 ); | |
7374 } | |
7375 v24 += uCharWidth - v9; | |
7376 v23 = uOutXa-- == 1; | |
7377 v11 += this->uTargetSurfacePitch - v9; | |
7378 } | |
7379 while ( !v23 ); | |
7380 } | |
7381 } | |
7382 } | |
7383 | |
7384 //----- (004A6A68) -------------------------------------------------------- | |
7385 void Render::_4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | |
7386 { | |
7387 Render *v5; // ebx@1 | |
7388 unsigned __int16 v6; // ax@1 | |
7389 | |
7390 v5 = this; | |
7391 | |
7392 Texture tex; // [sp+Ch] [bp-48h]@1 | |
7393 //Texture::Texture(&tex); | |
7394 | |
7395 v6 = a4->uTextureHeight - height; | |
7396 memcpy(&tex, a4, sizeof(tex)); | |
7397 tex.uTextureHeight = v6; | |
7398 if ( (signed __int16)v6 > 0 ) | |
7399 DrawTextureIndexed(a2, a3, &tex); | |
7400 } | |
7401 | |
7402 //----- (004A6AB1) -------------------------------------------------------- | |
1268 | 7403 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
7404 { | |
0 | 7405 int v8; // edi@2 |
7406 unsigned int v9; // esi@2 | |
7407 unsigned __int16 *v10; // eax@2 | |
7408 unsigned char *v11; // edx@2 | |
7409 unsigned int v12; // ebx@3 | |
7410 signed int v13; // edx@5 | |
7411 int v14; // edx@6 | |
7412 signed int v15; // ebx@7 | |
7413 unsigned int v16; // edx@9 | |
7414 signed int v17; // edi@10 | |
7415 signed int v18; // ebx@13 | |
7416 unsigned int v19; // edx@15 | |
7417 signed int v20; // esi@16 | |
7418 int v21; // ebx@22 | |
7419 char v22; // zf@28 | |
7420 int v23; // ebx@31 | |
7421 unsigned __int16 v24; // si@35 | |
7422 int v25; // [sp+Ch] [bp-4h]@2 | |
7423 int v26; // [sp+1Ch] [bp+Ch]@24 | |
7424 int v27; // [sp+1Ch] [bp+Ch]@33 | |
7425 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
7426 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
7427 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
7428 | |
7429 auto a2 = x; | |
7430 auto a3 = y; | |
7431 auto a6 = uFontHeight; | |
7432 if ( this->uNumSceneBegins ) | |
7433 { | |
7434 v8 = a5; | |
7435 v9 = a6; | |
7436 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
1268 | 7437 v11 = (unsigned char *)font_pixels; |
7438 v25 = (int)font_pixels; | |
0 | 7439 if ( this->bClip ) |
7440 { | |
7441 v12 = this->uClipX; | |
7442 if ( a2 < (signed int)v12 ) | |
7443 { | |
1268 | 7444 v25 = v12 - a2 + (int)font_pixels; |
0 | 7445 v10 += v12 - a2; |
7446 v8 = a5 + a2 - v12; | |
7447 } | |
7448 v13 = this->uClipY; | |
7449 if ( a3 < v13 ) | |
7450 { | |
7451 v14 = v13 - a3; | |
7452 v25 += a5 * v14; | |
7453 v9 = a6 + a3 - this->uClipY; | |
7454 v10 += this->uTargetSurfacePitch * v14; | |
7455 } | |
7456 v15 = this->uClipX; | |
7457 if ( v15 < a2 ) | |
7458 v15 = a2; | |
7459 v16 = this->uClipZ; | |
7460 if ( v8 + v15 > (signed int)v16 ) | |
7461 { | |
7462 v17 = this->uClipX; | |
7463 if ( v17 < a2 ) | |
7464 v17 = a2; | |
7465 v8 = v16 - v17; | |
7466 } | |
7467 v18 = this->uClipY; | |
7468 if ( v18 < a3 ) | |
7469 v18 = a3; | |
7470 v19 = this->uClipW; | |
7471 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
7472 { | |
7473 v20 = this->uClipY; | |
7474 if ( v20 < a3 ) | |
7475 v20 = a3; | |
7476 v9 = v19 - v20; | |
7477 } | |
7478 v11 = (unsigned char *)v25; | |
7479 } | |
7480 if ( a8 ) | |
7481 { | |
7482 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
7483 if ( (signed int)v9 > 0 ) | |
7484 { | |
7485 v23 = a5; | |
7486 v30 = v9; | |
7487 do | |
7488 { | |
7489 if ( v8 > 0 ) | |
7490 { | |
7491 v27 = v8; | |
7492 do | |
7493 { | |
7494 if ( *v11 ) | |
7495 v24 = pPalette[*v11]; | |
7496 else | |
7497 v24 = v28; | |
7498 *v10 = v24; | |
7499 ++v10; | |
7500 ++v11; | |
7501 --v27; | |
7502 } | |
7503 while ( v27 ); | |
7504 } | |
7505 v11 += v23 - v8; | |
7506 v22 = v30-- == 1; | |
7507 v10 += this->uTargetSurfacePitch - v8; | |
7508 } | |
7509 while ( !v22 ); | |
7510 } | |
7511 } | |
7512 else | |
7513 { | |
7514 if ( (signed int)v9 > 0 ) | |
7515 { | |
7516 v21 = a5; | |
7517 v29 = v9; | |
7518 do | |
7519 { | |
7520 if ( v8 > 0 ) | |
7521 { | |
7522 v26 = v8; | |
7523 do | |
7524 { | |
7525 if ( *v11 ) | |
7526 *v10 = pPalette[*v11]; | |
7527 ++v10; | |
7528 ++v11; | |
7529 --v26; | |
7530 } | |
7531 while ( v26 ); | |
7532 } | |
7533 v11 += v21 - v8; | |
7534 v22 = v29-- == 1; | |
7535 v10 += this->uTargetSurfacePitch - v8; | |
7536 } | |
7537 while ( !v22 ); | |
7538 } | |
7539 } | |
7540 } | |
7541 } | |
7542 | |
7543 //----- (004A68EF) -------------------------------------------------------- | |
7544 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
7545 { | |
7546 Texture *v4; // edi@2 | |
7547 unsigned int v5; // ebx@4 | |
7548 unsigned __int16 *v6; // eax@4 | |
7549 signed int v7; // edx@5 | |
7550 int v8; // edx@6 | |
7551 signed int v9; // edx@7 | |
7552 int v10; // edx@8 | |
7553 signed int v11; // edx@9 | |
7554 signed int v12; // esi@12 | |
7555 signed int v13; // esi@15 | |
7556 unsigned int v14; // edx@17 | |
7557 signed int v15; // esi@18 | |
7558 unsigned __int8 *v16; // ebx@22 | |
7559 char v17; // zf@28 | |
7560 int v18; // [sp+10h] [bp-10h]@4 | |
7561 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7562 int v20; // [sp+1Ch] [bp-4h]@4 | |
7563 int v21; // [sp+28h] [bp+8h]@24 | |
7564 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
7565 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7566 | |
7567 if ( this->uNumSceneBegins ) | |
7568 { | |
7569 v4 = pTexture; | |
7570 if ( pTexture ) | |
7571 { | |
7572 if ( pTexture->pPalette16 ) | |
7573 { | |
7574 v5 = pTexture->uTextureHeight; | |
7575 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7576 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7577 v20 = pTexture->uTextureWidth; |
7578 v18 = pTexture->uTextureWidth; | |
7579 if ( this->bClip ) | |
7580 { | |
7581 v7 = this->uClipX; | |
7582 if ( a2 < v7 ) | |
7583 { | |
7584 v8 = v7 - a2; | |
7585 v19 += v8; | |
7586 v20 += a2 - this->uClipX; | |
7587 v6 += v8; | |
7588 } | |
7589 v9 = this->uClipY; | |
7590 v5 = pTexture->uTextureHeight; | |
7591 if ( a3 < v9 ) | |
7592 { | |
7593 v10 = v9 - a3; | |
7594 v19 += v18 * v10; | |
7595 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7596 v4 = pTexture; | |
7597 v6 += this->uTargetSurfacePitch * v10; | |
7598 } | |
7599 v11 = this->uClipX; | |
7600 if ( v11 < a2 ) | |
7601 v11 = a2; | |
7602 pTexturea = this->uClipZ; | |
7603 if ( v11 + v20 > (signed int)pTexturea ) | |
7604 { | |
7605 v12 = this->uClipX; | |
7606 if ( v12 < a2 ) | |
7607 v12 = a2; | |
7608 v20 = pTexturea - v12; | |
7609 } | |
7610 v13 = this->uClipY; | |
7611 if ( v13 < a3 ) | |
7612 v13 = a3; | |
7613 v14 = this->uClipW; | |
7614 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7615 { | |
7616 v15 = this->uClipY; | |
7617 if ( v15 < a3 ) | |
7618 v15 = a3; | |
7619 v5 = v14 - v15; | |
7620 } | |
7621 } | |
7622 if ( (signed int)v5 > 0 ) | |
7623 { | |
7624 v22 = v5; | |
7625 v16 = v19; | |
7626 do | |
7627 { | |
7628 if ( v20 > 0 ) | |
7629 { | |
7630 v21 = v20; | |
7631 do | |
7632 { | |
7633 if ( *v16 ) | |
7634 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7635 ++v6; | |
7636 ++v16; | |
7637 --v21; | |
7638 } | |
7639 while ( v21 ); | |
7640 } | |
7641 v16 += v18 - v20; | |
7642 v17 = v22-- == 1; | |
7643 v6 += this->uTargetSurfacePitch - v20; | |
7644 } | |
7645 while ( !v17 ); | |
7646 } | |
7647 } | |
7648 } | |
7649 } | |
7650 } | |
7651 | |
7652 //----- (004A6776) -------------------------------------------------------- | |
315 | 7653 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 7654 { |
7655 Texture *v4; // edi@2 | |
7656 unsigned int v5; // ebx@4 | |
7657 unsigned __int16 *v6; // eax@4 | |
7658 unsigned int v7; // edx@5 | |
7659 unsigned int v8; // edx@6 | |
7660 unsigned int v9; // edx@7 | |
7661 unsigned int v10; // edx@8 | |
7662 unsigned int v11; // edx@9 | |
7663 unsigned int v12; // esi@12 | |
7664 unsigned int v13; // esi@15 | |
7665 unsigned int v14; // edx@17 | |
7666 unsigned int v15; // esi@18 | |
7667 unsigned __int8 *v16; // ebx@22 | |
7668 char v17; // zf@28 | |
7669 int v18; // [sp+10h] [bp-10h]@4 | |
7670 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7671 int v20; // [sp+1Ch] [bp-4h]@4 | |
7672 int a2a; // [sp+28h] [bp+8h]@24 | |
7673 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
7674 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
7675 | |
7676 if ( this->uNumSceneBegins ) | |
7677 { | |
7678 v4 = a4; | |
7679 if ( a4 ) | |
7680 { | |
7681 if ( a4->pPalette16 ) | |
7682 { | |
7683 v5 = a4->uTextureHeight; | |
7684 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7685 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7686 v20 = a4->uTextureWidth; |
7687 v18 = a4->uTextureWidth; | |
7688 if ( this->bClip ) | |
7689 { | |
7690 v7 = this->uClipX; | |
7691 if ( (signed int)a2 < (signed int)v7 ) | |
7692 { | |
7693 v8 = v7 - a2; | |
7694 v19 += v8; | |
7695 v20 += a2 - this->uClipX; | |
7696 v6 += v8; | |
7697 } | |
7698 v9 = this->uClipY; | |
7699 v5 = a4->uTextureHeight; | |
7700 if ( (signed int)a3 < (signed int)v9 ) | |
7701 { | |
7702 v10 = v9 - a3; | |
7703 v19 += v18 * v10; | |
7704 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
7705 v4 = a4; | |
7706 v6 += this->uTargetSurfacePitch * v10; | |
7707 } | |
7708 v11 = this->uClipX; | |
7709 if ( (signed int)v11 < (signed int)a2 ) | |
7710 v11 = a2; | |
7711 a4a = this->uClipZ; | |
7712 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
7713 { | |
7714 v12 = this->uClipX; | |
7715 if ( (signed int)v12 < (signed int)a2 ) | |
7716 v12 = a2; | |
7717 v20 = a4a - v12; | |
7718 } | |
7719 v13 = this->uClipY; | |
7720 if ( (signed int)v13 < (signed int)a3 ) | |
7721 v13 = a3; | |
7722 v14 = this->uClipW; | |
7723 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7724 { | |
7725 v15 = this->uClipY; | |
7726 if ( (signed int)v15 < (signed int)a3 ) | |
7727 v15 = a3; | |
7728 v5 = v14 - v15; | |
7729 } | |
7730 } | |
7731 if ( (signed int)v5 > 0 ) | |
7732 { | |
7733 a3a = v5; | |
7734 v16 = v19; | |
7735 do | |
7736 { | |
7737 if ( v20 > 0 ) | |
7738 { | |
7739 a2a = v20; | |
7740 do | |
7741 { | |
7742 if ( *v16 ) | |
7743 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
7744 ++v6; | |
7745 ++v16; | |
7746 --a2a; | |
7747 } | |
7748 while ( a2a ); | |
7749 } | |
7750 v16 += v18 - v20; | |
7751 v17 = a3a-- == 1; | |
7752 v6 += this->uTargetSurfacePitch - v20; | |
7753 } | |
7754 while ( !v17 ); | |
7755 } | |
7756 } | |
7757 } | |
7758 } | |
7759 } | |
7760 | |
7761 //----- (004A65CC) -------------------------------------------------------- | |
7762 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
7763 { | |
7764 unsigned __int16 *v8; // esi@6 | |
7765 unsigned int v9; // edi@6 | |
7766 unsigned int v10; // eax@7 | |
7767 unsigned int v11; // eax@8 | |
7768 unsigned int v12; // eax@9 | |
7769 unsigned int v13; // eax@10 | |
7770 unsigned int v14; // edx@11 | |
7771 unsigned int v15; // eax@13 | |
7772 unsigned int v16; // edx@14 | |
7773 unsigned int v17; // edx@17 | |
7774 unsigned int v18; // eax@19 | |
7775 unsigned int v19; // edx@20 | |
7776 int v20; // eax@27 | |
7777 int v21; // edx@29 | |
7778 int v22; // [sp+Ch] [bp-Ch]@6 | |
7779 int v23; // [sp+Ch] [bp-Ch]@24 | |
7780 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
7781 int xa; // [sp+20h] [bp+8h]@26 | |
7782 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
7783 int v27; // [sp+2Ch] [bp+14h]@6 | |
7784 | |
7785 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
7786 { | |
7787 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | |
710 | 7788 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7789 v27 = a4->uTextureWidth; |
7790 v9 = a4->uTextureHeight; | |
7791 v22 = a4->uTextureWidth; | |
7792 if ( this->bClip ) | |
7793 { | |
7794 v10 = this->uClipX; | |
7795 if ( (signed int)x < (signed int)v10 ) | |
7796 { | |
7797 v11 = v10 - x; | |
7798 v24 += v11; | |
7799 v27 += x - this->uClipX; | |
7800 v8 += v11; | |
7801 } | |
7802 v12 = this->uClipY; | |
7803 if ( (signed int)y < (signed int)v12 ) | |
7804 { | |
7805 v13 = v12 - y; | |
7806 v24 += v22 * v13; | |
7807 v9 = y - this->uClipY + a4->uTextureHeight; | |
7808 v8 += this->uTargetSurfacePitch * v13; | |
7809 } | |
7810 v14 = this->uClipX; | |
7811 if ( (signed int)v14 < (signed int)x ) | |
7812 v14 = x; | |
7813 v15 = this->uClipZ; | |
7814 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
7815 { | |
7816 v16 = this->uClipX; | |
7817 if ( (signed int)v16 < (signed int)x ) | |
7818 v16 = x; | |
7819 v27 = v15 - v16; | |
7820 } | |
7821 v17 = this->uClipY; | |
7822 if ( (signed int)v17 < (signed int)y ) | |
7823 v17 = y; | |
7824 v18 = this->uClipW; | |
7825 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
7826 { | |
7827 v19 = this->uClipY; | |
7828 if ( (signed int)v19 < (signed int)y ) | |
7829 v19 = y; | |
7830 v9 = v18 - v19; | |
7831 } | |
7832 } | |
7833 if ( (signed int)v9 > 0 ) | |
7834 { | |
7835 ya = v9; | |
7836 v23 = v22 - v27; | |
7837 do | |
7838 { | |
7839 if ( v27 > 0 ) | |
7840 { | |
7841 xa = v27; | |
7842 do | |
7843 { | |
7844 v20 = *v24; | |
7845 if ( v20 >= a7 && v20 <= a8 ) | |
7846 { | |
7847 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7848 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7849 v21 = 2 * a8 - v21 - a7; | |
7850 *v8 = a4->pPalette16[v21]; | |
7851 } | |
7852 ++v8; | |
7853 ++v24; | |
7854 --xa; | |
7855 } | |
7856 while ( xa ); | |
7857 } | |
7858 v8 += this->uTargetSurfacePitch - v27; | |
7859 v24 += v23; | |
7860 --ya; | |
7861 } | |
7862 while ( ya ); | |
7863 } | |
7864 } | |
7865 } | |
7866 | |
7867 //----- (004A63E6) -------------------------------------------------------- | |
7868 void Render::_4A63E6(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
7869 { | |
7870 Texture *v8; // eax@2 | |
7871 Texture *v9; // ebx@4 | |
7872 unsigned __int16 *v10; // esi@6 | |
7873 unsigned int v11; // edi@7 | |
7874 unsigned int v12; // eax@9 | |
7875 unsigned int v13; // eax@10 | |
7876 unsigned int v14; // edx@11 | |
7877 unsigned int v15; // eax@13 | |
7878 unsigned int v16; // edx@14 | |
7879 unsigned int v17; // edx@17 | |
7880 unsigned int v18; // eax@19 | |
7881 unsigned int v19; // edx@20 | |
7882 int v20; // eax@27 | |
7883 int v21; // edx@29 | |
7884 int v22; // [sp+Ch] [bp-Ch]@6 | |
7885 int v23; // [sp+Ch] [bp-Ch]@24 | |
7886 int v24; // [sp+10h] [bp-8h]@6 | |
7887 int v25; // [sp+14h] [bp-4h]@6 | |
7888 int i; // [sp+20h] [bp+8h]@25 | |
7889 int v27; // [sp+24h] [bp+Ch]@23 | |
7890 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
7891 | |
7892 if ( this->uNumSceneBegins ) | |
7893 { | |
7894 v8 = a4; | |
7895 if ( a4 ) | |
7896 { | |
7897 if ( a4->pPalette16 ) | |
7898 { | |
7899 v9 = a5; | |
7900 if ( a5 ) | |
7901 { | |
7902 if ( a5->pPalette16 ) | |
7903 { | |
7904 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7905 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7906 v25 = v8->uTextureWidth; |
7907 v24 = v8->uTextureHeight; | |
7908 v22 = v8->uTextureWidth; | |
7909 if ( this->bClip ) | |
7910 { | |
7911 v11 = this->uClipX; | |
7912 if ( (signed int)a2 < (signed int)v11 ) | |
7913 { | |
7914 v28 += v11 - a2; | |
7915 v25 += a2 - v11; | |
7916 v9 = a5; | |
7917 v10 += v11 - a2; | |
7918 } | |
7919 v12 = this->uClipY; | |
7920 if ( (signed int)a3 < (signed int)v12 ) | |
7921 { | |
7922 v13 = v12 - a3; | |
7923 v9 = a5; | |
7924 v28 += v22 * v13; | |
7925 v24 += a3 - this->uClipY; | |
7926 v10 += this->uTargetSurfacePitch * v13; | |
7927 } | |
7928 v14 = this->uClipX; | |
7929 if ( (signed int)v14 < (signed int)a2 ) | |
7930 v14 = a2; | |
7931 v15 = this->uClipZ; | |
7932 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
7933 { | |
7934 v16 = this->uClipX; | |
7935 if ( (signed int)v16 < (signed int)a2 ) | |
7936 v16 = a2; | |
7937 v25 = v15 - v16; | |
7938 } | |
7939 v17 = this->uClipY; | |
7940 if ( (signed int)v17 < (signed int)a3 ) | |
7941 v17 = a3; | |
7942 v18 = this->uClipW; | |
7943 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
7944 { | |
7945 v19 = this->uClipY; | |
7946 if ( (signed int)v19 < (signed int)a3 ) | |
7947 v19 = a3; | |
7948 v24 = v18 - v19; | |
7949 } | |
7950 } | |
7951 v27 = 0; | |
7952 if ( v24 > 0 ) | |
7953 { | |
7954 v23 = v22 - v25; | |
7955 do | |
7956 { | |
7957 for ( i = 0; i < v25; ++v28 ) | |
7958 { | |
7959 if ( *v28 ) | |
7960 { | |
710 | 7961 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 7962 if ( v20 >= a7 ) |
7963 { | |
7964 if ( v20 <= a8 ) | |
7965 { | |
7966 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7967 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7968 v21 = 2 * a8 - v21 - a7; | |
7969 v9 = a5; | |
7970 *v10 = a5->pPalette16[v21]; | |
7971 } | |
7972 } | |
7973 } | |
7974 ++i; | |
7975 ++v10; | |
7976 } | |
7977 ++v27; | |
7978 v10 += this->uTargetSurfacePitch - v25; | |
7979 v28 += v23; | |
7980 } | |
7981 while ( v27 < v24 ); | |
7982 } | |
7983 } | |
7984 } | |
7985 } | |
7986 } | |
7987 } | |
7988 } | |
7989 | |
7990 //----- (004A6274) -------------------------------------------------------- | |
7991 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
7992 { | |
7993 Texture *pCurrentTexture; // edi@2 | |
7994 int uHeight; // ebx@4 | |
7995 unsigned __int16 *v6; // eax@4 | |
7996 unsigned int v7; // edx@5 | |
7997 unsigned int v8; // edx@6 | |
7998 unsigned int v9; // edx@7 | |
7999 unsigned int v10; // edx@8 | |
8000 unsigned int v11; // edx@9 | |
8001 unsigned int v12; // esi@12 | |
8002 unsigned int v13; // esi@15 | |
8003 unsigned int v14; // edx@17 | |
8004 unsigned int v15; // esi@18 | |
8005 unsigned __int8 *v16; // ebx@22 | |
8006 char uFlag; // zf@28 | |
8007 int v18; // [sp+10h] [bp-10h]@4 | |
8008 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
8009 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
8010 int uXa; // [sp+28h] [bp+8h]@24 | |
8011 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
8012 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
8013 | |
8014 if ( this->uNumSceneBegins ) | |
8015 { | |
8016 pCurrentTexture = pTexture; | |
8017 if ( pTexture ) | |
8018 { | |
8019 if ( pTexture->pPalette16 ) | |
8020 { | |
8021 uHeight = pTexture->uTextureHeight; | |
8022 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 8023 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8024 uWidth = pTexture->uTextureWidth; |
8025 v18 = pTexture->uTextureWidth; | |
8026 if ( this->bClip ) | |
8027 { | |
8028 v7 = this->uClipX; | |
8029 if ( (signed int)uX < (signed int)v7 ) | |
8030 { | |
8031 v8 = v7 - uX; | |
8032 v19 += v8; | |
8033 uWidth += uX - this->uClipX; | |
8034 v6 += v8; | |
8035 } | |
8036 v9 = this->uClipY; | |
8037 uHeight = pTexture->uTextureHeight; | |
8038 if ( (signed int)uY < (signed int)v9 ) | |
8039 { | |
8040 v10 = v9 - uY; | |
8041 v19 += v18 * v10; | |
8042 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
8043 pCurrentTexture = pTexture; | |
8044 v6 += this->uTargetSurfacePitch * v10; | |
8045 } | |
8046 v11 = this->uClipX; | |
8047 if ( (signed int)v11 < (signed int)uX ) | |
8048 v11 = uX; | |
8049 pTexturea = this->uClipZ; | |
8050 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
8051 { | |
8052 v12 = this->uClipX; | |
8053 if ( (signed int)v12 < (signed int)uX ) | |
8054 v12 = uX; | |
8055 uWidth = pTexturea - v12; | |
8056 } | |
8057 v13 = this->uClipY; | |
8058 if ( (signed int)v13 < (signed int)uY ) | |
8059 v13 = uY; | |
8060 v14 = this->uClipW; | |
8061 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
8062 { | |
8063 v15 = this->uClipY; | |
8064 if ( (signed int)v15 < (signed int)uY ) | |
8065 v15 = uY; | |
8066 uHeight = v14 - v15; | |
8067 } | |
8068 } | |
8069 if ( (signed int)uHeight > 0 ) | |
8070 { | |
8071 uYa = uHeight; | |
8072 v16 = v19; | |
8073 do | |
8074 { | |
8075 if ( uWidth > 0 ) | |
8076 { | |
8077 uXa = uWidth; | |
8078 do | |
8079 { | |
8080 if ( *v16 ) | |
8081 *v6 = pCurrentTexture->pPalette16[*v16]; | |
8082 ++v6; | |
8083 ++v16; | |
8084 } | |
8085 while ( uXa-- !=1 ); | |
8086 } | |
8087 v16 += v18 - uWidth; | |
8088 uFlag = uYa-- == 1; | |
8089 v6 += this->uTargetSurfacePitch - uWidth; | |
8090 } | |
8091 while ( !uFlag ); | |
8092 } | |
8093 } | |
8094 } | |
8095 } | |
8096 } | |
8097 | |
8098 //----- (004A612A) -------------------------------------------------------- | |
710 | 8099 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 8100 { |
8101 Texture *v5; // eax@2 | |
8102 unsigned int v6; // edx@3 | |
8103 int v7; // ebx@3 | |
8104 int v8; // edi@3 | |
8105 signed int v9; // eax@4 | |
8106 int v10; // eax@5 | |
8107 unsigned int v11; // esi@6 | |
8108 signed int v12; // esi@8 | |
8109 unsigned int v13; // eax@10 | |
8110 signed int v14; // esi@11 | |
8111 unsigned int v15; // esi@14 | |
8112 unsigned int v16; // eax@16 | |
8113 unsigned int v17; // ecx@17 | |
8114 int v18; // edx@23 | |
8115 int v19; // [sp+Ch] [bp-Ch]@3 | |
8116 int v20; // [sp+10h] [bp-8h]@3 | |
8117 int uOutXa; // [sp+20h] [bp+8h]@21 | |
8118 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
8119 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
8120 | |
8121 if ( this->uNumSceneBegins ) | |
8122 { | |
8123 v5 = pTexture; | |
8124 if ( pTexture ) | |
8125 { | |
8126 v6 = uOutY; | |
8127 v7 = pTexture->uTextureHeight; | |
8128 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
710 | 8129 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8130 v8 = v5->uTextureWidth; |
8131 v20 = v5->uTextureWidth; | |
8132 v19 = v5->uTextureWidth; | |
8133 if ( this->bClip ) | |
8134 { | |
8135 v9 = this->uClipX; | |
8136 if ( uOutX < v9 ) | |
8137 { | |
8138 v10 = v9 - uOutX; | |
8139 uOutYa += v10; | |
8140 v8 += uOutX - this->uClipX; | |
8141 v20 = v8; | |
8142 pZBuffer += v10; | |
8143 } | |
8144 v11 = this->uClipY; | |
8145 if ( (signed int)v6 < (signed int)v11 ) | |
8146 { | |
8147 uOutYa += v19 * (v11 - v6); | |
8148 v7 += v6 - v11; | |
8149 pZBuffer += 640 * (v11 - v6); | |
8150 v8 = v20; | |
8151 } | |
8152 v12 = this->uClipX; | |
8153 if ( v12 < uOutX ) | |
8154 v12 = uOutX; | |
8155 v13 = this->uClipZ; | |
8156 if ( v8 + v12 > (signed int)v13 ) | |
8157 { | |
8158 v14 = this->uClipX; | |
8159 if ( v14 < uOutX ) | |
8160 v14 = uOutX; | |
8161 v8 = v13 - v14; | |
8162 } | |
8163 v15 = this->uClipY; | |
8164 if ( (signed int)v15 < (signed int)v6 ) | |
8165 v15 = v6; | |
8166 v16 = this->uClipW; | |
8167 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
8168 { | |
8169 v17 = this->uClipY; | |
8170 if ( (signed int)v17 >= (signed int)v6 ) | |
8171 v6 = v17; | |
8172 v7 = v16 - v6; | |
8173 } | |
8174 } | |
8175 if ( v7 > 0 ) | |
8176 { | |
8177 uOutXa = v7; | |
8178 do | |
8179 { | |
8180 if ( v8 > 0 ) | |
8181 { | |
8182 v18 = v8; | |
8183 do | |
8184 { | |
8185 if ( *uOutYa ) | |
8186 *pZBuffer = zVal; | |
8187 ++pZBuffer; | |
8188 ++uOutYa; | |
8189 --v18; | |
8190 } | |
8191 while ( v18 ); | |
8192 } | |
8193 pZBuffer += 640 - v8; | |
8194 uOutYa += v19 - v8; | |
8195 --uOutXa; | |
8196 } | |
8197 while ( uOutXa ); | |
8198 } | |
8199 } | |
8200 } | |
8201 } | |
8202 | |
8203 //----- (004A601E) -------------------------------------------------------- | |
991 | 8204 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 8205 { |
8206 signed int v5; // edx@3 | |
8207 int v6; // ebx@3 | |
8208 int v7; // esi@3 | |
8209 void *v8; // esi@3 | |
8210 unsigned int v9; // eax@4 | |
8211 unsigned int v10; // eax@6 | |
8212 signed int v11; // edi@8 | |
8213 unsigned int v12; // eax@10 | |
8214 signed int v13; // edi@11 | |
8215 unsigned int v14; // edi@14 | |
8216 unsigned int v15; // eax@16 | |
8217 unsigned int v16; // ecx@17 | |
8218 int v17; // [sp+18h] [bp+Ch]@3 | |
8219 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
8220 | |
8221 if ( this->uNumSceneBegins && pTexture ) | |
8222 { | |
8223 v5 = a3; | |
8224 v6 = pTexture->uTextureHeight; | |
8225 v7 = 5 * a3; | |
8226 v17 = pTexture->uTextureHeight; | |
8227 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
8228 pTexturea = pTexture->uTextureWidth; | |
8229 if ( this->bClip ) | |
8230 { | |
8231 v9 = this->uClipX; | |
8232 if ( a2 < (signed int)v9 ) | |
8233 { | |
8234 pTexturea += a2 - v9; | |
8235 v8 = (char *)v8 + 4 * (v9 - a2); | |
8236 } | |
8237 v10 = this->uClipY; | |
8238 if ( v5 < (signed int)v10 ) | |
8239 { | |
8240 v17 += v5 - v10; | |
8241 v8 = (char *)v8 + 2560 * (v10 - v5); | |
8242 } | |
8243 v11 = this->uClipX; | |
8244 if ( v11 < a2 ) | |
8245 v11 = a2; | |
8246 v12 = this->uClipZ; | |
8247 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
8248 { | |
8249 v13 = this->uClipX; | |
8250 if ( v13 < a2 ) | |
8251 v13 = a2; | |
8252 pTexturea = v12 - v13; | |
8253 } | |
8254 v14 = this->uClipY; | |
8255 if ( (signed int)v14 < v5 ) | |
8256 v14 = v5; | |
8257 v6 = v17; | |
8258 v15 = this->uClipW; | |
8259 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
8260 { | |
8261 v16 = this->uClipY; | |
8262 if ( (signed int)v16 < v5 ) | |
8263 v16 = v5; | |
8264 v6 = v15 - v16; | |
8265 } | |
8266 } | |
8267 if ( v6 > 0 ) | |
8268 { | |
8269 do | |
8270 { | |
8271 if ( (signed int)pTexturea > 0 ) | |
8272 { | |
8273 memset32(v8, a5, pTexturea); | |
8274 v8 = (char *)v8 + 4 * pTexturea; | |
8275 } | |
8276 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
8277 --v6; | |
8278 } | |
8279 while ( v6 ); | |
8280 } | |
8281 } | |
8282 } | |
8283 | |
8284 //----- (004A5EB2) -------------------------------------------------------- | |
8285 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
8286 { | |
8287 Texture *v4; // edi@2 | |
8288 unsigned int v5; // ebx@4 | |
8289 unsigned __int16 *pTarget; // eax@4 | |
8290 unsigned int v7; // edx@5 | |
8291 unsigned int v8; // edx@6 | |
8292 unsigned int v9; // edx@7 | |
8293 unsigned int v10; // edx@8 | |
8294 unsigned int v11; // edx@9 | |
8295 unsigned int v12; // esi@12 | |
8296 unsigned int v13; // esi@15 | |
8297 unsigned int v14; // edx@17 | |
8298 unsigned int v15; // esi@18 | |
8299 unsigned __int8 *v16; // edx@22 | |
8300 char v17; // zf@26 | |
8301 int v18; // [sp+10h] [bp-10h]@4 | |
8302 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
8303 int v20; // [sp+1Ch] [bp-4h]@4 | |
8304 int uXa; // [sp+28h] [bp+8h]@24 | |
8305 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
8306 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
8307 | |
8308 if ( this->uNumSceneBegins ) | |
8309 { | |
8310 v4 = a4; | |
8311 if ( a4 ) | |
8312 { | |
8313 if ( a4->pPalette16 ) | |
8314 { | |
8315 v5 = a4->uTextureHeight; | |
8316 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 8317 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8318 v20 = a4->uTextureWidth; |
8319 v18 = a4->uTextureWidth; | |
8320 if ( this->bClip ) | |
8321 { | |
8322 v7 = this->uClipX; | |
8323 if ( (signed int)uX < (signed int)v7 ) | |
8324 { | |
8325 v8 = v7 - uX; | |
8326 v19 += v8; | |
8327 v20 += uX - this->uClipX; | |
8328 pTarget += v8; | |
8329 } | |
8330 v9 = this->uClipY; | |
8331 v5 = a4->uTextureHeight; | |
8332 if ( (signed int)uY < (signed int)v9 ) | |
8333 { | |
8334 v10 = v9 - uY; | |
8335 v19 += v18 * v10; | |
8336 v5 = uY - this->uClipY + a4->uTextureHeight; | |
8337 v4 = a4; | |
8338 pTarget += this->uTargetSurfacePitch * v10; | |
8339 } | |
8340 v11 = this->uClipX; | |
8341 if ( (signed int)v11 < (signed int)uX ) | |
8342 v11 = uX; | |
8343 v23 = this->uClipZ; | |
8344 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
8345 { | |
8346 v12 = this->uClipX; | |
8347 if ( (signed int)v12 < (signed int)uX ) | |
8348 v12 = uX; | |
8349 v20 = v23 - v12; | |
8350 } | |
8351 v13 = this->uClipY; | |
8352 if ( (signed int)v13 < (signed int)uY ) | |
8353 v13 = uY; | |
8354 v14 = this->uClipW; | |
8355 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
8356 { | |
8357 v15 = this->uClipY; | |
8358 if ( (signed int)v15 < (signed int)uY ) | |
8359 v15 = uY; | |
8360 v5 = v14 - v15; | |
8361 } | |
8362 } | |
8363 if ( (signed int)v5 > 0 ) | |
8364 { | |
8365 uYa = v5; | |
8366 v16 = v19; | |
8367 do | |
8368 { | |
8369 if ( v20 > 0 ) | |
8370 { | |
8371 uXa = v20; | |
8372 do | |
8373 { | |
8374 *pTarget = v4->pPalette16[*v16]; | |
8375 ++pTarget; | |
8376 ++v16; | |
8377 --uXa; | |
8378 } | |
8379 while ( uXa ); | |
8380 } | |
8381 v16 += v18 - v20; | |
8382 v17 = uYa-- == 1; | |
8383 pTarget += this->uTargetSurfacePitch - v20; | |
8384 } | |
8385 while ( !v17 ); | |
8386 } | |
8387 } | |
8388 } | |
8389 } | |
8390 } | |
8391 | |
8392 //----- (004667E9) -------------------------------------------------------- | |
8393 void Render::ChangeBetweenWinFullscreenModes() | |
8394 { | |
8395 float v0; // ST14_4@17 | |
8396 int v4; // edx@26 | |
8397 ObjectDesc *v5; // eax@26 | |
8398 RGBTexture *v6; // esi@33 | |
8399 const char *v8; // [sp-4h] [bp-28h]@33 | |
8400 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
8401 | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8402 if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) |
0 | 8403 { |
8404 ModalWindow(pGlobalTXT_LocalizationStrings[62], 0);// "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window." | |
8405 return; | |
8406 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8407 if ( pRenderer->bWindowMode || !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8408 { |
0 | 8409 if ( pEventTimer->bPaused ) |
8410 BYTE1(dword_6BE364_game_settings_1) |= 8u; | |
8411 else | |
8412 pEventTimer->Pause(); | |
8413 if ( pMiscTimer->bPaused ) | |
8414 BYTE1(dword_6BE364_game_settings_1) |= 0x10u; | |
8415 else | |
8416 pMiscTimer->Pause(); | |
8417 pMouse->bActive = 0; | |
8418 if ( pRenderer->pRenderD3D ) | |
8419 { | |
8420 pBitmaps_LOD->ReleaseHardwareTextures(); | |
8421 pSprites_LOD->ReleaseAll(); | |
8422 } | |
8423 if ( pRenderer->bWindowMode ) | |
8424 { | |
8425 if ( GetWindowRect(hWnd, &Rect) ) | |
8426 { | |
8427 WriteWindowsRegistryInt("window X", Rect.left); | |
8428 WriteWindowsRegistryInt("window Y", Rect.top); | |
8429 uWindowX = Rect.left; | |
8430 uWindowY = Rect.top; | |
8431 } | |
8432 SetMenu(hWnd, 0); | |
8433 SetWindowLongA(hWnd, -20, 0); | |
8434 SetWindowLongA(hWnd, -16, 0x10000000u); | |
8435 pRenderer->InitializeFullscreen(hWnd); | |
8436 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | |
8437 pGame->pGammaController->Initialize(v0); | |
8438 } | |
8439 else | |
8440 { | |
8441 ClipCursor(0); | |
8442 pRenderer->SwitchToWindow(hWnd); | |
8443 SetWindowLongA(hWnd, -16, uWindowStyle); | |
8444 SetMenu(hWnd, hOSMenu); | |
8445 } | |
8446 if ( pRenderer->pRenderD3D ) | |
8447 { | |
8448 pBitmaps_LOD->_410423_move_textures_to_device(); | |
8449 pSprites_LOD->MoveSpritesToVideoMemory(); | |
8450 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8451 if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits |
0 | 8452 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8453 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8454 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8455 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8456 pPaletteManager->RecalculateAll(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8457 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8458 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8459 for (int i = 0; i < pObjectList->uNumObjects; i++) |
0 | 8460 { |
8461 BYTE3(v4) = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8462 v5 = &pObjectList->pObjects[i]; |
0 | 8463 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; |
8464 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
8465 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8466 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8467 SetUserInterface(pParty->alignment, true); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8468 if ( pVideoPlayer->pVideoFrame.pPixels ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8469 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); |
0 | 8470 if ( uCurrentMenuID != 6 ) |
8471 { | |
8472 if ( uCurrentMenuID == 8 ) | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8473 dword_A74C88 = 1; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8474 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8475 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8476 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8477 if ( uCurrentMenuID ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8478 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8479 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8480 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8481 v8 = "makeme.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8482 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8483 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8484 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8485 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8486 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8487 v8 = "title.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8488 if ( uCurrentMenuID ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8489 v8 = "lsave640.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8490 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8491 v6->Load(v8, 0); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8492 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8493 } |
0 | 8494 viewparams->bRedrawGameUI = 1; |
688 | 8495 viewparams->InitGrayPalette(); |
0 | 8496 pMouse->SetCurrentCursorBitmap(); |
8497 if ( pRenderer->bWindowMode ) | |
8498 { | |
8499 InvalidateRect(0, 0, 0); | |
8500 MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | |
8501 ShowWindow(hWnd, 1); | |
8502 } | |
8503 pMouse->bActive = 1; | |
8504 if ( pVideoPlayer->AnyMovieLoaded() ) | |
898 | 8505 pVideoPlayer->SelectMovieType(); |
0 | 8506 if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) |
8507 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | |
8508 else | |
8509 pEventTimer->Resume(); | |
8510 if ( BYTE1(dword_6BE364_game_settings_1) & 0x10 ) | |
8511 BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; | |
8512 else | |
8513 pMiscTimer->Resume(); | |
8514 } | |
8515 } | |
8516 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
8517 // A74C88: using guessed type int dword_A74C88; | |
8518 | |
8519 | |
8520 //----- (004524D8) -------------------------------------------------------- | |
8521 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
8522 { | |
8523 int v11; // eax@13 | |
8524 int v12; // ecx@13 | |
8525 void *v13; // eax@13 | |
8526 unsigned __int8 v14; // zf@13 | |
8527 unsigned __int8 v15; // sf@13 | |
8528 int v16; // esi@14 | |
8529 int v17; // ecx@16 | |
8530 int v18; // esi@16 | |
8531 unsigned __int16 *v19; // eax@16 | |
8532 int v20; // edx@16 | |
8533 int v21; // ecx@16 | |
8534 int v22; // eax@16 | |
8535 int v23; // esi@16 | |
8536 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
8537 int v27; // [sp+28h] [bp-Ch]@14 | |
8538 int v28; // [sp+2Ch] [bp-8h]@13 | |
8539 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
8540 | |
8541 //v3 = this; | |
8542 //sprintf(Str1, "%s", pName); | |
8543 //v4 = uNumItems; | |
8544 if (!uNumItems) | |
8545 return nullptr; | |
8546 | |
8547 //{ | |
8548 //v5 = 0, pDesta = uNumItems; | |
8549 uint idx1 = 0, | |
8550 idx2 = uNumItems; | |
8551 while (true) | |
8552 { | |
8553 auto i = idx1 + (idx2 - idx1) / 2; | |
8554 | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
8555 auto res = _stricmp(pName, pSpriteNames[i]); |
0 | 8556 if (!res) |
8557 { | |
8558 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
8559 break; | |
8560 } | |
8561 else if (res < 0) | |
8562 idx2 = idx1 + (idx2 - idx1) / 2; | |
8563 else | |
8564 idx1 = i + 1; | |
8565 | |
8566 if ( idx1 >= idx2 ) | |
8567 return false; | |
8568 } | |
8569 | |
8570 | |
8571 uint uCompressedSize = 0; | |
8572 fread(&uCompressedSize, 4, 1, pFile); | |
8573 | |
8574 auto pTex = new HWLTexture; | |
670 | 8575 fread(&pTex->uBufferWidth, 4, 1, pFile); |
8576 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
8577 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
8578 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 8579 fread(&pTex->uWidth, 4, 1, pFile); |
8580 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 8581 fread(&pTex->uAreaX, 4, 1, pFile); |
8582 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 8583 |
8584 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
8585 if (uCompressedSize) | |
8586 { | |
8587 auto pCompressedData = new char[uCompressedSize]; | |
8588 { | |
8589 fread(pCompressedData, 1, uCompressedSize, pFile); | |
8590 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
8591 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
8592 } | |
8593 delete [] pCompressedData; | |
8594 } | |
8595 else | |
8596 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
8597 | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8598 if ( field_61A94_scale_hwls_to_half ) //is it even possible to ever get here? field_61A94_scale_hwls_to_half is only set to zero |
0 | 8599 { |
8600 v11 = pTex->uHeight / 2; | |
8601 v12 = pTex->uWidth / 2; | |
8602 pTex->uHeight = v11; | |
8603 pTex->uWidth = v12; | |
8604 v13 = new unsigned __int16[v12 * v11]; | |
8605 v28 = 0; | |
8606 v14 = pTex->uHeight == 0; | |
8607 v15 = (pTex->uHeight & 0x80000000u) != 0; | |
8608 v26 = (unsigned __int16 *)v13; | |
8609 if ( !(v15 | v14) ) | |
8610 { | |
8611 v16 = pTex->uWidth; | |
8612 v27 = 1; | |
8613 do | |
8614 { | |
8615 pDestb = 0; | |
8616 if ( v16 > 0 ) | |
8617 { | |
8618 do | |
8619 { | |
8620 v17 = v16 * v27; | |
8621 v18 = v28 * v16; | |
8622 v19 = pTex->pPixels; | |
8623 v20 = pDestb + 2 * v18; | |
8624 v21 = (int)&v19[2 * (pDestb + v17)]; | |
8625 v22 = (int)&v19[2 * v20]; | |
8626 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
8627 LOWORD(v21) = *(unsigned short *)v21; | |
8628 v23 = pDestb++ + v18; | |
8629 v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
8630 v16 = pTex->uWidth; | |
8631 } | |
8632 while (pDestb < pTex->uWidth); | |
8633 } | |
8634 ++v28; | |
8635 v27 += 2; | |
8636 } | |
8637 while ( v28 < (signed int)pTex->uHeight ); | |
8638 } | |
8639 delete [] pTex->pPixels; | |
8640 pTex->pPixels = v26; | |
8641 } | |
8642 return pTex; | |
8643 //result = pTex; | |
8644 // } | |
8645 // else | |
8646 // { | |
8647 //LABEL_8: | |
8648 // return nullptr; | |
8649 // } | |
8650 } | |
8651 | |
8652 //----- (0045271F) -------------------------------------------------------- | |
8653 bool RenderHWLContainer::Release() | |
8654 { | |
8655 __int32 v4; // eax@6 | |
8656 FILE *v5; // ST24_4@6 | |
8657 FILE *File; // [sp+4h] [bp-4h]@6 | |
8658 | |
1162 | 8659 if ( this->bDumpDebug) |
0 | 8660 { |
8661 File = fopen("logd3d.txt", "w"); | |
1162 | 8662 v4 = ftell(this->pFile); |
8663 v5 = this->pFile; | |
8664 this->uDataOffset = v4; | |
8665 fwrite(&this->uNumItems, 4u, 1u, v5); | |
8666 for (int i = 0; i < this->uNumItems; i++) | |
8667 { | |
8668 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
8669 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
8670 } | |
8671 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
8672 fseek(this->pFile, 4, 0); | |
8673 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
8674 fclose(this->pFile); | |
0 | 8675 fclose(File); |
8676 } | |
8677 else | |
8678 { | |
8679 fclose(this->pFile); | |
1162 | 8680 for (int i = 0; i < this->uNumItems; i++) |
8681 { | |
8682 free(this->pSpriteNames[i]); | |
0 | 8683 } |
8684 } | |
1093 | 8685 return true; |
0 | 8686 } |
8687 | |
8688 //----- (00452347) -------------------------------------------------------- | |
8689 RenderHWLContainer::RenderHWLContainer(): | |
8690 bDumpDebug(false) | |
8691 { | |
8692 this->pFile = 0; | |
8693 uSignature = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8694 this->uDataOffset = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8695 memset(&this->uNumItems, 0, 0x61A84u); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8696 this->uNumItems = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8697 this->field_61A94_scale_hwls_to_half = 0; |
0 | 8698 } |
8699 | |
8700 //----- (0045237F) -------------------------------------------------------- | |
8701 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
8702 { | |
8703 pFile = _wfopen(pFilename, L"rb"); | |
8704 if (!pFile) | |
8705 { | |
8706 Log::Warning(L"Failed to open file: %s", pFilename); | |
8707 return false; | |
8708 } | |
8709 | |
8710 fread(&uSignature, 1, 4, pFile); | |
8711 if (uSignature != 'TD3D') | |
8712 { | |
8713 Log::Warning(L"Invalid format: %s", pFilename); | |
8714 return false; | |
8715 } | |
8716 | |
8717 fread(&uDataOffset, 4, 1, pFile); | |
8718 fseek(pFile, uDataOffset, SEEK_SET); | |
8719 fread(&uNumItems, 4, 1, pFile); | |
8720 | |
8721 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
8722 for (uint i = 0; i < uNumItems; ++i) | |
8723 { | |
8724 pSpriteNames[i] = new char[20]; | |
8725 fread(pSpriteNames[i], 1, 20, pFile); | |
8726 } | |
8727 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
8728 | |
8729 return true; | |
8730 } | |
8731 | |
8732 //----- (004A1C1E) -------------------------------------------------------- | |
8733 void DoRenderBillboards_D3D() | |
8734 { | |
186 | 8735 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
8736 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8737 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8738 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8739 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8740 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8741 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8742 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8743 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8744 { |
1390 | 8745 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; |
8746 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
8747 } | |
8748 p->pQuads[0].pos.x = 10; | |
8749 p->pQuads[0].pos.y = 10; | |
8750 | |
8751 p->pQuads[1].pos.x = 10; | |
8752 p->pQuads[1].pos.y = 200; | |
8753 | |
8754 p->pQuads[2].pos.x = 100; | |
8755 p->pQuads[2].pos.y = 200; | |
8756 | |
8757 p->pQuads[3].pos.x = 100; | |
8758 p->pQuads[3].pos.y = 10; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8759 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8760 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8761 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8762 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8763 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8764 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8765 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8766 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8767 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8768 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8769 }*/ |
0 | 8770 |
8771 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) | |
8772 { | |
101 | 8773 auto p = &pRenderer->pBillboardRenderListD3D[i]; |
0 | 8774 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8775 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
0 | 8776 SetBillboardBlendOptions(p->uOpacity); |
8777 | |
101 | 8778 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8779 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8780 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8781 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8782 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 8783 } |
8784 | |
8785 if (pRenderer->bFogEnabled) | |
8786 { | |
8787 pRenderer->bFogEnabled = false; | |
186 | 8788 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 8789 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
8790 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8791 } | |
186 | 8792 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
8793 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8794 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8795 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8796 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8797 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8798 } |
8799 | |
8800 //----- (004A1DA8) -------------------------------------------------------- | |
8801 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
8802 { | |
8803 switch (a1) | |
8804 { | |
8805 case RenderBillboardD3D::Transparent: | |
8806 { | |
8807 if (pRenderer->bFogEnabled) | |
8808 { | |
8809 pRenderer->bFogEnabled = false; | |
186 | 8810 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 8811 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
8812 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8813 } | |
8814 | |
186 | 8815 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); |
8816 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
8817 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8818 } |
8819 break; | |
8820 | |
8821 case RenderBillboardD3D::Opaque_1: | |
8822 case RenderBillboardD3D::Opaque_2: | |
8823 case RenderBillboardD3D::Opaque_3: | |
8824 { | |
8825 if (pRenderer->bUsingSpecular) | |
8826 { | |
8827 if (!pRenderer->bFogEnabled) | |
8828 { | |
8829 pRenderer->bFogEnabled = true; | |
186 | 8830 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
8831 } | |
8832 } | |
8833 | |
8834 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8835 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8836 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 8837 } |
8838 break; | |
8839 | |
8840 default: | |
8841 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8842 assert(false); |
0 | 8843 break; |
8844 } | |
8845 } | |
1297 | 8846 //----- (0040DF3D) -------------------------------------------------------- |
8847 void __cdecl CallRenderPresent() | |
8848 { | |
8849 pRenderer->Present(); | |
8850 } | |
1390 | 8851 |
8852 | |
8853 | |
8854 //----- (0044EC20) -------------------------------------------------------- | |
8855 /*bool RenderD3D::DoesRaiseExceptions() | |
8856 { | |
8857 return true; | |
8858 }*/ |