Mercurial > mm7
annotate Render.cpp @ 1641:466c5e15f524
Excess wrapper (IndoorLocation_drawstru) removed.
author | Nomad |
---|---|
date | Tue, 17 Sep 2013 18:39:32 +0200 |
parents | afc1c3514dd5 |
children | 8971dc85b8fb |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
4 |
1277 | 5 #include "Outdoor_stuff.h" |
1016 | 6 #include "VideoPlayer.h" |
7 #include "Sprites.h" | |
8 #include "Mouse.h" | |
9 #include "GammaControl.h" | |
10 #include "stru6.h" | |
1183 | 11 #include "GUIWindow.h" |
1016 | 12 #include "DecalBuilder.h" |
13 #include "ParticleEngine.h" | |
0 | 14 #include "Render.h" |
15 #include "Outdoor.h" | |
16 #include "Party.h" | |
17 #include "LOD.h" | |
18 #include "Viewport.h" | |
19 #include "Math.h" | |
20 #include "PaletteManager.h" | |
21 #include "Time.h" | |
22 #include "Game.h" | |
23 #include "LightmapBuilder.h" | |
24 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
25 #include "SpriteObject.h" |
0 | 26 #include "DecorationList.h" |
27 #include "OSInfo.h" | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
28 #include "Actor.h" |
0 | 29 #include "Log.h" |
179 | 30 #include "TileFrameTable.h" |
189 | 31 #include "texts.h" |
0 | 32 #include "mm7_data.h" |
860 | 33 #include "MM7.h" |
1262 | 34 #include "Lights.h" |
0 | 35 |
36 #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | |
37 #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | |
38 | |
39 struct IDirectDrawClipper *pDDrawClipper; | |
40 struct Render *pRenderer; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
41 struct RenderVertexD3D3 pVertices[50]; |
0 | 42 int uNumDecorationsDrawnThisFrame; // weak |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
43 RenderBillboard pBillboardRenderList[500]; |
0 | 44 unsigned int uNumBillboardsToDraw; |
45 int uNumSpritesDrawnThisFrame; // weak | |
46 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
47 RenderVertexSoft array_507D30[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
48 RenderVertexSoft array_50AC10[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
49 RenderVertexSoft array_73D150[20]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
50 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
51 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 52 |
53 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
54 | |
55 /* 384 */ | |
56 #pragma pack(push, 1) | |
57 struct PCXHeader_1 | |
58 { | |
59 char manufacturer; | |
60 char version; | |
61 char encoding; | |
62 char bpp; | |
63 __int16 left; | |
64 __int16 up; | |
65 __int16 right; | |
66 __int16 bottom; | |
67 __int16 hdpi; | |
68 __int16 vdpi; | |
69 }; | |
70 #pragma pack(pop) | |
71 | |
72 /* 385 */ | |
73 #pragma pack(push, 1) | |
74 struct PCXHeader_2 | |
75 { | |
76 char reserved; | |
77 char planes; | |
78 __int16 pitch; | |
79 __int16 palette_info; | |
80 }; | |
81 #pragma pack(pop) | |
82 | |
83 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
84 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
85 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
86 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
87 | |
88 //----- (0049E79F) -------------------------------------------------------- | |
1458 | 89 bool CheckTextureStages() |
0 | 90 { |
91 bool v0; // edi@1 | |
92 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
93 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
94 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
95 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
96 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
97 | |
98 v0 = false; | |
99 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); | |
100 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
101 | |
102 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
186 | 103 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 104 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u)); |
105 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
106 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
107 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
108 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u)); | |
109 | |
110 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
186 | 111 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
0 | 112 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u)); |
113 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u)); | |
114 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u)); | |
115 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u)); | |
116 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u)); | |
117 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u)); | |
118 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u)); | |
119 | |
120 if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
121 v0 = true; | |
122 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); | |
123 pTexture1->Release(); | |
124 pTexture2->Release(); | |
125 pSurface1->Release(); | |
126 pSurface2->Release(); | |
127 return v0; | |
128 } | |
129 | |
130 //----- (00440CB8) -------------------------------------------------------- | |
131 void Render::DrawBillboardList_BLV() | |
132 { | |
133 __int16 v2; // ax@3 | |
134 int v5; // eax@11 | |
135 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
136 | |
137 soft_billboard.uParentBillboardID = -1; | |
138 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; | |
139 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
140 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
141 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
142 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
143 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
144 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
145 | |
1637 | 146 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw; |
617 | 147 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 148 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
149 auto p = pBillboardRenderList + i; |
0 | 150 |
151 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
152 soft_billboard.uParentBillboardID = i; | |
153 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
154 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
|
155 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 156 soft_billboard.sZValue = p->sZValue; |
157 soft_billboard.uFlags = p->field_1E; | |
158 soft_billboard.uTintColor = p->uTintColor; | |
159 v2 = p->uHwSpriteID; | |
160 if ( v2 != -1 ) | |
161 { | |
162 if ( pRenderer->pRenderD3D ) | |
657 | 163 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 164 else |
165 { | |
657 | 166 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 167 if (p->field_1E & 0x0100) |
168 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
169 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
170 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
171 v5 = p->uHwSpriteID; | |
172 if ( v5 >= 0 ) | |
733 | 173 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 174 } |
175 } | |
176 } | |
177 } | |
178 | |
179 //----- (004A16A5) -------------------------------------------------------- | |
1458 | 180 bool AreRenderSurfacesOk() |
0 | 181 { |
182 char v0; // zf@4 | |
183 bool result; // eax@8 | |
184 | |
185 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
186 { | |
187 if ( !pRenderer->pBackBuffer4 ) | |
188 goto LABEL_9; | |
189 v0 = pRenderer->pFrontBuffer4 == 0; | |
190 } | |
191 else | |
192 { | |
193 if ( !pRenderer->pBackBuffer2 ) | |
194 goto LABEL_9; | |
195 v0 = pRenderer->pFrontBuffer2 == 0; | |
196 } | |
197 if ( !v0 ) | |
198 { | |
199 LOBYTE(result) = 1; | |
200 return result; | |
201 } | |
202 LABEL_9: | |
203 LOBYTE(result) = 0; | |
204 return result; | |
205 } | |
206 | |
1338 | 207 void Render::RenderTerrainD3D() // New function |
86 | 208 { |
209 int v6; // ecx@8 | |
1427 | 210 struct Polygon *pTilePolygon; // ebx@8 |
186 | 211 |
212 //warning: the game uses CW culling by default, ccw is incosistent | |
213 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
214 | |
1338 | 215 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ |
216 | |
217 //Ãåíåðàöèÿ ìåñòîïîëîæåíèÿ âåðøèí------------------------------------------------------------------------- | |
218 //ðåø¸òêà âåðøèí äåëèòñÿ íà äâå ÷àñòè îò -64 äî 0 è îò 0 äî 64 | |
219 // | |
220 // -64 X 0 64 | |
221 // --------------- 64 | |
222 // | | | | |
223 // | | | | |
224 // | | | | |
225 // 0|------+------| Z | |
226 // | | | | |
227 // | | | | |
228 // | | | | |
229 // --------------- | |
230 // -64 | |
231 | |
232 int blockScale = 512; | |
233 int heightScale = 32; | |
234 for (unsigned int z = 0; z < 128; ++z) | |
235 { | |
236 for (unsigned int x = 0; x < 128; ++x) | |
237 { | |
238 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
239 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
240 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 241 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
242 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 243 } |
244 } | |
1338 | 245 //-------------------------------------------------------------------------------------------------------------------- |
246 | |
247 // | |
1344 | 248 for (unsigned int z = 0; z < 127; ++z) |
249 { | |
250 for (unsigned int x = 0; x < 127; ++x) | |
1338 | 251 { |
1637 | 252 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; |
1427 | 253 pTilePolygon->flags = 0; |
254 pTilePolygon->field_32 = 0; | |
255 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
256 pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; | |
257 if (pTilePolygon->uTileBitmapID == 0xFFFF) | |
106 | 258 continue; |
186 | 259 |
1338 | 260 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1427 | 261 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); |
262 pTilePolygon->field_32 = 0; | |
263 pTilePolygon->field_59 = 1; | |
264 pTilePolygon->sTextureDeltaU = 0; | |
265 pTilePolygon->sTextureDeltaV = 0; | |
1338 | 266 // x,z x+1,z |
267 // .____________. | |
268 // | | | |
269 // | | | |
270 // | | | |
271 // | | | |
272 // | | | |
273 // .____________. | |
274 // x,z+1 x+1,z+1 | |
275 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
106 | 276 array_73D150[0].u = 0; |
277 array_73D150[0].v = 0; | |
1338 | 278 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z |
106 | 279 array_73D150[1].u = 1; |
280 array_73D150[1].v = 0; | |
1338 | 281 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 |
106 | 282 array_73D150[2].u = 1; |
283 array_73D150[2].v = 1; | |
1338 | 284 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 |
106 | 285 array_73D150[3].u = 0; |
286 array_73D150[3].v = 1; | |
1338 | 287 //v58 = 0; |
288 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
289 //pTile->field_32 |= 0x0001; | |
1427 | 290 pTilePolygon->pODMFace = nullptr; |
291 pTilePolygon->uNumVertices = 4; | |
292 pTilePolygon->field_59 = 5; | |
1338 | 293 |
294 //shading (çàòåíåíèå)---------------------------------------------------------------------------- | |
295 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
1424 | 296 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; |
638 | 297 assert(norm_idx < uNumTerrainNormals); |
298 | |
299 auto norm = pTerrainNormals + norm_idx; | |
1338 | 300 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
301 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
302 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
1427 | 303 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); |
1338 | 304 //----------------------------------------------------------------------------------------------- |
638 | 305 |
1637 | 306 ++pODMRenderParams->uNumPolygons; |
307 ++pODMRenderParams->field_44; | |
308 assert(pODMRenderParams->uNumPolygons < 20000); | |
265 | 309 |
1427 | 310 pTilePolygon->uBModelID = 0; |
311 pTilePolygon->uBModelFaceID = 0; | |
312 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
313 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
106 | 314 { |
315 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 316 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 317 } |
140 | 318 |
1338 | 319 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))---------------------- |
186 | 320 bool transparent = false; |
1427 | 321 if ( !( pTilePolygon->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable |
322 { | |
323 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id) | |
1338 | 324 { |
325 //transparent = false; | |
326 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
327 } | |
328 else | |
329 { | |
1427 | 330 v6 = pTilePolygon->uTileBitmapID; |
331 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) ) | |
1338 | 332 transparent = true; |
333 } | |
179 | 334 |
140 | 335 assert(v6 < 1000); // many random crashes here |
186 | 336 |
337 // for all shore tiles - draw a tile water under them since they're half-empty | |
1427 | 338 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX |
339 pTilePolygon->DrawBorderTiles(); | |
340 | |
341 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1338 | 342 } |
343 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû | |
344 //pTile->DrawBorderTiles(); | |
345 //-------------------------------------------------------------------------------------------------------------------------------- | |
186 | 346 |
1637 | 347 --pODMRenderParams->uNumPolygons; |
348 --pODMRenderParams->field_44; | |
106 | 349 } |
350 } | |
351 } | |
0 | 352 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
353 |
0 | 354 |
355 //----- (0047BACF) -------------------------------------------------------- | |
356 void Render::TransformBillboardsAndSetPalettesODM() | |
357 { | |
142 | 358 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
359 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
360 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
361 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
362 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
363 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
364 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
365 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
366 //int v8; // ebx@4 |
0 | 367 unsigned __int16 *v9; // eax@7 |
368 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
369 //DWORD v11; // eax@13 |
0 | 370 int v12; // eax@13 |
371 int v13; // eax@14 | |
372 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
373 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 374 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
375 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 376 int v18; // [sp+60h] [bp-4h]@13 |
377 | |
378 billboard.uParentBillboardID = -1; | |
379 billboard.pTarget = pRenderer->pTargetSurface; | |
380 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
381 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 382 billboard.uViewportX = pViewport->uViewportTL_X; |
383 billboard.uViewportY = pViewport->uViewportTL_Y; | |
384 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
385 billboard.uViewportW = pViewport->uViewportBR_Y; | |
1637 | 386 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw; |
142 | 387 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
388 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 389 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
390 auto pBillboard = pBillboardRenderList + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
391 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
392 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
393 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
394 billboard.uParentBillboardID = i; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
395 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
396 billboard.uTintColor = pBillboard->uTintColor; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
397 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
398 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
399 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
400 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
401 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
402 if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
403 //if (pRenderer->pRenderD3D) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
404 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
405 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
657 | 406 pBillboard->dimming_level, pBillboard); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
407 /*else |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
408 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
409 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
410 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
411 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 412 if ( *(v1 - 10) & 2 ) |
413 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
414 else | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
415 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 416 v10 = (*(v1 - 9) & 1) == 0; |
417 billboard.pPalette = v9; | |
418 if ( !v10 ) | |
419 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
420 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
421 { | |
323 | 422 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 423 v15 = abs(v12); |
424 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
425 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
426 } | |
427 v13 = *((short *)v1 - 8); | |
428 if ( v13 >= 0 ) | |
733 | 429 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
430 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
431 } |
0 | 432 } |
433 } | |
434 | |
435 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
436 void Render::DrawSpriteObjects_ODM() |
0 | 437 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
438 //char *v0; // edi@2 |
430 | 439 //ObjectDesc *v1; // ebx@4 |
0 | 440 __int16 v2; // cx@5 |
441 RenderBillboard *v3; // esi@10 | |
442 SpriteFrame *v4; // eax@10 | |
430 | 443 //SpriteFrame *v5; // ebx@10 |
0 | 444 unsigned int v6; // eax@10 |
430 | 445 //int v7; // ecx@10 |
446 //int v8; // edx@10 | |
0 | 447 int v9; // ecx@10 |
448 unsigned __int16 v10; // ax@10 | |
430 | 449 //int *v11; // eax@14 |
0 | 450 int v12; // eax@22 |
451 int v13; // ST3C_4@23 | |
452 int v14; // eax@23 | |
453 int v15; // ecx@23 | |
454 int v16; // ebx@23 | |
455 int v17; // ecx@25 | |
456 int v18; // eax@25 | |
457 int v19; // ST40_4@26 | |
458 int v20; // ecx@26 | |
459 int v21; // ST44_4@28 | |
460 int v22; // ST3C_4@29 | |
461 signed __int64 v23; // qtt@30 | |
462 int v24; // ebx@30 | |
463 int v25; // ST3C_4@30 | |
464 int v26; // eax@31 | |
465 char v27; // zf@31 | |
430 | 466 //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 |
467 //__int16 a5; // [sp+10h] [bp-30h]@10 | |
0 | 468 int v30; // [sp+14h] [bp-2Ch]@23 |
469 int v31; // [sp+14h] [bp-2Ch]@29 | |
470 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
471 int v33; // [sp+18h] [bp-28h]@23 | |
472 int v34; // [sp+18h] [bp-28h]@26 | |
473 int v35; // [sp+18h] [bp-28h]@30 | |
474 int v36; // [sp+1Ch] [bp-24h]@10 | |
475 int v37; // [sp+1Ch] [bp-24h]@23 | |
476 int a6; // [sp+20h] [bp-20h]@10 | |
477 int a6a; // [sp+20h] [bp-20h]@23 | |
478 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
479 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 480 int v42; // [sp+2Ch] [bp-14h]@23 |
481 int y; // [sp+30h] [bp-10h]@10 | |
482 int x; // [sp+34h] [bp-Ch]@10 | |
483 int z; // [sp+38h] [bp-8h]@10 | |
484 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
485 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
486 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
487 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
|
488 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
489 auto object = &pSpriteObjects[i]; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
490 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
491 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
492 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
493 //{ |
430 | 494 if (!object->uObjectDescID) // item probably pciked up |
495 continue; | |
496 | |
497 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
498 auto object_desc = pObjectList->pObjects + object->uObjectDescID; | |
499 if (object_desc->NoSprite()) | |
500 continue; | |
501 | |
502 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
503 //if ( !(v1->uFlags & 1) ) | |
504 //{ | |
505 //v2 = *((short *)v0 - 14) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
506 v2 = object->uType; |
430 | 507 if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) |
508 { | |
509 //a5 = *(short *)v0; | |
510 x = object->vPosition.x; | |
511 y = object->vPosition.y; | |
512 z = object->vPosition.z; | |
513 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; | |
514 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
515 //v5 = v4; | |
516 //v28 = v4; | |
517 v36 = v4->uFlags; | |
518 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
519 v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
430 | 520 //LOWORD(v7) = object->uFacing; |
521 //v8 = v36; | |
522 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
523 v10 = v4->pHwSpriteIDs[v9]; | |
0 | 524 v3->uHwSpriteID = v10; |
525 if ( v36 & 0x20 ) | |
526 { | |
430 | 527 //v8 = v36; |
528 z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
0 | 529 } |
530 v46 = 0; | |
430 | 531 if ( v36 & 2 ) |
0 | 532 v46 = 2; |
430 | 533 //v11 = (int *)(256 << v9); |
534 if ( (256 << v9) & v36 ) | |
0 | 535 v46 |= 4u; |
430 | 536 if ( v36 & 0x40000 ) |
0 | 537 v46 |= 0x40u; |
430 | 538 if ( v36 & 0x20000 ) |
0 | 539 LOBYTE(v46) = v46 | 0x80; |
540 if ( a6 ) | |
541 { | |
430 | 542 //LOBYTE(v11) = byte_4E94D3; |
543 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
0 | 544 } |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
545 v12 = (x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
546 if (pGame->pIndoorCameraD3D->sRotationX) |
0 | 547 { |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
548 v13 = (y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
1637 | 549 v30 = ((unsigned __int64)(v12 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) |
550 + ((unsigned __int64)(v13 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16); | |
551 v37 = (unsigned __int64)(v12 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; | |
552 a6a = (unsigned __int64)(v13 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
553 v33 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
1637 | 554 v14 = (unsigned __int64)(v30 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16; |
555 v15 = (unsigned __int64)(v33 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16; | |
0 | 556 v16 = v15 + v14; |
557 v42 = v15 + v14; | |
1637 | 558 if ( v15 + v14 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 ) |
0 | 559 { |
560 v17 = a6a - v37; | |
561 v40 = a6a - v37; | |
1637 | 562 v18 = ((unsigned __int64)(v33 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16) |
563 - ((unsigned __int64)(v30 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16); | |
0 | 564 goto LABEL_29; |
565 } | |
566 } | |
567 else | |
568 { | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
569 v34 = (y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
1637 | 570 v19 = (unsigned __int64)(v12 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; |
571 v20 = (unsigned __int64)(v34 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; | |
0 | 572 v16 = v20 + v19; |
573 v42 = v20 + v19; | |
1637 | 574 if ( v20 + v19 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 ) |
0 | 575 { |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
576 v21 = (unsigned __int64)(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16) * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; |
1637 | 577 v17 = ((unsigned __int64)(v34 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - v21; |
578 v40 = ((unsigned __int64)(v34 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - v21; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
579 v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
0 | 580 LABEL_29: |
581 v31 = v18; | |
582 v22 = abs(v17); | |
583 if ( abs(v16) >= v22 ) | |
584 { | |
585 LODWORD(v23) = 0; | |
1637 | 586 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); |
0 | 587 v24 = v23 / v42; |
588 v25 = v23 / v42; | |
589 LODWORD(v23) = 0; | |
1637 | 590 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); |
430 | 591 v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); |
592 v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
593 | |
594 //if (::uNumBillboardsToDraw >= 500) | |
595 // return; | |
596 assert(::uNumBillboardsToDraw < 500); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
597 ++::uNumBillboardsToDraw; |
0 | 598 ++uNumSpritesDrawnThisFrame; |
430 | 599 |
600 object->uAttributes |= 1; | |
601 v3->uPalette = v4->uPaletteIndex; | |
602 v3->uIndoorSectorID = object->uSectorID; | |
603 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
604 v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
605 v3->pSpriteFrame = v4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
606 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 607 v3->field_1E = v46; |
430 | 608 v3->world_x = x; |
609 v3->world_y = y; | |
610 v3->world_z = z; | |
0 | 611 v3->uScreenSpaceX = v35; |
612 v3->uScreenSpaceY = v32; | |
613 HIWORD(v26) = HIWORD(v42); | |
614 LOWORD(v26) = 0; | |
430 | 615 v27 = (object->uAttributes & 0x20) == 0; |
862 | 616 v3->sZValue = v26 + (PID(OBJECT_Item,i)); |
657 | 617 v3->dimming_level = 0; |
0 | 618 v3->uTintColor = 0; |
619 if ( !v27 ) | |
620 { | |
621 if ( !pRenderer->pRenderD3D ) | |
622 v3->sZValue = 0; | |
623 } | |
624 } | |
625 goto LABEL_34; | |
626 } | |
627 } | |
628 } | |
430 | 629 //} |
0 | 630 LABEL_34: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
631 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
632 //++v41; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
633 //v0 += 112; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
634 //} |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
635 //while ( v41 < (signed int)uNumSpriteObjects ); |
0 | 636 } |
637 } | |
638 | |
639 //----- (0049D9BC) -------------------------------------------------------- | |
640 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
641 { | |
642 size_t v4; // eax@1 | |
643 size_t v5; // eax@1 | |
644 IUnknown *v6; // eax@10 | |
645 size_t v7; // eax@13 | |
646 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
647 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
648 int v11; // [sp+430h] [bp-CCh]@16 | |
649 int v12; // [sp+434h] [bp-C8h]@16 | |
650 int v13; // [sp+438h] [bp-C4h]@16 | |
651 int v14; // [sp+474h] [bp-88h]@16*/ | |
652 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
653 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
654 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
655 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
656 int v19; // [sp+4C8h] [bp-34h]@16 | |
657 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
658 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
659 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
660 | |
661 v4 = strlen(lpDriverName); | |
662 v20.pDriverName = new char[v4 + 1]; | |
663 v5 = strlen(lpDevDesc); | |
664 v20.pDeviceDesc = new char[v5 + 1]; | |
665 strcpy(v20.pDriverName, lpDriverName); | |
666 strcpy(v20.pDeviceDesc, lpDevDesc); | |
667 if ( lpGUID ) | |
668 { | |
669 v20.pGUID = new GUID; | |
670 memcpy(v20.pGUID, lpGUID, 0x10u); | |
671 } | |
672 else | |
673 { | |
674 v20.pGUID = 0; | |
675 } | |
676 | |
677 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
678 { | |
679 delete [] v20.pDriverName; | |
680 delete [] v20.pDeviceDesc; | |
681 if ( v20.pGUID ) | |
682 delete v20.pGUID; | |
683 } | |
684 else | |
685 { | |
686 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
687 { | |
688 delete [] v20.pDriverName; | |
689 delete [] v20.pDeviceDesc; | |
690 if ( v20.pGUID ) | |
691 delete v20.pGUID; | |
692 v6 = (IUnknown *)pDirectDraw; | |
693 } | |
694 else | |
695 { | |
696 pDirectDraw->Release(); | |
697 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
698 { | |
699 v20.pDDraw4DevDesc = 0; | |
700 } | |
701 else | |
702 { | |
703 v7 = strlen(ddDevId.szDescription); | |
704 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
705 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
706 } | |
707 memset(&ddsCaps, 0, 0x10u); | |
708 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
709 &ddsCaps, | |
710 (LPDWORD)&v20.uVideoMem, | |
711 (LPDWORD)&uFreeVideoMem))) | |
712 v20.uVideoMem = 0; | |
713 memset(&v10, 0, 0x7Cu); | |
714 v10.dwSize = 124; | |
715 v10.dwFlags = 6; | |
716 v10.dwHeight = 640; | |
717 v10.dwWidth = 480; | |
718 v10.ddpfPixelFormat.dwSize = 32; | |
719 | |
720 v19 = 0; | |
721 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
722 0, | |
723 0, | |
724 &v19, | |
725 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
726 || !v19 | |
727 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
728 { | |
729 delete [] v20.pDriverName; | |
730 delete [] v20.pDeviceDesc; | |
731 if ( v20.pDDraw4DevDesc ) | |
732 free(v20.pDDraw4DevDesc); | |
733 if ( v20.pGUID ) | |
734 delete v20.pGUID; | |
735 v6 = (IUnknown *)pDirectDraw4; | |
736 } | |
737 else | |
738 { | |
739 aux.pInfo = pOut; | |
740 aux.ptr_4 = &v20; | |
741 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
742 delete [] v20.pDriverName; | |
743 delete [] v20.pDeviceDesc; | |
744 if ( v20.pDDraw4DevDesc ) | |
745 free(v20.pDDraw4DevDesc); | |
746 if ( v20.pGUID ) | |
747 delete v20.pGUID; | |
748 pDirectDraw4->Release(); | |
749 v6 = (IUnknown *)pDirect3D3; | |
750 pDirectDraw4 = 0; | |
751 } | |
752 } | |
753 v6->Release(); | |
754 } | |
755 return 1; | |
756 } | |
757 | |
758 //----- (0049D784) -------------------------------------------------------- | |
759 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
760 { | |
761 int v6; // eax@1 | |
762 signed int v7; // edi@1 | |
763 signed int v8; // edi@14 | |
764 size_t v9; // eax@30 | |
765 size_t v10; // eax@30 | |
766 size_t v11; // eax@30 | |
767 size_t v12; // eax@30 | |
768 size_t v13; // eax@30 | |
769 | |
770 v6 = pHWDesc->dwFlags; | |
771 v7 = -1; | |
772 if ( v6 ) | |
773 { | |
774 if ( !a6->ptr_4->pGUID ) | |
775 v7 = 0; | |
776 if ( v6 && a6->ptr_4->pGUID ) | |
777 v7 = 1; | |
778 } | |
779 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
780 v7 = 2; | |
781 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
782 v7 = 3; | |
783 if ( v7 != -1 ) | |
784 { | |
785 v8 = v7; | |
786 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
787 a6->pInfo[v8].uCaps = 0; | |
788 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
789 a6->pInfo[v8].uCaps |= 2u; | |
790 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
791 a6->pInfo[v8].uCaps |= 4u; | |
792 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
793 a6->pInfo[v8].uCaps |= 8u; | |
794 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
795 a6->pInfo[v8].uCaps |= 0x10u; | |
796 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
797 a6->pInfo[v8].uCaps |= 0x20u; | |
798 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
799 a6->pInfo[v8].uCaps |= 0x40u; | |
800 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
801 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
802 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
803 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
804 v9 = strlen(lpDeviceName); | |
805 a6->pInfo[v8].pName = new char[v9 + 1]; | |
806 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
807 v10 = strlen(lpDeviceDesc); | |
808 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
809 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
1631 | 810 a6->pInfo[v8].pGUID = new GUID; |
0 | 811 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); |
812 v11 = strlen(a6->ptr_4->pDriverName); | |
813 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
814 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
815 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
816 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
817 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
818 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
819 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
820 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
821 if ( a6->ptr_4->pGUID ) | |
822 { | |
823 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
824 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
825 } | |
826 else | |
827 { | |
828 a6->pInfo[v8].pDirectDrawGUID = 0; | |
829 } | |
830 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
831 } | |
832 return 1; | |
833 } | |
834 | |
835 //----- (0049D75C) -------------------------------------------------------- | |
836 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
837 { | |
838 HRESULT result; // eax@3 | |
839 | |
840 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
841 { | |
842 *a2 = 1; | |
843 result = 0; | |
844 } | |
845 else | |
846 { | |
847 result = 1; | |
848 } | |
849 return result; | |
850 } | |
851 | |
852 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
853 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
854 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
855 //char *v0; // esi@2 |
639 | 856 //DecorationDesc *v1; // ebx@6 |
0 | 857 __int16 v2; // ax@6 |
858 double v3; // st7@7 | |
639 | 859 //int v4; // eax@9 |
860 //int v5; // edx@9 | |
0 | 861 unsigned int v6; // edi@9 |
862 int v7; // eax@9 | |
863 SpriteFrame *v8; // eax@9 | |
635 | 864 //SpriteFrame *v9; // edi@9 |
0 | 865 unsigned __int16 *v10; // eax@9 |
866 int v11; // ecx@9 | |
867 int v12; // eax@9 | |
868 int v13; // ecx@9 | |
869 int v14; // ecx@20 | |
870 char v15; // dl@20 | |
871 signed int v16; // eax@20 | |
872 int v17; // eax@23 | |
873 int v18; // ecx@24 | |
874 int v19; // eax@24 | |
875 int v20; // ecx@24 | |
876 int v21; // ebx@26 | |
877 int v22; // eax@26 | |
878 int v23; // eax@30 | |
879 signed __int64 v24; // qtt@31 | |
880 int v25; // ebx@31 | |
881 int v26; // ecx@32 | |
882 RenderBillboard *v27; // eax@37 | |
883 __int16 v28; // dx@37 | |
884 __int16 v29; // cx@37 | |
885 int v30; // ecx@37 | |
886 int v31; // ebx@37 | |
619 | 887 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
639 | 888 //int x; // [sp+74h] [bp-30h]@9 |
889 //int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
890 //int v35; // [sp+7Ch] [bp-28h]@1 |
639 | 891 //int v36; // [sp+80h] [bp-24h]@9 |
0 | 892 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
893 int v38; // [sp+88h] [bp-1Ch]@9 | |
894 int v39; // [sp+8Ch] [bp-18h]@24 | |
895 int v40; // [sp+90h] [bp-14h]@24 | |
896 int v41; // [sp+94h] [bp-10h]@24 | |
897 int v42; // [sp+98h] [bp-Ch]@9 | |
898 int a5; // [sp+9Ch] [bp-8h]@9 | |
899 int b; // [sp+A0h] [bp-4h]@22 | |
900 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
901 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
902 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
903 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
904 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
905 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
906 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
907 { |
1202 | 908 auto decor = &pLevelDecorations[i]; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
909 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
910 |
1491
6d21ef91cb2d
Rename LevelDecoration::_47A825 to LevelDecoration::IsObeliskChestActive().
yoctozepto
parents:
1490
diff
changeset
|
911 if ((!(decor->uFlags & LEVEL_DECORATION_OBELISK_CHEST) || decor->IsObeliskChestActive()) && !(decor->uFlags & LEVEL_DECORATION_INVISIBLE)) |
1490 | 912 { |
913 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
914 auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; | |
915 v2 = decor_desc->uFlags; | |
916 if ( (char)v2 >= 0 ) | |
917 { | |
918 if ( !(v2 & 0x22) ) | |
0 | 919 { |
1490 | 920 //v4 = decor->vPosition.x; |
921 //v5 = decor->vPosition.z; | |
922 v6 = pMiscTimer->uTotalGameTimeElapsed; | |
923 //y = decor->vPosition.y; | |
924 //x = decor->vPosition.x; | |
925 //v36 = decor->vPosition.z; | |
926 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
927 | |
928 | |
929 #pragma region "New: seasons change" | |
930 extern bool change_seasons; | |
931 if (change_seasons) | |
932 switch (pParty->uCurrentMonth) | |
933 { | |
934 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
935 case 11: case 0: case 1: // winter | |
936 switch (decor_desc->uSpriteID) | |
937 { | |
938 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
939 case 548: // flower10 | |
940 case 547: // flower09 | |
941 case 541: // flower03 | |
942 case 539: continue; // flower01 | |
943 | |
944 case 483: // tree01 | |
945 case 486: // tree04 | |
946 case 492: // tree10 | |
947 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); | |
948 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
949 break; | |
950 | |
951 default: | |
952 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
953 } | |
954 break; | |
955 | |
956 case 2: case 3: case 4: // spring | |
957 switch (decor_desc->uSpriteID) | |
958 { | |
959 } | |
960 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
961 break; | |
962 | |
963 case 8: case 9: case 10: // autumn | |
964 switch (decor_desc->uSpriteID) | |
965 { | |
966 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
967 case 548: // flower10 | |
968 case 547: // flower09 | |
969 case 541: // flower03 | |
970 case 539: continue; // flower01 | |
971 | |
972 case 483: // tree01 | |
973 case 486: // tree04 | |
974 case 492: // tree10 | |
975 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); | |
976 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
977 break; | |
978 | |
979 default: | |
980 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
981 } | |
982 break; | |
983 | |
984 case 5: case 6: case 7: // summer | |
985 //all green by default | |
986 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
987 break; | |
988 | |
989 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
990 } | |
991 else | |
992 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
993 #pragma endregion | |
994 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
995 | |
996 //v9 = v8; | |
997 v42 = v8->uFlags; | |
998 a5 = v8->uGlowRadius; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
999 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1000 decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
1490 | 1001 v11 = *((int *)v0 + 2); |
1002 v37 = v10; | |
1003 v12 = v42; | |
1004 v38 = 0; | |
1005 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
1006 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
1007 + v11 | |
1008 - (signed int)v37) >> 8) & 7; | |
1009 v37 = (unsigned __int16 *)v13; | |
1010 if ( v42 & 2 ) | |
1011 v38 = 2; | |
1012 if ( (256 << v13) & v42 ) | |
1013 v38 |= 4u; | |
1014 if ( v12 & 0x40000 ) | |
1015 v38 |= 0x40u; | |
1016 if ( v12 & 0x20000 ) | |
1017 LOBYTE(v38) = v38 | 0x80; | |
1018 if ( a5 ) | |
0 | 1019 { |
1490 | 1020 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) |
0 | 1021 { |
1490 | 1022 v14 = decor_desc->uColoredLightRed; |
1023 v15 = decor_desc->uColoredLightGreen; | |
1024 v16 = decor_desc->uColoredLightBlue; | |
0 | 1025 } |
1026 else | |
1027 { | |
1490 | 1028 v16 = 255; |
1029 v14 = 255; | |
1030 v15 = 255; | |
1031 } | |
1032 b = v16; | |
1033 pStationaryLightsStack->AddLight( | |
1034 decor->vPosition.x, | |
1035 decor->vPosition.y, | |
1036 decor->vPosition.z + decor_desc->uDecorationHeight / 2, | |
1037 a5, | |
1038 v14, | |
1039 v15, | |
1040 v16, | |
1041 byte_4E94D0); | |
1042 } | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1043 v17 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1044 if (pGame->pIndoorCameraD3D->sRotationX) |
1490 | 1045 { |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1046 v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
1637 | 1047 v18 = ((unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) |
1048 + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16); | |
1490 | 1049 v42 = v18; |
1637 | 1050 b = (unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; |
1051 a5 = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1052 v40 = (decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
1637 | 1053 v41 = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16; |
1054 v19 = (unsigned __int64)(v18 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16; | |
1055 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16); | |
1056 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16); | |
1057 if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) | |
1490 | 1058 { |
1059 v21 = a5 - b; | |
1060 v41 = a5 - b; | |
1637 | 1061 a5 = (unsigned __int64)(v42 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16; |
1062 b = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16; | |
1063 v22 = ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16) - a5; | |
1490 | 1064 LABEL_30: |
1065 v42 = v22; | |
1066 v40 = 2 * abs(v20); | |
1067 v23 = abs(v21); | |
1068 if ( v40 >= v23 ) | |
0 | 1069 { |
1490 | 1070 LODWORD(v24) = 0; |
1637 | 1071 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
1490 | 1072 a5 = v24 / v39; |
1073 v25 = pViewport->uScreenCenterX | |
1074 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
1075 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
1076 v41 = v24 / v39; | |
1077 v40 = pViewport->uScreenCenterY | |
1078 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
1079 v42 = v8->scale; | |
1080 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; | |
1081 v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; | |
1082 if ( pRenderer->pRenderD3D ) | |
1083 { | |
1084 v26 = v41; | |
1085 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
1086 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
1087 } | |
1088 else | |
1089 { | |
1090 v26 = v41; | |
1091 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
1092 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
1093 } | |
1094 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) | |
1095 { | |
1096 if (::uNumBillboardsToDraw >= 500) | |
1097 return; | |
1098 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; | |
1099 ++uNumDecorationsDrawnThisFrame; | |
1100 v27->uHwSpriteID = *v37; | |
1101 v28 = v8->uPaletteIndex; | |
1102 v27->_screenspace_x_scaler_packedfloat = v26; | |
1103 v27->_screenspace_y_scaler_packedfloat = v26; | |
1104 v29 = v38; | |
1105 v27->uScreenSpaceX = v25; | |
1106 HIBYTE(v29) |= 2u; | |
1107 v27->uPalette = v28; | |
1108 v27->field_1E = v29; | |
1109 v27->world_x = decor->vPosition.x; | |
1110 v27->world_y = decor->vPosition.y; | |
1111 v27->world_z = decor->vPosition.z; | |
1112 v27->uScreenSpaceY = v40; | |
1113 HIWORD(v30) = HIWORD(v39); | |
1114 v31 = PID(OBJECT_Decoration,i); | |
1115 LOWORD(v30) = 0; | |
1116 v27->uIndoorSectorID = 0; | |
1117 v27->sZValue = v30 + v31; | |
1118 v27->dimming_level = 0; | |
1119 v27->pSpriteFrame = v8; | |
1120 v27->uTintColor = 0; | |
1121 } | |
0 | 1122 } |
1490 | 1123 goto LABEL_38; |
1124 } | |
1125 } | |
1126 else | |
1127 { | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1128 v42 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1129 v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
1637 | 1130 b = (unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; |
1131 a5 = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; | |
1132 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16); | |
1133 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16); | |
1134 if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) | |
1490 | 1135 { |
1637 | 1136 a5 = (unsigned __int64)(v42 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; |
1137 b = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; | |
1138 v21 = ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - a5; | |
1139 v41 = ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - a5; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1140 v22 = (decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
1490 | 1141 goto LABEL_30; |
0 | 1142 } |
1143 } | |
1144 } | |
1490 | 1145 } |
1146 else | |
1147 { | |
1148 memset(&local_0, 0, 0x68u); | |
1149 v3 = (double)*((signed int *)v0 - 1); | |
1150 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; | |
1151 local_0.uDiffuse = 0xFF3C1E; | |
1152 local_0.x = v3; | |
1153 local_0.y = (double)*(signed int *)v0; | |
1154 local_0.z = (double)*((signed int *)v0 + 1); | |
1155 local_0.r = 0.0; | |
1156 local_0.g = 0.0; | |
1157 local_0.b = 0.0; | |
1158 local_0.flt_28 = 1.0; | |
1159 local_0.timeToLive = (rand() & 0x80) + 128; | |
1160 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
1161 pGame->pParticleEngine->AddParticle(&local_0); | |
1162 } | |
1163 } | |
0 | 1164 LABEL_38: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1165 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1166 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1167 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1168 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1169 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 1170 } |
1171 | |
1172 //----- (0049D717) -------------------------------------------------------- | |
1173 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1174 { | |
1175 HRESULT v2; // esi@2 | |
1176 | |
1177 if ( Src->dwFlags & 0x400 | 0x2000 ) | |
1178 { | |
1179 v2 = 0; | |
1180 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
1181 goto LABEL_6; | |
1182 if ( !Dst->dwSize ) | |
1183 { | |
1184 v2 = 1; | |
1185 LABEL_6: | |
1186 memcpy(Dst, Src, 0x20u); | |
1187 return v2; | |
1188 } | |
1189 } | |
1190 return 1; | |
1191 } | |
1192 | |
1193 //----- (0049DC28) -------------------------------------------------------- | |
1194 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1195 { | |
1196 RenderD3D__DevInfo *v2; // eax@1 | |
1197 | |
1198 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1199 *pOutDevices = v2; | |
1200 memset(v2, 0, 0xA0u); | |
1201 DirectDrawEnumerateA((LPDDENUMCALLBACKA)RenderD3D__DeviceEnumerator, *pOutDevices); | |
1202 } | |
1203 | |
1204 //----- (0049DC58) -------------------------------------------------------- | |
1205 RenderD3D::RenderD3D() | |
1206 { | |
1207 RenderD3D *v1; // esi@1 | |
1208 | |
1209 v1 = this; | |
1210 this->pHost = 0; | |
1211 this->pDirect3D = 0; | |
1212 this->pUnk = 0; | |
1213 this->pBackBuffer = 0; | |
1214 this->pFrontBuffer = 0; | |
1215 this->pZBuffer = 0; | |
1216 this->pDevice = 0; | |
1217 this->pViewport = 0; | |
1218 this->field_40 = 1; | |
1219 this->field_44 = 10; | |
1220 GetAvailableDevices(&this->pAvailableDevices); | |
1221 } | |
1222 | |
1223 //----- (0049DC90) -------------------------------------------------------- | |
1224 void RenderD3D::Release() | |
1225 { | |
1226 RenderD3D *v1; // esi@1 | |
1227 IDirectDraw4 *v2; // eax@2 | |
1228 signed int v3; // edi@4 | |
1229 IDirect3DViewport3 *v4; // eax@22 | |
1230 IUnknown *v5; // eax@24 | |
1231 IDirectDrawSurface4 *v6; // eax@26 | |
1232 IDirect3DDevice3 *v7; // eax@28 | |
1233 IDirect3D3 *v8; // eax@30 | |
1234 IDirectDrawSurface4 *v9; // eax@32 | |
1235 IDirectDrawSurface4 *v10; // eax@34 | |
1236 IDirectDraw4 *v11; // eax@36 | |
1237 | |
1238 v1 = this; | |
1239 if ( !this->bWindowed ) | |
1240 { | |
1241 v2 = this->pHost; | |
1242 if ( v2 ) | |
1243 { | |
1244 v2->RestoreDisplayMode(); | |
1245 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
1246 v1->pHost->FlipToGDISurface(); | |
1247 } | |
1248 } | |
1249 v3 = 0; | |
1250 do | |
1251 { | |
1252 if ( v1->pAvailableDevices[v3].pDriverName ) | |
1253 { | |
1254 free(v1->pAvailableDevices[v3].pDriverName); | |
1255 v1->pAvailableDevices[v3].pDriverName = 0; | |
1256 } | |
1257 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
1258 { | |
1259 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
1260 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
1261 } | |
1262 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
1263 { | |
1264 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
1265 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
1266 } | |
1267 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
1268 { | |
1269 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
1270 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
1271 } | |
1272 if ( v1->pAvailableDevices[v3].pName ) | |
1273 { | |
1274 free(v1->pAvailableDevices[v3].pName); | |
1275 v1->pAvailableDevices[v3].pName = 0; | |
1276 } | |
1277 if ( v1->pAvailableDevices[v3].pDescription ) | |
1278 { | |
1279 free(v1->pAvailableDevices[v3].pDescription); | |
1280 v1->pAvailableDevices[v3].pDescription = 0; | |
1281 } | |
1282 if ( v1->pAvailableDevices[v3].pGUID ) | |
1283 { | |
1284 free(v1->pAvailableDevices[v3].pGUID); | |
1285 v1->pAvailableDevices[v3].pGUID = 0; | |
1286 } | |
1287 ++v3; | |
1288 } | |
1289 while ( v3 < 4 ); | |
1290 if ( v1->pAvailableDevices ) | |
1291 { | |
1292 free(v1->pAvailableDevices); | |
1293 v1->pAvailableDevices = 0; | |
1294 } | |
1295 v4 = v1->pViewport; | |
1296 if ( v4 ) | |
1297 { | |
1298 v4->Release(); | |
1299 v1->pViewport = 0; | |
1300 } | |
1301 v5 = v1->pUnk; | |
1302 if ( v5 ) | |
1303 { | |
1304 v5->Release(); | |
1305 v1->pUnk = 0; | |
1306 } | |
1307 v6 = v1->pZBuffer; | |
1308 if ( v6 ) | |
1309 { | |
1310 v6->Release(); | |
1311 v1->pZBuffer = 0; | |
1312 } | |
1313 v7 = v1->pDevice; | |
1314 if ( v7 ) | |
1315 { | |
1316 v7->Release(); | |
1317 v1->pDevice = 0; | |
1318 } | |
1319 v8 = v1->pDirect3D; | |
1320 if ( v8 ) | |
1321 { | |
1322 v8->Release(); | |
1323 v1->pDirect3D = 0; | |
1324 } | |
1325 v9 = v1->pBackBuffer; | |
1326 if ( v9 ) | |
1327 { | |
1328 v9->Release(); | |
1329 v1->pBackBuffer = 0; | |
1330 } | |
1331 v10 = v1->pFrontBuffer; | |
1332 if ( v10 ) | |
1333 { | |
1334 v10->Release(); | |
1335 v1->pFrontBuffer = 0; | |
1336 } | |
1337 v11 = v1->pHost; | |
1338 if ( v11 ) | |
1339 { | |
1340 v11->Release(); | |
1341 v1->pHost = 0; | |
1342 } | |
1343 } | |
1344 | |
1345 //----- (0049DE14) -------------------------------------------------------- | |
1346 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | |
1347 { | |
1348 //IDirectDraw4 *v8; // eax@12 | |
1349 //IDirectDraw4 *v9; // eax@16 | |
1350 //IDirectDraw4 *v10; // eax@20 | |
1351 //IDirectDraw4 *v13; // eax@35 | |
1352 const char *v23; // [sp-4h] [bp-DCh]@9 | |
1353 const char *v24; // [sp-4h] [bp-DCh]@13 | |
1354 const char *v25; // [sp-4h] [bp-DCh]@19 | |
1355 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1356 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1357 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1358 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1359 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
1360 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1361 | |
1362 this->bWindowed = bWindowed; | |
1363 this->hWindow = hWnd; | |
1364 | |
1365 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
1366 { | |
1367 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1368 return 0; | |
1369 } | |
1370 | |
1371 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1372 { | |
1373 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1374 if (lpDD) | |
1375 lpDD->Release(); | |
1376 return 0; | |
1377 } | |
1378 lpDD->Release(); | |
1379 lpDD = 0; | |
1380 | |
1381 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1382 { | |
1383 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
1384 { | |
1385 v23 = "Init - Failed to set cooperative level.\n"; | |
1386 sprintf(pErrorMessage, v23); | |
1387 LABEL_65: | |
1388 if (pHost) | |
1389 { | |
1390 pHost->Release(); | |
1391 pHost = 0; | |
1392 } | |
1393 return 0; | |
1394 } | |
1395 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1396 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1397 ddsd2.dwFlags = DDSD_CAPS; | |
1398 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
1399 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1400 { | |
1401 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1402 pHost->GetDisplayMode(&ddsd2); | |
1403 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
1404 { | |
1405 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
1406 goto LABEL_14; | |
1407 } | |
1408 | |
1409 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
1410 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
1411 ddsd2.dwWidth = 640; | |
1412 ddsd2.dwHeight = 480; | |
1413 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | |
1414 { | |
1415 v24 = "Init - Failed to create back buffer.\n"; | |
1416 LABEL_14: | |
1417 sprintf(pErrorMessage, v24); | |
1418 if (pFrontBuffer) | |
1419 { | |
1420 pFrontBuffer->Release(); | |
1421 pFrontBuffer = 0; | |
1422 } | |
1423 goto LABEL_65; | |
1424 } | |
1425 if ( pHost->CreateClipper(0, &v30, 0) ) | |
1426 { | |
1427 v25 = "Init - Failed to create clipper.\n"; | |
1428 goto LABEL_45; | |
1429 } | |
1430 v30->SetHWnd(0, hWnd); | |
1431 pFrontBuffer->SetClipper(v30); | |
1432 | |
1433 v30->Release(); | |
1434 v30 = 0; | |
1435 | |
1436 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1437 | |
1438 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1439 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1440 ddsd2.dwWidth = 640; | |
1441 ddsd2.dwHeight = 480; | |
1442 | |
1443 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1444 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1445 &ddsd2.ddpfPixelFormat) ) | |
1446 goto LABEL_21; | |
1447 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1448 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
1449 | |
1450 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1451 { | |
1452 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
1453 { | |
1454 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1455 pBackBuffer, | |
1456 &pDevice, | |
1457 0) ) | |
1458 { | |
1459 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1460 d3dvp2.dvClipWidth = 2.0; | |
1461 d3dvp2.dvClipY = 1.0; | |
1462 d3dvp2.dvClipHeight = 2.0; | |
1463 d3dvp2.dvMaxZ = 1.0; | |
1464 d3dvp2.dvMinZ = 0.0; | |
1465 goto LABEL_54; | |
1466 } | |
1467 LABEL_51: | |
1468 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1469 if (pDirect3D) | |
1470 { | |
1471 pDirect3D->Release(); | |
1472 pDirect3D = 0; | |
1473 } | |
1474 goto LABEL_59; | |
1475 } | |
1476 LABEL_48: | |
1477 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1478 if (pZBuffer) | |
1479 { | |
1480 pZBuffer->Release(); | |
1481 pZBuffer = 0; | |
1482 } | |
1483 goto LABEL_61; | |
1484 } | |
1485 goto LABEL_44; | |
1486 } | |
1487 LABEL_36: | |
1488 v23 = "Init - Failed to create front buffer.\n"; | |
1489 sprintf(pErrorMessage, v23); | |
1490 goto LABEL_65; | |
1491 } | |
1492 if ( uDeviceID == 1 ) | |
1493 v26 = 1045; | |
1494 else | |
1495 v26 = 1041; | |
1496 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
1497 { | |
1498 v23 = "Init - Failed to set cooperative level.\n"; | |
1499 sprintf(pErrorMessage, v23); | |
1500 goto LABEL_65; | |
1501 } | |
1502 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
1503 { | |
1504 v23 = "Init - Failed to set display mode.\n"; | |
1505 sprintf(pErrorMessage, v23); | |
1506 goto LABEL_65; | |
1507 } | |
1508 | |
1509 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1510 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1511 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
1512 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
1513 ddsd2.dwBackBufferCount = 1; | |
1514 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1515 goto LABEL_36; | |
1516 //a3a = &pBackBuffer; | |
1517 //v14 = *v34; | |
1518 memset(&v27, 0, sizeof(DDSCAPS2)); | |
1519 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
1520 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
1521 //hWnda = &pDirect3D; | |
1522 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1523 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
1524 { | |
1525 v25 = "Init - Failed to get D3D interface.\n"; | |
1526 goto LABEL_45; | |
1527 } | |
1528 | |
1529 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1530 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1531 ddsd2.dwWidth = 640; | |
1532 ddsd2.dwHeight = 480; | |
1533 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1534 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1535 &ddsd2.ddpfPixelFormat) ) | |
1536 { | |
1537 LABEL_21: | |
1538 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
1539 goto LABEL_45; | |
1540 } | |
1541 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1542 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
1543 //uDeviceIDa = &pZBuffer; | |
1544 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1545 { | |
1546 LABEL_44: | |
1547 v25 = "Init - Failed to create z-buffer.\n"; | |
1548 LABEL_45: | |
1549 sprintf(pErrorMessage, v25); | |
1550 if (pBackBuffer) | |
1551 { | |
1552 pBackBuffer->Release(); | |
1553 pBackBuffer = 0; | |
1554 } | |
1555 LABEL_63: | |
1556 //v19 = &pFrontBuffer; | |
1557 if (pFrontBuffer) | |
1558 { | |
1559 pFrontBuffer->Release(); | |
1560 pFrontBuffer= 0; | |
1561 } | |
1562 goto LABEL_65; | |
1563 } | |
1564 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
1565 goto LABEL_48; | |
1566 //v33 = &pDevice; | |
1567 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1568 pBackBuffer, | |
1569 &pDevice, | |
1570 0) ) | |
1571 goto LABEL_51; | |
1572 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1573 d3dvp2.dvClipWidth = 2.0; | |
1574 d3dvp2.dvClipY = 1.0; | |
1575 d3dvp2.dvClipHeight = 2.0; | |
1576 d3dvp2.dvMaxZ = 1.0; | |
1577 | |
1578 LABEL_54: | |
1579 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
1580 //v17 = *hWnda; | |
1581 d3dvp2.dwWidth = 640; | |
1582 d3dvp2.dwHeight = 480; | |
1583 d3dvp2.dvClipX = -1.0; | |
1584 //v18 = v17->lpVtbl; | |
1585 //v32 = &v4->pViewport; | |
1586 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
1587 { | |
1588 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
1589 if (pDevice) | |
1590 { | |
1591 pDevice->Release(); | |
1592 pDevice = 0; | |
1593 } | |
1594 if (pDirect3D) | |
1595 { | |
1596 pDirect3D->Release(); | |
1597 pDirect3D = 0; | |
1598 } | |
1599 LABEL_59: | |
1600 if (pZBuffer) | |
1601 { | |
1602 pZBuffer->Release(); | |
1603 pZBuffer = 0; | |
1604 } | |
1605 LABEL_61: | |
1606 if (pBackBuffer) | |
1607 { | |
1608 pBackBuffer->Release(); | |
1609 pBackBuffer = 0; | |
1610 } | |
1611 goto LABEL_63; | |
1612 } | |
1613 | |
1614 pDevice->AddViewport(pViewport); | |
1615 pViewport->SetViewport2(&d3dvp2); | |
1616 pDevice->SetCurrentViewport(pViewport); | |
1617 return 1; | |
1618 } | |
1619 | |
1620 //----- (0049E444) -------------------------------------------------------- | |
1621 unsigned int RenderD3D::GetDeviceCaps() | |
1622 { | |
1623 unsigned int v1; // ebx@1 | |
1624 RenderD3D *v2; // edi@1 | |
1625 IDirect3DDevice3 *v3; // eax@1 | |
1626 unsigned int result; // eax@2 | |
1627 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
1628 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
1629 | |
1630 v1 = 0; | |
1631 v2 = this; | |
1632 memset(&halCaps, 0, 0xFCu); | |
1633 halCaps.dwSize = 252; | |
1634 memset(&refCaps, 0, 0xFCu); | |
1635 v3 = v2->pDevice; | |
1636 refCaps.dwSize = 252; | |
1637 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
1638 { | |
1639 result = 1; | |
1640 } | |
1641 else | |
1642 { | |
1643 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
1644 v1 = 2; | |
1645 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
1646 v1 |= 4u; | |
1647 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
1648 v1 |= 8u; | |
1649 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
1650 v1 |= 0x10u; | |
1651 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
1652 v1 |= 0x20u; | |
1653 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
1654 v1 |= 0x40u; | |
1655 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
1656 LOBYTE(v1) = v1 | 0x80; | |
1657 result = v1; | |
1658 } | |
1659 return result; | |
1660 } | |
1661 | |
1662 //----- (0049E4FC) -------------------------------------------------------- | |
1663 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
1664 { | |
1665 uint uClearFlags = 0; | |
1666 | |
1667 if (bClearColor) | |
1668 uClearFlags |= D3DCLEAR_TARGET; | |
1669 if (bClearDepth) | |
1670 uClearFlags |= D3DCLEAR_ZBUFFER; | |
1671 | |
1672 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
1673 if (uClearFlags) | |
1674 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
1675 } | |
1676 | |
1677 //----- (0049E54D) -------------------------------------------------------- | |
1678 void RenderD3D::Present(bool bForceBlit) | |
1679 { | |
1680 RECT v5; // [sp+18h] [bp-18h]@1 | |
1681 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
1682 | |
1683 v5.left = 0; | |
1684 v5.top = 0; | |
1685 v5.bottom = 480; | |
1686 v5.right = 640; | |
1687 | |
1688 if (bWindowed || bForceBlit) | |
1689 { | |
1690 RECT rc; | |
1691 GetClientRect(hWindow, &rc); | |
1692 Point.y = 0; | |
1693 Point.x = 0; | |
1694 ClientToScreen(hWindow, &Point); | |
1695 OffsetRect(&rc, Point.x, Point.y); | |
1696 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
1697 } | |
1698 else | |
1699 pFrontBuffer->Flip(0, 1); | |
1700 } | |
1701 | |
1702 //----- (0049E5D4) -------------------------------------------------------- | |
1703 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
1704 { | |
1705 unsigned int v8; // edx@4 | |
1706 unsigned int v9; // ebx@5 | |
1707 unsigned int v10; // eax@5 | |
1708 DWORD v11; // edx@5 | |
1709 //int v12; // edx@7 | |
1710 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
1711 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
1712 | |
1713 //v15 = this; | |
1714 memset(&ddsd2, 0, 0x7Cu); | |
1715 ddsd2.dwSize = 0x7Cu; | |
1716 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1717 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
1718 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
1719 ddsd2.dwHeight = uTextureHeight; | |
1720 ddsd2.dwWidth = uTextureWidth; | |
1721 if ( bMipmaps ) | |
1722 { | |
1723 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
1724 { | |
1725 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
1726 LABEL_8: | |
1727 ddsd2.dwMipMapCount = v8; | |
1728 if ( !v8 ) | |
1729 goto LABEL_12; | |
1730 goto LABEL_11; | |
1731 } | |
1732 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
1733 { | |
1734 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
1735 goto LABEL_8; | |
1736 } | |
1737 v9 = GetMaxMipLevels(uTextureWidth); | |
1738 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
1739 ddsd2.dwMipMapCount = v9 - v10; | |
1740 if ( v9 == v10 ) | |
1741 { | |
1742 ddsd2.dwFlags = 0x1007u; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
1743 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used |
0 | 1744 ddsd2.ddsCaps.dwCaps = v11; |
1745 goto LABEL_12; | |
1746 } | |
1747 } | |
1748 else | |
1749 { | |
1750 ddsd2.dwMipMapCount = 1; | |
1751 } | |
1752 LABEL_11: | |
1753 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1754 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1755 LABEL_12: | |
1756 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
1757 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
1758 if (bAlphaChannel) | |
1759 { | |
1760 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
1761 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
1762 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
1763 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1764 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
1765 } | |
1766 else | |
1767 { | |
1768 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
1769 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
1770 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
1771 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1772 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
1773 } | |
1774 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
1775 return false; | |
1776 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
1777 { | |
1778 (*pOutSurface)->Release(); | |
1779 *pOutSurface = 0; | |
1780 return false; | |
1781 } | |
1782 return true; | |
1783 } | |
1784 | |
1785 //----- (004A5190) -------------------------------------------------------- | |
1786 void RenderD3D::HandleLostResources() | |
1787 { | |
1788 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
1789 pBitmaps_LOD->_410423_move_textures_to_device(); | |
1790 pSprites_LOD->ReleaseLostHardwareSprites(); | |
1791 } | |
1792 | |
1793 //----- (004A2050) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
1794 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) |
0 | 1795 { |
1796 Render *v5; // edi@1 | |
1797 unsigned int v6; // ebx@1 | |
1798 LightmapBuilder *v7; // esi@3 | |
1799 int v8; // eax@7 | |
1800 ODMFace *v9; // eax@12 | |
1801 char *v10; // esi@12 | |
1802 double v11; // st7@14 | |
1803 double v12; // st7@14 | |
1804 int v13; // eax@14 | |
1805 ODMFace *v14; // ecx@14 | |
1806 double v15; // st7@14 | |
1807 float v16; // ST48_4@15 | |
1808 int v17; // eax@15 | |
1809 char v18; // zf@17 | |
1810 HRESULT v19; // eax@18 | |
1811 HRESULT v20; // eax@18 | |
1812 HRESULT v21; // eax@20 | |
1813 HRESULT v22; // eax@20 | |
1814 unsigned int v23; // ecx@20 | |
1815 char *v24; // eax@21 | |
1816 HRESULT v25; // eax@23 | |
1817 HRESULT v26; // eax@23 | |
1818 HRESULT v27; // eax@24 | |
1819 HRESULT v28; // eax@25 | |
1820 HRESULT v29; // eax@25 | |
1821 HRESULT v30; // eax@25 | |
1822 HRESULT v31; // eax@25 | |
1823 HRESULT v32; // eax@26 | |
1824 unsigned int v33; // ecx@26 | |
1825 char *v34; // eax@27 | |
1826 int v35; // edx@28 | |
1827 HRESULT v36; // eax@29 | |
1828 HRESULT v37; // eax@29 | |
1829 HRESULT v38; // eax@29 | |
1830 HRESULT v39; // eax@29 | |
1831 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
1832 unsigned int v41; // eax@29 | |
1833 HRESULT v42; // eax@30 | |
1834 HRESULT v43; // eax@30 | |
1835 HRESULT v44; // eax@30 | |
1836 char *v45; // esi@34 | |
1837 int v46; // ecx@35 | |
1838 double v47; // st6@35 | |
1839 int v48; // eax@36 | |
1840 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
1841 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
1842 int v51; // [sp+50h] [bp-18h]@0 | |
1843 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
1844 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
1845 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
1846 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
1847 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
1848 int v57; // [sp+60h] [bp-8h]@34 | |
638 | 1849 unsigned int a2; // [sp+64h] [bp-4h]@4 |
0 | 1850 |
1851 v5 = this; | |
1852 v6 = 0; | |
1853 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
1854 { | |
1855 v7 = pGame->pLightmapBuilder; | |
1856 v53 = v7; | |
1857 v54 = v7->std__vector_000004_size; | |
1858 if ( v7->std__vector_000004_size) | |
638 | 1859 a2 = 0xFFFFFFFF; |
1860 pGame->AlterGamma_ODM(a4, &a2); | |
1394 | 1861 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) |
0 | 1862 { |
638 | 1863 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 1864 v7->DrawLightmaps(/*v8, 0*/); |
0 | 1865 } |
1866 else | |
1867 { | |
1868 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
1869 { | |
323 | 1870 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1871 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
1872 if (bUsingSpecular) | |
1873 { | |
186 | 1874 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
1875 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1876 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1877 } |
1073 | 1878 for (uint i = 0; i < uNumVertices; ++i) |
1879 { | |
1880 | |
1881 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1882 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1883 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1884 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1885 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1886 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
1887 | |
1888 if ( this->bUsingSpecular ) | |
0 | 1889 { |
1073 | 1890 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1891 } |
1073 | 1892 else |
1893 { | |
1894 d3d_vertex_buffer[i].specular = 0; | |
1895 } | |
1896 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1897 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1898 | |
1899 } | |
323 | 1900 |
1901 if (a4->uAttributes & FACE_OUTLINED) | |
1902 { | |
1903 int color; | |
1904 if (GetTickCount() % 300 >= 150) | |
1905 color = 0xFFFF2020; | |
1906 else color = 0xFF901010; | |
1907 | |
1908 for (uint i = 0; i < uNumVertices; ++i) | |
1909 d3d_vertex_buffer[i].diffuse = color; | |
1910 } | |
1911 | |
0 | 1912 pRenderD3D->pDevice->SetTexture(0, pTexture); |
1913 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1914 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1915 d3d_vertex_buffer, |
0 | 1916 uNumVertices, |
1917 D3DDP_DONOTLIGHT); | |
1918 } | |
1919 else | |
1920 { | |
1073 | 1921 for (uint i = 0; i < uNumVertices; ++i) |
1922 { | |
1923 | |
1924 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1925 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1926 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1927 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1928 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1929 if ( this->bUsingSpecular ) | |
0 | 1930 { |
1073 | 1931 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1932 } |
1073 | 1933 else |
1934 { | |
1935 d3d_vertex_buffer[i].specular = 0; | |
1936 } | |
1937 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1938 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1939 | |
1940 } | |
1941 | |
186 | 1942 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
1943 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 1944 if (bUsingSpecular) |
186 | 1945 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 1946 |
1947 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
1948 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1949 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1950 d3d_vertex_buffer, |
0 | 1951 uNumVertices, |
1952 D3DDP_DONOTLIGHT)); | |
1953 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
1954 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1955 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
1394 | 1956 v53->DrawLightmaps(/*-1, 0*/); |
1073 | 1957 for (uint i = 0; i < uNumVertices; ++i) |
1958 { | |
1959 d3d_vertex_buffer[i].diffuse = a2; | |
1960 } | |
0 | 1961 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 1962 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1963 if ( !pRenderer->bUsingSpecular ) |
186 | 1964 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
1965 | |
1966 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
1967 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
1968 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 1969 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1970 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1971 d3d_vertex_buffer, |
0 | 1972 uNumVertices, |
1973 D3DDP_DONOTLIGHT)); | |
1974 if (bUsingSpecular) | |
1975 { | |
186 | 1976 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 1977 |
1073 | 1978 for (uint i = 0; i < uNumVertices; ++i) |
1979 { | |
1980 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
1981 d3d_vertex_buffer[i].specular = 0; | |
1982 } | |
1983 | |
0 | 1984 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 1985 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
1986 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 1987 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1988 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1989 d3d_vertex_buffer, |
0 | 1990 uNumVertices, |
1991 D3DDP_DONOTLIGHT)); | |
186 | 1992 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 1993 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
1994 v41 = GetLevelFogColor(); | |
1995 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
1996 v6 = 0; | |
1997 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
1998 } | |
186 | 1999 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
2000 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 2001 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
2002 } | |
2003 } | |
2004 } | |
2005 } | |
2006 // 4D864C: using guessed type char byte_4D864C; | |
2007 | |
2008 //----- (0049EB79) -------------------------------------------------------- | |
2009 Render::~Render() | |
2010 { | |
2011 Render *v1; // esi@1 | |
2012 | |
2013 v1 = this; | |
1583 | 2014 free(this->pDefaultZBuffer); |
0 | 2015 v1->pD3DBitmaps.Release(); |
2016 v1->pD3DSprites.Release(); | |
2017 Release(); | |
2018 v1->bWindowMode = 1; | |
2019 //nullsub_1(); | |
2020 //nullsub_1(); | |
2021 } | |
2022 | |
2023 //----- (0049E756) -------------------------------------------------------- | |
2024 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
2025 { | |
2026 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
2027 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
2028 | |
2029 halCaps.dwSize = 380; | |
2030 refCaps.dwSize = 380; | |
2031 this_->GetCaps(&halCaps, &refCaps); | |
2032 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
2033 } | |
2034 | |
2035 //----- (0049E992) -------------------------------------------------------- | |
2036 Render::Render() | |
2037 { | |
2038 Render *v1; // esi@1 | |
2039 int v2; // eax@1 | |
2040 char v3; // zf@1 | |
2041 | |
2042 v1 = this; | |
2043 this->pDirectDraw4 = 0; | |
2044 this->pFrontBuffer4 = 0; | |
2045 this->pBackBuffer4 = 0; | |
2046 this->pColorKeySurface4 = 0; | |
2047 this->pDirectDraw2 = 0; | |
2048 this->pFrontBuffer2 = 0; | |
2049 this->pBackBuffer2 = 0; | |
2050 this->pSomeSurface2 = 0; | |
2051 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
2052 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2053 v1->bWindowMode = 1; | |
2054 v1->field_40054 = 0; | |
2055 v1->field_10 = 640; | |
2056 v1->field_14 = 480; | |
2057 v1->field_40030 = 0; | |
2058 v1->field_4002C = 0; | |
2059 v1->pActiveZBuffer = 0; | |
2060 v1->pDefaultZBuffer = 0; | |
709 | 2061 v1->raster_clip_y = 0; |
2062 v1->raster_clip_x = 0; | |
2063 v1->raster_clip_z = 639; | |
2064 v1->raster_clip_w = 479; | |
0 | 2065 v1->field_4003C = (int)&unk_4EED80; |
2066 v1->field_40040 = dword_4EED78; | |
2067 v1->uClipZ = 640; | |
2068 v1->field_40044 = 2; | |
2069 v1->field_40048 = 6; | |
2070 v1->pFrontBuffer4 = 0; | |
2071 v1->pBackBuffer4 = 0; | |
2072 v1->pColorKeySurface4 = 0; | |
2073 v1->pDirectDraw4 = 0; | |
2074 v1->pRenderD3D = 0; | |
2075 v1->uNumSceneBegins = 0; | |
2076 v1->uNumD3DSceneBegins = 0; | |
2077 v1->field_40110 = 0; | |
2078 v1->pTargetSurface = 0; | |
2079 v1->uTargetSurfacePitch = 0; | |
2080 v1->uClipY = 0; | |
2081 v1->uClipX = 0; | |
2082 v1->uClipW = 480; | |
2083 v1->bClip = 1; | |
2084 v1->bColorKeySupported = 0; | |
2085 v1->bRequiredTextureStagesAvailable = 0; | |
2086 v1->bTinting = 1; | |
2087 LOBYTE(v1->field_103668) = 0; | |
2088 v1->field_1036B8 = 0; | |
2089 v1->_gpu_memory_used = 0; | |
2090 uNumBillboardsToDraw = 0; | |
2091 bFogEnabled = false; | |
265 | 2092 |
2093 hd_water_tile_id = -1; | |
2094 hd_water_current_frame = 0; | |
0 | 2095 } |
2096 | |
1512 | 2097 bool Render::Initialize(bool bWindowed, uint32_t uDefaultDevice, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
0 | 2098 { |
2099 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
2100 bStartInWindow = bWindowed; | |
2101 | |
2102 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | |
2103 | |
2104 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
2105 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
2106 | |
2107 this->bTinting = bTinting; | |
2108 | |
2109 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
2110 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
2111 | |
2112 return r1 && r2; | |
2113 } | |
2114 | |
2115 //----- (0049EBF1) -------------------------------------------------------- | |
2116 void Render::_49EBF1() | |
2117 { | |
2118 signed int uNumRedBits; // edx@1 | |
2119 signed int uNuGreenBits; // edi@1 | |
2120 signed int uNumBlueBits; // esi@1 | |
2121 unsigned int v4; // edx@4 | |
2122 unsigned int v5; // edi@4 | |
2123 int v6; // ebx@4 | |
2124 int v7; // edx@4 | |
2125 signed int v8; // [sp+8h] [bp-24h]@1 | |
2126 signed int v9; // [sp+Ch] [bp-20h]@1 | |
2127 signed int v10; // [sp+20h] [bp-Ch]@1 | |
2128 signed int i; // [sp+24h] [bp-8h]@2 | |
2129 signed int v12; // [sp+28h] [bp-4h]@3 | |
2130 | |
2131 v10 = 0; | |
2132 uNumRedBits = 1 << this->uTargetRBits; | |
2133 uNuGreenBits = 1 << this->uTargetGBits; | |
2134 uNumBlueBits = 1 << this->uTargetBBits; | |
2135 v9 = 1 << this->uTargetRBits; | |
2136 v8 = 1 << this->uTargetGBits; | |
2137 if ( uNumRedBits > 0 ) | |
2138 { | |
2139 do | |
2140 { | |
2141 for ( i = 0; i < uNuGreenBits; ++i ) | |
2142 { | |
2143 v12 = 0; | |
2144 if ( uNumBlueBits > 0 ) | |
2145 { | |
2146 do | |
2147 { | |
2148 v4 = this->uTargetBBits; | |
2149 v5 = v4 + this->uTargetGBits; | |
2150 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
2151 v7 = (v10 << v5) + v12++ + (i << v4); | |
2152 this->field_2C[v7] = v6; | |
2153 } | |
2154 while ( v12 < uNumBlueBits ); | |
2155 uNumRedBits = v9; | |
2156 uNuGreenBits = v8; | |
2157 } | |
2158 } | |
2159 ++v10; | |
2160 } | |
2161 while ( v10 < uNumRedBits ); | |
2162 } | |
2163 } | |
2164 | |
2165 //----- (0049ECC4) -------------------------------------------------------- | |
2166 void Render::ClearBlack() | |
2167 { | |
2168 if (pRenderD3D) | |
2169 { | |
2170 if (field_40110) | |
2171 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
2172 } | |
2173 else | |
2174 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
2175 } | |
2176 | |
2177 //----- (0049ED18) -------------------------------------------------------- | |
2178 void Render::PresentBlackScreen() | |
2179 { | |
2180 LONG w; // edx@3 | |
2181 IDirectDrawSurface *v2; // eax@3 | |
2182 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
2183 RECT x; // [sp+68h] [bp-10h]@3 | |
2184 | |
2185 memset(&v3, 0, sizeof(DDBLTFX)); | |
2186 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
2187 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
2188 { | |
2189 x.left = uWindowX; | |
2190 x.right = uWindowX + uWindowHeight; | |
2191 x.top = uWindowY; | |
2192 w = uWindowY + uWindowWidth; | |
2193 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
2194 } | |
2195 else | |
2196 { | |
2197 x.left = uWindowX; | |
2198 x.right = uWindowX + uWindowHeight; | |
2199 x.top = uWindowY; | |
2200 w = uWindowY + uWindowWidth; | |
2201 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
2202 } | |
2203 x.bottom = w; | |
2204 v3.dwFillColor = 0; | |
2205 v3.dwSize = 100; | |
2206 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
2207 pRenderer->Present(); | |
2208 } | |
2209 | |
2210 //----- (0049EDB6) -------------------------------------------------------- | |
2211 void Render::SavePCXScreenshot() | |
2212 { | |
2213 Render *v1; // esi@1 | |
2214 __int16 v2; // di@1 | |
2215 int v3; // eax@4 | |
2216 int v4; // ecx@4 | |
2217 int v5; // eax@8 | |
2218 FILE *v6; // edi@10 | |
2219 int v7; // ecx@11 | |
2220 int v8; // eax@11 | |
2221 int v9; // eax@13 | |
2222 int v10; // ecx@15 | |
2223 unsigned __int8 v11; // dl@15 | |
2224 signed int v12; // eax@18 | |
2225 char v13; // zf@27 | |
2226 HRESULT v14; // eax@29 | |
2227 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
2228 __int16 v16; // [sp+44h] [bp-120h]@10 | |
2229 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2230 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2231 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2232 char *v20; // [sp+11Ch] [bp-48h]@14 | |
2233 char *v21; // [sp+120h] [bp-44h]@14 | |
2234 int v24; // [sp+124h] [bp-40h]@11 | |
2235 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
2236 int var38; // [sp+12Ch] [bp-38h]@4 | |
2237 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2238 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2239 void *ptr; // [sp+148h] [bp-1Ch]@10 | |
2240 void *v28; // [sp+14Ch] [bp-18h]@8 | |
2241 int v29; // [sp+150h] [bp-14h]@4 | |
2242 int v30; // [sp+154h] [bp-10h]@4 | |
2243 char v31; // [sp+15Ah] [bp-Ah]@25 | |
2244 unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 | |
2245 int i; // [sp+15Ch] [bp-8h]@10 | |
2246 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | |
2247 | |
2248 v1 = this; | |
2249 v2 = 0; | |
2250 if ( !this->pRenderD3D || this->field_40110 ) | |
2251 { | |
2252 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | |
2253 File = fopen(Filename, "wb"); | |
2254 if ( File ) | |
2255 { | |
2256 v3 = v1->field_10; | |
2257 v4 = v1->field_14; | |
2258 var38 = v3; | |
2259 v29 = v4; | |
2260 v30 = v3; | |
2261 if ( v3 & 1 ) | |
2262 v30 = v3 + 1; | |
2263 if ( v1->pRenderD3D ) | |
2264 { | |
2265 memset(&Dst, 0, 0x7Cu); | |
2266 Dst.dwSize = 124; | |
168 | 2267 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 2268 return; |
2269 v28 = Dst.lpSurface; | |
2270 v5 = Dst.lPitch >> 1; | |
2271 v2 = 0; | |
2272 } | |
2273 else | |
2274 { | |
2275 pRenderer->BeginScene(); | |
2276 v28 = pRenderer->pTargetSurface; | |
2277 v5 = pRenderer->uTargetSurfacePitch; | |
2278 } | |
2279 i = v5; | |
2280 header1.right = var38 - 1; | |
2281 header1.left = v2; | |
2282 header1.bottom = v29 - 1; | |
2283 header1.up = v2; | |
2284 header2.pitch = v30; | |
2285 memset(color_map, 0, sizeof(color_map)); | |
2286 memset(v15, 0, sizeof(v15)); | |
2287 header2.reserved = 0; | |
2288 header1.manufacturer = 10; | |
2289 v16 = 0; | |
2290 v6 = File; | |
2291 header1.version = 5; | |
2292 header1.encoding = 1; | |
2293 header1.bpp = 8; | |
2294 header1.hdpi = 75; | |
2295 header1.vdpi = 75; | |
2296 header2.planes = 3; | |
2297 header2.palette_info = 1; | |
2298 fwrite(&header1, 1u, 1u, File); | |
2299 fwrite(&header1.version, 1u, 1u, v6); | |
2300 fwrite(&header1.encoding, 1u, 1u, v6); | |
2301 fwrite(&header1.bpp, 1u, 1u, v6); | |
2302 fwrite(&header1.left, 2u, 1u, v6); | |
2303 fwrite(&header1.up, 2u, 1u, v6); | |
2304 fwrite(&header1.right, 2u, 1u, v6); | |
2305 fwrite(&header1.bottom, 2u, 1u, v6); | |
2306 fwrite(&header1.hdpi, 2u, 1u, v6); | |
2307 fwrite(&header1.vdpi, 2u, 1u, v6); | |
2308 fwrite(color_map, 0x30u, 1u, v6); | |
2309 fwrite(&header2, 1u, 1u, v6); | |
2310 fwrite(&header2.planes, 1u, 1u, v6); | |
2311 fwrite(&header2.pitch, 2u, 1u, v6); | |
2312 fwrite(&header2.palette_info, 2u, 1u, v6); | |
2313 fwrite(v15, 0x3Au, 1u, v6); | |
1583 | 2314 ptr = malloc(3 * var38 + 6); |
0 | 2315 if ( v29 > 0 ) |
2316 { | |
2317 v7 = v30; | |
2318 File = (FILE *)v29; | |
2319 v29 = 3 * v30; | |
2320 v24 = 2 * i; | |
2321 v8 = (int)v28; | |
2322 while ( 1 ) | |
2323 { | |
2324 i = v8; | |
2325 v9 = 0; | |
2326 if ( var38 > 0 ) | |
2327 { | |
2328 v21 = (char *)ptr + v7; | |
2329 v20 = (char *)ptr + 2 * v30; | |
2330 do | |
2331 { | |
2332 *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) | |
2333 + LOBYTE(v1->uTargetBBits) | |
2334 + v1->uTargetRBits | |
2335 - 8); | |
2336 v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) | |
2337 + LOBYTE(v1->uTargetGBits) | |
2338 - 8); | |
2339 v10 = i; | |
2340 v11 = LOBYTE(v1->uTargetBMask); | |
2341 i += 2; | |
2342 v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); | |
2343 } | |
2344 while ( v9 < var38 ); | |
2345 } | |
2346 for ( i = 0; i < v29; i += v34 ) | |
2347 { | |
2348 v34 = 1; | |
2349 v32 = *((char *)ptr + i); | |
2350 do | |
2351 { | |
2352 v12 = i + v34; | |
2353 if ( *((char *)ptr + v12) != v32 ) | |
2354 break; | |
2355 if ( !(v12 % v30) ) | |
2356 break; | |
2357 ++v34; | |
2358 } | |
2359 while ( v34 < 0x3Fu ); | |
2360 if ( i + v34 > v29 ) | |
2361 v34 = 3 * v30 - i; | |
2362 if ( v34 > 1u || v32 >= 0xC0u ) | |
2363 { | |
2364 v31 = v34 | 0xC0; | |
2365 fwrite(&v31, 1u, 1u, v6); | |
2366 } | |
2367 fwrite(&v32, 1u, 1u, v6); | |
2368 } | |
2369 v8 = (int)((char *)v28 + v24); | |
2370 v13 = File == (FILE *)1; | |
2371 File = (FILE *)((char *)File - 1); | |
2372 v28 = (char *)v28 + v24; | |
2373 if ( v13 ) | |
2374 break; | |
2375 v7 = v30; | |
2376 } | |
2377 } | |
2378 if ( v1->pRenderD3D ) | |
2379 { | |
2380 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
2381 } | |
2382 else | |
2383 { | |
2384 pRenderer->EndScene(); | |
2385 } | |
2386 | |
1583 | 2387 free(ptr); |
0 | 2388 fclose(v6); |
2389 } | |
2390 } | |
2391 } | |
2392 // 4EFA80: using guessed type int dword_4EFA80; | |
2393 | |
2394 //----- (0049F1BC) -------------------------------------------------------- | |
2395 void Render::_49F1BC(const char *a1) | |
2396 { | |
2397 Render *v2; // esi@1 | |
2398 __int16 v3; // di@1 | |
2399 int v4; // eax@4 | |
2400 char *v5; // ecx@4 | |
2401 unsigned int v6; // eax@8 | |
2402 FILE *v7; // edi@10 | |
2403 int v8; // ecx@11 | |
2404 int v9; // eax@11 | |
2405 int v10; // eax@13 | |
2406 const char *v11; // ecx@15 | |
2407 unsigned __int8 v12; // dl@15 | |
2408 signed int v13; // eax@18 | |
2409 char v14; // zf@27 | |
2410 HRESULT v15; // eax@29 | |
2411 char v16; // [sp+Ch] [bp-12Ch]@10 | |
2412 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
2413 int Dst; // [sp+48h] [bp-F0h]@7 | |
2414 int v19; // [sp+58h] [bp-E0h]@8 | |
2415 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
2416 char v21; // [sp+C4h] [bp-74h]@10 | |
2417 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
2418 char *v23; // [sp+F8h] [bp-40h]@14 | |
2419 int v24; // [sp+FCh] [bp-3Ch]@11 | |
2420 int v25; // [sp+100h] [bp-38h]@4 | |
2421 FILE *File; // [sp+104h] [bp-34h]@3 | |
2422 char Str; // [sp+108h] [bp-30h]@10 | |
2423 char v28; // [sp+109h] [bp-2Fh]@10 | |
2424 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
2425 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
2426 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
2427 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
2428 __int16 v33; // [sp+110h] [bp-28h]@10 | |
2429 __int16 v34; // [sp+112h] [bp-26h]@10 | |
2430 __int16 v35; // [sp+114h] [bp-24h]@10 | |
2431 __int16 v36; // [sp+116h] [bp-22h]@10 | |
2432 char v37; // [sp+118h] [bp-20h]@10 | |
2433 char v38; // [sp+119h] [bp-1Fh]@10 | |
2434 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
2435 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
2436 void *ptr; // [sp+120h] [bp-18h]@10 | |
2437 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
2438 int v43; // [sp+128h] [bp-10h]@4 | |
2439 char v44; // [sp+12Fh] [bp-9h]@25 | |
2440 char *i; // [sp+130h] [bp-8h]@10 | |
2441 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
2442 | |
2443 v2 = this; | |
2444 v3 = 0; | |
2445 if ( !this->pRenderD3D || this->field_40110 ) | |
2446 { | |
2447 ++dword_4EFA84; | |
2448 File = fopen(a1, "wb"); | |
2449 if ( File ) | |
2450 { | |
2451 v4 = v2->field_10; | |
2452 v5 = (char *)v2->field_14; | |
2453 v25 = v4; | |
2454 a1 = v5; | |
2455 v43 = v4; | |
2456 if ( v4 & 1 ) | |
2457 v43 = v4 + 1; | |
2458 if ( v2->pRenderD3D ) | |
2459 { | |
2460 memset(&Dst, 0, 0x7Cu); | |
2461 Dst = 124; | |
168 | 2462 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 2463 return; |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
2464 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
0 | 2465 v42 = v20; |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
2466 __debugbreak(); // warning C4700: uninitialized local variable 'v19' used |
0 | 2467 v6 = v19 >> 1; |
2468 v3 = 0; | |
2469 } | |
2470 else | |
2471 { | |
2472 pRenderer->BeginScene(); | |
2473 v42 = pRenderer->pTargetSurface; | |
2474 v6 = pRenderer->uTargetSurfacePitch; | |
2475 } | |
2476 i = (char *)v6; | |
2477 v33 = v25 - 1; | |
2478 v31 = v3; | |
2479 v34 = (short)a1 - 1; | |
2480 v32 = v3; | |
2481 v39 = v43; | |
2482 memset(&v21, 0, 0x30u); | |
2483 memset(&v16, 0, 0x38u); | |
2484 v37 = 0; | |
2485 Str = 10; | |
2486 v17 = 0; | |
2487 v7 = File; | |
2488 v28 = 5; | |
2489 v29 = 1; | |
2490 v30 = 8; | |
2491 v35 = 75; | |
2492 v36 = 75; | |
2493 v38 = 3; | |
2494 v40 = 1; | |
2495 fwrite(&Str, 1u, 1u, File); | |
2496 fwrite(&v28, 1u, 1u, v7); | |
2497 fwrite(&v29, 1u, 1u, v7); | |
2498 fwrite(&v30, 1u, 1u, v7); | |
2499 fwrite(&v31, 2u, 1u, v7); | |
2500 fwrite(&v32, 2u, 1u, v7); | |
2501 fwrite(&v33, 2u, 1u, v7); | |
2502 fwrite(&v34, 2u, 1u, v7); | |
2503 fwrite(&v35, 2u, 1u, v7); | |
2504 fwrite(&v36, 2u, 1u, v7); | |
2505 fwrite(&v21, 0x30u, 1u, v7); | |
2506 fwrite(&v37, 1u, 1u, v7); | |
2507 fwrite(&v38, 1u, 1u, v7); | |
2508 fwrite(&v39, 2u, 1u, v7); | |
2509 fwrite(&v40, 2u, 1u, v7); | |
2510 fwrite(&v16, 0x3Au, 1u, v7); | |
1583 | 2511 ptr = malloc(3 * v25 + 6); |
0 | 2512 if ( (signed int)a1 > 0 ) |
2513 { | |
2514 v8 = v43; | |
2515 File = (FILE *)a1; | |
2516 v24 = 3 * v43; | |
2517 v22 = 2 * (int)i; | |
2518 v9 = (int)v42; | |
2519 while ( 1 ) | |
2520 { | |
2521 a1 = (const char *)v9; | |
2522 v10 = 0; | |
2523 if ( v25 > 0 ) | |
2524 { | |
2525 i = (char *)ptr + v8; | |
2526 v23 = (char *)ptr + 2 * v43; | |
2527 do | |
2528 { | |
2529 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
2530 + LOBYTE(v2->uTargetBBits) | |
2531 + v2->uTargetRBits | |
2532 - 8); | |
2533 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
2534 + LOBYTE(v2->uTargetGBits) | |
2535 - 8); | |
2536 v11 = a1; | |
2537 v12 = LOBYTE(v2->uTargetBMask); | |
2538 a1 += 2; | |
2539 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
2540 } | |
2541 while ( v10 < v25 ); | |
2542 } | |
2543 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
2544 { | |
2545 BYTE3(a1) = 1; | |
2546 v46 = *((char *)ptr + (int)i); | |
2547 do | |
2548 { | |
2549 v13 = (signed int)&i[BYTE3(a1)]; | |
2550 if ( *((char *)ptr + v13) != v46 ) | |
2551 break; | |
2552 if ( !(v13 % v43) ) | |
2553 break; | |
2554 ++BYTE3(a1); | |
2555 } | |
2556 while ( BYTE3(a1) < 0x3Fu ); | |
2557 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
2558 BYTE3(a1) = 3 * v43 - (char)i; | |
2559 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
2560 { | |
2561 v44 = BYTE3(a1) | 0xC0; | |
2562 fwrite(&v44, 1u, 1u, v7); | |
2563 } | |
2564 fwrite(&v46, 1u, 1u, v7); | |
2565 } | |
2566 v9 = (int)&v42[v22 / 2]; | |
2567 v14 = File == (FILE *)1; | |
2568 File = (FILE *)((char *)File - 1); | |
2569 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
2570 if ( v14 ) | |
2571 break; | |
2572 v8 = v43; | |
2573 } | |
2574 } | |
2575 if ( v2->pRenderD3D ) | |
2576 { | |
2577 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
2578 } | |
2579 else | |
2580 { | |
2581 pRenderer->EndScene(); | |
2582 } | |
1583 | 2583 free(ptr); |
0 | 2584 fclose(v7); |
2585 } | |
2586 } | |
2587 } | |
2588 // 4EFA84: using guessed type int dword_4EFA84; | |
2589 | |
2590 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 2591 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
2592 { | |
0 | 2593 Render *v7; // ebx@1 |
2594 void *v8; // esi@3 | |
2595 void *v9; // esi@3 | |
2596 int v10; // ecx@4 | |
810 | 2597 unsigned short* v11; // eax@4 |
0 | 2598 int v12; // eax@6 |
2599 int v13; // eax@8 | |
2600 int v14; // ecx@8 | |
2601 signed int v15; // eax@11 | |
2602 char v16; // zf@20 | |
2603 int result; // eax@21 | |
2604 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
2605 // __int16 v19; // [sp+44h] [bp-74h]@3 | |
2606 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 2607 char *lineG; // [sp+78h] [bp-40h]@7 |
2608 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 2609 int v23; // [sp+80h] [bp-38h]@4 |
2610 int v24; // [sp+84h] [bp-34h]@4 | |
2611 int v25; // [sp+88h] [bp-30h]@4 | |
2612 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 2613 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
2614 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
2615 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
2616 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 2617 char v43; // [sp+B3h] [bp-5h]@18 |
2618 int i; // [sp+B4h] [bp-4h]@6 | |
810 | 2619 unsigned short* line_pictute_data; |
2620 byte test_byte; | |
2621 unsigned char pict_byte; | |
0 | 2622 |
2623 v7 = this; | |
810 | 2624 pitch = wight; |
2625 if ( wight & 1 ) | |
2626 pitch = wight + 1; | |
2627 Src.left = 0; | |
2628 Src.up = 0; | |
2629 Src.right = wight - 1; | |
2630 Src.bottom = heidth - 1; | |
2631 v27.pitch = pitch; | |
0 | 2632 memset(&v20, 0, 0x30u); |
2633 memset(&v18, 0, 0x38u); | |
810 | 2634 v8 = data_buff; |
2635 v27.reserved = 0; | |
0 | 2636 *(_WORD *)&v18[56] = 0; |
810 | 2637 Src.manufacturer = 10; |
2638 Src.version = 5; | |
2639 Src.encoding = 1; | |
2640 Src.bpp = 8; | |
2641 Src.hdpi = 75; | |
2642 Src.vdpi = 75; | |
2643 v27.planes = 3; | |
2644 v27.palette_info = 1; | |
2645 memcpy(data_buff, &Src, 1u); | |
0 | 2646 v8 = (char *)v8 + 1; |
810 | 2647 memcpy(v8, &Src.version, 1u); |
0 | 2648 v8 = (char *)v8 + 1; |
810 | 2649 memcpy(v8, &Src.encoding, 1u); |
0 | 2650 v8 = (char *)v8 + 1; |
810 | 2651 memcpy(v8, &Src.bpp, 1u); |
0 | 2652 v8 = (char *)v8 + 1; |
810 | 2653 memcpy(v8, &Src.left, 2u); |
0 | 2654 v8 = (char *)v8 + 2; |
810 | 2655 memcpy(v8, &Src.up, 2u); |
0 | 2656 v8 = (char *)v8 + 2; |
810 | 2657 memcpy(v8, &Src.right, 2u); |
0 | 2658 v8 = (char *)v8 + 2; |
810 | 2659 memcpy(v8, &Src.bottom, 2u); |
0 | 2660 v8 = (char *)v8 + 2; |
810 | 2661 memcpy(v8, &Src.hdpi, 2u); |
0 | 2662 v8 = (char *)v8 + 2; |
810 | 2663 memcpy(v8, &Src.vdpi, 2u); |
0 | 2664 v8 = (char *)v8 + 2; |
2665 memcpy(v8, &v20, 0x30u); | |
2666 v8 = (char *)v8 + 48; | |
810 | 2667 memcpy(v8, &v27, 1u); |
0 | 2668 v8 = (char *)v8 + 1; |
810 | 2669 memcpy(v8, &v27.planes, 1u); |
0 | 2670 v8 = (char *)v8 + 1; |
810 | 2671 memcpy(v8, &v27.pitch, 2u); |
0 | 2672 v8 = (char *)v8 + 2; |
810 | 2673 memcpy(v8, &v27.palette_info, 2u); |
0 | 2674 v8 = (char *)v8 + 2; |
2675 memcpy(v8, &v18, 0x3Au); | |
2676 v9 = (char *)v8 + 58; | |
810 | 2677 |
1583 | 2678 lineRGB = (char*)malloc(3 * (wight + 2)); |
810 | 2679 if ( heidth > 0 ) |
2680 { | |
2681 v10 = pitch; | |
2682 v25 = heidth; | |
2683 v26 = 3 * pitch; | |
2684 v23 = 2 * wight; | |
2685 v11 = picture_data; | |
2686 v24 = (int)picture_data; | |
0 | 2687 while ( 1 ) |
2688 { | |
810 | 2689 line_pictute_data = v11; |
0 | 2690 v12 = 0; |
2691 i = 0; | |
810 | 2692 if ( wight > 0 ) |
2693 { | |
2694 lineG = (char *)lineRGB + pitch; | |
2695 lineB = (char *)lineRGB + 2 * pitch; | |
0 | 2696 do |
2697 { | |
810 | 2698 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); |
2699 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); | |
2700 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); | |
2701 | |
2702 v12++; | |
2703 } | |
2704 while ( v12 < wight ); | |
0 | 2705 } |
2706 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
2707 { | |
810 | 2708 test_byte = 1; |
2709 pict_byte = lineRGB [i]; | |
0 | 2710 do |
2711 { | |
810 | 2712 v15 = i + test_byte; |
2713 if ( *((char *)lineRGB + v15) != pict_byte ) | |
0 | 2714 break; |
810 | 2715 if ( !(v15 % pitch) ) |
0 | 2716 break; |
810 | 2717 ++test_byte; |
2718 } | |
2719 while ( test_byte < 0x3Fu ); | |
2720 if ( i + test_byte > v26 ) | |
2721 test_byte = 3 * pitch - i; | |
2722 if ( test_byte > 1u || pict_byte >= 0xC0u ) | |
2723 { | |
2724 v43 = test_byte | 0xC0; | |
0 | 2725 memcpy(v9, &v43, 1u); |
2726 v9 = (char *)v9 + 1; | |
2727 } | |
810 | 2728 memcpy(v9, &pict_byte, 1u); |
2729 i += test_byte; | |
2730 } | |
2731 v11 +=wight ; | |
0 | 2732 v16 = v25-- == 1; |
810 | 2733 |
0 | 2734 if ( v16 ) |
2735 break; | |
810 | 2736 v10 = pitch; |
2737 } | |
2738 } | |
1583 | 2739 free(lineRGB); |
810 | 2740 *(int *)packed_size = (char *)v9 - data_buff; |
2741 | |
0 | 2742 } |
2743 | |
2744 //----- (0049F8B5) -------------------------------------------------------- | |
2745 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) | |
2746 { | |
1430 | 2747 //Render *v5; // esi@1 |
0 | 2748 FILE *result; // eax@1 |
2749 FILE *v7; // edi@4 | |
2750 int v8; // ecx@5 | |
2751 int v9; // eax@5 | |
2752 int v10; // eax@7 | |
2753 int v11; // ecx@9 | |
2754 signed int v12; // eax@12 | |
2755 char v13; // zf@21 | |
2756 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
2757 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
2758 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
2759 int v17; // [sp+70h] [bp-34h]@5 | |
2760 int v18; // [sp+74h] [bp-30h]@5 | |
2761 char *v19; // [sp+78h] [bp-2Ch]@5 | |
2762 int v20; // [sp+7Ch] [bp-28h]@5 | |
2763 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
2764 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
2765 void *ptr; // [sp+98h] [bp-Ch]@4 | |
2766 int v24; // [sp+9Ch] [bp-8h]@2 | |
2767 char *i; // [sp+A0h] [bp-4h]@8 | |
2768 | |
2769 result = fopen(Filename, "wb"); | |
2770 Filename = (const char *)result; | |
2771 if ( result ) | |
2772 { | |
2773 v24 = a4; | |
2774 if ( a4 & 1 ) | |
2775 v24 = a4 + 1; | |
2776 header1.left = 0; | |
2777 header1.up = 0; | |
2778 header1.right = a4 - 1; | |
2779 header1.bottom = a5 - 1; | |
2780 header2.pitch = v24; | |
2781 memset(color_map, 0, sizeof(color_map)); | |
2782 header2.reserved = 0; | |
2783 memset(v14, 0, sizeof(v14)); | |
2784 v15 = 0; | |
2785 header1.manufacturer = 10; | |
2786 header1.version = 5; | |
2787 header1.encoding = 1; | |
2788 header1.bpp = 8; | |
2789 header1.hdpi = 75; | |
2790 header1.vdpi = 75; | |
2791 header2.planes = 3; | |
2792 header2.palette_info = 1; | |
2793 fwrite(&header1, 1u, 1u, (FILE *)Filename); | |
2794 v7 = (FILE *)Filename; | |
2795 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); | |
2796 fwrite(&header1.encoding, 1u, 1u, v7); | |
2797 fwrite(&header1.bpp, 1u, 1u, v7); | |
2798 fwrite(&header1.left, 2u, 1u, v7); | |
2799 fwrite(&header1.up, 2u, 1u, v7); | |
2800 fwrite(&header1.right, 2u, 1u, v7); | |
2801 fwrite(&header1.bottom, 2u, 1u, v7); | |
2802 fwrite(&header1.hdpi, 2u, 1u, v7); | |
2803 fwrite(&header1.vdpi, 2u, 1u, v7); | |
2804 fwrite(color_map, 0x30u, 1u, v7); | |
2805 fwrite(&header2, 1u, 1u, v7); | |
2806 fwrite(&header2.planes, 1u, 1u, v7); | |
2807 fwrite(&header2.pitch, 2u, 1u, v7); | |
2808 fwrite(&header2.palette_info, 2u, 1u, v7); | |
2809 fwrite(v14, 0x3Au, 1u, v7); | |
1583 | 2810 ptr = malloc(3 * a4 + 6); |
0 | 2811 if ( a5 > 0 ) |
2812 { | |
2813 v8 = v24; | |
2814 v18 = a5; | |
2815 v20 = 3 * v24; | |
2816 v17 = 2 * a4; | |
2817 v9 = (int)a3; | |
2818 v19 = a3; | |
2819 while ( 1 ) | |
2820 { | |
2821 a5 = v9; | |
2822 v10 = 0; | |
2823 if ( a4 > 0 ) | |
2824 { | |
2825 a3 = (char *)ptr + v8; | |
2826 i = (char *)ptr + 2 * v24; | |
2827 do | |
2828 { | |
1430 | 2829 *((char *)ptr + v10) = (signed int)(this->uTargetRMask & *(short *)a5) >> (LOBYTE(this->uTargetGBits) |
2830 + LOBYTE(this->uTargetBBits) | |
2831 + this->uTargetRBits | |
0 | 2832 - 8); |
1430 | 2833 a3[v10] = (signed int)(this->uTargetGMask & *(short *)a5) >> (LOBYTE(this->uTargetBBits) |
2834 + LOBYTE(this->uTargetGBits) | |
0 | 2835 - 8); |
2836 v11 = a5; | |
2837 a5 += 2; | |
1430 | 2838 i[v10++] = (this->uTargetBMask & *(char *)v11) << (8 - LOBYTE(this->uTargetBBits)); |
0 | 2839 } |
2840 while ( v10 < a4 ); | |
2841 } | |
2842 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) | |
2843 { | |
2844 BYTE3(a5) = 1; | |
2845 BYTE3(Filename) = *((char *)ptr + (int)i); | |
2846 do | |
2847 { | |
2848 v12 = (signed int)&i[BYTE3(a5)]; | |
2849 if ( *((char *)ptr + v12) != BYTE3(Filename) ) | |
2850 break; | |
2851 if ( !(v12 % v24) ) | |
2852 break; | |
2853 ++BYTE3(a5); | |
2854 } | |
2855 while ( BYTE3(a5) < 0x3Fu ); | |
2856 if ( (signed int)&i[BYTE3(a5)] > v20 ) | |
2857 BYTE3(a5) = 3 * v24 - (char)i; | |
2858 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) | |
2859 { | |
2860 BYTE3(a3) = BYTE3(a5) | 0xC0; | |
2861 fwrite((char *)&a3 + 3, 1u, 1u, v7); | |
2862 } | |
2863 fwrite((char *)&Filename + 3, 1u, 1u, v7); | |
2864 } | |
2865 v9 = (int)&v19[v17]; | |
2866 v13 = v18-- == 1; | |
2867 v19 += v17; | |
2868 if ( v13 ) | |
2869 break; | |
2870 v8 = v24; | |
2871 } | |
2872 } | |
1583 | 2873 free(ptr); |
0 | 2874 result = (FILE *)fclose(v7); |
2875 } | |
2876 return result; | |
2877 } | |
2878 | |
2879 //----- (0049FBCD) -------------------------------------------------------- | |
2880 void Render::ClearTarget(unsigned int uColor) | |
2881 { | |
2882 if (pRenderD3D) | |
2883 { | |
2884 if (field_40110) | |
2885 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
2886 } | |
2887 else | |
2888 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
2889 } | |
2890 | |
2891 //----- (0049FC23) -------------------------------------------------------- | |
2892 void Render::Release2() | |
2893 { | |
2894 Release(); | |
2895 bWindowMode = 1; | |
2896 } | |
2897 | |
2898 //----- (0049FC37) -------------------------------------------------------- | |
2899 void Render::Present() | |
2900 { | |
2901 Render *v1; // esi@1 | |
2902 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
2903 RECT a4; // [sp+18h] [bp-18h]@11 | |
2904 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
2905 | |
2906 v1 = this; | |
2907 if ( !pRenderer->pRenderD3D || this->field_40110 ) | |
2908 { | |
2909 this->pBeforePresentFunction(); | |
2910 if ( v1->pRenderD3D ) | |
2911 { | |
2912 if ( v1->field_40110 ) | |
2913 { | |
2914 pRenderD3D->Present(false); | |
2915 } | |
2916 } | |
2917 else | |
2918 { | |
2919 if ( v1->bWindowMode ) | |
2920 { | |
2921 RestoreFrontBuffer(); | |
2922 GetClientRect(v1->hWnd, &Rect); | |
2923 Point.y = 0; | |
2924 Point.x = 0; | |
2925 ClientToScreen(v1->hWnd, &Point); | |
2926 OffsetRect(&Rect, Point.x, Point.y); | |
2927 a4.top = 0; | |
2928 a4.bottom = 480; | |
2929 a4.left = 0; | |
2930 a4.right = 640; | |
2931 PresentRect(&Rect, &a4); | |
2932 } | |
2933 else | |
2934 { | |
2935 RestoreFrontBuffer(); | |
2936 a4.top = 0; | |
2937 a4.bottom = 480; | |
2938 a4.left = 0; | |
2939 a4.right = 640; | |
2940 BltBackToFontFast(0, 0, &a4); | |
2941 } | |
2942 } | |
2943 } | |
2944 } | |
2945 | |
2946 //----- (0049FD3A) -------------------------------------------------------- | |
2947 void Render::_49FD3A() | |
2948 { | |
2949 Render *v2; // esi@1 | |
2950 IDirectDrawSurface4 *v3; // eax@6 | |
2951 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
2952 RECT v5; // [sp+8h] [bp-10h]@6 | |
2953 | |
2954 auto a1 = this; | |
2955 v2 = a1; | |
2956 if ( a1->pRenderD3D ) | |
2957 { | |
2958 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
2959 pFrontBuffer4->Restore(); | |
2960 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
2961 pBackBuffer4->Restore(); | |
2962 v3 = v2->pBackBuffer4; | |
2963 v4 = v2->pFrontBuffer4; | |
2964 v5.top = 0; | |
2965 v5.bottom = 480; | |
2966 v5.left = 0; | |
2967 v5.right = 640; | |
2968 v3->BltFast(0, 0, v4, &v5, 16u); | |
2969 } | |
2970 } | |
2971 | |
2972 //----- (0049FDBF) -------------------------------------------------------- | |
2973 void Render::CreateZBuffer() | |
2974 { | |
2975 if (!pDefaultZBuffer) | |
2976 { | |
2977 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
1583 | 2978 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); |
871 | 2979 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 2980 } |
2981 } | |
2982 | |
2983 //----- (0049FE05) -------------------------------------------------------- | |
2984 void Render::Release() | |
2985 { | |
2986 Render *v1; // esi@1 | |
2987 RenderD3D *v2; // ecx@1 | |
2988 char v3; // zf@4 | |
2989 void *v4; // ebx@6 | |
2990 IDirectDraw *v5; // eax@10 | |
2991 IDirectDrawSurface2 *v6; // eax@11 | |
2992 IDirectDrawSurface2 *v7; // eax@13 | |
2993 IDirectDrawSurface2 *v8; // eax@15 | |
2994 IDirectDraw2 *v9; // eax@17 | |
2995 IDirectDraw4 *v10; // eax@19 | |
2996 IDirectDrawSurface4 *v11; // eax@20 | |
2997 IDirectDrawSurface4 *v12; // eax@22 | |
2998 IDirectDrawSurface4 *v13; // eax@24 | |
2999 IDirectDraw4 *v14; // eax@26 | |
3000 unsigned __int16 **v15; // ebx@28 | |
3001 void **v16; // esi@29 | |
3002 | |
3003 v1 = this; | |
3004 v2 = this->pRenderD3D; | |
3005 if ( v2 ) | |
3006 { | |
3007 if ( v1->field_40110 ) | |
3008 { | |
3009 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
3010 pRenderD3D->Present(0); | |
3011 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
3012 } | |
3013 v1->pColorKeySurface4 = 0; | |
3014 v1->pBackBuffer4 = 0; | |
3015 v3 = v1->pTargetSurface == 0; | |
3016 v1->pFrontBuffer4 = 0; | |
3017 v1->pDirectDraw4 = 0; | |
3018 if ( !v3 ) | |
3019 { | |
3020 free(v1->ptr_400E8); | |
3021 v1->pTargetSurface = 0; | |
3022 v1->ptr_400E8 = 0; | |
3023 } | |
3024 v4 = v1->pRenderD3D; | |
3025 if ( v4 ) | |
3026 { | |
3027 pRenderD3D->Release(); | |
3028 free(v4); | |
3029 } | |
3030 v1->pRenderD3D = 0; | |
3031 } | |
3032 else | |
3033 { | |
3034 if ( bWinNT4_0 == 1 ) | |
3035 { | |
3036 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
3037 if ( !v5 ) | |
3038 return; | |
3039 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
3040 v1->pDirectDraw2->FlipToGDISurface(); | |
3041 v6 = v1->pSomeSurface2; | |
3042 if ( v6 ) | |
3043 { | |
3044 v6->Release(); | |
3045 v1->pSomeSurface2 = 0; | |
3046 } | |
3047 v7 = v1->pBackBuffer2; | |
3048 if ( v7 ) | |
3049 { | |
3050 v7->Release(); | |
3051 v1->pBackBuffer2 = 0; | |
3052 } | |
3053 v8 = v1->pFrontBuffer2; | |
3054 if ( v8 ) | |
3055 { | |
3056 v8->Release(); | |
3057 v1->pFrontBuffer2 = 0; | |
3058 } | |
3059 v9 = v1->pDirectDraw2; | |
3060 if ( v9 ) | |
3061 { | |
3062 v9->Release(); | |
3063 v1->pDirectDraw2 = 0; | |
3064 } | |
3065 } | |
3066 else | |
3067 { | |
3068 v10 = v1->pDirectDraw4; | |
3069 if ( !v10 ) | |
3070 return; | |
3071 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
3072 v1->pDirectDraw4->FlipToGDISurface(); | |
3073 v11 = v1->pColorKeySurface4; | |
3074 if ( v11 ) | |
3075 { | |
3076 v11->Release(); | |
3077 v1->pColorKeySurface4 = 0; | |
3078 } | |
3079 v12 = v1->pBackBuffer4; | |
3080 if ( v12 ) | |
3081 { | |
3082 v12->Release(); | |
3083 v1->pBackBuffer4 = 0; | |
3084 } | |
3085 v13 = v1->pFrontBuffer4; | |
3086 if ( v13 ) | |
3087 { | |
3088 v13->Release(); | |
3089 v1->pFrontBuffer4 = 0; | |
3090 } | |
3091 v14 = v1->pDirectDraw4; | |
3092 if ( v14 ) | |
3093 { | |
3094 v14->Release(); | |
3095 v1->pDirectDraw4 = 0; | |
3096 } | |
3097 } | |
3098 v15 = &v1->pTargetSurface; | |
3099 if ( v1->pTargetSurface ) | |
3100 { | |
3101 v16 = (void **)&v1->ptr_400E8; | |
3102 free(*v16); | |
3103 *v15 = 0; | |
3104 *v16 = 0; | |
3105 } | |
3106 } | |
3107 } | |
3108 | |
3109 //----- (0049FFD7) -------------------------------------------------------- | |
3110 void Render::CreateSomeTexture() | |
3111 { | |
3112 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
3113 } | |
3114 | |
3115 //----- (0049FFFB) -------------------------------------------------------- | |
3116 bool Render::InitializeFullscreen(HWND hWnd) | |
3117 { | |
3118 //Render *v2; // esi@1 | |
3119 //HWND v3; // ebx@1 | |
3120 //void *v4; // eax@2 | |
3121 //RenderD3D *v5; // eax@3 | |
3122 unsigned int v6; // edx@5 | |
3123 RenderD3D__DevInfo *v7; // ecx@5 | |
3124 bool v8; // eax@6 | |
3125 RenderD3D *v9; // ecx@13 | |
3126 unsigned int v10; // eax@13 | |
3127 RenderD3D *v11; // eax@25 | |
3128 HRESULT v12; // eax@25 | |
3129 int v13; // ecx@25 | |
3130 int v14; // eax@27 | |
3131 signed int v15; // ebx@31 | |
3132 bool v16; // eax@35 | |
3133 char v17; // zf@35 | |
3134 IDirectDraw4 *v18; // eax@38 | |
3135 HRESULT v19; // eax@38 | |
3136 int *v20; // eax@39 | |
3137 int *v22; // eax@42 | |
3138 int v23; // ecx@42 | |
3139 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3140 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3141 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
3142 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
3143 void *v28; // [sp+2FCh] [bp-10h]@2 | |
3144 int v29; // [sp+308h] [bp-4h]@2 | |
3145 | |
3146 //v2 = this; | |
3147 this->field_40110 = 0; | |
3148 this->pColorKeySurface4 = 0; | |
3149 this->pBackBuffer4 = 0; | |
3150 this->pFrontBuffer4 = 0; | |
3151 this->pDirectDraw4 = 0; | |
3152 this->bColorKeySupported = 0; | |
3153 Release(); | |
3154 //v3 = hWnd; | |
3155 this->hWnd = hWnd; | |
3156 CreateZBuffer(); | |
3157 if ( bUserDirect3D ) | |
3158 { | |
3159 pRenderD3D = new RenderD3D; | |
3160 v28 = pRenderD3D; | |
3161 v6 = uDesiredDirect3DDevice; | |
3162 v29 = -1; | |
3163 v7 = pRenderD3D->pAvailableDevices; | |
3164 if ( v7[v6].bIsDeviceCompatible ) | |
3165 { | |
3166 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | |
3167 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
3168 } | |
3169 else | |
3170 { | |
3171 if ( v7[1].bIsDeviceCompatible ) | |
3172 { | |
3173 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | |
3174 uAcquiredDirect3DDevice = 1; | |
3175 } | |
3176 else | |
3177 { | |
3178 if ( !v7->bIsDeviceCompatible ) | |
1545 | 3179 Error("There aren't any D3D devices to create."); |
3180 | |
0 | 3181 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); |
3182 uAcquiredDirect3DDevice = 0; | |
3183 } | |
3184 } | |
3185 if ( !v8 ) | |
1545 | 3186 Error("D3Drend->Init failed."); |
3187 | |
0 | 3188 v9 = pRenderD3D; |
3189 pBackBuffer4 = v9->pBackBuffer; | |
3190 pFrontBuffer4 = v9->pFrontBuffer; | |
3191 pDirectDraw4 = v9->pHost; | |
3192 v10 = pRenderD3D->GetDeviceCaps(); | |
3193 if ( v10 & 1 ) | |
3194 { | |
3195 if ( pRenderD3D ) | |
3196 { | |
3197 pRenderD3D->Release(); | |
3198 delete pRenderD3D; | |
3199 } | |
3200 pRenderD3D = 0; | |
3201 pBackBuffer4 = 0; | |
3202 pFrontBuffer4 = 0; | |
3203 pDirectDraw4 = 0; | |
1545 | 3204 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3205 } |
3206 if ( v10 & 0x3E ) | |
3207 { | |
3208 if ( pRenderD3D ) | |
3209 { | |
3210 pRenderD3D->Release(); | |
3211 delete pRenderD3D; | |
3212 } | |
3213 pColorKeySurface4 = 0; | |
3214 pRenderD3D = 0; | |
3215 pBackBuffer4 = 0; | |
3216 pFrontBuffer4 = 0; | |
3217 pDirectDraw4 = 0; | |
1545 | 3218 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3219 } |
3220 if ( (v10 & 0x80u) != 0 ) | |
3221 { | |
3222 if ( pRenderD3D ) | |
3223 { | |
3224 pRenderD3D->Release(); | |
3225 delete pRenderD3D; | |
3226 } | |
3227 pRenderD3D = 0; | |
3228 pBackBuffer4 = 0; | |
3229 pFrontBuffer4 = 0; | |
3230 pDirectDraw4 = 0; | |
1545 | 3231 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3232 } |
3233 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
3234 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
3235 memset(&halCaps, 0, 0xFCu); | |
3236 halCaps.dwSize = 252; | |
3237 memset(&refCaps, 0, 0xFCu); | |
3238 v11 = pRenderD3D; | |
3239 refCaps.dwSize = 252; | |
3240 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
3241 v13 = halCaps.dwMinTextureWidth; | |
3242 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3243 v13 = halCaps.dwMinTextureHeight; | |
3244 v14 = halCaps.dwMaxTextureWidth; | |
3245 uMinDeviceTextureDim = v13; | |
3246 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
3247 v14 = halCaps.dwMaxTextureHeight; | |
3248 uMaxDeviceTextureDim = v14; | |
3249 if ( (unsigned int)v13 < 4 ) | |
3250 uMinDeviceTextureDim = 4; | |
3251 CreateSomeTexture(); | |
3252 v15 = 1; | |
3253 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3254 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
3255 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3256 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
3257 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3258 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
3259 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3260 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3261 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3262 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3263 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3264 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3265 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3266 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3267 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3268 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
3269 } | |
3270 else | |
3271 { | |
3272 CreateDirectDraw(); | |
3273 SetDirectDrawCooperationMode(hWnd, 1); | |
3274 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3275 CreateDirectDrawPrimarySurface(); | |
3276 v15 = 1; | |
3277 } | |
3278 ddpfPrimareSuface.dwSize = 32; | |
3279 GetTargetPixelFormat(&ddpfPrimareSuface); | |
3280 ParseTargetPixelFormat(); | |
3281 _49EBF1(); | |
3282 if ( pRenderD3D ) | |
3283 { | |
3284 v16 = IsColorKeySupported(pDirectDraw4); | |
3285 v17 = uAcquiredDirect3DDevice == v15; | |
3286 bColorKeySupported = v16; | |
3287 if ( !v17 ) | |
3288 bColorKeySupported = 0; | |
3289 if ( bColorKeySupported ) | |
3290 { | |
3291 memset(&ddsd2, 0, 0x7Cu); | |
3292 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3293 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3294 v18 = pDirectDraw4; | |
3295 ddsd2.dwSize = 124; | |
3296 ddsd2.dwFlags = 65543; | |
3297 ddsd2.ddsCaps.dwCaps = 2112; | |
3298 ddsd2.dwWidth = 640; | |
3299 ddsd2.dwHeight = 480; | |
3300 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3301 pBeforePresentFunction = Present_ColorKey; | |
3302 } | |
3303 else | |
3304 { | |
3305 pTargetSurface = 0; | |
3306 ptr_400E8 = 0; | |
1631 | 3307 v20 = (int *)malloc(0x96020u); |
0 | 3308 ptr_400E8 = v20; |
3309 if ( !v20 | |
3310 || (memset(&pDesc, 0, 0x7Cu), | |
3311 pDesc.dwSize = 124, | |
3312 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
3313 return 0; | |
3314 pBackBuffer4->Unlock(0); | |
3315 v22 = ptr_400E8 + 4; | |
3316 v23 = (unsigned int)pDesc.lpSurface & 7; | |
3317 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
3318 uTargetSurfacePitch = 640; | |
3319 pBeforePresentFunction = Present_NoColorKey; | |
3320 v15 = 1; | |
3321 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | |
3322 } | |
3323 field_40110 = v15; | |
3324 } | |
3325 else | |
3326 { | |
3327 pBeforePresentFunction = 0;//nullsub_1; | |
3328 } | |
3329 bWindowMode = 0; | |
3330 pParty->uFlags |= 2u; | |
1583 | 3331 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; __debugbreak(); // replace with actual float |
0 | 3332 pViewport->_4C02F8(36044); |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
3333 return v15 != 0; |
0 | 3334 } |
3335 | |
3336 //----- (004A05F3) -------------------------------------------------------- | |
3337 bool Render::SwitchToWindow(HWND hWnd) | |
3338 { | |
3339 //Render *v2; // esi@1 | |
3340 //void *v3; // eax@2 | |
3341 //RenderD3D *v4; // eax@3 | |
3342 //unsigned int v5; // edx@5 | |
3343 //RenderD3D__DevInfo *v6; // ecx@5 | |
3344 bool v7; // eax@7 | |
3345 //RenderD3D *v8; // ecx@12 | |
3346 unsigned int v9; // eax@12 | |
3347 RenderD3D *v10; // eax@24 | |
3348 HRESULT v11; // eax@24 | |
3349 int v12; // eax@24 | |
3350 int v13; // eax@26 | |
3351 bool v14; // eax@32 | |
3352 char v15; // zf@32 | |
3353 IDirectDraw4 *v16; // eax@35 | |
3354 HRESULT v17; // eax@35 | |
3355 int *v18; // eax@36 | |
3356 int *v19; // edx@38 | |
3357 int v20; // eax@38 | |
3358 unsigned int v21; // ecx@38 | |
3359 int v22; // eax@41 | |
3360 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
3361 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3362 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
3363 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
3364 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
3365 int v29; // [sp+308h] [bp-4h]@2 | |
3366 | |
3367 pParty->uFlags |= 2u; | |
3368 //v2 = this; | |
3369 flt_6BE3A0 = 0.55000001f; | |
3370 pViewport->_4C02F8(36044); | |
3371 field_40110 = 0; | |
3372 Release(); | |
3373 pColorKeySurface4 = 0; | |
3374 pBackBuffer4 = 0; | |
3375 pFrontBuffer4 = 0; | |
3376 pDirectDraw4 = 0; | |
3377 bColorKeySupported = 0; | |
3378 CreateZBuffer(); | |
3379 if ( bUserDirect3D ) | |
3380 { | |
1631 | 3381 /*v3 = malloc(0x148u); |
0 | 3382 thisa = (RenderD3D *)v3; |
3383 v29 = 0; | |
3384 if ( v3 ) | |
3385 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3386 else | |
3387 v4 = 0;*/ | |
3388 pRenderD3D = new RenderD3D; | |
3389 //v4 = pRenderD3D; | |
3390 //v5 = uDesiredDirect3DDevice; | |
3391 v29 = -1; | |
3392 //v6 = pRenderD3D->pAvailableDevices; | |
3393 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
3394 uDesiredDirect3DDevice != 1 ) | |
3395 { | |
3396 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | |
3397 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
3398 } | |
3399 else | |
3400 { | |
3401 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
1545 | 3402 Error("There aren't any D3D devices to init."); |
3403 | |
0 | 3404 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); |
3405 uAcquiredDirect3DDevice = 0; | |
3406 } | |
3407 if ( !v7 ) | |
1545 | 3408 Error("D3Drend->Init failed."); |
0 | 3409 |
3410 //v8 = pRenderD3D; | |
3411 pColorKeySurface4 = 0; | |
3412 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
3413 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3414 pDirectDraw4 = pRenderD3D->pHost; | |
3415 v9 = pRenderD3D->GetDeviceCaps(); | |
3416 if ( v9 & 1 ) | |
3417 { | |
3418 if (pRenderD3D) | |
3419 { | |
3420 pRenderD3D->Release(); | |
3421 delete pRenderD3D; | |
3422 } | |
3423 pRenderD3D = 0; | |
3424 pBackBuffer4 = 0; | |
3425 pFrontBuffer4 = 0; | |
3426 pDirectDraw4 = 0; | |
1545 | 3427 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3428 } |
3429 if ( v9 & 0x3E ) | |
3430 { | |
3431 if (pRenderD3D) | |
3432 { | |
3433 pRenderD3D->Release(); | |
3434 delete pRenderD3D; | |
3435 } | |
3436 pColorKeySurface4 = 0; | |
3437 pRenderD3D = 0; | |
3438 pBackBuffer4 = 0; | |
3439 pFrontBuffer4 = 0; | |
3440 pDirectDraw4 = 0; | |
1545 | 3441 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3442 } |
3443 if ( (v9 & 0x80u) != 0 ) | |
3444 { | |
3445 if (pRenderD3D) | |
3446 { | |
3447 pRenderD3D->Release(); | |
3448 delete pRenderD3D; | |
3449 } | |
3450 pRenderD3D = 0; | |
3451 pBackBuffer4 = 0; | |
3452 pFrontBuffer4 = 0; | |
3453 pDirectDraw4 = 0; | |
1545 | 3454 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3455 } |
3456 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
3457 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
3458 memset(&halCaps, 0, 0xFCu); | |
3459 halCaps.dwSize = 252; | |
3460 memset(&refCaps, 0, 0xFCu); | |
3461 //v10 = v2->pRenderD3D; | |
3462 refCaps.dwSize = 252; | |
3463 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3464 v12 = halCaps.dwMinTextureWidth; | |
3465 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3466 v12 = halCaps.dwMinTextureHeight; | |
3467 uMinDeviceTextureDim = v12; | |
3468 v13 = halCaps.dwMaxTextureWidth; | |
3469 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3470 v13 = halCaps.dwMaxTextureHeight; | |
3471 uMaxDeviceTextureDim = v13; | |
3472 CreateSomeTexture(); | |
3473 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
3474 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
3475 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3476 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
3477 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
3478 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3479 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3480 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3481 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3482 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3483 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3484 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3485 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3486 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3487 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
3488 } | |
3489 else | |
3490 { | |
3491 CreateDirectDraw(); | |
3492 SetDirectDrawCooperationMode(hWnd, 0); | |
3493 field_4004C = 1; | |
3494 CreateFrontBuffer(); | |
3495 CreateClipper(hWnd); | |
3496 CreateBackBuffer(); | |
3497 field_40030 = 0; | |
3498 field_18_locked_pitch = 0; | |
3499 } | |
3500 ddpfPrimareSuface.dwSize = 32; | |
3501 GetTargetPixelFormat(&ddpfPrimareSuface); | |
3502 ParseTargetPixelFormat(); | |
3503 _49EBF1(); | |
3504 if ( !pRenderD3D ) | |
3505 { | |
3506 pBeforePresentFunction = 0;//nullsub_1; | |
3507 goto LABEL_47; | |
3508 } | |
3509 v14 = IsColorKeySupported(pDirectDraw4); | |
3510 v15 = uAcquiredDirect3DDevice == 1; | |
3511 bColorKeySupported = v14; | |
3512 if ( !v15 ) | |
3513 bColorKeySupported = 0; | |
3514 if ( bColorKeySupported ) | |
3515 { | |
3516 memset(&ddsd2, 0, 0x7Cu); | |
3517 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3518 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3519 v16 = pDirectDraw4; | |
3520 ddsd2.dwSize = 124; | |
3521 ddsd2.dwFlags = 65543; | |
3522 ddsd2.ddsCaps.dwCaps = 2112; | |
3523 ddsd2.dwWidth = 640; | |
3524 ddsd2.dwHeight = 480; | |
3525 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3526 pBeforePresentFunction = Present_ColorKey; | |
3527 LABEL_45: | |
3528 field_40110 = 1; | |
3529 LABEL_47: | |
3530 bWindowMode = 1; | |
3531 hWnd = hWnd; | |
3532 return 0; | |
3533 } | |
3534 pTargetSurface = 0; | |
3535 ptr_400E8 = 0; | |
3536 v18 = (int *)new char[0x96020]; | |
3537 memset(v18, -1, 0x96020); | |
3538 ptr_400E8 = v18; | |
3539 if ( v18 ) | |
3540 { | |
3541 memset(&pDesc, 0, 0x7Cu); | |
3542 pDesc.dwSize = 124; | |
168 | 3543 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) |
0 | 3544 { |
3545 pRenderer->pBackBuffer4->Unlock(0); | |
3546 v19 = ptr_400E8; | |
3547 v20 = (unsigned int)pDesc.lpSurface & 7; | |
3548 v21 = (unsigned int)ptr_400E8 & 7; | |
3549 if ( v21 == v20 ) | |
3550 { | |
3551 pTargetSurface = (unsigned __int16 *)v19; | |
3552 } | |
3553 else | |
3554 { | |
3555 if ( (signed int)v21 >= v20 ) | |
3556 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
3557 else | |
3558 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
3559 pTargetSurface = (unsigned __int16 *)v22; | |
3560 } | |
3561 uTargetSurfacePitch = 640; | |
3562 pBeforePresentFunction = Present_NoColorKey; | |
3563 goto LABEL_45; | |
3564 } | |
3565 } | |
3566 return 0; | |
3567 } | |
3568 | |
3569 //----- (004A0BEE) -------------------------------------------------------- | |
709 | 3570 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) |
0 | 3571 { |
3572 int v6; // edi@1 | |
3573 int v7; // edx@5 | |
3574 unsigned int v8; // ebx@5 | |
3575 int v9; // eax@7 | |
3576 unsigned int v10; // ecx@9 | |
3577 unsigned int v11; // esi@13 | |
3578 int v12; // eax@17 | |
3579 int v13; // eax@21 | |
3580 Render *v14; // edi@21 | |
3581 int v15; // eax@25 | |
3582 int v16; // eax@27 | |
3583 signed int v17; // eax@28 | |
3584 signed int v18; // edi@30 | |
3585 signed __int64 v19; // qax@41 | |
3586 int v20; // edi@41 | |
3587 unsigned int v21; // edi@46 | |
3588 int v22; // esi@47 | |
3589 int v23; // ebx@47 | |
3590 signed int v24; // edx@50 | |
3591 signed int v25; // esi@52 | |
3592 unsigned __int16 *v26; // ecx@52 | |
3593 int v27; // ebx@54 | |
3594 int v28; // edi@55 | |
3595 int v29; // edx@55 | |
3596 int v30; // ebx@60 | |
3597 int v31; // edx@61 | |
3598 int v32; // edi@61 | |
3599 int v34; // [sp+Ch] [bp-10h]@3 | |
3600 Render *v35; // [sp+10h] [bp-Ch]@1 | |
3601 __int64 v36; // [sp+14h] [bp-8h]@1 | |
3602 signed int v37; // [sp+18h] [bp-4h]@28 | |
3603 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
3604 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | |
3605 int uYb; // [sp+28h] [bp+Ch]@47 | |
3606 int uZa; // [sp+2Ch] [bp+10h]@38 | |
3607 | |
3608 v36 = 0i64; | |
709 | 3609 v6 = this->raster_clip_x; |
0 | 3610 v35 = this; |
3611 if ( (signed int)uX < v6 ) | |
3612 HIDWORD(v36) = 8; | |
709 | 3613 v34 = this->raster_clip_z; |
3614 if ( (signed int)uX > this->raster_clip_z ) | |
0 | 3615 HIDWORD(v36) |= 4u; |
709 | 3616 v7 = this->raster_clip_y; |
0 | 3617 v8 = uY; |
3618 if ( (signed int)uY < v7 ) | |
3619 HIDWORD(v36) |= 2u; | |
709 | 3620 v9 = this->raster_clip_w; |
0 | 3621 if ( (signed int)uY > v9 ) |
3622 HIDWORD(v36) |= 1u; | |
3623 v10 = uZ; | |
3624 if ( (signed int)uZ < v6 ) | |
3625 LODWORD(v36) = 8; | |
3626 if ( (signed int)uZ > v34 ) | |
3627 LODWORD(v36) = v36 | 4; | |
3628 v11 = uW; | |
3629 if ( (signed int)uW < v7 ) | |
3630 LODWORD(v36) = v36 | 2; | |
3631 if ( (signed int)uW > v9 ) | |
3632 LODWORD(v36) = v36 | 1; | |
3633 LOBYTE(v12) = v36; | |
3634 if ( (unsigned int)v36 & HIDWORD(v36) ) | |
3635 return v12; | |
3636 if ( !v36 ) | |
3637 { | |
3638 LABEL_46: | |
3639 v21 = pRenderer->uTargetSurfacePitch; | |
3640 if ( pRenderer->uTargetSurfacePitch ) | |
3641 { | |
3642 v12 = uX + v8 * pRenderer->uTargetSurfacePitch; | |
3643 v22 = v11 - v8; | |
3644 v23 = v22; | |
3645 uYb = v22; | |
3646 if ( v22 < 0 ) | |
3647 { | |
3648 v23 = -v22; | |
3649 uYb = -v22; | |
3650 v21 = -pRenderer->uTargetSurfacePitch; | |
3651 } | |
3652 uXa = v10 - uX; | |
3653 if ( (uXa & 0x80000000u) == 0 ) | |
3654 { | |
3655 v24 = 1; | |
3656 } | |
3657 else | |
3658 { | |
3659 uXa = -uXa; | |
3660 v24 = -1; | |
3661 } | |
3662 v25 = 0; | |
3663 v26 = v35->pTargetSurface; | |
3664 if ( v26 ) | |
3665 { | |
3666 if ( (signed int)uXa <= v23 ) | |
3667 { | |
3668 v30 = v23 + 1; | |
3669 if ( v30 > 0 ) | |
3670 { | |
3671 v31 = 2 * v24; | |
3672 v32 = 2 * v21; | |
3673 v12 = (int)&v26[v12]; | |
3674 do | |
3675 { | |
3676 v25 += uXa; | |
3677 *(short *)v12 = uColor; | |
3678 v12 += v32; | |
3679 if ( v25 > 0 ) | |
3680 { | |
3681 v25 -= uYb; | |
3682 v12 += v31; | |
3683 } | |
3684 --v30; | |
3685 } | |
3686 while ( v30 ); | |
3687 } | |
3688 } | |
3689 else | |
3690 { | |
3691 v27 = uXa + 1; | |
3692 if ( (signed int)(uXa + 1) > 0 ) | |
3693 { | |
3694 v28 = 2 * v21; | |
3695 v29 = 2 * v24; | |
3696 v12 = (int)&v26[v12]; | |
3697 do | |
3698 { | |
3699 v25 += uYb; | |
3700 *(short *)v12 = uColor; | |
3701 v12 += v29; | |
3702 if ( v25 > (signed int)uXa ) | |
3703 { | |
3704 v25 -= uXa; | |
3705 v12 += v28; | |
3706 } | |
3707 --v27; | |
3708 } | |
3709 while ( v27 ); | |
3710 } | |
3711 } | |
3712 } | |
3713 } | |
3714 return v12; | |
3715 } | |
3716 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | |
3717 { | |
3718 if ( BYTE4(v36) & 8 ) | |
3719 { | |
3720 v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX); | |
3721 v14 = v35; | |
3722 v8 = v13 + uY; | |
709 | 3723 uX = v35->raster_clip_x; |
0 | 3724 goto LABEL_24; |
3725 } | |
3726 v10 = v6; | |
3727 v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW; | |
3728 } | |
3729 v14 = v35; | |
3730 LABEL_24: | |
3731 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
3732 { | |
709 | 3733 v15 = v14->raster_clip_z; |
0 | 3734 if ( BYTE4(v36) & 4 ) |
3735 { | |
3736 v14 = v35; | |
3737 v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX); | |
709 | 3738 uX = v35->raster_clip_z; |
0 | 3739 } |
3740 else | |
3741 { | |
3742 v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10); | |
709 | 3743 v10 = v14->raster_clip_z; |
0 | 3744 v11 += v16; |
3745 } | |
3746 } | |
709 | 3747 v17 = v14->raster_clip_y; |
0 | 3748 v37 = 0; |
709 | 3749 uYa = v14->raster_clip_y; |
0 | 3750 if ( (signed int)v8 < v17 ) |
3751 v37 = 2; | |
709 | 3752 v18 = v14->raster_clip_w; |
0 | 3753 if ( (signed int)v8 > v18 ) |
3754 v37 |= 1u; | |
3755 if ( (signed int)v11 >= v17 ) | |
3756 v12 = 0; | |
3757 else | |
3758 v12 = 2; | |
3759 if ( (signed int)v11 > v18 ) | |
3760 LOBYTE(v12) = v12 | 1; | |
3761 if ( !(v12 & v37) ) | |
3762 { | |
3763 v12 ^= v37; | |
3764 uZa = v12; | |
3765 if ( v12 & 2 ) | |
3766 { | |
3767 if ( v37 & 2 ) | |
3768 { | |
3769 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | |
3770 LOBYTE(v12) = (char)v35; | |
709 | 3771 v8 = v35->raster_clip_y; |
0 | 3772 } |
3773 else | |
3774 { | |
3775 v19 = (signed int)((uX - v10) * (uYa - v11)); | |
3776 v20 = v8 - v11; | |
3777 v11 = uYa; | |
3778 v12 = v19 / v20; | |
3779 v10 += v12; | |
3780 } | |
3781 } | |
3782 if ( uZa & 1 ) | |
3783 { | |
3784 if ( v37 & 1 ) | |
3785 { | |
709 | 3786 uX += (signed int)((v10 - uX) * (v35->raster_clip_w - v8)) / (signed int)(v11 - v8); |
0 | 3787 LOBYTE(v12) = (char)v35; |
709 | 3788 v8 = v35->raster_clip_w; |
0 | 3789 } |
3790 else | |
3791 { | |
709 | 3792 v12 = (signed int)((uX - v10) * (v35->raster_clip_w - v11)) / (signed int)(v8 - v11); |
3793 v11 = v35->raster_clip_w; | |
0 | 3794 v10 += v12; |
3795 } | |
3796 } | |
3797 goto LABEL_46; | |
3798 } | |
3799 return v12; | |
3800 } | |
3801 | |
3802 //----- (004A0E80) -------------------------------------------------------- | |
3803 void Render::ClearZBuffer(int a2, int a3) | |
3804 { | |
3805 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
3806 } | |
3807 | |
3808 //----- (004A0E97) -------------------------------------------------------- | |
709 | 3809 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
3810 { | |
3811 this->raster_clip_x = uX; | |
3812 this->raster_clip_y = uY; | |
3813 this->raster_clip_z = uZ; | |
3814 this->raster_clip_w = uW; | |
0 | 3815 } |
3816 | |
3817 //----- (004A0EB6) -------------------------------------------------------- | |
3818 void Render::ParseTargetPixelFormat() | |
3819 { | |
3820 Render *v1; // eax@1 | |
3821 signed int v2; // ecx@1 | |
3822 DWORD uRedMask; // edx@1 | |
3823 unsigned int uGreenMask; // esi@5 | |
3824 signed int v5; // ecx@5 | |
3825 unsigned int uBlueMask; // edx@9 | |
3826 signed int v7; // ecx@9 | |
3827 unsigned int v8; // ecx@13 | |
3828 | |
3829 v1 = this; | |
3830 v2 = 0; | |
3831 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | |
3832 v1->uTargetBBits = 0; | |
3833 v1->uTargetGBits = 0; | |
3834 v1->uTargetRBits = 0; | |
3835 do | |
3836 { | |
3837 if ( (1 << v2) & uRedMask ) | |
3838 ++v1->uTargetRBits; | |
3839 ++v2; | |
3840 } | |
3841 while ( v2 < 16 ); | |
3842 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | |
3843 v5 = 0; | |
3844 do | |
3845 { | |
3846 if ( (1 << v5) & uGreenMask ) | |
3847 ++v1->uTargetGBits; | |
3848 ++v5; | |
3849 } | |
3850 while ( v5 < 16 ); | |
3851 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | |
3852 v7 = 0; | |
3853 do | |
3854 { | |
3855 if ( (1 << v7) & uBlueMask ) | |
3856 ++v1->uTargetBBits; | |
3857 ++v7; | |
3858 } | |
3859 while ( v7 < 16 ); | |
3860 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
3861 v1->uTargetGMask = uGreenMask; | |
3862 v1->uTargetRMask = v8; | |
3863 v1->uTargetBMask = uBlueMask; | |
3864 } | |
3865 | |
3866 //----- (004A0F40) -------------------------------------------------------- | |
3867 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
3868 { | |
3869 IDirectDrawSurface4 *v4; // esi@1 | |
168 | 3870 HRESULT result; // eax@1 |
0 | 3871 HRESULT v6; // eax@4 |
3872 int v7; // [sp-8h] [bp-14h]@10 | |
3873 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
3874 char v9; // [sp+Bh] [bp-1h]@1 | |
3875 | |
3876 v4 = pSurface; | |
3877 v9 = 1; | |
3878 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
3879 if ( result == DDERR_SURFACELOST ) | |
3880 { | |
3881 v6 = v4->Restore(); | |
3882 if ( v6 ) | |
3883 { | |
3884 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
3885 { | |
3886 LABEL_20: | |
3887 v9 = 0; | |
3888 result = (bool)memset(pDesc, 0, 4u); | |
3889 goto LABEL_21; | |
3890 } | |
3891 pRenderer->pFrontBuffer4->Restore(); | |
3892 v4->Restore(); | |
3893 } | |
3894 result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
3895 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3896 goto LABEL_20; | |
3897 ErrD3D(result); | |
3898 if ( result ) | |
3899 { | |
3900 //v8 = 0; | |
3901 //v7 = 2161; | |
3902 LABEL_19: | |
3903 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
3904 goto LABEL_20; | |
3905 } | |
3906 if ( pRenderer->pRenderD3D ) | |
3907 pRenderD3D->HandleLostResources(); | |
3908 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
3909 } | |
3910 else | |
3911 { | |
3912 if ( result ) | |
3913 { | |
3914 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3915 goto LABEL_20; | |
3916 ErrD3D(result); | |
3917 //v8 = 0; | |
3918 //v7 = 2199; | |
3919 //goto LABEL_19; | |
3920 } | |
3921 } | |
3922 LABEL_21: | |
3923 LOBYTE(result) = v9; | |
3924 return result; | |
3925 } | |
3926 | |
3927 //----- (004A1032) -------------------------------------------------------- | |
3928 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
3929 { | |
3930 IDirectDrawSurface2 *v4; // esi@1 | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
3931 HRESULT v5; // eax@1 |
0 | 3932 HRESULT v6; // eax@2 |
3933 int v7; // [sp-8h] [bp-10h]@8 | |
3934 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
3935 | |
3936 v4 = pSurface; | |
3937 v5 = pSurface->Lock( | |
3938 0, | |
3939 pDesc, | |
3940 uLockFlags, | |
3941 0); | |
3942 BYTE3(pSurface) = 1; | |
3943 if ( v5 == DDERR_SURFACELOST ) | |
3944 { | |
3945 v6 = v4->Restore(); | |
3946 if ( !v6 ) | |
3947 goto LABEL_5; | |
3948 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
3949 { | |
3950 pRenderer->pFrontBuffer2->Restore(); | |
3951 v4->Restore(); | |
3952 LABEL_5: | |
3953 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
3954 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
3955 goto LABEL_14; | |
3956 if ( !v5 ) | |
3957 return true; | |
3958 ErrD3D(v5); | |
3959 //v8 = 0; | |
3960 //v7 = 2247; | |
3961 goto LABEL_13; | |
3962 } | |
3963 else | |
3964 { | |
3965 pDesc->dwSize = 0; | |
3966 return false; | |
3967 } | |
3968 } | |
3969 else | |
3970 { | |
3971 if ( !v5 ) | |
3972 return true; | |
3973 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
3974 { | |
3975 //v8 = 0; | |
3976 //v7 = 2269; | |
3977 ErrD3D(v5); | |
3978 pDesc->dwSize = 0; | |
3979 return false; | |
3980 LABEL_13: | |
3981 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
3982 goto LABEL_14; | |
3983 } | |
3984 } | |
3985 LABEL_14: | |
3986 return true; | |
3987 } | |
3988 | |
3989 //----- (004A10E4) -------------------------------------------------------- | |
3990 void Render::CreateDirectDraw() | |
3991 { | |
3992 Render *v1; // edi@1 | |
3993 HRESULT v2; // eax@1 | |
3994 HRESULT v3; // eax@5 | |
3995 int v6; // [sp-Ch] [bp-20h]@3 | |
3996 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
3997 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
3998 | |
3999 v1 = this; | |
4000 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
4001 | |
4002 pDirectDraw2 = nullptr; | |
4003 pDirectDraw4 = nullptr; | |
4004 | |
4005 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4006 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
4007 else | |
4008 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
4009 | |
4010 lpDD->Release(); | |
4011 lpDD = nullptr; | |
4012 } | |
4013 | |
4014 //----- (004A1169) -------------------------------------------------------- | |
4015 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
4016 { | |
4017 DWORD flags; // eax@1 | |
4018 IDirectDraw *v4; // ecx@3 | |
4019 HRESULT v5; // eax@5 | |
4020 int v6; // [sp-8h] [bp-8h]@3 | |
4021 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
4022 | |
4023 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
4024 DDSCL_NORMAL; | |
4025 | |
4026 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4027 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
4028 else | |
4029 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
4030 } | |
4031 | |
4032 //----- (004A11C6) -------------------------------------------------------- | |
4033 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
4034 { | |
4035 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4036 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
4037 else | |
4038 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
4039 } | |
4040 | |
4041 //----- (004A121C) -------------------------------------------------------- | |
4042 void Render::CreateFrontBuffer() | |
4043 { | |
4044 Render *v1; // esi@1 | |
4045 IDirectDraw *pDD; // eax@3 | |
4046 IDirectDrawSurface **pOutSurf; // esi@3 | |
4047 struct _DDSURFACEDESC *v4; // edx@3 | |
4048 HRESULT v5; // eax@5 | |
4049 int v6; // [sp-8h] [bp-8Ch]@3 | |
4050 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4051 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4052 | |
4053 v1 = this; | |
4054 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4055 { | |
4056 memset(&a2, 0, 0x7Cu); | |
4057 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
4058 a2.dwSize = 124; | |
4059 a2.dwFlags = 1; | |
4060 v7 = 0; | |
4061 a2.ddsCaps.dwCaps = 512; | |
4062 v6 = 2357; | |
4063 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
4064 v4 = (struct _DDSURFACEDESC *)&a2; | |
4065 } | |
4066 else | |
4067 { | |
4068 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
4069 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
4070 a2.lPitch = 108; | |
4071 a2.dwBackBufferCount = 1; | |
4072 v7 = 0; | |
4073 a2.dwTextureStage = 512; | |
4074 v6 = 2346; | |
4075 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
4076 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
4077 } | |
4078 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
4079 } | |
4080 | |
4081 //----- (004A12CD) -------------------------------------------------------- | |
4082 void Render::CreateBackBuffer() | |
4083 { | |
4084 Render *v1; // esi@1 | |
4085 IDirectDraw *v2; // eax@3 | |
4086 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
4087 struct _DDSURFACEDESC *v4; // edx@3 | |
4088 HRESULT v5; // eax@5 | |
4089 int v6; // [sp-8h] [bp-8Ch]@3 | |
4090 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4091 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4092 | |
4093 v1 = this; | |
4094 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4095 { | |
4096 memset(&a2, 0, 0x7Cu); | |
4097 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
4098 a2.dwSize = 124; | |
4099 a2.dwFlags = 7; | |
4100 v7 = 0; | |
4101 a2.ddsCaps.dwCaps = 2112; | |
4102 a2.dwWidth = 640; | |
4103 a2.dwHeight = 480; | |
4104 v6 = 2387; | |
4105 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4106 v4 = (struct _DDSURFACEDESC *)&a2; | |
4107 } | |
4108 else | |
4109 { | |
4110 memset(&a2.lPitch, 0, 0x6Cu); | |
4111 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4112 a2.lPitch = 108; | |
4113 a2.dwBackBufferCount = 7; | |
4114 v7 = 0; | |
4115 a2.dwTextureStage = 2112; | |
4116 a2.dwAlphaBitDepth = 640; | |
4117 a2.dwMipMapCount = 480; | |
4118 v6 = 2374; | |
4119 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4120 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
4121 } | |
4122 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
4123 } | |
4124 | |
4125 //----- (004A139A) -------------------------------------------------------- | |
4126 void Render::CreateDirectDrawPrimarySurface() | |
4127 { | |
4128 Render *v1; // esi@1 | |
4129 int v2; // ebx@3 | |
4130 IDirectDraw2 *v3; // eax@3 | |
4131 HRESULT v4; // eax@3 | |
4132 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
4133 DDSCAPS2 *v6; // edx@3 | |
4134 IDirectDraw4 *v7; // eax@4 | |
4135 HRESULT v8; // eax@4 | |
4136 int v9; // ST14_4@5 | |
4137 IDirectDrawSurface *v10; // ST10_4@5 | |
4138 HRESULT v11; // eax@5 | |
4139 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
4140 const char *v13; // [sp+0h] [bp-A0h]@0 | |
4141 int v14; // [sp+4h] [bp-9Ch]@0 | |
4142 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
4143 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
4144 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
4145 int a4; // [sp+98h] [bp-8h]@3 | |
4146 | |
4147 v1 = this; | |
4148 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4149 { | |
4150 v2 = 0; | |
4151 this->field_4004C = 1; | |
4152 memset(&ddsd2, 0, 0x7Cu); | |
4153 v7 = v1->pDirectDraw4; | |
4154 ddsd2.dwBackBufferCount = 1; | |
4155 ddsd2.dwSize = 0x7Cu; | |
4156 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4157 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4158 ErrD3D(v7->CreateSurface( | |
4159 &ddsd2, | |
4160 &pFrontBuffer4, | |
4161 0)); | |
4162 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
4163 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4164 } | |
4165 else | |
4166 { | |
4167 v2 = 0; | |
4168 this->field_4004C = 1; | |
4169 | |
4170 DDSURFACEDESC ddsd; | |
4171 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4172 | |
4173 ddsd.lpSurface = (LPVOID)1; | |
4174 ddsd.lPitch = 108; | |
4175 ddsd.dwBackBufferCount = 33; | |
4176 ddsd.ddsCaps.dwCaps = 8728; | |
4177 ErrD3D(pDirectDraw2->CreateSurface( | |
4178 &ddsd, | |
4179 (IDirectDrawSurface **)&pFrontBuffer2, | |
4180 0)); | |
4181 | |
4182 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4183 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4184 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4185 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used |
0 | 4186 v9 = (int)v6; |
4187 v10 = pFrontBuffer; // BUG | |
4188 | |
4189 v17.dwCaps = 4; | |
4190 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4191 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
4192 v1->field_40030 = v2; | |
4193 v1->field_18_locked_pitch = v2; | |
4194 } | |
4195 | |
4196 //----- (004A14F4) -------------------------------------------------------- | |
4197 void Render::CreateClipper(HWND a2) | |
4198 { | |
4199 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4200 { | |
4201 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
4202 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4203 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
4204 } | |
4205 else | |
4206 { | |
4207 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
4208 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4209 } | |
4210 } | |
4211 | |
4212 //----- (004A15D8) -------------------------------------------------------- | |
4213 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4214 { | |
4215 IDirectDrawSurface *v2; // eax@3 | |
4216 | |
4217 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4218 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4219 else | |
4220 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4221 v2->GetPixelFormat(pOut); | |
4222 } | |
4223 | |
4224 //----- (004A1605) -------------------------------------------------------- | |
4225 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4226 { | |
4227 Render *v3; // esi@1 | |
4228 signed int v4; // eax@3 | |
4229 | |
4230 v3 = this; | |
4231 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4232 { | |
4233 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4234 memset(&pDesc, 0, 0x7Cu); | |
4235 pDesc.dwSize = 124; | |
168 | 4236 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4237 *pOutSurfacePtr = pDesc.lpSurface; |
4238 v4 = pDesc.lPitch; | |
4239 } | |
4240 else | |
4241 { | |
4242 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4243 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4244 pDesc.lPitch = 108; | |
4245 LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); | |
4246 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
4247 v4 = pDesc.dwReserved; | |
4248 } | |
4249 *pOutPixelsPerRow = v4 >> 1; | |
4250 } | |
4251 | |
4252 //----- (004A169E) -------------------------------------------------------- | |
4253 bool Render::UsingDirect3D() | |
4254 { | |
4255 return bUserDirect3D == 0; | |
4256 } | |
4257 | |
4258 //----- (004A16E1) -------------------------------------------------------- | |
4259 void Render::UnlockBackBuffer() | |
4260 { | |
4261 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4262 ErrD3D(pBackBuffer4->Unlock(0)); | |
4263 else | |
4264 ErrD3D(pBackBuffer2->Unlock(0)); | |
4265 } | |
4266 | |
4267 //----- (004A172E) -------------------------------------------------------- | |
4268 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4269 { | |
4270 Render *v3; // esi@1 | |
4271 signed int v4; // eax@3 | |
4272 | |
4273 v3 = this; | |
4274 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4275 { | |
4276 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4277 memset(&pDesc, 0, 0x7Cu); | |
4278 pDesc.dwSize = 124; | |
168 | 4279 LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4280 *pOutSurface = pDesc.lpSurface; |
4281 v4 = pDesc.lPitch; | |
4282 } | |
4283 else | |
4284 { | |
4285 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4286 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4287 pDesc.lPitch = 108; | |
4288 LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); | |
4289 *pOutSurface = (void *)pDesc.lpSurface; | |
4290 v4 = pDesc.dwReserved; | |
4291 } | |
4292 *pOutPixelsPerRow = v4 >> 1; | |
4293 } | |
4294 | |
4295 //----- (004A17C7) -------------------------------------------------------- | |
4296 void Render::UnlockFrontBuffer() | |
4297 { | |
4298 IDirectDrawSurface *pFront; // eax@3 | |
4299 HRESULT v2; // eax@5 | |
4300 signed int v3; // [sp-8h] [bp-Ch]@3 | |
4301 int v4; // [sp-4h] [bp-8h]@3 | |
4302 | |
4303 auto a5 = this; | |
4304 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4305 { | |
4306 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
4307 v4 = 0; | |
4308 v3 = 2615; | |
4309 } | |
4310 else | |
4311 { | |
4312 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
4313 v4 = 0; | |
4314 v3 = 2611; | |
4315 } | |
4316 ErrD3D(pFront->Unlock(0)); | |
4317 } | |
4318 | |
4319 //----- (004A1814) -------------------------------------------------------- | |
4320 void Render::RestoreFrontBuffer() | |
4321 { | |
4322 IDirectDrawSurface **v1; // esi@2 | |
4323 | |
4324 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
4325 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
4326 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
4327 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
4328 (*v1)->Restore(); | |
4329 } | |
4330 | |
4331 //----- (004A184C) -------------------------------------------------------- | |
4332 HRESULT Render::_4A184C() | |
4333 { | |
4334 IDirectDrawSurface **pBack; // esi@2 | |
4335 HRESULT result; // eax@4 | |
4336 | |
4337 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
4338 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
4339 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
4340 result = (*pBack)->IsLost(); | |
4341 if ( result == DDERR_SURFACELOST ) | |
4342 result = (*pBack)->Restore(); | |
4343 return result; | |
4344 } | |
4345 | |
4346 //----- (004A1884) -------------------------------------------------------- | |
4347 void Render::PresentRect(RECT *a2, RECT *a3) | |
4348 { | |
4349 IDirectDrawSurface *pFront; // eax@3 | |
4350 HRESULT v4; // eax@5 | |
4351 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
4352 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
4353 DWORD v7; // [sp-14h] [bp-14h]@3 | |
4354 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
4355 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
4356 int v10; // [sp-8h] [bp-8h]@3 | |
4357 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
4358 | |
4359 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4360 { | |
4361 v11 = 0; | |
4362 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4363 v10 = 2657; | |
4364 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4365 v8 = 0; | |
4366 v7 = DDBLT_WAIT; | |
4367 v6 = a3; | |
4368 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4369 } | |
4370 else | |
4371 { | |
4372 v11 = 0; | |
4373 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4374 v10 = 2653; | |
4375 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4376 v8 = 0; | |
4377 v7 = DDBLT_WAIT; | |
4378 v6 = a3; | |
4379 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
4380 } | |
4381 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
4382 } | |
4383 | |
4384 //----- (004A18F5) -------------------------------------------------------- | |
4385 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4386 { | |
4387 IDirectDrawSurface *pFront; // eax@3 | |
4388 HRESULT v6; // eax@5 | |
4389 int v7; // [sp-8h] [bp-8h]@3 | |
4390 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
4391 | |
4392 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
4393 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
4394 else | |
4395 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
4396 } | |
4397 | |
4398 //----- (004A194A) -------------------------------------------------------- | |
4399 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
4400 { | |
4401 IDirectDrawSurface *pFront; // eax@3 | |
4402 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
4403 | |
4404 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4405 { | |
4406 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4407 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4408 } | |
4409 else | |
4410 { | |
4411 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4412 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
4413 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4414 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 4415 } |
4416 | |
4417 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4418 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4419 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4420 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4421 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4422 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4423 //int v6; // ecx@5 |
0 | 4424 unsigned int v7; // edx@6 |
4425 char *v8; // ecx@12 | |
4426 void *v9; // edi@16 | |
4427 unsigned int v10; // eax@16 | |
4428 void *v11; // edi@21 | |
4429 unsigned int v12; // eax@21 | |
4430 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4431 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4432 if (uNumBillboardsToDraw >= 999 ) |
0 | 4433 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4434 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4435 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4436 uNumBillboardsToDraw = 1; |
0 | 4437 return 0; |
4438 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4439 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4440 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4441 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4442 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4443 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
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 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4446 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4447 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4448 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4449 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4450 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4451 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4452 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4453 if (z > *(float *)v8 ) |
0 | 4454 { |
4455 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
4456 { | |
4457 v7 = pRenderer->uNumBillboardsToDraw; | |
4458 } | |
4459 else | |
4460 { | |
4461 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4462 { | |
4463 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
4464 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
4465 do | |
4466 { | |
4467 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
4468 v9 = (char *)v9 - 156; | |
4469 --v10; | |
4470 } | |
4471 while ( v10 ); | |
4472 } | |
4473 ++v7; | |
4474 } | |
717 | 4475 //LABEL_23: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4476 uNumBillboardsToDraw++; |
0 | 4477 return v7; |
4478 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4479 if (z <= *(float *)v8 ) |
0 | 4480 { |
4481 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4482 { | |
4483 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
4484 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
4485 do | |
4486 { | |
4487 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
4488 v11 = (char *)v11 - 156; | |
4489 --v12; | |
4490 } | |
4491 while ( v12 ); | |
4492 } | |
717 | 4493 //goto LABEL_23; |
4494 uNumBillboardsToDraw++; | |
4495 return v7; | |
0 | 4496 } |
4497 return v7; | |
4498 } | |
4499 | |
4500 //----- (004A1E9D) -------------------------------------------------------- | |
4501 unsigned int Render::GetBillboardDrawListSize() | |
4502 { | |
4503 return pRenderer->uNumBillboardsToDraw; | |
4504 } | |
4505 | |
4506 //----- (004A1EA3) -------------------------------------------------------- | |
4507 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
4508 { | |
4509 return pRenderer->pBillboardRenderListD3D[uBillboardID].uParentBillboardID; | |
4510 } | |
4511 | |
4512 //----- (004A1EB6) -------------------------------------------------------- | |
4513 void Render::BeginSceneD3D() | |
4514 { | |
4515 if (!uNumD3DSceneBegins++) | |
4516 { | |
4517 if (pRenderD3D) | |
4518 { | |
4519 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
4520 pRenderer->uNumBillboardsToDraw = 0; | |
4521 pRenderD3D->pDevice->BeginScene(); | |
1390 | 4522 |
0 | 4523 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
4524 uFogColor = GetLevelFogColor(); | |
4525 else | |
4526 uFogColor = 0; | |
4527 | |
4528 if ( uFogColor & 0xFF000000 ) | |
4529 { | |
4530 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
4531 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
4532 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4533 bUsingSpecular = true; | |
4534 } | |
4535 else | |
4536 { | |
4537 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
4538 bUsingSpecular = 0; | |
4539 } | |
4540 } | |
4541 else | |
4542 { | |
4543 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
4544 if (pTargetSurface) | |
4545 field_18_locked_pitch = uTargetSurfacePitch; | |
4546 else | |
4547 --uNumD3DSceneBegins; | |
4548 } | |
4549 } | |
4550 } | |
4551 | |
4552 //----- (004A1FE1) -------------------------------------------------------- | |
4553 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
4554 { | |
4555 --uNumD3DSceneBegins; | |
4556 if (uNumD3DSceneBegins) | |
4557 return; | |
4558 | |
4559 if (pRenderD3D) | |
4560 { | |
4561 pGame->draw_debug_outlines(); | |
161 | 4562 DoRenderBillboards_D3D(); |
0 | 4563 pGame->pStru6Instance->RenderSpecialEffects(); |
4564 pRenderD3D->pDevice->EndScene(); | |
4565 } | |
4566 else | |
4567 pGame->pStru6Instance->RenderSpecialEffects(); | |
4568 } | |
4569 | |
4570 //----- (004A2031) -------------------------------------------------------- | |
349 | 4571 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
4572 { | |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4573 // __debugbreak(); // should not fire outside decal builder |
349 | 4574 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 4575 } |
4576 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4577 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 4578 { |
4579 int v5; // ebx@1 | |
4580 int v6; // edi@1 | |
4581 int v8; // eax@7 | |
4582 float v9; // eax@12 | |
4583 float *v10; // esi@12 | |
4584 float v11; // ecx@14 | |
4585 double v12; // st7@14 | |
4586 double v13; // st7@14 | |
4587 double v14; // st7@14 | |
4588 signed int v15; // eax@14 | |
4589 int v16; // eax@15 | |
4590 float v17; // ST48_4@15 | |
4591 char v18; // zf@17 | |
4592 int v19; // eax@18 | |
4593 int v20; // eax@18 | |
4594 int v21; // edx@20 | |
4595 signed int v22; // ecx@20 | |
4596 int v23; // eax@20 | |
4597 const char *v24; // ST4C_4@20 | |
4598 unsigned int v25; // ST50_4@20 | |
4599 int v26; // ST54_4@20 | |
4600 int v27; // eax@20 | |
4601 _UNKNOWN *v28; // eax@21 | |
4602 int v29; // ecx@23 | |
4603 int v30; // eax@23 | |
4604 int v31; // eax@23 | |
4605 int v32; // eax@24 | |
4606 int v33; // eax@25 | |
4607 int v34; // eax@25 | |
4608 int v35; // eax@25 | |
4609 int v36; // eax@25 | |
4610 signed int v37; // ecx@26 | |
4611 int v38; // eax@26 | |
4612 _UNKNOWN *v39; // eax@27 | |
4613 int v40; // edx@28 | |
4614 int v41; // eax@29 | |
4615 int v42; // eax@29 | |
4616 int v43; // eax@29 | |
4617 int v44; // eax@29 | |
4618 unsigned int v46; // eax@29 | |
4619 int v47; // eax@30 | |
4620 int v48; // eax@30 | |
4621 int v49; // eax@30 | |
4622 double v52; // st6@35 | |
4623 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
4624 int v57; // [sp+5Ch] [bp-Ch]@3 | |
4625 signed int v59; // [sp+60h] [bp-8h]@12 | |
4626 int v61; // [sp+64h] [bp-4h]@4 | |
4627 int i; | |
4628 | |
4629 v6 = (int)this; | |
4630 v5 = 0; | |
4631 if (!this->uNumD3DSceneBegins) | |
4632 return; | |
4633 | |
4634 | |
4635 | |
4636 | |
186 | 4637 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 4638 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
4639 if (this->bUsingSpecular) | |
4640 { | |
186 | 4641 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4642 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4643 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 4644 } |
4645 | |
4646 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
4647 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
1637 | 4648 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4649 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); |
4650 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
4651 pVertices[0].specular = 0; | |
4652 pVertices[0].texcoord.x = array_50AC10[0].u; | |
4653 pVertices[0].texcoord.y = array_50AC10[0].v; | |
4654 | |
4655 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
4656 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
1637 | 4657 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4658 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); |
4659 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
4660 pVertices[1].specular = 0; | |
4661 pVertices[1].texcoord.x = array_50AC10[3].u; | |
4662 pVertices[1].texcoord.y = array_50AC10[3].v; | |
4663 | |
4664 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
4665 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
1637 | 4666 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4667 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); |
4668 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
4669 pVertices[2].specular = 0; | |
4670 pVertices[2].texcoord.x = array_50AC10[1].u; | |
4671 pVertices[2].texcoord.y = array_50AC10[1].v; | |
4672 | |
4673 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
4674 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
4675 | |
4676 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
4677 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
1637 | 4678 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4679 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); |
4680 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
4681 pVertices[5].specular = 0; | |
4682 pVertices[5].texcoord.x = array_50AC10[2].u; | |
4683 pVertices[5].texcoord.y = array_50AC10[2].v; | |
4684 | |
4685 | |
4686 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4687 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
4688 | |
186 | 4689 }*/ |
4690 | |
0 | 4691 //----- (004A26BC) -------------------------------------------------------- |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4692 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
186 | 4693 { |
4694 //RenderVertexSoft *pVertices; // esi@0 | |
4695 //int v7; // edi@1 | |
0 | 4696 unsigned int v8; // ebx@1 |
4697 LightmapBuilder *v9; // esi@3 | |
4698 unsigned int v10; // edx@3 | |
4699 int v11; // eax@5 | |
4700 int v12; // eax@11 | |
4701 char *v13; // esi@11 | |
4702 double v14; // st7@13 | |
4703 double v15; // st7@13 | |
4704 signed int v16; // eax@13 | |
4705 int v17; // ecx@13 | |
4706 double v18; // st7@13 | |
4707 float v19; // ST78_4@14 | |
4708 int v20; // eax@14 | |
4709 char v21; // zf@16 | |
4710 HRESULT v22; // eax@17 | |
4711 HRESULT v23; // eax@17 | |
4712 HRESULT v24; // eax@19 | |
4713 HRESULT v25; // eax@19 | |
4714 unsigned int v26; // ecx@19 | |
4715 char *v27; // eax@20 | |
4716 HRESULT v28; // eax@22 | |
4717 HRESULT v29; // eax@22 | |
4718 HRESULT v30; // eax@23 | |
4719 HRESULT v31; // eax@24 | |
4720 HRESULT v32; // eax@24 | |
4721 HRESULT v33; // eax@24 | |
4722 HRESULT v34; // eax@24 | |
4723 HRESULT v35; // eax@25 | |
4724 HRESULT v36; // eax@25 | |
4725 unsigned int v37; // ecx@25 | |
4726 char *v38; // eax@26 | |
4727 int v39; // edx@27 | |
4728 HRESULT v40; // eax@28 | |
4729 HRESULT v41; // eax@28 | |
4730 HRESULT v42; // eax@28 | |
4731 HRESULT v43; // eax@28 | |
4732 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
4733 unsigned int v45; // eax@28 | |
4734 HRESULT v46; // eax@29 | |
4735 HRESULT v47; // eax@29 | |
4736 HRESULT v48; // eax@29 | |
186 | 4737 //IDirect3DDevice3 *v49; // eax@35 |
0 | 4738 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
4739 int v51; // eax@40 | |
4740 char *v52; // esi@40 | |
4741 double v53; // st7@42 | |
4742 double v54; // st7@42 | |
4743 signed int v55; // eax@42 | |
4744 int v56; // ecx@42 | |
4745 double v57; // st7@42 | |
4746 float v58; // ST7C_4@43 | |
4747 int v59; // eax@43 | |
186 | 4748 //signed int v60; // [sp+78h] [bp-14h]@31 |
4749 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 4750 const char *v62; // [sp+80h] [bp-Ch]@0 |
4751 const char *v63; // [sp+80h] [bp-Ch]@19 | |
4752 int v64; // [sp+84h] [bp-8h]@0 | |
4753 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
4754 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
4755 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 4756 int a7; |
4757 | |
4758 //v7 = (int)this; | |
0 | 4759 v8 = 0; |
186 | 4760 if (!this->uNumD3DSceneBegins) |
75 | 4761 return; |
4762 if ( uNumVertices < 3) | |
4763 return; | |
4764 | |
186 | 4765 //v61 = pVertices; |
4766 | |
75 | 4767 /* v9 = pGame->pLightmapBuilder; |
0 | 4768 v65 = v9; |
75 | 4769 v10 = v9->std__vector_000004_size;*/ |
1394 | 4770 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) |
0 | 4771 { |
638 | 4772 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 4773 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); |
0 | 4774 } |
4775 else | |
4776 { | |
186 | 4777 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 4778 byte_4D864C && pGame->uFlags & 2 ) |
4779 { | |
186 | 4780 if (clampAtTextureBorders) |
4781 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 4782 else |
186 | 4783 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
4784 | |
4785 if (transparent || this->bUsingSpecular) | |
4786 { | |
4787 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4788 if (transparent) | |
0 | 4789 { |
186 | 4790 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
4791 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
4792 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
4793 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 4794 } |
4795 else | |
4796 { | |
186 | 4797 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
4798 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 4799 } |
186 | 4800 } |
1073 | 4801 |
4802 for (uint i = 0; i < uNumVertices; ++i) | |
4803 { | |
4804 | |
4805 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4806 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4807 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4808 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4809 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4810 if ( this->bUsingSpecular ) | |
0 | 4811 { |
1073 | 4812 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4813 } |
1073 | 4814 else |
4815 { | |
4816 d3d_vertex_buffer[i].specular = 0; | |
4817 } | |
4818 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4819 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4820 } | |
4821 | |
4822 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4823 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
186 | 4824 if (transparent) |
4825 { | |
4826 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
4827 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4828 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4829 } |
4830 } | |
4831 else | |
4832 { | |
1073 | 4833 for (uint i = 0; i < uNumVertices; ++i) |
4834 { | |
4835 | |
4836 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4837 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4838 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4839 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4840 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4841 if ( this->bUsingSpecular ) | |
0 | 4842 { |
1073 | 4843 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4844 } |
1073 | 4845 else |
4846 { | |
4847 d3d_vertex_buffer[i].specular = 0; | |
4848 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4849 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
1073 | 4850 d3d_vertex_buffer[i].specular = v20; |
4851 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4852 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4853 } | |
186 | 4854 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4855 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4856 if (pRenderer->bUsingSpecular) | |
4857 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 4858 |
4859 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 4860 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 4861 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4862 d3d_vertex_buffer, |
0 | 4863 uNumVertices, |
4864 16)); | |
4865 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 4866 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 4867 //(*(void (**)(void))(*(int *)v63 + 88))(); |
1394 | 4868 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
1073 | 4869 for (uint i = 0; i < uNumVertices; ++i) |
4870 { | |
4871 d3d_vertex_buffer[i].diffuse = -1; | |
4872 } | |
0 | 4873 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 4874 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4875 if ( !pRenderer->bUsingSpecular ) |
4876 { | |
186 | 4877 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4878 } | |
4879 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4880 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4881 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
4882 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4883 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4884 d3d_vertex_buffer, |
0 | 4885 uNumVertices, |
4886 16)); | |
4887 if ( pRenderer->bUsingSpecular ) | |
4888 { | |
186 | 4889 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4890 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 4891 for (uint i = 0; i < uNumVertices; ++i) |
4892 { | |
4893 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4894 d3d_vertex_buffer[i].specular = 0; | |
4895 } | |
4896 | |
75 | 4897 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 4898 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4899 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
4900 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4901 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4902 d3d_vertex_buffer, |
0 | 4903 uNumVertices, |
4904 16)); | |
186 | 4905 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4906 //v44 = pRenderer->pRenderD3D->pDevice; |
4907 v45 = GetLevelFogColor(); | |
4908 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
4909 v8 = 0; | |
4910 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
4911 } | |
186 | 4912 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4913 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4914 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
4915 } | |
4916 } | |
186 | 4917 |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
4918 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
4919 if (pODMRenderParams->flags & ODM_RENDER_DRAW_TERRAIN_OUTLINES) |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4920 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 4921 } |
4922 // 4A26BC: could not find valid save-restore pair for esi | |
4923 // 4D864C: using guessed type char byte_4D864C; | |
4924 | |
4925 //----- (004A2DA3) -------------------------------------------------------- | |
1427 | 4926 void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
852 | 4927 { |
67 | 4928 int v7; // eax@7 |
4929 | |
4930 if ( !this->uNumD3DSceneBegins ) | |
4931 return; | |
4932 if ( uNumVertices >= 3 ) | |
4933 { | |
186 | 4934 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 4935 if ( this->bUsingSpecular ) |
4936 { | |
186 | 4937 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4938 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4939 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 4940 } |
1427 | 4941 for ( uint i = 0; i < uNumVertices; ++i ) |
67 | 4942 { |
4943 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4944 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4945 pVertices[i].pos.z = 0.99989998; | |
168 | 4946 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 4947 |
840 | 4948 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 4949 v7 = 0; |
4950 if (this->bUsingSpecular) | |
1427 | 4951 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, array_50AC10[i].vWorldViewPosition.x); |
67 | 4952 pVertices[i].specular = v7; |
4953 pVertices[i].texcoord.x = array_50AC10[i].u; | |
4954 pVertices[i].texcoord.y = array_50AC10[i].v; | |
4955 } | |
4956 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4957 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 4958 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 4959 } |
4960 } | |
4961 | |
4962 //----- (004A2ED5) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4963 void Render::_4A2ED5(signed int a2, struct Polygon *a3, IDirect3DTexture2 *pHwTex) |
0 | 4964 { |
4965 signed int v4; // edi@2 | |
4966 int v5; // eax@3 | |
4967 int v6; // edx@5 | |
1072 | 4968 RenderVertexD3D3 *v7; // eax@6 |
4969 RenderVertexSoft *v8; // ecx@6 | |
4970 //double v9; // st6@7 | |
4971 //int v10; // ebx@7 | |
4972 //int v11; // ebx@7 | |
0 | 4973 |
4974 if ( this->uNumD3DSceneBegins ) | |
4975 { | |
4976 v4 = a2; | |
4977 if ( a2 >= 3 ) | |
4978 { | |
186 | 4979 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
638 | 4980 v5 = 31 - (a3->dimming_level & 0x1F); |
4981 if ( v5 < pOutdoor->max_terrain_dimming_level ) | |
4982 v5 = pOutdoor->max_terrain_dimming_level; | |
0 | 4983 v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); |
1072 | 4984 for (uint i = 0; i < a2; ++i) |
4985 { | |
4986 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
4987 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
4988 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / array_507D30[i].vWorldViewPosition.y; | |
4989 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; | |
4990 d3d_vertex_buffer[i].diffuse = v6; | |
4991 d3d_vertex_buffer[i].specular = 0; | |
4992 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
4993 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
4994 } | |
4995 | |
0 | 4996 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 4997 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 4998 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4999 d3d_vertex_buffer, |
0 | 5000 a2, |
5001 28)); | |
5002 } | |
5003 } | |
5004 } | |
5005 | |
1390 | 5006 |
5007 //----- (00479A53) -------------------------------------------------------- | |
5008 void Render::DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID) | |
5009 { | |
5010 BLVFace *pFace; // esi@1 | |
5011 unsigned int v3; // edi@1 | |
5012 PolygonType v4; // al@1 | |
5013 double v5; // st7@3 | |
5014 signed __int64 v6; // qax@3 | |
5015 PolygonType v7; // cl@3 | |
5016 int v8; // esi@7 | |
5017 int v9; // eax@7 | |
5018 unsigned int v10; // eax@7 | |
5019 double v11; // st6@7 | |
5020 int v12; // edx@7 | |
5021 int v13; // eax@7 | |
5022 char *v14; // esi@8 | |
5023 void *v15; // ecx@9 | |
5024 int v16; // eax@9 | |
5025 int v17; // edi@9 | |
5026 double v18; // st7@9 | |
5027 signed int v19; // ebx@9 | |
5028 void *v20; // ecx@9 | |
5029 int v21; // ebx@11 | |
5030 int v22; // eax@14 | |
5031 signed __int64 v23; // qtt@16 | |
5032 double v24; // st7@16 | |
5033 unsigned __int8 v25; // sf@16 | |
5034 unsigned __int8 v26; // of@16 | |
5035 Render *v27; // ecx@17 | |
5036 double v28; // st7@20 | |
5037 char *v29; // ebx@20 | |
5038 char *v30; // edx@20 | |
5039 unsigned __int8 v31; // c0@21 | |
5040 unsigned __int8 v32; // c3@21 | |
5041 double v33; // st6@23 | |
5042 char *v34; // esi@30 | |
5043 const void *v35; // ecx@31 | |
5044 int v36; // eax@31 | |
5045 const void *v37; // edi@31 | |
5046 signed __int64 v38; // qax@31 | |
5047 int v39; // ecx@31 | |
5048 int v40; // ebx@33 | |
5049 int v41; // eax@36 | |
5050 signed __int64 v42; // qtt@39 | |
5051 int v43; // eax@39 | |
5052 char v44; // zf@39 | |
5053 double v45; // st7@39 | |
5054 double v46; // st7@39 | |
5055 unsigned int v47; // edx@40 | |
5056 double v48; // st7@41 | |
5057 RenderVertexSoft *v49; // ebx@41 | |
5058 void *v50; // edi@43 | |
5059 double v51; // st7@46 | |
5060 RenderVertexSoft *v52; // edx@46 | |
5061 void *v53; // edi@48 | |
5062 char *v54; // ebx@52 | |
5063 unsigned int v55; // eax@53 | |
5064 unsigned int v56; // eax@55 | |
5065 int v57; // ST10_4@55 | |
5066 Texture *v58; // eax@55 | |
5067 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
|
5068 struct Polygon *v60; // [sp+0h] [bp-174h]@17 |
1390 | 5069 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
|
5070 struct Polygon v62; // [sp+14h] [bp-160h]@6 |
1390 | 5071 unsigned int v63; // [sp+120h] [bp-54h]@7 |
5072 double v64; // [sp+124h] [bp-50h]@7 | |
5073 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
5074 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
5075 float v67; // [sp+130h] [bp-44h]@7 | |
5076 __int64 v68; // [sp+134h] [bp-40h]@3 | |
5077 __int64 v69; // [sp+13Ch] [bp-38h]@3 | |
5078 int v70; // [sp+144h] [bp-30h]@3 | |
5079 int X; // [sp+148h] [bp-2Ch]@9 | |
5080 int v72; // [sp+14Ch] [bp-28h]@7 | |
5081 float v73; // [sp+150h] [bp-24h]@16 | |
5082 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
5083 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 | |
5084 float v76; // [sp+15Ch] [bp-18h]@9 | |
5085 int v77; // [sp+160h] [bp-14h]@9 | |
5086 int v78; // [sp+164h] [bp-10h]@7 | |
5087 void *v79; // [sp+168h] [bp-Ch]@9 | |
5088 float v80; // [sp+16Ch] [bp-8h]@3 | |
5089 const void *v81; // [sp+170h] [bp-4h]@7 | |
5090 | |
5091 __debugbreak(); | |
5092 | |
5093 pFace = &pIndoor->pFaces[uFaceID]; | |
5094 v65 = uFaceID; | |
5095 v3 = uNumVertices; | |
5096 v4 = pFace->uPolygonType; | |
5097 if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor ) | |
5098 { | |
5099 if ( (signed int)uNumVertices > 0 ) | |
5100 { | |
5101 v54 = (char *)&array_507D30[0].u; | |
5102 LODWORD(v80) = uNumVertices; | |
5103 do | |
5104 { | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
5105 v69 = (GetTickCount() >> 5) - pGame->pIndoorCameraD3D->vPartyPos.x; |
1390 | 5106 *(float *)v54 = (double)v69 + *(float *)v54; |
5107 *(float *)v54 = *(float *)v54 * 0.25; | |
5108 v55 = GetTickCount(); | |
5109 v54 += 48; | |
5110 v44 = LODWORD(v80)-- == 1; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
5111 v68 = pGame->pIndoorCameraD3D->vPartyPos.y + (v55 >> 5); |
1390 | 5112 *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25; |
5113 } | |
5114 while ( !v44 ); | |
5115 uFaceID = v65; | |
5116 } | |
5117 v56 = 8 * uFaceID; | |
5118 LOBYTE(v56) = PID(OBJECT_BModel,uFaceID); | |
5119 v57 = v56; | |
5120 v58 = pFace->GetTexture(); | |
5121 pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0); | |
5122 return; | |
5123 } | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
5124 HIDWORD(v69) = pGame->pIndoorCameraD3D->sRotationX; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
5125 HIDWORD(v68) = pGame->pIndoorCameraD3D->vPartyPos.z; |
1390 | 5126 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY; |
1641 | 5127 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z) |
5128 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) | |
1390 | 5129 * 65536.0) |
5130 + *(float *)&v74); | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
5131 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064; |
1390 | 5132 *(float *)&v75 = v5; |
5133 v80 = cos(v5) * 16192.0; | |
5134 v6 = (signed __int64)(*(float *)&v74 | |
1641 | 5135 - (double)pBLVRenderParams->fov_rad_fixpoint |
1390 | 5136 / ((v80 + 0.0000001) |
5137 * 65535.0) | |
5138 * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68))); | |
5139 v7 = pFace->uPolygonType; | |
5140 if ( v7 == 4 || v7 == 3 ) | |
5141 v70 = v6; | |
1544 | 5142 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); |
1427 | 5143 v62.Create_48607B(&stru_8019C8); |
1390 | 5144 v62.uTileBitmapID = pFace->uBitmapID; |
5145 v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0); | |
5146 if ( !v62.pTexture ) | |
5147 return; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
5148 v8 = pGame->pIndoorCameraD3D->sRotationX; |
1390 | 5149 v62.dimming_level = 0; |
5150 v62.uNumVertices = v3; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
5151 v9 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); |
1390 | 5152 v62.v_18.y = 0; |
5153 v62.v_18.x = -v9; | |
5154 v62.v_18.z = -stru_5C6E00->Cos(v8 + 16); | |
5155 v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX; | |
5156 memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3])); | |
5157 LODWORD(v80) = v10; | |
5158 v62.field_24 = 33554432; | |
5159 v64 = (double)(signed int)v10 * 0.5; | |
5160 v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); | |
5161 LODWORD(v80) = v62.pTexture->uTextureWidth; | |
5162 v11 = 1.0 / (double)SLODWORD(v80); | |
5163 LODWORD(v80) = v62.pTexture->uTextureHeight; | |
5164 v12 = v62.pTexture->uWidthMinus1; | |
5165 v13 = v62.pTexture->uHeightMinus1; | |
5166 v67 = v11; | |
5167 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; | |
5168 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
5169 v78 = 0; | |
5170 v81 = 0; | |
5171 *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80); | |
5172 if ( (signed int)v62.uNumVertices <= 0 ) | |
5173 { | |
5174 LABEL_17: | |
5175 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; | |
5176 v27 = pRenderer; | |
5177 v60 = &v62; | |
5178 v59 = v62.uNumVertices; | |
5179 goto LABEL_18; | |
5180 } | |
5181 v14 = (char *)&array_507D30[0].vWorldViewProjY; | |
5182 while ( 2 ) | |
5183 { | |
5184 v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14)); | |
5185 LODWORD(v80) = v62.ptr_38->field_14; | |
5186 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; | |
5187 v16 = v77 + v62.ptr_38->field_C; | |
5188 v77 = (int)v15; | |
5189 v74 = v16; | |
5190 LODWORD(v80) = v62.ptr_38->field_20; | |
5191 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; | |
5192 v79 = v15; | |
5193 v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18); | |
5194 LODWORD(v80) = v62.v_18.z; | |
5195 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16); | |
5196 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1)); | |
5197 v18 = *(float *)v14 - 1.0; | |
5198 v19 = -v62.field_24; | |
5199 v77 = -v62.field_24; | |
5200 X = (int)((char *)v79 + v62.v_18.x); | |
5201 LODWORD(v76) = (signed __int64)v18; | |
5202 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
5203 while ( 1 ) | |
5204 { | |
5205 v79 = v20; | |
5206 if ( !X ) | |
5207 goto LABEL_14; | |
5208 v21 = abs(v19 >> 14); | |
5209 if ( v21 <= abs(X) ) | |
5210 break; | |
5211 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5212 break; | |
5213 v19 = v77; | |
5214 v20 = v79; | |
5215 LABEL_14: | |
5216 LODWORD(v80) = v62.v_18.z; | |
5217 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16); | |
5218 v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16; | |
5219 --LODWORD(v76); | |
5220 v20 = (char *)v20 + v72; | |
5221 X = v22 + v62.v_18.x; | |
5222 v78 = 1; | |
5223 } | |
5224 if ( !v78 ) | |
5225 { | |
5226 LODWORD(v23) = v77 << 16; | |
5227 HIDWORD(v23) = v77 >> 16; | |
5228 v79 = (void *)(v23 / X); | |
5229 v77 = v17; | |
5230 LODWORD(v80) = v62.ptr_38->field_10; | |
5231 v77 = v17; | |
5232 LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16); | |
5233 LODWORD(v80) = v62.ptr_38->field_1C; | |
5234 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16)); | |
5235 v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16; | |
5236 LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16; | |
5237 v14 += 48; | |
5238 LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4); | |
5239 v81 = (char *)v81 + 1; | |
5240 v24 = (double)SLODWORD(v80) * 0.000015259022; | |
5241 LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4); | |
5242 v26 = __OFSUB__((int)v81, v62.uNumVertices); | |
5243 v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0; | |
5244 *((float *)v14 - 10) = v24 * v67; | |
5245 *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1); | |
5246 *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79; | |
5247 if ( !(v25 ^ v26) ) | |
5248 goto LABEL_17; | |
5249 continue; | |
5250 } | |
5251 break; | |
5252 } | |
5253 LODWORD(v73) = 0; | |
5254 v80 = v76; | |
5255 if ( (signed int)v62.uNumVertices > 0 ) | |
5256 { | |
5257 v28 = (double)SLODWORD(v76); | |
5258 LODWORD(v76) = (int)(char *)array_50AC10 + 28; | |
5259 v29 = (char *)&array_50AC10[0].vWorldViewProjX; | |
5260 v30 = (char *)&array_507D30[1].vWorldViewProjY; | |
5261 v79 = array_50AC10; | |
5262 v81 = array_507D30; | |
5263 v78 = v62.uNumVertices; | |
5264 do | |
5265 { | |
5266 v31 = v28 < *((float *)v30 - 12); | |
5267 v32 = v28 == *((float *)v30 - 12); | |
5268 ++LODWORD(v73); | |
5269 memcpy(v79, v81, 0x30u); | |
5270 v79 = (char *)v79 + 48; | |
5271 LODWORD(v76) += 48; | |
5272 v29 += 48; | |
5273 if ( v31 | v32 || v28 >= *(float *)v30 ) | |
5274 { | |
5275 if ( v28 >= *((float *)v30 - 12) || v28 <= *(float *)v30 ) | |
5276 goto LABEL_28; | |
5277 v33 = (*((float *)v30 - 1) - *((float *)v30 - 13)) * v28 / (*(float *)v30 - *((float *)v30 - 12)) | |
5278 + *((float *)v30 - 1); | |
5279 } | |
5280 else | |
5281 { | |
5282 v33 = (*((float *)v30 - 13) - *((float *)v30 - 1)) * v28 / (*((float *)v30 - 12) - *(float *)v30) | |
5283 + *((float *)v30 - 13); | |
5284 } | |
5285 *(float *)v29 = v33; | |
5286 v79 = (char *)v79 + 48; | |
5287 v29 += 48; | |
5288 ++LODWORD(v73); | |
5289 *(unsigned int *)LODWORD(v76) = v28; | |
5290 LODWORD(v76) += 48; | |
5291 LABEL_28: | |
5292 v81 = (char *)v81 + 48; | |
5293 v30 += 48; | |
5294 --v78; | |
5295 } | |
5296 while ( v78 ); | |
5297 } | |
5298 if ( SLODWORD(v73) <= 0 ) | |
5299 goto LABEL_40; | |
5300 v34 = (char *)&array_50AC10[0].vWorldViewProjY; | |
5301 v65 = v77 >> 14; | |
5302 HIDWORD(v69) = LODWORD(v73); | |
5303 do | |
5304 { | |
5305 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34)); | |
5306 v78 = v62.ptr_38->field_14; | |
5307 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); | |
5308 v36 = (int)((char *)v81 + v62.ptr_38->field_C); | |
5309 v81 = v35; | |
5310 v74 = v36; | |
5311 v78 = v62.ptr_38->field_20; | |
5312 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); | |
5313 v78 = (int)v35; | |
5314 v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18); | |
5315 v81 = (const void *)v62.v_18.z; | |
5316 v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16; | |
5317 v37 = (const void *)(v72 | |
5318 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1))); | |
5319 v38 = (signed __int64)(*(float *)v34 - 1.0); | |
5320 v81 = 0; | |
5321 LODWORD(v76) = v38; | |
5322 v39 = v72 * (v70 - v38); | |
5323 while ( 1 ) | |
5324 { | |
5325 v78 = v39; | |
5326 if ( !X ) | |
5327 goto LABEL_36; | |
5328 v40 = abs(X); | |
5329 if ( abs((signed __int64)v65) <= v40 ) | |
5330 break; | |
5331 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5332 break; | |
5333 v39 = v78; | |
5334 LABEL_36: | |
5335 v78 = v62.v_18.z; | |
5336 v41 = (unsigned __int64)(v62.v_18.z * (signed __int64)v39) >> 16; | |
5337 --LODWORD(v76); | |
5338 v39 += v72; | |
5339 X = v41 + v62.v_18.x; | |
5340 v81 = (const void *)1; | |
5341 } | |
5342 if ( v81 ) | |
5343 { | |
5344 v79 = (void *)v62.v_18.z; | |
5345 v78 = 2 * LODWORD(v76); | |
5346 v81 = (const void *)((unsigned __int64)(v62.v_18.z | |
5347 * (signed __int64)(signed int)(signed __int64)(((double)v70 | |
5348 - ((double)(2 * LODWORD(v76)) | |
5349 - *(float *)v34)) | |
5350 * (double)v72)) >> 16); | |
5351 X = (int)((char *)v81 + v62.v_18.x); | |
5352 } | |
5353 LODWORD(v42) = v77 << 16; | |
5354 HIDWORD(v42) = v77 >> 16; | |
5355 v79 = (void *)(v42 / X); | |
5356 v81 = v37; | |
5357 v78 = v62.ptr_38->field_10; | |
5358 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); | |
5359 v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); | |
5360 v74 = (unsigned int)v37; | |
5361 LODWORD(v76) = v43; | |
5362 v78 = v62.ptr_38->field_1C; | |
5363 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16)); | |
5364 v74 = (unsigned __int64)(v43 * v42 / X) >> 16; | |
5365 v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16); | |
5366 v34 += 48; | |
5367 v78 = v66 + ((signed int)v74 >> 4); | |
5368 v44 = HIDWORD(v69)-- == 1; | |
5369 v45 = (double)v78 * 0.000015259022; | |
5370 v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4); | |
5371 *((float *)v34 - 10) = v45 * v67; | |
5372 *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1); | |
5373 v46 = (double)(signed int)v79; | |
5374 *((float *)v34 - 16) = 0.000015258789 * v46; | |
5375 *((float *)v34 - 11) = 65536.0 / v46; | |
5376 } | |
5377 while ( !v44 ); | |
5378 LABEL_40: | |
5379 v47 = 0; | |
5380 if ( SLODWORD(v73) > 0 ) | |
5381 { | |
5382 v48 = (double)SLODWORD(v80); | |
5383 v75 = array_507D30; | |
5384 v49 = array_50AC10; | |
5385 HIDWORD(v69) = LODWORD(v73); | |
5386 do | |
5387 { | |
5388 if ( v48 >= v49->vWorldViewProjY ) | |
5389 { | |
5390 v50 = v75; | |
5391 ++v47; | |
5392 ++v75; | |
5393 memcpy(v50, v49, 0x30u); | |
5394 } | |
5395 ++v49; | |
5396 --HIDWORD(v69); | |
5397 } | |
5398 while ( HIDWORD(v69) ); | |
5399 } | |
5400 v62.uNumVertices = v47; | |
5401 pRenderer->_4A2ED5(v47, &v62, pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]); | |
5402 *(float *)&v74 = 0.0; | |
5403 if ( SLODWORD(v73) > 0 ) | |
5404 { | |
5405 v51 = (double)SLODWORD(v80); | |
5406 v75 = array_507D30; | |
5407 v52 = array_50AC10; | |
5408 v80 = v73; | |
5409 do | |
5410 { | |
5411 if ( v51 <= v52->vWorldViewProjY ) | |
5412 { | |
5413 v53 = v75; | |
5414 ++v74; | |
5415 ++v75; | |
5416 memcpy(v53, v52, 0x30u); | |
5417 } | |
5418 ++v52; | |
5419 --LODWORD(v80); | |
5420 } | |
5421 while ( v80 != 0.0 ); | |
5422 } | |
5423 v62.uNumVertices = v74; | |
5424 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; | |
5425 v60 = &v62; | |
5426 v59 = v74; | |
5427 v27 = pRenderer; | |
5428 LABEL_18: | |
5429 v27->_4A2ED5(v59, v60, v61); | |
5430 } | |
5431 | |
5432 | |
0 | 5433 //----- (004A2FC0) -------------------------------------------------------- |
5434 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
5435 { | |
5436 //Render *v8; // edi@1 | |
5437 //unsigned int v9; // esi@3 | |
1072 | 5438 RenderVertexSoft *v12; // ecx@9 |
5439 RenderVertexD3D3 *v13; // eax@9 | |
0 | 5440 double v14; // st6@10 |
5441 int v15; // edx@10 | |
5442 Texture *v16; // edx@10 | |
5443 double v17; // st6@10 | |
5444 //char v18; // zf@10 | |
5445 Texture *v19; // edx@10 | |
595 | 5446 //Texture *v23; // edx@16 |
5447 //char *v24; // ecx@16 | |
5448 //char *v25; // eax@16 | |
5449 //double v26; // st6@17 | |
5450 //int v27; // esi@17 | |
5451 //double v28; // st6@17 | |
5452 //unsigned int v33; // ecx@18 | |
5453 //char *v34; // eax@19 | |
0 | 5454 //Texture *v45; // edx@23 |
5455 //char *v46; // ecx@23 | |
5456 //char *v47; // eax@23 | |
5457 //double v48; // st6@24 | |
5458 //int v49; // esi@24 | |
5459 //double v50; // st6@24 | |
5460 const char *v53; // [sp-Ch] [bp-20h]@21 | |
5461 //int v54; // [sp-8h] [bp-1Ch]@21 | |
5462 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
5463 const char *v56; // [sp+0h] [bp-14h]@0 | |
5464 int v57; // [sp+4h] [bp-10h]@0 | |
5465 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
5466 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
5467 //int a3a; // [sp+10h] [bp-4h]@4 | |
5468 | |
5469 //v8 = this; | |
5470 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
5471 return; | |
5472 | |
5473 //auto a3 = pFace; | |
5474 //auto a6 = uPackedID; | |
5475 //v59 = pGame->pLightmapBuilder; | |
5476 //v9 = v59->std__vector_000004_size; | |
5477 | |
5478 auto uCorrectedColor = uColor; | |
5479 if (pGame->pLightmapBuilder->std__vector_000004_size) | |
5480 uCorrectedColor = 0xFFFFFFFF; | |
638 | 5481 pGame->AlterGamma_BLV(pFace, &uCorrectedColor); |
0 | 5482 |
792 | 5483 |
5484 if (pFace->uAttributes & FACE_OUTLINED) | |
5485 { | |
5486 int color; | |
5487 if (GetTickCount() % 300 >= 150) | |
5488 uColor = uCorrectedColor = 0xFF20FF20; | |
5489 else uColor = uCorrectedColor = 0xFF109010; | |
5490 } | |
5491 | |
1394 | 5492 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) |
0 | 5493 { |
5494 __debugbreak(); | |
5495 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 5496 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 5497 for (uint i = 0; i < uNumVertices; ++i) |
5498 { | |
5499 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5500 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5501 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5502 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5503 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
5504 d3d_vertex_buffer[i].specular = 0; | |
5505 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5506 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5507 } | |
5508 | |
186 | 5509 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5510 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
5511 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
5512 D3DPT_TRIANGLEFAN, | |
5513 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5514 d3d_vertex_buffer, |
0 | 5515 uNumVertices, |
5516 28)); | |
1394 | 5517 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
0 | 5518 } |
5519 else | |
5520 { | |
5521 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
5522 byte_4D864C && pGame->uFlags & 2) | |
5523 { | |
5524 for (uint i = 0; i < uNumVertices; ++i) | |
5525 { | |
186 | 5526 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
5527 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5528 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5529 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5530 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
5531 d3d_vertex_buffer[i].specular = 0; | |
5532 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5533 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5534 } | |
5535 | |
5536 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 5537 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
5538 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5539 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5540 d3d_vertex_buffer, |
0 | 5541 uNumVertices, |
5542 28)); | |
5543 } | |
5544 else | |
5545 { | |
595 | 5546 for (uint i = 0; i < uNumVertices; ++i) |
5547 { | |
5548 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5549 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5550 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5551 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5552 d3d_vertex_buffer[i].diffuse = uColor; | |
5553 d3d_vertex_buffer[i].specular = 0; | |
5554 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5555 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5556 } | |
5557 //__debugbreak(); | |
5558 //if ( (signed int)uNumVertices > 0 ) | |
5559 //{ | |
5560 //v23 = pTex; | |
5561 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
5562 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
5563 //pTex = (Texture *)uNumVertices; | |
5564 //uint v18; | |
5565 //do | |
5566 //{ | |
5567 //v26 = *(float *)v24 * 0.061758894; | |
5568 //v27 = *((int *)v24 + 3); | |
5569 //*((int *)v25 + 4) = 0; | |
5570 //*((int *)v25 - 1) = v27; | |
5571 //*(int *)v25 = *((int *)v24 + 4); | |
5572 //*((int *)v25 + 3) = uColor; | |
5573 //v25 += 32; | |
5574 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
5575 //v28 = 1.0 / *(float *)v24; | |
5576 //v24 += 48; | |
5577 //v18 = pTex == (Texture *)1; | |
5578 //pTex = (Texture *)((char *)pTex - 1); | |
5579 //*((float *)v25 - 6) = v28; | |
0 | 5580 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 5581 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 5582 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 5583 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
5584 //} | |
5585 //while ( !v18 ); | |
5586 //} | |
0 | 5587 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 5588 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5589 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 5590 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5591 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5592 d3d_vertex_buffer, |
0 | 5593 uNumVertices, |
5594 28)); | |
595 | 5595 |
5596 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1394 | 5597 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
595 | 5598 |
5599 for (uint i = 0; i < uNumVertices; ++i) | |
5600 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
5601 /*v33 = uNumVertices; | |
0 | 5602 if ( (signed int)uNumVertices > 0 ) |
5603 { | |
186 | 5604 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 5605 do |
5606 { | |
5607 *(int *)v34 = uCorrectedColor; | |
5608 v34 += 32; | |
5609 --v33; | |
5610 } | |
5611 while ( v33 ); | |
595 | 5612 }*/ |
0 | 5613 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5614 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
5615 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5616 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5617 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5618 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
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)); | |
186 | 5624 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
5625 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5626 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 5627 } |
5628 } | |
5629 } | |
5630 // 4D864C: using guessed type char byte_4D864C; | |
5631 | |
5632 //----- (004A43B1) -------------------------------------------------------- | |
717 | 5633 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
5634 { | |
5635 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
5636 //double v5; // st7@2 | |
5637 //float v6; // ST08_4@2 | |
0 | 5638 unsigned int v7; // eax@2 |
717 | 5639 //int v8; // ecx@2 |
5640 //unsigned int v9; // esi@2 | |
5641 //Sprite *v10; // edi@5 | |
0 | 5642 signed int v11; // eax@9 |
5643 signed int v12; // eax@9 | |
717 | 5644 //double v13; // st7@12 |
5645 //double v14; // st6@12 | |
0 | 5646 double v15; // st5@12 |
5647 double v16; // st4@12 | |
5648 double v17; // st3@12 | |
5649 double v18; // st2@12 | |
5650 int v19; // ecx@14 | |
5651 double v20; // st3@14 | |
5652 int v21; // ecx@16 | |
5653 double v22; // st3@16 | |
717 | 5654 //IDirect3DTexture2 *v23; // eax@18 |
5655 //signed int v24; // [sp+18h] [bp-18h]@5 | |
5656 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
5657 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 5658 float v27; // [sp+24h] [bp-Ch]@5 |
5659 int v28; // [sp+28h] [bp-8h]@2 | |
5660 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 5661 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 5662 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 5663 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 5664 float a1; // [sp+40h] [bp+10h]@5 |
5665 | |
717 | 5666 //v26 = this; |
0 | 5667 if ( this->uNumD3DSceneBegins ) |
5668 { | |
717 | 5669 //v4 = pSoftBillboard; |
5670 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
5671 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
5672 //v6 = pSoftBillboard->zbuffer_depth; | |
5673 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
5674 //v8 = dimming_level; | |
5675 //v9 = v7; | |
657 | 5676 v28 = dimming_level & 0xFF000000; |
5677 if ( dimming_level & 0xFF000000 ) | |
717 | 5678 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; |
0 | 5679 else |
717 | 5680 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; |
5681 //v10 = a3; | |
5682 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
5683 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
5684 pBillboardRenderListD3D[v7].uParentBillboardID = pSoftBillboard->uParentBillboardID; | |
5685 //v25 = pSoftBillboard->uScreenSpaceX; | |
5686 //v24 = pSoftBillboard->uScreenSpaceY; | |
5687 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
5688 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
5689 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5690 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
5691 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5692 v31 = v31 * -1.0; |
717 | 5693 if ( pSoftBillboard->uTintColor && this->bTinting ) |
5694 { | |
5695 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
737 | 5696 v12 = BlendColors(pSoftBillboard->uTintColor, v11); |
0 | 5697 if ( v28 ) |
5698 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
5699 } | |
5700 else | |
5701 { | |
717 | 5702 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
5703 } | |
5704 //v13 = (double)v25; | |
1390 | 5705 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; |
5706 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
5707 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
717 | 5708 //v14 = (double)v24; |
5709 //v32 = v14; | |
1390 | 5710 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; |
717 | 5711 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); |
1390 | 5712 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; |
717 | 5713 v16 = 1.0 / pSoftBillboard->zbuffer_depth; |
1390 | 5714 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; |
5715 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
5716 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
717 | 5717 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); |
5718 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
5719 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5720 v17 = v17 * -1.0; |
1390 | 5721 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; |
5722 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
5723 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
5724 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
5725 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
5726 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
5727 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
5728 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
717 | 5729 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; |
5730 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5731 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5732 v20 = v20 * -1.0; |
1390 | 5733 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; |
5734 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
5735 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
5736 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
5737 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
5738 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
5739 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
5740 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
717 | 5741 v21 = pSprite->uBufferHeight - pSprite->uAreaY; |
5742 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5743 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5744 v22 = v22 * -1.0; |
1390 | 5745 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; |
5746 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
5747 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
5748 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
5749 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
5750 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
5751 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
5752 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
717 | 5753 //v23 = pSprite->pTexture; |
5754 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
5755 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
5756 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 5757 } |
5758 } | |
5759 | |
5760 //----- (004A354F) -------------------------------------------------------- | |
5761 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5762 { | |
743 | 5763 //double v5; // st7@3 |
5764 //float v6; // ST20_4@3 | |
5765 //float v7; // ST00_4@3 | |
0 | 5766 unsigned int v8; // esi@3 |
743 | 5767 //int v9; // eax@3 |
5768 //int v10; // ebx@3 | |
0 | 5769 float v11; // ST28_4@3 |
743 | 5770 //double v12; // st7@3 |
5771 //float v13; // ST24_4@3 | |
5772 //double v14; // st6@3 | |
5773 //float v15; // ST1C_4@3 | |
0 | 5774 float v16; // ST2C_4@3 |
5775 float v17; // ST30_4@3 | |
5776 signed int v18; // ST18_4@3 | |
5777 signed int v19; // ST14_4@3 | |
5778 signed int v20; // ST10_4@3 | |
5779 signed int v21; // eax@3 | |
5780 double v22; // st6@3 | |
5781 float v23; // ST2C_4@3 | |
5782 float v24; // ST30_4@3 | |
5783 signed int v25; // ST10_4@3 | |
5784 signed int v26; // ST14_4@3 | |
5785 signed int v27; // ST18_4@3 | |
5786 signed int v28; // eax@3 | |
5787 double v29; // st6@3 | |
5788 float v30; // ecx@3 | |
5789 float v31; // ST2C_4@3 | |
5790 float v32; // ST30_4@3 | |
5791 signed int v33; // ST10_4@3 | |
5792 signed int v34; // ST14_4@3 | |
5793 signed int v35; // ST18_4@3 | |
5794 signed int v36; // eax@3 | |
5795 float v37; // ecx@3 | |
5796 double v38; // st6@3 | |
5797 float v39; // ST2C_4@3 | |
5798 float v40; // ST30_4@3 | |
5799 signed int v41; // ST10_4@3 | |
5800 signed int v42; // ST14_4@3 | |
5801 signed int v43; // ST18_4@3 | |
5802 signed int v44; // eax@3 | |
5803 double v45; // st6@3 | |
5804 float v46; // eax@3 | |
5805 | |
5806 if ( this->uNumD3DSceneBegins ) | |
5807 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5808 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5809 { |
743 | 5810 //v5 = (double)a2->zbuffer_depth; |
5811 //v6 = v5; | |
5812 //v7 = v5; | |
5813 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
0 | 5814 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; |
5815 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
5816 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
5817 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
743 | 5818 //v9 = a2->uScreenSpaceX; |
5819 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5820 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 5821 //v12 = (double) a2->uScreenSpaceX; |
5822 //v13 = v12; | |
5823 //v14 = (double)(a2->uScreenSpaceY - 12); | |
5824 //v15 = v14; | |
5825 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5826 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5827 v18 = stru_5C6E00->Cos(angle); |
5828 v19 = stru_5C6E00->Sin(angle); | |
5829 v20 = stru_5C6E00->Sin(angle); | |
5830 v21 = stru_5C6E00->Cos(angle); | |
1390 | 5831 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5832 + (double)(v18 >> 16)) |
5833 * v16 | |
5834 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
5835 + (double)(v19 >> 16)) | |
5836 * v17) | |
743 | 5837 * v11 + (double) a2->uScreenSpaceX; |
0 | 5838 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
5839 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
5840 - 12.0) | |
5841 * v11 | |
5842 + (double)a2->uScreenSpaceY; | |
1390 | 5843 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5844 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5845 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
5846 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
5847 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5848 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5849 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
743 | 5850 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5851 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5852 v25 = stru_5C6E00->Cos(angle); |
5853 v26 = stru_5C6E00->Sin(angle); | |
5854 v27 = stru_5C6E00->Sin(angle); | |
5855 v28 = stru_5C6E00->Cos(angle); | |
1390 | 5856 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
0 | 5857 + (double)(v25 >> 16)) |
740 | 5858 * v31 |
0 | 5859 - ((double)(unsigned __int16)v26 * 0.000015259022 |
5860 + (double)(v26 >> 16)) | |
740 | 5861 * v32) |
743 | 5862 * v11 + (double) a2->uScreenSpaceX; |
740 | 5863 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
5864 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 5865 - 12.0) |
5866 * v11 | |
5867 + (double)a2->uScreenSpaceY; | |
1390 | 5868 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5869 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5870 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
5871 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5872 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
5873 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5874 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5875 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
743 | 5876 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
5877 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5878 v33 = stru_5C6E00->Cos(angle); |
5879 v34 = stru_5C6E00->Sin(angle); | |
5880 v35 = stru_5C6E00->Sin(angle); | |
5881 v36 = stru_5C6E00->Cos(angle); | |
1390 | 5882 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
0 | 5883 + (double)(v33 >> 16)) |
740 | 5884 * v23 |
0 | 5885 - ((double)(unsigned __int16)v34 * 0.000015259022 |
5886 + (double)(v34 >> 16)) | |
740 | 5887 * v24) |
743 | 5888 * v11 + (double) a2->uScreenSpaceX; |
1390 | 5889 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
740 | 5890 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
5891 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 5892 - 12.0) |
5893 * v11 | |
5894 + (double)a2->uScreenSpaceY; | |
1390 | 5895 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5896 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
5897 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5898 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5899 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
5900 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5901 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
743 | 5902 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5903 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5904 v41 = stru_5C6E00->Cos(angle); |
5905 v42 = stru_5C6E00->Sin(angle); | |
5906 v43 = stru_5C6E00->Sin(angle); | |
5907 v44 = stru_5C6E00->Cos(angle); | |
1390 | 5908 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
0 | 5909 + (double)(v41 >> 16)) |
5910 * v39 | |
5911 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
5912 + (double)(v42 >> 16)) | |
5913 * v40) | |
743 | 5914 * v11 + (double) a2->uScreenSpaceX; |
0 | 5915 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
5916 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
5917 - 12.0) | |
5918 * v11 | |
5919 + (double)a2->uScreenSpaceY; | |
1390 | 5920 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5921 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5922 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
5923 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5924 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5925 pBillboardRenderListD3D[v8].pTexture = a3; |
743 | 5926 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 5927 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5928 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; |
5929 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5930 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5931 } |
5932 } | |
5933 } | |
5934 | |
5935 //----- (004A3AD9) -------------------------------------------------------- | |
5936 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5937 { | |
5938 double v5; // st7@2 | |
5939 float v6; // ST28_4@2 | |
5940 float v7; // ST00_4@2 | |
5941 unsigned int v8; // esi@2 | |
5942 int v9; // eax@2 | |
5943 int v10; // ebx@2 | |
5944 float v11; // ST34_4@2 | |
5945 double v12; // st7@2 | |
5946 float v13; // ST2C_4@2 | |
5947 double v14; // st6@2 | |
5948 float v15; // ST24_4@2 | |
5949 float v16; // ST38_4@2 | |
5950 float v17; // ST3C_4@2 | |
5951 signed int v18; // ST1C_4@2 | |
5952 int v19; // ST30_4@2 | |
5953 signed int v20; // ST20_4@2 | |
5954 signed int v21; // ST18_4@2 | |
5955 signed int v22; // eax@2 | |
5956 double v23; // st6@2 | |
5957 float v24; // ST20_4@2 | |
5958 float v25; // ST1C_4@2 | |
5959 float v26; // ST38_4@2 | |
5960 float v27; // ST3C_4@2 | |
5961 signed int v28; // ST18_4@2 | |
5962 signed int v29; // ST14_4@2 | |
5963 signed int v30; // ST10_4@2 | |
5964 signed int v31; // eax@2 | |
5965 double v32; // st6@2 | |
5966 float v33; // ST38_4@2 | |
5967 float v34; // ST3C_4@2 | |
5968 signed int v35; // ST10_4@2 | |
5969 signed int v36; // ST14_4@2 | |
5970 signed int v37; // ST18_4@2 | |
5971 signed int v38; // eax@2 | |
5972 double v39; // st6@2 | |
5973 float v40; // ST38_4@2 | |
5974 float v41; // ST3C_4@2 | |
5975 signed int v42; // ST10_4@2 | |
5976 signed int v43; // ST14_4@2 | |
5977 signed int v44; // ST18_4@2 | |
5978 signed int v45; // eax@2 | |
5979 double v46; // st6@2 | |
5980 | |
5981 if ( this->uNumD3DSceneBegins ) | |
5982 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5983 v5 = (double)a2->zbuffer_depth; |
0 | 5984 v6 = v5; |
5985 v7 = v5; | |
5986 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
5987 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
5988 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
5989 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
5990 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
5991 v9 = a2->uScreenSpaceX; | |
5992 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5993 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 5994 v12 = (double)v9; |
5995 v13 = v12; | |
5996 v14 = (double)(v10 - 12); | |
5997 v15 = v14; | |
5998 v16 = (double)(v9 - 12) - v12; | |
5999 v17 = (double)(v10 - 25) - v14; | |
323 | 6000 v18 = stru_5C6E00->Cos(angle); |
0 | 6001 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 6002 v20 = stru_5C6E00->Sin(angle); |
6003 v21 = stru_5C6E00->Sin(angle); | |
6004 v22 = stru_5C6E00->Cos(angle); | |
1390 | 6005 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 6006 + (double)(v18 >> 16)) |
6007 * v16 | |
6008 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
6009 + (double)(v20 >> 16)) | |
6010 * v17) | |
6011 * v11 + v13; | |
6012 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
6013 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
6014 - 12.0) | |
6015 * v11 | |
6016 + (double)a2->uScreenSpaceY; | |
1390 | 6017 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
6018 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
6019 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
1637 | 6020 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 6021 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; |
0 | 6022 v25 = 1.0 / v6; |
1390 | 6023 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; |
6024 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
6025 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
0 | 6026 v26 = (double)(a2->uScreenSpaceX - 12) - v13; |
6027 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 6028 v28 = stru_5C6E00->Cos(angle); |
6029 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6030 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6031 v31 = stru_5C6E00->Cos(angle); | |
1390 | 6032 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
0 | 6033 + (double)(v28 >> 16)) |
6034 * v26 | |
6035 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
6036 + (double)(v29 >> 16)) | |
6037 * v27) | |
6038 * v11 + v13; | |
6039 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
6040 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
6041 - 12.0) | |
6042 * v11 | |
6043 + (double)a2->uScreenSpaceY; | |
1390 | 6044 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; |
6045 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
6046 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
6047 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
6048 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
6049 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
6050 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
0 | 6051 v33 = (double)(a2->uScreenSpaceX + 12) - v13; |
6052 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 6053 v35 = stru_5C6E00->Cos(angle); |
6054 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6055 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6056 v38 = stru_5C6E00->Cos(angle); | |
1390 | 6057 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
0 | 6058 + (double)(v35 >> 16)) |
6059 * v33 | |
6060 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
6061 + (double)(v36 >> 16)) | |
6062 * v34) | |
6063 * v11 + v13; | |
6064 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
6065 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
6066 - 12.0) | |
6067 * v11 | |
6068 + (double)a2->uScreenSpaceY; | |
1390 | 6069 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
6070 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
6071 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
6072 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
6073 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
6074 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
6075 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
0 | 6076 v40 = (double)(a2->uScreenSpaceX + 12) - v13; |
6077 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 6078 v42 = stru_5C6E00->Cos(angle); |
6079 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6080 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6081 v45 = stru_5C6E00->Cos(angle); | |
1390 | 6082 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
0 | 6083 + (double)(v42 >> 16)) |
6084 * v40 | |
6085 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
6086 + (double)(v43 >> 16)) | |
6087 * v41) | |
6088 * v11 + v13; | |
6089 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
6090 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
6091 - 12.0) | |
6092 * v11 | |
6093 + (double)a2->uScreenSpaceY; | |
1390 | 6094 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; |
6095 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
6096 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
6097 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 6098 pBillboardRenderListD3D[v8].pTexture = a3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6099 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 6100 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 6101 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; |
6102 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
6103 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 6104 } |
6105 } | |
6106 | |
6107 //----- (004A4023) -------------------------------------------------------- | |
657 | 6108 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
|
6109 { |
0 | 6110 unsigned int v8; // esi@2 |
6111 double v14; // st6@14 | |
6112 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6113 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6114 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6115 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6116 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6117 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6118 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6119 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6120 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6121 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6122 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 6123 float v29; // [sp+28h] [bp-8h]@5 |
6124 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6125 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6126 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6127 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6128 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6129 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6130 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6131 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6132 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
|
6133 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
|
6134 |
657 | 6135 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
|
6136 if (a2->uTintColor & 0x00FFFFFF && bTinting) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6137 { |
737 | 6138 diffuse = BlendColors(a2->uTintColor, diffuse); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6139 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6140 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6141 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6142 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6143 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6144 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6145 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
|
6146 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6147 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6148 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6149 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6150 v14 *= -1.0; |
1390 | 6151 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; |
6152 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
6153 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 6154 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 6155 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; |
6156 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
6157 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
6158 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6159 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6160 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6161 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6162 if ( a2->uFlags & 4 ) |
0 | 6163 v14 = v14 * -1.0; |
1390 | 6164 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; |
6165 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
6166 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
6167 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 6168 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 6169 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; |
6170 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
6171 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6172 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6173 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
|
6174 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6175 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6176 v14 *= -1.0; |
1390 | 6177 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; |
6178 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
6179 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
6180 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 6181 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 6182 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; |
6183 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
6184 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6185 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6186 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
|
6187 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6188 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6189 v14 *= -1.0; |
1390 | 6190 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; |
6191 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
6192 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
6193 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 6194 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 6195 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; |
6196 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
6197 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6198 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6199 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6200 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6201 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6202 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6203 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6204 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6205 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6206 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6207 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6208 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6209 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 6210 } |
6211 | |
6212 //----- (004A48E4) -------------------------------------------------------- | |
6213 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
6214 { | |
6215 int v6; // ecx@1 | |
6216 int v7; // ebx@1 | |
6217 int v8; // ecx@1 | |
6218 int v9; // edx@1 | |
6219 int v10; // edi@1 | |
6220 unsigned int x; // esi@1 | |
6221 int result; // eax@8 | |
6222 int v13; // [sp+Ch] [bp-10h]@1 | |
6223 int v14; // [sp+10h] [bp-Ch]@1 | |
6224 int v15; // [sp+14h] [bp-8h]@1 | |
6225 int v16; // [sp+18h] [bp-4h]@1 | |
6226 int v17; // [sp+24h] [bp+8h]@1 | |
6227 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
6228 int v19; // [sp+34h] [bp+18h]@1 | |
6229 | |
6230 v6 = screenSpaceX; | |
6231 v7 = (a6 >> 1) + screenSpaceY; | |
6232 v17 = 0; | |
6233 v15 = 0; | |
6234 v8 = (a6 >> 1) + v6; | |
6235 v14 = (a6 >> 1) * (a6 >> 1); | |
6236 v9 = 2 * (a6 >> 1); | |
6237 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
6238 x = v8 - (a6 >> 1); | |
6239 v16 = (a6 >> 1) + screenSpaceY - v8; | |
6240 v19 = a6 >> 1; | |
6241 v13 = v9; | |
6242 v18 = v8; | |
6243 do | |
6244 { | |
6245 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
6246 if ( v15 ) | |
6247 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
6248 v14 -= v15; | |
6249 if ( v14 <= v10 ) | |
6250 { | |
6251 if ( v19 != v17 ) | |
6252 { | |
6253 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
6254 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
6255 } | |
6256 --v19; | |
6257 v13 -= 2; | |
6258 ++x; | |
6259 v10 -= v13; | |
6260 } | |
6261 result = v17++; | |
6262 v15 += 2; | |
6263 --v18; | |
6264 } | |
6265 while ( result < v19 ); | |
6266 return result; | |
6267 } | |
6268 | |
6269 //----- (004A49D0) -------------------------------------------------------- | |
6270 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
6271 { | |
1159 | 6272 int absXDifference; // eax@1 |
6273 int absYDifference; // eax@1 | |
6274 unsigned int smallerabsdiff; // ebx@1 | |
6275 unsigned int largerabsdiff; | |
0 | 6276 double v16; // st7@7 |
6277 double v17; // st7@7 | |
6278 double v18; // st6@7 | |
6279 double v20; // st4@8 | |
6280 double v21; // st4@10 | |
6281 double v22; // st4@10 | |
6282 double v23; // st4@10 | |
6283 double v25; // st4@11 | |
6284 double v26; // st4@13 | |
6285 double v28; // st4@13 | |
6286 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
1159 | 6287 int xDifference; // [sp+88h] [bp-Ch]@1 |
0 | 6288 signed int v32; // [sp+8Ch] [bp-8h]@1 |
1159 | 6289 int yDifference; // [sp+90h] [bp-4h]@1 |
6290 | |
6291 xDifference = bankersRounding(dstX - srcX); | |
6292 yDifference = bankersRounding(dstY - srcY); | |
6293 absYDifference = abs(yDifference); | |
6294 absXDifference = abs(xDifference); | |
6295 smallerabsdiff = min(absXDifference, absYDifference); | |
6296 largerabsdiff = max(absXDifference, absYDifference); | |
6297 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
0 | 6298 v16 = 1.0 / (double)v32; |
1159 | 6299 v17 = (double)yDifference * v16 * a4; |
6300 v18 = (double)xDifference * v16 * a4; | |
6301 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
6302 { | |
1637 | 6303 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
6304 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
1159 | 6305 } |
6306 else | |
6307 { | |
6308 v20 = a3 * 0.061758894; | |
6309 v25 = a7 * 0.061758894; | |
6310 } | |
6311 v21 = 1.0 / a3; | |
6312 v22 = (double)yDifference * v16 * a8; | |
6313 v23 = (double)xDifference * v16 * a8; | |
6314 v26 = 1.0 - 1.0 / v25; | |
6315 v28 = 1.0 / a7; | |
0 | 6316 v29[0].pos.x = srcX + v17; |
6317 v29[0].pos.y = srcY - v18; | |
1159 | 6318 v29[0].pos.z = 1.0 - 1.0 / v20; |
6319 v29[0].rhw = v21; | |
0 | 6320 v29[0].diffuse = -1; |
6321 v29[0].specular = 0; | |
6322 v29[0].texcoord.x = 1.0; | |
6323 v29[0].texcoord.y = 0.0; | |
1159 | 6324 |
0 | 6325 v29[1].pos.x = v22 + dstX; |
6326 v29[1].pos.y = dstY - v23; | |
1159 | 6327 v29[1].pos.z = v26; |
6328 v29[1].rhw = v28; | |
0 | 6329 v29[1].diffuse = -16711936; |
6330 v29[1].specular = 0; | |
6331 v29[1].texcoord.x = 1.0; | |
6332 v29[1].texcoord.y = 1.0; | |
1159 | 6333 |
6334 v29[2].pos.x = dstX - v22; | |
6335 v29[2].pos.y = v23 + dstY; | |
6336 v29[2].pos.z = v26; | |
0 | 6337 v29[2].rhw = v28; |
1159 | 6338 v29[2].diffuse = -1; |
6339 v29[2].specular = 0; | |
0 | 6340 v29[2].texcoord.x = 0.0; |
6341 v29[2].texcoord.y = 1.0; | |
1159 | 6342 |
0 | 6343 v29[3].pos.x = srcX - v17; |
6344 v29[3].pos.y = v18 + srcY; | |
1159 | 6345 v29[3].pos.z = v29[0].pos.z; |
6346 v29[3].rhw = v21; | |
6347 v29[3].diffuse = -1; | |
6348 v29[3].specular = 0; | |
0 | 6349 v29[3].texcoord.x = 0.0; |
6350 v29[3].texcoord.y = 0.0; | |
186 | 6351 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
6352 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6353 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
6354 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6355 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6356 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 6357 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
6358 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
6359 D3DPT_TRIANGLEFAN, | |
6360 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6361 v29, | |
6362 4, | |
6363 24)); | |
186 | 6364 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
6365 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6366 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6367 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6368 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6369 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 6370 } |
6371 | |
6372 //----- (004A4CC9) -------------------------------------------------------- | |
1390 | 6373 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) |
6374 { | |
0 | 6375 unsigned int v5; // eax@7 |
6376 char *v7; // edx@8 | |
6377 double v10; // st6@9 | |
6378 double v11; // st6@10 | |
6379 int v12; // ebx@13 | |
1390 | 6380 |
6381 if (a1->uNumVertices < 3) | |
6382 return; | |
6383 | |
6384 float depth = 1000000.0; | |
6385 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6386 { | |
6387 if (a1->field_104[i].z < depth) | |
6388 depth = a1->field_104[i * 4].z; | |
6389 } | |
6390 | |
6391 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
6392 pBillboardRenderListD3D[v5].field_90 = 0; | |
6393 pBillboardRenderListD3D[v5].uParentBillboardID = -1; | |
6394 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | |
6395 pBillboardRenderListD3D[v5].pTexture = 0; | |
6396 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
6397 pBillboardRenderListD3D[v5].z_order = depth; | |
6398 | |
6399 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6400 { | |
6401 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
6402 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
6403 | |
6404 v10 = a1->field_104[i].z; | |
6405 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
6406 v11 = v10 * 0.061758894; | |
6407 else | |
1637 | 6408 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
1390 | 6409 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; |
6410 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
6411 | |
6412 if (diffuse & 0xFF000000) | |
6413 v12 = a1->field_104[i].diffuse; | |
6414 else | |
6415 v12 = diffuse; | |
6416 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
6417 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
6418 | |
6419 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
6420 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
0 | 6421 } |
6422 } | |
6423 | |
6424 //----- (004A4DE1) -------------------------------------------------------- | |
6425 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
6426 { | |
6427 HRESULT v12; // eax@14 | |
6428 unsigned __int16 *v13; // ecx@19 | |
6429 unsigned __int16 *v14; // eax@19 | |
6430 DWORD v15; // edx@20 | |
6431 HRESULT v16; // eax@23 | |
6432 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
6433 | |
6434 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
6435 if ( pHWLTexture ) | |
6436 { | |
6437 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
6438 if ( !pRenderD3D->CreateTexture( | |
6439 pHWLTexture->uWidth, | |
6440 pHWLTexture->uHeight, | |
6441 pOutSurface, | |
6442 pOutTexture, | |
6443 true, | |
6444 bMipMaps, | |
6445 uMinDeviceTextureDim) ) | |
1545 | 6446 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6447 //v10 = *pOutSurface; |
6448 //v11 = 0; | |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1574
diff
changeset
|
6449 if (bMipMaps) |
0 | 6450 { |
6451 Dst._450DDE(); | |
6452 //v20 = 0; | |
6453 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
6454 | |
6455 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
6456 while ( 1 ) | |
6457 { | |
6458 DDSCAPS2 v19; | |
6459 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6460 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6461 | |
6462 DDSURFACEDESC2 desc; | |
6463 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6464 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6465 | |
168 | 6466 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6467 { |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1574
diff
changeset
|
6468 /*Dst.sub_451007_scale_image_bicubic( |
0 | 6469 pHWLTexture->pPixels, |
6470 pHWLTexture->uWidth, | |
6471 pHWLTexture->uHeight, | |
6472 pHWLTexture->uWidth, | |
6473 (unsigned short *)desc.lpSurface, | |
6474 desc.dwWidth, | |
6475 desc.dwHeight, | |
6476 desc.lPitch >> 1, | |
6477 0, | |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1574
diff
changeset
|
6478 0);*/ |
0 | 6479 ErrD3D(pNextSurf->Unlock(0)); |
6480 //bMipMaps = 0x4D86ACu; | |
6481 } | |
6482 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
6483 break; | |
6484 //v10 = (IDirectDrawSurface4 *)pName; | |
6485 //v11 = 0; | |
6486 } | |
6487 //v20 = -1; | |
6488 //nullsub_1(); | |
6489 } | |
6490 else | |
6491 { | |
6492 DDSCAPS2 v19; | |
6493 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6494 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6495 | |
6496 DDSURFACEDESC2 desc; | |
6497 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6498 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6499 | |
168 | 6500 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6501 { |
6502 bMipMaps = 0; | |
6503 v13 = pHWLTexture->pPixels; | |
6504 v14 = (unsigned __int16 *)desc.lpSurface; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6505 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
|
6506 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6507 for (v15 = 0; v15 < desc.dwWidth; v15++) |
0 | 6508 { |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6509 *v14 = *v13; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6510 ++v14; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6511 ++v13; |
0 | 6512 } |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6513 v14 += (desc.lPitch >> 1) - desc.dwWidth; |
0 | 6514 } |
6515 ErrD3D((*pOutSurface)->Unlock(0)); | |
6516 } | |
6517 } | |
6518 delete [] pHWLTexture->pPixels; | |
6519 delete pHWLTexture; | |
6520 return true; | |
6521 } | |
6522 return false; | |
6523 } | |
6524 | |
6525 //----- (004A5048) -------------------------------------------------------- | |
670 | 6526 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
6527 { | |
6528 | |
6529 HWLTexture *sprite_texture; // eax@1 | |
0 | 6530 unsigned __int16 *v9; // edx@5 |
6531 LPVOID v10; // eax@5 | |
6532 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6533 | |
670 | 6534 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
6535 if ( sprite_texture ) | |
6536 { | |
6537 _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; | |
6538 pSprite->uAreaX = sprite_texture->uAreaX; | |
6539 pSprite->uAreaY = sprite_texture->uAreaY; | |
6540 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
6541 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
6542 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
6543 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6544 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6545 //v7 = v3->pRenderD3D; |
670 | 6546 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
1545 | 6547 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6548 //pSprite = v2->pTextureSurface; |
6549 //pSprite = (Sprite *)pSprite->pName; | |
6550 //v8 = pSprite; | |
670 | 6551 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 6552 Dst.dwSize = 124; |
670 | 6553 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
6554 { | |
6555 v9 = sprite_texture->pPixels; | |
6556 v10 = Dst.lpSurface; | |
6557 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 6558 { |
670 | 6559 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
6560 { | |
0 | 6561 *(int *)v10 = *(int *)v9; |
6562 v9 += 2; | |
6563 v10 = (char *)v10 + 4; | |
670 | 6564 } |
6565 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 6566 } |
670 | 6567 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
6568 } | |
6569 free(sprite_texture->pPixels); | |
6570 free(sprite_texture); | |
6571 return true; | |
6572 } | |
6573 return false; | |
0 | 6574 } |
6575 | |
6576 //----- (004A51CB) -------------------------------------------------------- | |
6577 void Render::BeginScene() | |
6578 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6579 //Render *v1; // esi@1 |
0 | 6580 unsigned int v2; // eax@1 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6581 /*int v3; // eax@5 |
0 | 6582 unsigned __int16 **v4; // edi@6 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6583 char *v5; // ebx@7*/ |
0 | 6584 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 |
6585 | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6586 //v1 = this; |
0 | 6587 v2 = this->uNumSceneBegins; |
6588 this->uNumSceneBegins = v2 + 1; | |
6589 if ( !v2 ) | |
6590 { | |
6591 if ( this->pRenderD3D ) | |
6592 { | |
6593 if ( this->bColorKeySupported ) | |
6594 { | |
6595 memset(&Dst, 0, 0x7Cu); | |
6596 Dst.dwSize = 124; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6597 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
|
6598 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6599 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6600 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6601 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
|
6602 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6603 --this->uNumSceneBegins; |
0 | 6604 } |
6605 } | |
6606 else | |
6607 { | |
6608 if ( !this->pTargetSurface ) | |
6609 { | |
6610 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
|
6611 if ( this->pTargetSurface ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6612 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6613 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
|
6614 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6615 --this->uNumSceneBegins; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6616 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6617 } |
0 | 6618 RestoreFrontBuffer(); |
6619 } | |
6620 } | |
6621 | |
6622 //----- (004A527D) -------------------------------------------------------- | |
6623 void Render::EndScene() | |
6624 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6625 if ( this->uNumSceneBegins ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6626 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6627 this->uNumSceneBegins--; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6628 if ( !this->uNumSceneBegins ) |
0 | 6629 { |
6630 if ( this->pRenderD3D ) | |
6631 { | |
6632 if ( this->bColorKeySupported ) | |
6633 { | |
6634 this->pTargetSurface = 0; | |
6635 this->uTargetSurfacePitch = 0; | |
6636 this->field_18_locked_pitch = 0; | |
6637 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
6638 } | |
6639 } | |
6640 else | |
6641 { | |
6642 this->pTargetSurface = 0; | |
6643 this->uTargetSurfacePitch = 0; | |
6644 this->field_18_locked_pitch = 0; | |
6645 UnlockBackBuffer(); | |
6646 } | |
6647 } | |
6648 } | |
6649 } | |
6650 | |
6651 //----- ( ) -------------------------------------------------------- | |
6652 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
6653 { | |
6654 unsigned int v3; // esi@1 | |
6655 double v4; // st7@2 | |
6656 double v5; // st7@6 | |
6657 double v6; // st6@6 | |
6658 unsigned int v7; // eax@6 | |
6659 double v8; // st5@6 | |
6660 double v9; // st4@6 | |
6661 HRESULT v10; // eax@6 | |
6662 HRESULT v11; // eax@6 | |
6663 unsigned int result; // eax@6 | |
6664 unsigned int v13; // eax@7 | |
6665 unsigned __int16 *v14; // ecx@7 | |
6666 int *v15; // eax@7 | |
6667 unsigned int v16; // ecx@8 | |
6668 __int16 v17; // ax@10 | |
6669 int v18; // esi@10 | |
6670 float v19; // edi@10 | |
6671 void *v20; // esi@10 | |
6672 int v21; // edx@10 | |
6673 int v22; // ecx@11 | |
6674 int v23; // edx@12 | |
6675 __int16 v24; // ax@15 | |
6676 int v25; // esi@15 | |
6677 float v26; // edi@15 | |
6678 char *v27; // esi@15 | |
6679 int v28; // edx@15 | |
6680 int v29; // ecx@16 | |
6681 int v30; // edx@17 | |
6682 int v31; // [sp-Ch] [bp-ACh]@11 | |
6683 int v32; // [sp-Ch] [bp-ACh]@16 | |
6684 const char *v33; // [sp+0h] [bp-A0h]@0 | |
6685 int v34; // [sp+4h] [bp-9Ch]@0 | |
6686 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
6687 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
6688 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
6689 int v38; // [sp+90h] [bp-10h]@7 | |
6690 double v39; // [sp+94h] [bp-Ch]@6 | |
6691 float v40; // [sp+9Ch] [bp-4h]@6 | |
6692 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6693 __debugbreak(); |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6694 |
0 | 6695 auto ecx0 = this; |
6696 v3 = 0; | |
1574 | 6697 |
6698 if (!this->pRenderD3D) | |
6699 __debugbreak(); // sw render | |
6700 | |
6701 //{ | |
0 | 6702 v4 = a3; |
6703 if ( a3 <= 1.0 ) | |
6704 { | |
6705 if ( v4 < 0.0 ) | |
6706 v4 = 0.0; | |
6707 } | |
6708 else | |
6709 { | |
6710 v4 = 1.0; | |
6711 } | |
1574 | 6712 __debugbreak(); // banker's rounding again |
0 | 6713 a3 = v4 * 255.0; |
6714 v39 = a3 + 6.7553994e15; | |
6715 LODWORD(v40) = LODWORD(v39); | |
693 | 6716 v5 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 6717 v36[0].pos.x = v5; |
693 | 6718 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 6719 v7 = this_ | (LODWORD(v39) << 24); |
693 | 6720 this_ = pViewport->uViewportBR_Y + 1; |
0 | 6721 v36[0].specular = 0; |
6722 v36[0].pos.y = v6; | |
6723 v36[0].diffuse = v7; | |
6724 v36[1].diffuse = v7; | |
6725 v36[0].pos.z = 0.0; | |
6726 v36[2].diffuse = v7; | |
6727 v36[3].diffuse = v7; | |
6728 v36[0].rhw = 1.0; | |
6729 v36[1].specular = 0; | |
6730 v36[0].texcoord.x = 0.0; | |
6731 v36[2].specular = 0; | |
6732 v36[3].specular = 0; | |
6733 v36[0].texcoord.y = 0.0; | |
6734 v36[1].pos.x = v5; | |
693 | 6735 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 6736 v36[1].pos.y = v8; |
6737 v36[1].pos.z = 0.0; | |
6738 v36[1].rhw = 1.0; | |
6739 v36[1].texcoord.x = 0.0; | |
6740 v36[1].texcoord.y = 0.0; | |
693 | 6741 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 6742 v36[2].pos.x = v9; |
6743 v36[2].pos.y = v8; | |
6744 v36[2].pos.z = 0.0; | |
6745 v36[2].rhw = 1.0; | |
6746 v36[2].texcoord.x = 0.0; | |
6747 v36[2].texcoord.y = 0.0; | |
6748 v36[3].pos.x = v9; | |
6749 v36[3].pos.y = v6; | |
6750 v36[3].pos.z = 0.0; | |
6751 v36[3].rhw = 1.0; | |
6752 v36[3].texcoord.x = 0.0; | |
6753 v36[3].texcoord.y = 0.0; | |
6754 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 6755 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
6756 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6757 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6758 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
6759 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
6760 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6761 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 6762 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
6763 D3DPT_TRIANGLEFAN, | |
6764 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6765 v36, | |
6766 4, | |
6767 28)); | |
186 | 6768 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
6769 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6770 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
6771 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6772 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6773 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
1574 | 6774 /*} |
0 | 6775 else |
6776 { | |
6777 v40 = (1.0 - a3) * 65536.0; | |
6778 v39 = v40 + 6.7553994e15; | |
6779 LODWORD(a3) = LODWORD(v39); | |
693 | 6780 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
6781 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
6782 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
6783 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 6784 v37 = 2 * v13; |
6785 LODWORD(v40) = (int)v14; | |
6786 | |
6787 int __i = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
6788 v15 = dword_F1B430.data(); |
0 | 6789 do |
6790 { | |
6791 v16 = v3; | |
6792 v3 += LODWORD(a3); | |
6793 dword_F1B430[__i++] = v16 >> 16; | |
6794 } | |
6795 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
6796 while (__i < 32); | |
6797 | |
6798 if ( pRenderer->uTargetGBits == 6 ) | |
6799 { | |
1574 | 6800 v17 = sr_42690D_colors_cvt(this_); |
0 | 6801 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); |
6802 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); | |
6803 v19 = v40; | |
6804 v20 = off_4EFDB0; | |
6805 v21 = HIDWORD(v39); | |
6806 do | |
6807 { | |
6808 v22 = v38; | |
6809 v31 = v21; | |
6810 do | |
6811 { | |
6812 v23 = (*(int *)((char *)v20 | |
6813 + ((((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; | |
6814 result = this_ | |
6815 + (*((int *)v20 | |
6816 + (((unsigned __int8)(*((char *)v20 | |
6817 + ((((unsigned __int16)(*(short *)((char *)v20 | |
6818 + ((*(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); | |
6819 *(unsigned int *)LODWORD(v19) = result; | |
6820 LODWORD(v19) += 4; | |
6821 --v22; | |
6822 } | |
6823 while ( v22 ); | |
6824 LODWORD(v19) += v37; | |
6825 v21 = v31 - 1; | |
6826 } | |
6827 while ( v31 != 1 ); | |
6828 } | |
6829 else | |
6830 { | |
1574 | 6831 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_); |
0 | 6832 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); |
6833 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
6834 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
6835 v26 = v40; | |
6836 v27 = (char *)off_4EFDB0; | |
6837 v28 = HIDWORD(v39); | |
6838 do | |
6839 { | |
6840 v29 = v38; | |
6841 v32 = v28; | |
6842 do | |
6843 { | |
6844 v30 = 32 | |
6845 * *(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; | |
6846 result = this_ | |
6847 + (*(int *)&v27[4 | |
6848 * (((unsigned __int8)(32 | |
6849 * 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); | |
6850 *(unsigned int *)LODWORD(v26) = result; | |
6851 LODWORD(v26) += 4; | |
6852 --v29; | |
6853 } | |
6854 while ( v29 ); | |
6855 LODWORD(v26) += v37; | |
6856 v28 = v32 - 1; | |
6857 } | |
6858 while ( v32 != 1 ); | |
6859 } | |
1574 | 6860 }*/ |
0 | 6861 return result; |
6862 } | |
6863 | |
6864 //----- (004A5B81) -------------------------------------------------------- | |
727 | 6865 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 6866 { |
6867 this->bClip = 1; | |
6868 this->uClipY = uY; | |
6869 this->uClipX = uX; | |
6870 this->uClipW = uW; | |
6871 this->uClipZ = uZ; | |
6872 } | |
6873 | |
6874 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 6875 void Render::ResetTextureClipRect() |
0 | 6876 { |
6877 this->uClipY = 0; | |
6878 this->uClipX = 0; | |
6879 this->bClip = 1; | |
6880 this->uClipW = 480; | |
6881 this->uClipZ = 640; | |
6882 } | |
6883 | |
6884 //----- (004A5BE3) -------------------------------------------------------- | |
6885 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
6886 { | |
6887 int v4; // edi@3 | |
6888 unsigned __int16 *v5; // edx@3 | |
6889 unsigned __int16 *v6; // esi@3 | |
6890 unsigned int v8; // eax@5 | |
6891 unsigned int v9; // ebx@5 | |
6892 unsigned int v11; // eax@7 | |
6893 unsigned int v12; // ebx@8 | |
6894 unsigned int v15; // eax@14 | |
6895 int v19; // [sp+10h] [bp-8h]@3 | |
6896 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
6897 int v23; // [sp+28h] [bp+10h]@3 | |
6898 | |
6899 if ( this->uNumSceneBegins && a4 ) | |
6900 { | |
6901 v4 = a4->uWidth; | |
6902 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
6903 v6 = a4->pPixels; | |
6904 v23 = a4->uHeight; | |
6905 v19 = v4; | |
6906 if ( this->bClip ) | |
6907 { | |
1152 | 6908 if ( (signed int)uOutX < (signed int)this->uClipX ) |
6909 { | |
6910 v8 = this->uClipX - uOutX; | |
6911 v9 = uOutX - this->uClipX; | |
0 | 6912 v8 *= 2; |
6913 v4 += v9; | |
6914 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
6915 v5 = (unsigned __int16 *)((char *)v5 + v8); | |
6916 } | |
1152 | 6917 if ( (signed int)uOutY < (signed int)this->uClipY ) |
6918 { | |
6919 v11 = this->uClipY - uOutY; | |
0 | 6920 v6 += v19 * v11; |
6921 v23 += uOutY - this->uClipY; | |
6922 v5 += this->uTargetSurfacePitch * v11; | |
6923 } | |
1152 | 6924 v12 = max(this->uClipX, uOutX); |
6925 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | |
6926 { | |
6927 v4 = this->uClipZ - max(this->uClipX, uOutX); | |
6928 } | |
6929 v15 = max(this->uClipY, uOutY); | |
6930 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) | |
6931 { | |
6932 v23 = this->uClipW - max(this->uClipY, uOutY); | |
6933 } | |
6934 } | |
6935 | |
6936 for (int outerCounter = 0; outerCounter < v23; outerCounter++) | |
6937 { | |
6938 for (int counter = 0; counter < v4; counter++) | |
6939 { | |
6940 *v5 = *v6; | |
6941 ++v5; | |
6942 ++v6; | |
6943 } | |
6944 v6 += v19 - v4; | |
6945 v5 += this->uTargetSurfacePitch - v4; | |
0 | 6946 } |
6947 } | |
6948 } | |
6949 | |
6950 //----- (004A5D33) -------------------------------------------------------- | |
6951 void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture) | |
6952 { | |
6953 Render *v6; // esi@1 | |
6954 unsigned __int16 *v7; // ebx@3 | |
6955 int v8; // ecx@3 | |
6956 int v9; // edx@3 | |
6957 int v10; // ecx@3 | |
6958 int v11; // edi@3 | |
6959 signed int v12; // eax@4 | |
6960 unsigned int v13; // eax@5 | |
6961 signed int v14; // eax@6 | |
6962 unsigned int v15; // eax@7 | |
6963 unsigned int v16; // edx@8 | |
6964 int v17; // eax@10 | |
6965 unsigned int v18; // ecx@11 | |
6966 unsigned int v19; // ecx@14 | |
6967 int v20; // eax@16 | |
6968 unsigned int v21; // ecx@17 | |
6969 int v22; // eax@21 | |
6970 int v23; // edi@23 | |
6971 int v24; // [sp+Ch] [bp-4h]@3 | |
6972 int a2a; // [sp+18h] [bp+8h]@21 | |
6973 unsigned int teal; // [sp+1Ch] [bp+Ch]@20 | |
6974 int a4a; // [sp+20h] [bp+10h]@3 | |
6975 int a4b; // [sp+20h] [bp+10h]@21 | |
6976 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
6977 | |
6978 v6 = this; | |
6979 if ( this->uNumSceneBegins && pTexture ) | |
6980 { | |
6981 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | |
6982 v8 = pTexture->uWidth; | |
6983 v24 = pTexture->uWidth; | |
6984 v9 = a4 + a5 * v8; | |
6985 v10 = v8 - a4; | |
6986 a4a = v10; | |
6987 v11 = pTexture->uHeight - a5; | |
6988 pTexturea = &pTexture->pPixels[v9]; | |
6989 if ( v6->bClip ) | |
6990 { | |
6991 v12 = v6->uClipX; | |
6992 if ( (signed int)pX < v12 ) | |
6993 { | |
6994 v13 = 2 * (v12 - pX); | |
6995 pTexturea = (unsigned __int16 *)((char *)pTexturea + v13); | |
6996 v10 += pX - v6->uClipX; | |
6997 v7 = (unsigned __int16 *)((char *)v7 + v13); | |
6998 a4a = v10; | |
6999 } | |
7000 v14 = v6->uClipY; | |
7001 if ( (signed int)pY < v14 ) | |
7002 { | |
7003 v15 = v14 - pY; | |
7004 pTexturea += v24 * v15; | |
7005 v11 += pY - v6->uClipY; | |
7006 v10 = a4a; | |
7007 v7 += v6->uTargetSurfacePitch * v15; | |
7008 } | |
7009 v16 = v6->uClipX; | |
7010 if ( (signed int)v16 < (signed int)pX ) | |
7011 v16 = pX; | |
7012 v17 = v6->uClipZ; | |
7013 if ( (signed int)(v10 + v16) > v17 ) | |
7014 { | |
7015 v18 = v6->uClipX; | |
7016 if ( (signed int)v18 < (signed int)pX ) | |
7017 v18 = pX; | |
7018 a4a = v17 - v18; | |
7019 } | |
7020 v19 = v6->uClipY; | |
7021 if ( (signed int)v19 < (signed int)pY ) | |
7022 v19 = pY; | |
7023 v20 = v6->uClipW; | |
7024 if ( (signed int)(v11 + v19) > v20 ) | |
7025 { | |
7026 v21 = v6->uClipY; | |
7027 if ( (signed int)v21 < (signed int)pY ) | |
7028 v21 = pY; | |
7029 v11 = v20 - v21; | |
7030 } | |
7031 } | |
949 | 7032 teal = TargetColor(0, 0xFFu, 0xFFu); |
0 | 7033 if ( v11 > 0 ) |
7034 { | |
7035 v22 = a4a; | |
7036 a2a = v11; | |
7037 a4b = 2 * (v24 - a4a); | |
7038 do | |
7039 { | |
7040 if ( v22 > 0 ) | |
7041 { | |
7042 v23 = v22; | |
7043 do | |
7044 { | |
7045 if ( *pTexturea != teal ) | |
7046 *v7 = *pTexturea; | |
7047 ++pTexturea; | |
7048 ++v7; | |
7049 --v23; | |
7050 } | |
7051 while ( v23 ); | |
7052 } | |
7053 v7 += v6->uTargetSurfacePitch - v22; | |
7054 pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b); | |
7055 --a2a; | |
7056 } | |
7057 while ( a2a ); | |
7058 } | |
7059 } | |
7060 } | |
7061 | |
7062 //----- (004A6E7E) -------------------------------------------------------- | |
7063 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
7064 { | |
7065 unsigned __int16 *v4; // eax@4 | |
7066 int v5; // edx@4 | |
7067 unsigned int v6; // edi@4 | |
7068 unsigned int v7; // edx@5 | |
7069 unsigned int v8; // edx@6 | |
7070 unsigned int v9; // edx@7 | |
7071 unsigned int v10; // edx@8 | |
7072 unsigned int v11; // ebx@9 | |
7073 unsigned int v12; // esi@11 | |
7074 unsigned int v13; // edx@12 | |
7075 unsigned int v14; // ebx@15 | |
7076 unsigned int v15; // esi@17 | |
7077 unsigned int v16; // edi@18 | |
7078 char v17; // zf@29 | |
7079 int v18; // [sp+14h] [bp-Ch]@4 | |
7080 int v19; // [sp+18h] [bp-8h]@4 | |
7081 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
7082 int v21; // [sp+28h] [bp+8h]@25 | |
7083 int v22; // [sp+28h] [bp+8h]@34 | |
7084 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
7085 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
7086 | |
7087 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
7088 { | |
7089 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7090 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7091 v5 = a4->uTextureWidth; |
7092 v6 = a4->uTextureHeight; | |
7093 v19 = a4->uTextureWidth; | |
7094 v18 = a4->uTextureWidth; | |
7095 if ( this->bClip ) | |
7096 { | |
7097 v7 = this->uClipX; | |
7098 if ( (signed int)a2 < (signed int)v7 ) | |
7099 { | |
7100 v8 = v7 - a2; | |
7101 v20 += v8; | |
7102 v19 += a2 - this->uClipX; | |
7103 v4 += v8; | |
7104 } | |
7105 v9 = this->uClipY; | |
7106 if ( (signed int)a3 < (signed int)v9 ) | |
7107 { | |
7108 v10 = v9 - a3; | |
7109 v20 += v18 * v10; | |
7110 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
7111 v4 += this->uTargetSurfacePitch * v10; | |
7112 } | |
7113 v11 = this->uClipX; | |
7114 v5 = v19; | |
7115 if ( (signed int)v11 < (signed int)a2 ) | |
7116 v11 = a2; | |
7117 v12 = this->uClipZ; | |
7118 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
7119 { | |
7120 v13 = this->uClipX; | |
7121 if ( (signed int)v13 < (signed int)a2 ) | |
7122 v13 = a2; | |
7123 v5 = v12 - v13; | |
7124 } | |
7125 v14 = this->uClipY; | |
7126 if ( (signed int)v14 < (signed int)a3 ) | |
7127 v14 = a3; | |
7128 v15 = this->uClipW; | |
7129 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
7130 { | |
7131 v16 = this->uClipY; | |
7132 if ( (signed int)v16 < (signed int)a3 ) | |
7133 v16 = a3; | |
7134 v6 = v15 - v16; | |
7135 } | |
7136 } | |
7137 if ( pRenderer->uTargetGBits == 5 ) | |
7138 { | |
7139 if ( (signed int)v6 > 0 ) | |
7140 { | |
7141 v23 = v6; | |
7142 do | |
7143 { | |
7144 if ( v5 > 0 ) | |
7145 { | |
7146 v21 = v5; | |
7147 do | |
7148 { | |
7149 if ( *v20 ) | |
7150 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
7151 ++v4; | |
7152 ++v20; | |
7153 --v21; | |
7154 } | |
7155 while ( v21 ); | |
7156 } | |
7157 v20 += v18 - v5; | |
7158 v17 = v23-- == 1; | |
7159 v4 += this->uTargetSurfacePitch - v5; | |
7160 } | |
7161 while ( !v17 ); | |
7162 } | |
7163 } | |
7164 else | |
7165 { | |
7166 if ( (signed int)v6 > 0 ) | |
7167 { | |
7168 v24 = v6; | |
7169 do | |
7170 { | |
7171 if ( v5 > 0 ) | |
7172 { | |
7173 v22 = v5; | |
7174 do | |
7175 { | |
7176 if ( *v20 ) | |
7177 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
7178 ++v4; | |
7179 ++v20; | |
7180 --v22; | |
7181 } | |
7182 while ( v22 ); | |
7183 } | |
7184 v20 += v18 - v5; | |
7185 v17 = v24-- == 1; | |
7186 v4 += this->uTargetSurfacePitch - v5; | |
7187 } | |
7188 while ( !v17 ); | |
7189 } | |
7190 } | |
7191 } | |
7192 } | |
7193 | |
7194 //----- (004A6DF5) -------------------------------------------------------- | |
7195 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
7196 { | |
7197 int result; // eax@0 | |
7198 int v8; // ecx@3 | |
7199 unsigned __int16 *v9; // edi@4 | |
7200 unsigned __int16 *v10; // ebx@4 | |
7201 int v11; // esi@4 | |
7202 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | |
7203 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | |
7204 | |
7205 if ( pBitmap ) | |
7206 { | |
7207 if ( pTarget ) | |
7208 { | |
7209 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | |
7210 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | |
7211 v8 = a7->z - a7->x; | |
7212 result = a7->w - a7->y; | |
7213 if ( result > 0 ) | |
7214 { | |
7215 v9 = pBitmapa; | |
7216 v10 = pTargeta; | |
7217 v11 = a7->w - a7->y; | |
7218 do | |
7219 { | |
7220 if ( v8 > 0 ) | |
7221 { | |
7222 result = v8; | |
7223 do | |
7224 { | |
7225 *v9 = *v10; | |
7226 ++v9; | |
7227 ++v10; | |
7228 --result; | |
7229 } | |
7230 while ( result ); | |
7231 } | |
7232 v9 += uBitmapPitch - v8; | |
7233 v10 += uTargetPitch - v8; | |
7234 --v11; | |
7235 } | |
7236 while ( v11 ); | |
7237 } | |
7238 } | |
7239 } | |
7240 return result; | |
7241 } | |
7242 | |
7243 //----- (004A6D87) -------------------------------------------------------- | |
7244 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
7245 { | |
7246 if (!uNumSceneBegins) | |
7247 return; | |
7248 | |
7249 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
7250 for (uint y = 0; y < uHeight; ++y) | |
7251 { | |
7252 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | |
7253 | |
7254 memset32(pDst, twoColors, uWidth / 2); | |
7255 if (uWidth & 1) | |
7256 pDst[uWidth - 1] = uColor16; | |
7257 } | |
7258 } | |
7259 | |
7260 //----- (004A6C4F) -------------------------------------------------------- | |
7261 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) | |
7262 { | |
7263 unsigned int v9; // edi@2 | |
7264 unsigned int v10; // esi@2 | |
7265 unsigned __int16 *v11; // eax@2 | |
7266 unsigned int v12; // ebx@3 | |
7267 signed int v13; // edx@5 | |
7268 int v14; // edx@6 | |
7269 signed int v15; // ebx@7 | |
7270 unsigned int v16; // edx@9 | |
7271 signed int v17; // edi@10 | |
7272 signed int v18; // ebx@13 | |
7273 unsigned int v19; // edx@15 | |
7274 signed int v20; // esi@16 | |
7275 unsigned int v21; // esi@22 | |
7276 unsigned __int16 v22; // dx@24 | |
7277 char v23; // zf@28 | |
7278 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
7279 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | |
7280 | |
7281 if ( this->uNumSceneBegins ) | |
7282 { | |
7283 v9 = uCharWidth; | |
7284 v10 = uCharHeight; | |
7285 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
7286 v24 = pFontPixels; | |
7287 if ( this->bClip ) | |
7288 { | |
7289 v12 = this->uClipX; | |
7290 if ( uOutX < (signed int)v12 ) | |
7291 { | |
7292 v24 = &pFontPixels[v12 - uOutX]; | |
7293 v11 += v12 - uOutX; | |
7294 v9 = uCharWidth + uOutX - v12; | |
7295 } | |
7296 v13 = this->uClipY; | |
7297 if ( uOutY < v13 ) | |
7298 { | |
7299 v14 = v13 - uOutY; | |
7300 v24 += uCharWidth * v14; | |
7301 v10 = uCharHeight + uOutY - this->uClipY; | |
7302 v11 += this->uTargetSurfacePitch * v14; | |
7303 } | |
7304 v15 = this->uClipX; | |
7305 if ( v15 < uOutX ) | |
7306 v15 = uOutX; | |
7307 v16 = this->uClipZ; | |
7308 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
7309 { | |
7310 v17 = this->uClipX; | |
7311 if ( v17 < uOutX ) | |
7312 v17 = uOutX; | |
7313 v9 = v16 - v17; | |
7314 } | |
7315 v18 = this->uClipY; | |
7316 if ( v18 < uOutY ) | |
7317 v18 = uOutY; | |
7318 v19 = this->uClipW; | |
7319 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
7320 { | |
7321 v20 = this->uClipY; | |
7322 if ( v20 < uOutY ) | |
7323 v20 = uOutY; | |
7324 v10 = v19 - v20; | |
7325 } | |
7326 } | |
7327 if ( (signed int)v10 > 0 ) | |
7328 { | |
7329 uOutXa = v10; | |
7330 do | |
7331 { | |
7332 if ( (signed int)v9 > 0 ) | |
7333 { | |
7334 v21 = v9; | |
7335 do | |
7336 { | |
7337 if ( *v24 ) | |
7338 { | |
7339 v22 = uShadowColor; | |
7340 if ( *v24 != 1 ) | |
7341 v22 = uFaceColor; | |
7342 *v11 = v22; | |
7343 } | |
7344 ++v11; | |
7345 ++v24; | |
7346 --v21; | |
7347 } | |
7348 while ( v21 ); | |
7349 } | |
7350 v24 += uCharWidth - v9; | |
7351 v23 = uOutXa-- == 1; | |
7352 v11 += this->uTargetSurfacePitch - v9; | |
7353 } | |
7354 while ( !v23 ); | |
7355 } | |
7356 } | |
7357 } | |
7358 | |
7359 //----- (004A6A68) -------------------------------------------------------- | |
1496 | 7360 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) |
7361 { | |
0 | 7362 Texture tex; // [sp+Ch] [bp-48h]@1 |
1496 | 7363 |
0 | 7364 memcpy(&tex, a4, sizeof(tex)); |
1496 | 7365 tex.uTextureHeight = a4->uTextureHeight - height; |
7366 if ( (signed __int16)tex.uTextureHeight > 0 ) | |
0 | 7367 DrawTextureIndexed(a2, a3, &tex); |
7368 } | |
7369 | |
7370 //----- (004A6AB1) -------------------------------------------------------- | |
1268 | 7371 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
7372 { | |
0 | 7373 int v8; // edi@2 |
7374 unsigned int v9; // esi@2 | |
7375 unsigned __int16 *v10; // eax@2 | |
7376 unsigned char *v11; // edx@2 | |
7377 unsigned int v12; // ebx@3 | |
7378 signed int v13; // edx@5 | |
7379 int v14; // edx@6 | |
7380 signed int v15; // ebx@7 | |
7381 unsigned int v16; // edx@9 | |
7382 signed int v17; // edi@10 | |
7383 signed int v18; // ebx@13 | |
7384 unsigned int v19; // edx@15 | |
7385 signed int v20; // esi@16 | |
7386 int v21; // ebx@22 | |
7387 char v22; // zf@28 | |
7388 int v23; // ebx@31 | |
7389 unsigned __int16 v24; // si@35 | |
7390 int v25; // [sp+Ch] [bp-4h]@2 | |
7391 int v26; // [sp+1Ch] [bp+Ch]@24 | |
7392 int v27; // [sp+1Ch] [bp+Ch]@33 | |
7393 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
7394 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
7395 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
7396 | |
7397 auto a2 = x; | |
7398 auto a3 = y; | |
7399 auto a6 = uFontHeight; | |
7400 if ( this->uNumSceneBegins ) | |
7401 { | |
7402 v8 = a5; | |
7403 v9 = a6; | |
7404 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
1268 | 7405 v11 = (unsigned char *)font_pixels; |
7406 v25 = (int)font_pixels; | |
0 | 7407 if ( this->bClip ) |
7408 { | |
7409 v12 = this->uClipX; | |
7410 if ( a2 < (signed int)v12 ) | |
7411 { | |
1268 | 7412 v25 = v12 - a2 + (int)font_pixels; |
0 | 7413 v10 += v12 - a2; |
7414 v8 = a5 + a2 - v12; | |
7415 } | |
7416 v13 = this->uClipY; | |
7417 if ( a3 < v13 ) | |
7418 { | |
7419 v14 = v13 - a3; | |
7420 v25 += a5 * v14; | |
7421 v9 = a6 + a3 - this->uClipY; | |
7422 v10 += this->uTargetSurfacePitch * v14; | |
7423 } | |
7424 v15 = this->uClipX; | |
7425 if ( v15 < a2 ) | |
7426 v15 = a2; | |
7427 v16 = this->uClipZ; | |
7428 if ( v8 + v15 > (signed int)v16 ) | |
7429 { | |
7430 v17 = this->uClipX; | |
7431 if ( v17 < a2 ) | |
7432 v17 = a2; | |
7433 v8 = v16 - v17; | |
7434 } | |
7435 v18 = this->uClipY; | |
7436 if ( v18 < a3 ) | |
7437 v18 = a3; | |
7438 v19 = this->uClipW; | |
7439 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
7440 { | |
7441 v20 = this->uClipY; | |
7442 if ( v20 < a3 ) | |
7443 v20 = a3; | |
7444 v9 = v19 - v20; | |
7445 } | |
7446 v11 = (unsigned char *)v25; | |
7447 } | |
7448 if ( a8 ) | |
7449 { | |
7450 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
7451 if ( (signed int)v9 > 0 ) | |
7452 { | |
7453 v23 = a5; | |
7454 v30 = v9; | |
7455 do | |
7456 { | |
7457 if ( v8 > 0 ) | |
7458 { | |
7459 v27 = v8; | |
7460 do | |
7461 { | |
7462 if ( *v11 ) | |
7463 v24 = pPalette[*v11]; | |
7464 else | |
7465 v24 = v28; | |
7466 *v10 = v24; | |
7467 ++v10; | |
7468 ++v11; | |
7469 --v27; | |
7470 } | |
7471 while ( v27 ); | |
7472 } | |
7473 v11 += v23 - v8; | |
7474 v22 = v30-- == 1; | |
7475 v10 += this->uTargetSurfacePitch - v8; | |
7476 } | |
7477 while ( !v22 ); | |
7478 } | |
7479 } | |
7480 else | |
7481 { | |
7482 if ( (signed int)v9 > 0 ) | |
7483 { | |
7484 v21 = a5; | |
7485 v29 = v9; | |
7486 do | |
7487 { | |
7488 if ( v8 > 0 ) | |
7489 { | |
7490 v26 = v8; | |
7491 do | |
7492 { | |
7493 if ( *v11 ) | |
7494 *v10 = pPalette[*v11]; | |
7495 ++v10; | |
7496 ++v11; | |
7497 --v26; | |
7498 } | |
7499 while ( v26 ); | |
7500 } | |
7501 v11 += v21 - v8; | |
7502 v22 = v29-- == 1; | |
7503 v10 += this->uTargetSurfacePitch - v8; | |
7504 } | |
7505 while ( !v22 ); | |
7506 } | |
7507 } | |
7508 } | |
7509 } | |
7510 | |
7511 //----- (004A68EF) -------------------------------------------------------- | |
7512 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
7513 { | |
7514 Texture *v4; // edi@2 | |
7515 unsigned int v5; // ebx@4 | |
7516 unsigned __int16 *v6; // eax@4 | |
7517 signed int v7; // edx@5 | |
7518 int v8; // edx@6 | |
7519 signed int v9; // edx@7 | |
7520 int v10; // edx@8 | |
7521 signed int v11; // edx@9 | |
7522 signed int v12; // esi@12 | |
7523 signed int v13; // esi@15 | |
7524 unsigned int v14; // edx@17 | |
7525 signed int v15; // esi@18 | |
7526 unsigned __int8 *v16; // ebx@22 | |
7527 char v17; // zf@28 | |
7528 int v18; // [sp+10h] [bp-10h]@4 | |
7529 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7530 int v20; // [sp+1Ch] [bp-4h]@4 | |
7531 int v21; // [sp+28h] [bp+8h]@24 | |
7532 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
7533 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7534 | |
7535 if ( this->uNumSceneBegins ) | |
7536 { | |
7537 v4 = pTexture; | |
7538 if ( pTexture ) | |
7539 { | |
7540 if ( pTexture->pPalette16 ) | |
7541 { | |
7542 v5 = pTexture->uTextureHeight; | |
7543 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7544 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7545 v20 = pTexture->uTextureWidth; |
7546 v18 = pTexture->uTextureWidth; | |
7547 if ( this->bClip ) | |
7548 { | |
7549 v7 = this->uClipX; | |
7550 if ( a2 < v7 ) | |
7551 { | |
7552 v8 = v7 - a2; | |
7553 v19 += v8; | |
7554 v20 += a2 - this->uClipX; | |
7555 v6 += v8; | |
7556 } | |
7557 v9 = this->uClipY; | |
7558 v5 = pTexture->uTextureHeight; | |
7559 if ( a3 < v9 ) | |
7560 { | |
7561 v10 = v9 - a3; | |
7562 v19 += v18 * v10; | |
7563 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7564 v4 = pTexture; | |
7565 v6 += this->uTargetSurfacePitch * v10; | |
7566 } | |
7567 v11 = this->uClipX; | |
7568 if ( v11 < a2 ) | |
7569 v11 = a2; | |
7570 pTexturea = this->uClipZ; | |
7571 if ( v11 + v20 > (signed int)pTexturea ) | |
7572 { | |
7573 v12 = this->uClipX; | |
7574 if ( v12 < a2 ) | |
7575 v12 = a2; | |
7576 v20 = pTexturea - v12; | |
7577 } | |
7578 v13 = this->uClipY; | |
7579 if ( v13 < a3 ) | |
7580 v13 = a3; | |
7581 v14 = this->uClipW; | |
7582 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7583 { | |
7584 v15 = this->uClipY; | |
7585 if ( v15 < a3 ) | |
7586 v15 = a3; | |
7587 v5 = v14 - v15; | |
7588 } | |
7589 } | |
7590 if ( (signed int)v5 > 0 ) | |
7591 { | |
7592 v22 = v5; | |
7593 v16 = v19; | |
7594 do | |
7595 { | |
7596 if ( v20 > 0 ) | |
7597 { | |
7598 v21 = v20; | |
7599 do | |
7600 { | |
7601 if ( *v16 ) | |
7602 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7603 ++v6; | |
7604 ++v16; | |
7605 --v21; | |
7606 } | |
7607 while ( v21 ); | |
7608 } | |
7609 v16 += v18 - v20; | |
7610 v17 = v22-- == 1; | |
7611 v6 += this->uTargetSurfacePitch - v20; | |
7612 } | |
7613 while ( !v17 ); | |
7614 } | |
7615 } | |
7616 } | |
7617 } | |
7618 } | |
7619 | |
7620 //----- (004A6776) -------------------------------------------------------- | |
315 | 7621 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 7622 { |
7623 Texture *v4; // edi@2 | |
7624 unsigned int v5; // ebx@4 | |
7625 unsigned __int16 *v6; // eax@4 | |
7626 unsigned int v7; // edx@5 | |
7627 unsigned int v8; // edx@6 | |
7628 unsigned int v9; // edx@7 | |
7629 unsigned int v10; // edx@8 | |
7630 unsigned int v11; // edx@9 | |
7631 unsigned int v12; // esi@12 | |
7632 unsigned int v13; // esi@15 | |
7633 unsigned int v14; // edx@17 | |
7634 unsigned int v15; // esi@18 | |
7635 unsigned __int8 *v16; // ebx@22 | |
7636 char v17; // zf@28 | |
7637 int v18; // [sp+10h] [bp-10h]@4 | |
7638 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7639 int v20; // [sp+1Ch] [bp-4h]@4 | |
7640 int a2a; // [sp+28h] [bp+8h]@24 | |
7641 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
7642 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
7643 | |
7644 if ( this->uNumSceneBegins ) | |
7645 { | |
7646 v4 = a4; | |
7647 if ( a4 ) | |
7648 { | |
7649 if ( a4->pPalette16 ) | |
7650 { | |
7651 v5 = a4->uTextureHeight; | |
7652 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7653 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7654 v20 = a4->uTextureWidth; |
7655 v18 = a4->uTextureWidth; | |
7656 if ( this->bClip ) | |
7657 { | |
7658 v7 = this->uClipX; | |
7659 if ( (signed int)a2 < (signed int)v7 ) | |
7660 { | |
7661 v8 = v7 - a2; | |
7662 v19 += v8; | |
7663 v20 += a2 - this->uClipX; | |
7664 v6 += v8; | |
7665 } | |
7666 v9 = this->uClipY; | |
7667 v5 = a4->uTextureHeight; | |
7668 if ( (signed int)a3 < (signed int)v9 ) | |
7669 { | |
7670 v10 = v9 - a3; | |
7671 v19 += v18 * v10; | |
7672 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
7673 v4 = a4; | |
7674 v6 += this->uTargetSurfacePitch * v10; | |
7675 } | |
7676 v11 = this->uClipX; | |
7677 if ( (signed int)v11 < (signed int)a2 ) | |
7678 v11 = a2; | |
7679 a4a = this->uClipZ; | |
7680 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
7681 { | |
7682 v12 = this->uClipX; | |
7683 if ( (signed int)v12 < (signed int)a2 ) | |
7684 v12 = a2; | |
7685 v20 = a4a - v12; | |
7686 } | |
7687 v13 = this->uClipY; | |
7688 if ( (signed int)v13 < (signed int)a3 ) | |
7689 v13 = a3; | |
7690 v14 = this->uClipW; | |
7691 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7692 { | |
7693 v15 = this->uClipY; | |
7694 if ( (signed int)v15 < (signed int)a3 ) | |
7695 v15 = a3; | |
7696 v5 = v14 - v15; | |
7697 } | |
7698 } | |
7699 if ( (signed int)v5 > 0 ) | |
7700 { | |
7701 a3a = v5; | |
7702 v16 = v19; | |
7703 do | |
7704 { | |
7705 if ( v20 > 0 ) | |
7706 { | |
7707 a2a = v20; | |
7708 do | |
7709 { | |
7710 if ( *v16 ) | |
7711 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
7712 ++v6; | |
7713 ++v16; | |
7714 --a2a; | |
7715 } | |
7716 while ( a2a ); | |
7717 } | |
7718 v16 += v18 - v20; | |
7719 v17 = a3a-- == 1; | |
7720 v6 += this->uTargetSurfacePitch - v20; | |
7721 } | |
7722 while ( !v17 ); | |
7723 } | |
7724 } | |
7725 } | |
7726 } | |
7727 } | |
7728 | |
7729 //----- (004A65CC) -------------------------------------------------------- | |
7730 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
7731 { | |
7732 unsigned __int16 *v8; // esi@6 | |
7733 unsigned int v9; // edi@6 | |
7734 unsigned int v10; // eax@7 | |
7735 unsigned int v11; // eax@8 | |
7736 unsigned int v12; // eax@9 | |
7737 unsigned int v13; // eax@10 | |
7738 unsigned int v14; // edx@11 | |
7739 unsigned int v15; // eax@13 | |
7740 unsigned int v16; // edx@14 | |
7741 unsigned int v17; // edx@17 | |
7742 unsigned int v18; // eax@19 | |
7743 unsigned int v19; // edx@20 | |
7744 int v20; // eax@27 | |
7745 int v21; // edx@29 | |
7746 int v22; // [sp+Ch] [bp-Ch]@6 | |
7747 int v23; // [sp+Ch] [bp-Ch]@24 | |
7748 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
7749 int xa; // [sp+20h] [bp+8h]@26 | |
7750 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
7751 int v27; // [sp+2Ch] [bp+14h]@6 | |
7752 | |
7753 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
7754 { | |
7755 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | |
710 | 7756 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7757 v27 = a4->uTextureWidth; |
7758 v9 = a4->uTextureHeight; | |
7759 v22 = a4->uTextureWidth; | |
7760 if ( this->bClip ) | |
7761 { | |
7762 v10 = this->uClipX; | |
7763 if ( (signed int)x < (signed int)v10 ) | |
7764 { | |
7765 v11 = v10 - x; | |
7766 v24 += v11; | |
7767 v27 += x - this->uClipX; | |
7768 v8 += v11; | |
7769 } | |
7770 v12 = this->uClipY; | |
7771 if ( (signed int)y < (signed int)v12 ) | |
7772 { | |
7773 v13 = v12 - y; | |
7774 v24 += v22 * v13; | |
7775 v9 = y - this->uClipY + a4->uTextureHeight; | |
7776 v8 += this->uTargetSurfacePitch * v13; | |
7777 } | |
7778 v14 = this->uClipX; | |
7779 if ( (signed int)v14 < (signed int)x ) | |
7780 v14 = x; | |
7781 v15 = this->uClipZ; | |
7782 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
7783 { | |
7784 v16 = this->uClipX; | |
7785 if ( (signed int)v16 < (signed int)x ) | |
7786 v16 = x; | |
7787 v27 = v15 - v16; | |
7788 } | |
7789 v17 = this->uClipY; | |
7790 if ( (signed int)v17 < (signed int)y ) | |
7791 v17 = y; | |
7792 v18 = this->uClipW; | |
7793 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
7794 { | |
7795 v19 = this->uClipY; | |
7796 if ( (signed int)v19 < (signed int)y ) | |
7797 v19 = y; | |
7798 v9 = v18 - v19; | |
7799 } | |
7800 } | |
7801 if ( (signed int)v9 > 0 ) | |
7802 { | |
7803 ya = v9; | |
7804 v23 = v22 - v27; | |
7805 do | |
7806 { | |
7807 if ( v27 > 0 ) | |
7808 { | |
7809 xa = v27; | |
7810 do | |
7811 { | |
7812 v20 = *v24; | |
7813 if ( v20 >= a7 && v20 <= a8 ) | |
7814 { | |
7815 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7816 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7817 v21 = 2 * a8 - v21 - a7; | |
7818 *v8 = a4->pPalette16[v21]; | |
7819 } | |
7820 ++v8; | |
7821 ++v24; | |
7822 --xa; | |
7823 } | |
7824 while ( xa ); | |
7825 } | |
7826 v8 += this->uTargetSurfacePitch - v27; | |
7827 v24 += v23; | |
7828 --ya; | |
7829 } | |
7830 while ( ya ); | |
7831 } | |
7832 } | |
7833 } | |
7834 | |
7835 //----- (004A63E6) -------------------------------------------------------- | |
1455 | 7836 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) |
0 | 7837 { |
7838 Texture *v8; // eax@2 | |
7839 Texture *v9; // ebx@4 | |
7840 unsigned __int16 *v10; // esi@6 | |
7841 unsigned int v11; // edi@7 | |
7842 unsigned int v12; // eax@9 | |
7843 unsigned int v13; // eax@10 | |
7844 unsigned int v14; // edx@11 | |
7845 unsigned int v15; // eax@13 | |
7846 unsigned int v16; // edx@14 | |
7847 unsigned int v17; // edx@17 | |
7848 unsigned int v18; // eax@19 | |
7849 unsigned int v19; // edx@20 | |
7850 int v20; // eax@27 | |
7851 int v21; // edx@29 | |
7852 int v22; // [sp+Ch] [bp-Ch]@6 | |
7853 int v23; // [sp+Ch] [bp-Ch]@24 | |
7854 int v24; // [sp+10h] [bp-8h]@6 | |
7855 int v25; // [sp+14h] [bp-4h]@6 | |
7856 int i; // [sp+20h] [bp+8h]@25 | |
7857 int v27; // [sp+24h] [bp+Ch]@23 | |
7858 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
7859 | |
7860 if ( this->uNumSceneBegins ) | |
7861 { | |
7862 v8 = a4; | |
7863 if ( a4 ) | |
7864 { | |
7865 if ( a4->pPalette16 ) | |
7866 { | |
7867 v9 = a5; | |
7868 if ( a5 ) | |
7869 { | |
7870 if ( a5->pPalette16 ) | |
7871 { | |
7872 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7873 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7874 v25 = v8->uTextureWidth; |
7875 v24 = v8->uTextureHeight; | |
7876 v22 = v8->uTextureWidth; | |
7877 if ( this->bClip ) | |
7878 { | |
7879 v11 = this->uClipX; | |
7880 if ( (signed int)a2 < (signed int)v11 ) | |
7881 { | |
7882 v28 += v11 - a2; | |
7883 v25 += a2 - v11; | |
7884 v9 = a5; | |
7885 v10 += v11 - a2; | |
7886 } | |
7887 v12 = this->uClipY; | |
7888 if ( (signed int)a3 < (signed int)v12 ) | |
7889 { | |
7890 v13 = v12 - a3; | |
7891 v9 = a5; | |
7892 v28 += v22 * v13; | |
7893 v24 += a3 - this->uClipY; | |
7894 v10 += this->uTargetSurfacePitch * v13; | |
7895 } | |
7896 v14 = this->uClipX; | |
7897 if ( (signed int)v14 < (signed int)a2 ) | |
7898 v14 = a2; | |
7899 v15 = this->uClipZ; | |
7900 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
7901 { | |
7902 v16 = this->uClipX; | |
7903 if ( (signed int)v16 < (signed int)a2 ) | |
7904 v16 = a2; | |
7905 v25 = v15 - v16; | |
7906 } | |
7907 v17 = this->uClipY; | |
7908 if ( (signed int)v17 < (signed int)a3 ) | |
7909 v17 = a3; | |
7910 v18 = this->uClipW; | |
7911 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
7912 { | |
7913 v19 = this->uClipY; | |
7914 if ( (signed int)v19 < (signed int)a3 ) | |
7915 v19 = a3; | |
7916 v24 = v18 - v19; | |
7917 } | |
7918 } | |
7919 v27 = 0; | |
7920 if ( v24 > 0 ) | |
7921 { | |
7922 v23 = v22 - v25; | |
7923 do | |
7924 { | |
7925 for ( i = 0; i < v25; ++v28 ) | |
7926 { | |
7927 if ( *v28 ) | |
7928 { | |
710 | 7929 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 7930 if ( v20 >= a7 ) |
7931 { | |
7932 if ( v20 <= a8 ) | |
7933 { | |
7934 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7935 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7936 v21 = 2 * a8 - v21 - a7; | |
7937 v9 = a5; | |
7938 *v10 = a5->pPalette16[v21]; | |
7939 } | |
7940 } | |
7941 } | |
7942 ++i; | |
7943 ++v10; | |
7944 } | |
7945 ++v27; | |
7946 v10 += this->uTargetSurfacePitch - v25; | |
7947 v28 += v23; | |
7948 } | |
7949 while ( v27 < v24 ); | |
7950 } | |
7951 } | |
7952 } | |
7953 } | |
7954 } | |
7955 } | |
7956 } | |
7957 | |
7958 //----- (004A6274) -------------------------------------------------------- | |
7959 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
7960 { | |
7961 Texture *pCurrentTexture; // edi@2 | |
7962 int uHeight; // ebx@4 | |
7963 unsigned __int16 *v6; // eax@4 | |
7964 unsigned int v7; // edx@5 | |
7965 unsigned int v8; // edx@6 | |
7966 unsigned int v9; // edx@7 | |
7967 unsigned int v10; // edx@8 | |
7968 unsigned int v11; // edx@9 | |
7969 unsigned int v12; // esi@12 | |
7970 unsigned int v13; // esi@15 | |
7971 unsigned int v14; // edx@17 | |
7972 unsigned int v15; // esi@18 | |
7973 unsigned __int8 *v16; // ebx@22 | |
7974 char uFlag; // zf@28 | |
7975 int v18; // [sp+10h] [bp-10h]@4 | |
7976 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7977 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
7978 int uXa; // [sp+28h] [bp+8h]@24 | |
7979 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
7980 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7981 | |
7982 if ( this->uNumSceneBegins ) | |
7983 { | |
7984 pCurrentTexture = pTexture; | |
7985 if ( pTexture ) | |
7986 { | |
7987 if ( pTexture->pPalette16 ) | |
7988 { | |
7989 uHeight = pTexture->uTextureHeight; | |
7990 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 7991 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7992 uWidth = pTexture->uTextureWidth; |
7993 v18 = pTexture->uTextureWidth; | |
7994 if ( this->bClip ) | |
7995 { | |
7996 v7 = this->uClipX; | |
7997 if ( (signed int)uX < (signed int)v7 ) | |
7998 { | |
7999 v8 = v7 - uX; | |
8000 v19 += v8; | |
8001 uWidth += uX - this->uClipX; | |
8002 v6 += v8; | |
8003 } | |
8004 v9 = this->uClipY; | |
8005 uHeight = pTexture->uTextureHeight; | |
8006 if ( (signed int)uY < (signed int)v9 ) | |
8007 { | |
8008 v10 = v9 - uY; | |
8009 v19 += v18 * v10; | |
8010 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
8011 pCurrentTexture = pTexture; | |
8012 v6 += this->uTargetSurfacePitch * v10; | |
8013 } | |
8014 v11 = this->uClipX; | |
8015 if ( (signed int)v11 < (signed int)uX ) | |
8016 v11 = uX; | |
8017 pTexturea = this->uClipZ; | |
8018 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
8019 { | |
8020 v12 = this->uClipX; | |
8021 if ( (signed int)v12 < (signed int)uX ) | |
8022 v12 = uX; | |
8023 uWidth = pTexturea - v12; | |
8024 } | |
8025 v13 = this->uClipY; | |
8026 if ( (signed int)v13 < (signed int)uY ) | |
8027 v13 = uY; | |
8028 v14 = this->uClipW; | |
8029 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
8030 { | |
8031 v15 = this->uClipY; | |
8032 if ( (signed int)v15 < (signed int)uY ) | |
8033 v15 = uY; | |
8034 uHeight = v14 - v15; | |
8035 } | |
8036 } | |
8037 if ( (signed int)uHeight > 0 ) | |
8038 { | |
8039 uYa = uHeight; | |
8040 v16 = v19; | |
8041 do | |
8042 { | |
8043 if ( uWidth > 0 ) | |
8044 { | |
8045 uXa = uWidth; | |
8046 do | |
8047 { | |
8048 if ( *v16 ) | |
8049 *v6 = pCurrentTexture->pPalette16[*v16]; | |
8050 ++v6; | |
8051 ++v16; | |
8052 } | |
8053 while ( uXa-- !=1 ); | |
8054 } | |
8055 v16 += v18 - uWidth; | |
8056 uFlag = uYa-- == 1; | |
8057 v6 += this->uTargetSurfacePitch - uWidth; | |
8058 } | |
8059 while ( !uFlag ); | |
8060 } | |
8061 } | |
8062 } | |
8063 } | |
8064 } | |
8065 | |
8066 //----- (004A612A) -------------------------------------------------------- | |
710 | 8067 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 8068 { |
8069 Texture *v5; // eax@2 | |
8070 unsigned int v6; // edx@3 | |
8071 int v7; // ebx@3 | |
8072 int v8; // edi@3 | |
8073 signed int v9; // eax@4 | |
8074 int v10; // eax@5 | |
8075 unsigned int v11; // esi@6 | |
8076 signed int v12; // esi@8 | |
8077 unsigned int v13; // eax@10 | |
8078 signed int v14; // esi@11 | |
8079 unsigned int v15; // esi@14 | |
8080 unsigned int v16; // eax@16 | |
8081 unsigned int v17; // ecx@17 | |
8082 int v18; // edx@23 | |
8083 int v19; // [sp+Ch] [bp-Ch]@3 | |
8084 int v20; // [sp+10h] [bp-8h]@3 | |
8085 int uOutXa; // [sp+20h] [bp+8h]@21 | |
8086 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
8087 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
8088 | |
8089 if ( this->uNumSceneBegins ) | |
8090 { | |
8091 v5 = pTexture; | |
8092 if ( pTexture ) | |
8093 { | |
8094 v6 = uOutY; | |
8095 v7 = pTexture->uTextureHeight; | |
8096 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
710 | 8097 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8098 v8 = v5->uTextureWidth; |
8099 v20 = v5->uTextureWidth; | |
8100 v19 = v5->uTextureWidth; | |
8101 if ( this->bClip ) | |
8102 { | |
8103 v9 = this->uClipX; | |
8104 if ( uOutX < v9 ) | |
8105 { | |
8106 v10 = v9 - uOutX; | |
8107 uOutYa += v10; | |
8108 v8 += uOutX - this->uClipX; | |
8109 v20 = v8; | |
8110 pZBuffer += v10; | |
8111 } | |
8112 v11 = this->uClipY; | |
8113 if ( (signed int)v6 < (signed int)v11 ) | |
8114 { | |
8115 uOutYa += v19 * (v11 - v6); | |
8116 v7 += v6 - v11; | |
8117 pZBuffer += 640 * (v11 - v6); | |
8118 v8 = v20; | |
8119 } | |
8120 v12 = this->uClipX; | |
8121 if ( v12 < uOutX ) | |
8122 v12 = uOutX; | |
8123 v13 = this->uClipZ; | |
8124 if ( v8 + v12 > (signed int)v13 ) | |
8125 { | |
8126 v14 = this->uClipX; | |
8127 if ( v14 < uOutX ) | |
8128 v14 = uOutX; | |
8129 v8 = v13 - v14; | |
8130 } | |
8131 v15 = this->uClipY; | |
8132 if ( (signed int)v15 < (signed int)v6 ) | |
8133 v15 = v6; | |
8134 v16 = this->uClipW; | |
8135 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
8136 { | |
8137 v17 = this->uClipY; | |
8138 if ( (signed int)v17 >= (signed int)v6 ) | |
8139 v6 = v17; | |
8140 v7 = v16 - v6; | |
8141 } | |
8142 } | |
8143 if ( v7 > 0 ) | |
8144 { | |
8145 uOutXa = v7; | |
8146 do | |
8147 { | |
8148 if ( v8 > 0 ) | |
8149 { | |
8150 v18 = v8; | |
8151 do | |
8152 { | |
8153 if ( *uOutYa ) | |
8154 *pZBuffer = zVal; | |
8155 ++pZBuffer; | |
8156 ++uOutYa; | |
8157 --v18; | |
8158 } | |
8159 while ( v18 ); | |
8160 } | |
8161 pZBuffer += 640 - v8; | |
8162 uOutYa += v19 - v8; | |
8163 --uOutXa; | |
8164 } | |
8165 while ( uOutXa ); | |
8166 } | |
8167 } | |
8168 } | |
8169 } | |
8170 | |
8171 //----- (004A601E) -------------------------------------------------------- | |
991 | 8172 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 8173 { |
8174 signed int v5; // edx@3 | |
8175 int v6; // ebx@3 | |
8176 int v7; // esi@3 | |
8177 void *v8; // esi@3 | |
8178 unsigned int v9; // eax@4 | |
8179 unsigned int v10; // eax@6 | |
8180 signed int v11; // edi@8 | |
8181 unsigned int v12; // eax@10 | |
8182 signed int v13; // edi@11 | |
8183 unsigned int v14; // edi@14 | |
8184 unsigned int v15; // eax@16 | |
8185 unsigned int v16; // ecx@17 | |
8186 int v17; // [sp+18h] [bp+Ch]@3 | |
8187 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
8188 | |
8189 if ( this->uNumSceneBegins && pTexture ) | |
8190 { | |
8191 v5 = a3; | |
8192 v6 = pTexture->uTextureHeight; | |
8193 v7 = 5 * a3; | |
8194 v17 = pTexture->uTextureHeight; | |
8195 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
8196 pTexturea = pTexture->uTextureWidth; | |
8197 if ( this->bClip ) | |
8198 { | |
8199 v9 = this->uClipX; | |
8200 if ( a2 < (signed int)v9 ) | |
8201 { | |
8202 pTexturea += a2 - v9; | |
8203 v8 = (char *)v8 + 4 * (v9 - a2); | |
8204 } | |
8205 v10 = this->uClipY; | |
8206 if ( v5 < (signed int)v10 ) | |
8207 { | |
8208 v17 += v5 - v10; | |
8209 v8 = (char *)v8 + 2560 * (v10 - v5); | |
8210 } | |
8211 v11 = this->uClipX; | |
8212 if ( v11 < a2 ) | |
8213 v11 = a2; | |
8214 v12 = this->uClipZ; | |
8215 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
8216 { | |
8217 v13 = this->uClipX; | |
8218 if ( v13 < a2 ) | |
8219 v13 = a2; | |
8220 pTexturea = v12 - v13; | |
8221 } | |
8222 v14 = this->uClipY; | |
8223 if ( (signed int)v14 < v5 ) | |
8224 v14 = v5; | |
8225 v6 = v17; | |
8226 v15 = this->uClipW; | |
8227 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
8228 { | |
8229 v16 = this->uClipY; | |
8230 if ( (signed int)v16 < v5 ) | |
8231 v16 = v5; | |
8232 v6 = v15 - v16; | |
8233 } | |
8234 } | |
8235 if ( v6 > 0 ) | |
8236 { | |
8237 do | |
8238 { | |
8239 if ( (signed int)pTexturea > 0 ) | |
8240 { | |
8241 memset32(v8, a5, pTexturea); | |
8242 v8 = (char *)v8 + 4 * pTexturea; | |
8243 } | |
8244 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
8245 --v6; | |
8246 } | |
8247 while ( v6 ); | |
8248 } | |
8249 } | |
8250 } | |
8251 | |
8252 //----- (004A5EB2) -------------------------------------------------------- | |
8253 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
8254 { | |
8255 Texture *v4; // edi@2 | |
8256 unsigned int v5; // ebx@4 | |
8257 unsigned __int16 *pTarget; // eax@4 | |
8258 unsigned int v7; // edx@5 | |
8259 unsigned int v8; // edx@6 | |
8260 unsigned int v9; // edx@7 | |
8261 unsigned int v10; // edx@8 | |
8262 unsigned int v11; // edx@9 | |
8263 unsigned int v12; // esi@12 | |
8264 unsigned int v13; // esi@15 | |
8265 unsigned int v14; // edx@17 | |
8266 unsigned int v15; // esi@18 | |
8267 unsigned __int8 *v16; // edx@22 | |
8268 char v17; // zf@26 | |
8269 int v18; // [sp+10h] [bp-10h]@4 | |
8270 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
8271 int v20; // [sp+1Ch] [bp-4h]@4 | |
8272 int uXa; // [sp+28h] [bp+8h]@24 | |
8273 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
8274 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
8275 | |
8276 if ( this->uNumSceneBegins ) | |
8277 { | |
8278 v4 = a4; | |
8279 if ( a4 ) | |
8280 { | |
8281 if ( a4->pPalette16 ) | |
8282 { | |
8283 v5 = a4->uTextureHeight; | |
8284 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 8285 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8286 v20 = a4->uTextureWidth; |
8287 v18 = a4->uTextureWidth; | |
8288 if ( this->bClip ) | |
8289 { | |
8290 v7 = this->uClipX; | |
8291 if ( (signed int)uX < (signed int)v7 ) | |
8292 { | |
8293 v8 = v7 - uX; | |
8294 v19 += v8; | |
8295 v20 += uX - this->uClipX; | |
8296 pTarget += v8; | |
8297 } | |
8298 v9 = this->uClipY; | |
8299 v5 = a4->uTextureHeight; | |
8300 if ( (signed int)uY < (signed int)v9 ) | |
8301 { | |
8302 v10 = v9 - uY; | |
8303 v19 += v18 * v10; | |
8304 v5 = uY - this->uClipY + a4->uTextureHeight; | |
8305 v4 = a4; | |
8306 pTarget += this->uTargetSurfacePitch * v10; | |
8307 } | |
8308 v11 = this->uClipX; | |
8309 if ( (signed int)v11 < (signed int)uX ) | |
8310 v11 = uX; | |
8311 v23 = this->uClipZ; | |
8312 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
8313 { | |
8314 v12 = this->uClipX; | |
8315 if ( (signed int)v12 < (signed int)uX ) | |
8316 v12 = uX; | |
8317 v20 = v23 - v12; | |
8318 } | |
8319 v13 = this->uClipY; | |
8320 if ( (signed int)v13 < (signed int)uY ) | |
8321 v13 = uY; | |
8322 v14 = this->uClipW; | |
8323 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
8324 { | |
8325 v15 = this->uClipY; | |
8326 if ( (signed int)v15 < (signed int)uY ) | |
8327 v15 = uY; | |
8328 v5 = v14 - v15; | |
8329 } | |
8330 } | |
8331 if ( (signed int)v5 > 0 ) | |
8332 { | |
8333 uYa = v5; | |
8334 v16 = v19; | |
8335 do | |
8336 { | |
8337 if ( v20 > 0 ) | |
8338 { | |
8339 uXa = v20; | |
8340 do | |
8341 { | |
8342 *pTarget = v4->pPalette16[*v16]; | |
8343 ++pTarget; | |
8344 ++v16; | |
8345 --uXa; | |
8346 } | |
8347 while ( uXa ); | |
8348 } | |
8349 v16 += v18 - v20; | |
8350 v17 = uYa-- == 1; | |
8351 pTarget += this->uTargetSurfacePitch - v20; | |
8352 } | |
8353 while ( !v17 ); | |
8354 } | |
8355 } | |
8356 } | |
8357 } | |
8358 } | |
8359 | |
8360 //----- (004667E9) -------------------------------------------------------- | |
8361 void Render::ChangeBetweenWinFullscreenModes() | |
8362 { | |
8363 float v0; // ST14_4@17 | |
8364 int v4; // edx@26 | |
8365 ObjectDesc *v5; // eax@26 | |
8366 RGBTexture *v6; // esi@33 | |
8367 const char *v8; // [sp-4h] [bp-28h]@33 | |
8368 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
8369 | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8370 if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) |
0 | 8371 { |
1458 | 8372 ModalWindow(pGlobalTXT_LocalizationStrings[62], UIMSG_0);// "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window." |
0 | 8373 return; |
8374 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8375 if ( pRenderer->bWindowMode || !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8376 { |
0 | 8377 if ( pEventTimer->bPaused ) |
8378 BYTE1(dword_6BE364_game_settings_1) |= 8u; | |
8379 else | |
8380 pEventTimer->Pause(); | |
8381 if ( pMiscTimer->bPaused ) | |
8382 BYTE1(dword_6BE364_game_settings_1) |= 0x10u; | |
8383 else | |
8384 pMiscTimer->Pause(); | |
8385 pMouse->bActive = 0; | |
8386 if ( pRenderer->pRenderD3D ) | |
8387 { | |
8388 pBitmaps_LOD->ReleaseHardwareTextures(); | |
8389 pSprites_LOD->ReleaseAll(); | |
8390 } | |
8391 if ( pRenderer->bWindowMode ) | |
8392 { | |
8393 if ( GetWindowRect(hWnd, &Rect) ) | |
8394 { | |
8395 WriteWindowsRegistryInt("window X", Rect.left); | |
8396 WriteWindowsRegistryInt("window Y", Rect.top); | |
8397 uWindowX = Rect.left; | |
8398 uWindowY = Rect.top; | |
8399 } | |
8400 SetMenu(hWnd, 0); | |
8401 SetWindowLongA(hWnd, -20, 0); | |
8402 SetWindowLongA(hWnd, -16, 0x10000000u); | |
8403 pRenderer->InitializeFullscreen(hWnd); | |
8404 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | |
8405 pGame->pGammaController->Initialize(v0); | |
8406 } | |
8407 else | |
8408 { | |
8409 ClipCursor(0); | |
8410 pRenderer->SwitchToWindow(hWnd); | |
8411 SetWindowLongA(hWnd, -16, uWindowStyle); | |
8412 } | |
8413 if ( pRenderer->pRenderD3D ) | |
8414 { | |
8415 pBitmaps_LOD->_410423_move_textures_to_device(); | |
8416 pSprites_LOD->MoveSpritesToVideoMemory(); | |
8417 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8418 if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits |
0 | 8419 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8420 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8421 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8422 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8423 pPaletteManager->RecalculateAll(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8424 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8425 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8426 for (int i = 0; i < pObjectList->uNumObjects; i++) |
0 | 8427 { |
8428 BYTE3(v4) = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8429 v5 = &pObjectList->pObjects[i]; |
0 | 8430 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; |
8431 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
8432 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8433 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8434 SetUserInterface(pParty->alignment, true); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8435 if ( pVideoPlayer->pVideoFrame.pPixels ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8436 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); |
0 | 8437 if ( uCurrentMenuID != 6 ) |
8438 { | |
8439 if ( uCurrentMenuID == 8 ) | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8440 dword_A74C88 = 1; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8441 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8442 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8443 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8444 if ( uCurrentMenuID ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8445 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8446 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8447 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8448 v8 = "makeme.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8449 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8450 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8451 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8452 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8453 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8454 v8 = "title.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8455 if ( uCurrentMenuID ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8456 v8 = "lsave640.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8457 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8458 v6->Load(v8, 0); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8459 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8460 } |
0 | 8461 viewparams->bRedrawGameUI = 1; |
688 | 8462 viewparams->InitGrayPalette(); |
0 | 8463 pMouse->SetCurrentCursorBitmap(); |
8464 if ( pRenderer->bWindowMode ) | |
8465 { | |
8466 InvalidateRect(0, 0, 0); | |
8467 MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | |
1586 | 8468 ShowWindow(hWnd, SW_SHOWNORMAL); |
0 | 8469 } |
8470 pMouse->bActive = 1; | |
8471 if ( pVideoPlayer->AnyMovieLoaded() ) | |
898 | 8472 pVideoPlayer->SelectMovieType(); |
0 | 8473 if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) |
8474 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | |
8475 else | |
8476 pEventTimer->Resume(); | |
8477 if ( BYTE1(dword_6BE364_game_settings_1) & 0x10 ) | |
8478 BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; | |
8479 else | |
8480 pMiscTimer->Resume(); | |
8481 } | |
8482 } | |
8483 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
8484 // A74C88: using guessed type int dword_A74C88; | |
8485 | |
8486 | |
8487 //----- (004524D8) -------------------------------------------------------- | |
8488 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
8489 { | |
1583 | 8490 //int v11; // eax@13 |
8491 //int v12; // ecx@13 | |
0 | 8492 void *v13; // eax@13 |
1583 | 8493 //unsigned __int8 v14; // zf@13 |
8494 //unsigned __int8 v15; // sf@13 | |
0 | 8495 int v16; // esi@14 |
8496 int v17; // ecx@16 | |
8497 int v18; // esi@16 | |
8498 unsigned __int16 *v19; // eax@16 | |
8499 int v20; // edx@16 | |
8500 int v21; // ecx@16 | |
8501 int v22; // eax@16 | |
8502 int v23; // esi@16 | |
8503 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
8504 int v27; // [sp+28h] [bp-Ch]@14 | |
8505 int v28; // [sp+2Ch] [bp-8h]@13 | |
8506 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
8507 | |
8508 //v3 = this; | |
8509 //sprintf(Str1, "%s", pName); | |
8510 //v4 = uNumItems; | |
8511 if (!uNumItems) | |
8512 return nullptr; | |
8513 | |
8514 //{ | |
8515 //v5 = 0, pDesta = uNumItems; | |
8516 uint idx1 = 0, | |
8517 idx2 = uNumItems; | |
8518 while (true) | |
8519 { | |
8520 auto i = idx1 + (idx2 - idx1) / 2; | |
8521 | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
8522 auto res = _stricmp(pName, pSpriteNames[i]); |
0 | 8523 if (!res) |
8524 { | |
8525 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
8526 break; | |
8527 } | |
8528 else if (res < 0) | |
8529 idx2 = idx1 + (idx2 - idx1) / 2; | |
8530 else | |
8531 idx1 = i + 1; | |
8532 | |
8533 if ( idx1 >= idx2 ) | |
8534 return false; | |
8535 } | |
8536 | |
8537 | |
8538 uint uCompressedSize = 0; | |
8539 fread(&uCompressedSize, 4, 1, pFile); | |
8540 | |
8541 auto pTex = new HWLTexture; | |
670 | 8542 fread(&pTex->uBufferWidth, 4, 1, pFile); |
8543 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
8544 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
8545 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 8546 fread(&pTex->uWidth, 4, 1, pFile); |
8547 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 8548 fread(&pTex->uAreaX, 4, 1, pFile); |
8549 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 8550 |
8551 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
8552 if (uCompressedSize) | |
8553 { | |
8554 auto pCompressedData = new char[uCompressedSize]; | |
8555 { | |
8556 fread(pCompressedData, 1, uCompressedSize, pFile); | |
8557 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
8558 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
8559 } | |
8560 delete [] pCompressedData; | |
8561 } | |
8562 else | |
8563 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
8564 | |
1583 | 8565 if ( scale_hwls_to_half ) |
8566 { | |
8567 pTex->uHeight /= 2; | |
8568 pTex->uWidth /= 2; | |
8569 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
0 | 8570 v28 = 0; |
8571 v26 = (unsigned __int16 *)v13; | |
1583 | 8572 if ( pTex->uHeight > 0 ) |
0 | 8573 { |
8574 v16 = pTex->uWidth; | |
8575 v27 = 1; | |
8576 do | |
8577 { | |
8578 pDestb = 0; | |
8579 if ( v16 > 0 ) | |
8580 { | |
8581 do | |
8582 { | |
8583 v17 = v16 * v27; | |
8584 v18 = v28 * v16; | |
8585 v19 = pTex->pPixels; | |
8586 v20 = pDestb + 2 * v18; | |
8587 v21 = (int)&v19[2 * (pDestb + v17)]; | |
8588 v22 = (int)&v19[2 * v20]; | |
8589 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
8590 LOWORD(v21) = *(unsigned short *)v21; | |
8591 v23 = pDestb++ + v18; | |
1583 | 8592 extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); |
8593 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
0 | 8594 v16 = pTex->uWidth; |
8595 } | |
8596 while (pDestb < pTex->uWidth); | |
8597 } | |
8598 ++v28; | |
8599 v27 += 2; | |
8600 } | |
8601 while ( v28 < (signed int)pTex->uHeight ); | |
8602 } | |
8603 delete [] pTex->pPixels; | |
8604 pTex->pPixels = v26; | |
8605 } | |
8606 return pTex; | |
8607 } | |
8608 | |
8609 //----- (0045271F) -------------------------------------------------------- | |
8610 bool RenderHWLContainer::Release() | |
8611 { | |
8612 __int32 v4; // eax@6 | |
8613 FILE *v5; // ST24_4@6 | |
8614 FILE *File; // [sp+4h] [bp-4h]@6 | |
8615 | |
1162 | 8616 if ( this->bDumpDebug) |
0 | 8617 { |
8618 File = fopen("logd3d.txt", "w"); | |
1162 | 8619 v4 = ftell(this->pFile); |
8620 v5 = this->pFile; | |
8621 this->uDataOffset = v4; | |
8622 fwrite(&this->uNumItems, 4u, 1u, v5); | |
8623 for (int i = 0; i < this->uNumItems; i++) | |
8624 { | |
8625 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
8626 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
8627 } | |
8628 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
8629 fseek(this->pFile, 4, 0); | |
8630 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
8631 fclose(this->pFile); | |
0 | 8632 fclose(File); |
8633 } | |
8634 else | |
8635 { | |
8636 fclose(this->pFile); | |
1162 | 8637 for (int i = 0; i < this->uNumItems; i++) |
8638 { | |
8639 free(this->pSpriteNames[i]); | |
0 | 8640 } |
8641 } | |
1093 | 8642 return true; |
0 | 8643 } |
8644 | |
8645 //----- (00452347) -------------------------------------------------------- | |
8646 RenderHWLContainer::RenderHWLContainer(): | |
8647 bDumpDebug(false) | |
8648 { | |
8649 this->pFile = 0; | |
8650 uSignature = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8651 this->uDataOffset = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8652 memset(&this->uNumItems, 0, 0x61A84u); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8653 this->uNumItems = 0; |
1583 | 8654 this->scale_hwls_to_half = false; |
0 | 8655 } |
8656 | |
8657 //----- (0045237F) -------------------------------------------------------- | |
8658 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
8659 { | |
8660 pFile = _wfopen(pFilename, L"rb"); | |
8661 if (!pFile) | |
8662 { | |
8663 Log::Warning(L"Failed to open file: %s", pFilename); | |
8664 return false; | |
8665 } | |
8666 | |
8667 fread(&uSignature, 1, 4, pFile); | |
8668 if (uSignature != 'TD3D') | |
8669 { | |
8670 Log::Warning(L"Invalid format: %s", pFilename); | |
8671 return false; | |
8672 } | |
8673 | |
8674 fread(&uDataOffset, 4, 1, pFile); | |
8675 fseek(pFile, uDataOffset, SEEK_SET); | |
8676 fread(&uNumItems, 4, 1, pFile); | |
8677 | |
8678 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
8679 for (uint i = 0; i < uNumItems; ++i) | |
8680 { | |
8681 pSpriteNames[i] = new char[20]; | |
8682 fread(pSpriteNames[i], 1, 20, pFile); | |
8683 } | |
8684 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
8685 | |
8686 return true; | |
8687 } | |
8688 | |
8689 //----- (004A1C1E) -------------------------------------------------------- | |
8690 void DoRenderBillboards_D3D() | |
8691 { | |
186 | 8692 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
8693 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8694 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8695 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8696 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8697 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8698 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8699 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8700 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8701 { |
1390 | 8702 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; |
8703 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
8704 } | |
8705 p->pQuads[0].pos.x = 10; | |
8706 p->pQuads[0].pos.y = 10; | |
8707 | |
8708 p->pQuads[1].pos.x = 10; | |
8709 p->pQuads[1].pos.y = 200; | |
8710 | |
8711 p->pQuads[2].pos.x = 100; | |
8712 p->pQuads[2].pos.y = 200; | |
8713 | |
8714 p->pQuads[3].pos.x = 100; | |
8715 p->pQuads[3].pos.y = 10; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8716 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8717 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8718 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8719 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8720 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8721 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8722 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8723 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8724 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8725 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8726 }*/ |
0 | 8727 |
8728 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) | |
8729 { | |
101 | 8730 auto p = &pRenderer->pBillboardRenderListD3D[i]; |
0 | 8731 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8732 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
0 | 8733 SetBillboardBlendOptions(p->uOpacity); |
8734 | |
101 | 8735 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8736 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8737 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8738 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8739 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 8740 } |
8741 | |
8742 if (pRenderer->bFogEnabled) | |
8743 { | |
8744 pRenderer->bFogEnabled = false; | |
186 | 8745 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 8746 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
8747 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8748 } | |
186 | 8749 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
8750 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8751 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8752 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8753 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8754 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8755 } |
8756 | |
8757 //----- (004A1DA8) -------------------------------------------------------- | |
8758 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
8759 { | |
8760 switch (a1) | |
8761 { | |
8762 case RenderBillboardD3D::Transparent: | |
8763 { | |
8764 if (pRenderer->bFogEnabled) | |
8765 { | |
8766 pRenderer->bFogEnabled = false; | |
186 | 8767 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 8768 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
8769 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8770 } | |
8771 | |
186 | 8772 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); |
8773 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
8774 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8775 } |
8776 break; | |
8777 | |
8778 case RenderBillboardD3D::Opaque_1: | |
8779 case RenderBillboardD3D::Opaque_2: | |
8780 case RenderBillboardD3D::Opaque_3: | |
8781 { | |
8782 if (pRenderer->bUsingSpecular) | |
8783 { | |
8784 if (!pRenderer->bFogEnabled) | |
8785 { | |
8786 pRenderer->bFogEnabled = true; | |
186 | 8787 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
8788 } | |
8789 } | |
8790 | |
8791 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8792 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8793 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 8794 } |
8795 break; | |
8796 | |
8797 default: | |
8798 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8799 assert(false); |
0 | 8800 break; |
8801 } | |
8802 } | |
1297 | 8803 //----- (0040DF3D) -------------------------------------------------------- |
1458 | 8804 void CallRenderPresent() |
1297 | 8805 { |
8806 pRenderer->Present(); | |
8807 } |