Mercurial > mm7
annotate Render.cpp @ 2301:df24d11208df
stru319::DoesDmgTypeDoDamage moved to Actor class
author | Grumpy7 |
---|---|
date | Sun, 16 Mar 2014 20:28:44 +0100 |
parents | 8193a64c7461 |
children | 25f771e528f0 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2245
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2245
diff
changeset
|
2 |
2153 | 3 #include "Render.h" |
1277 | 4 #include "Outdoor_stuff.h" |
1016 | 5 #include "VideoPlayer.h" |
6 #include "Sprites.h" | |
7 #include "Mouse.h" | |
8 #include "GammaControl.h" | |
9 #include "stru6.h" | |
1183 | 10 #include "GUIWindow.h" |
1016 | 11 #include "DecalBuilder.h" |
12 #include "ParticleEngine.h" | |
0 | 13 #include "Outdoor.h" |
14 #include "Party.h" | |
15 #include "LOD.h" | |
16 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2016
diff
changeset
|
17 #include "OurMath.h" |
0 | 18 #include "PaletteManager.h" |
2044 | 19 #include "Timer.h" |
0 | 20 #include "Game.h" |
21 #include "LightmapBuilder.h" | |
22 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
23 #include "SpriteObject.h" |
0 | 24 #include "DecorationList.h" |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
25 #include "Actor.h" |
0 | 26 #include "Log.h" |
179 | 27 #include "TileFrameTable.h" |
189 | 28 #include "texts.h" |
0 | 29 #include "mm7_data.h" |
860 | 30 #include "MM7.h" |
1262 | 31 #include "Lights.h" |
1828
35c1e4ff6ba7
party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents:
1814
diff
changeset
|
32 #include "Level/Decoration.h" |
2155 | 33 #include "Vis.h" |
0 | 34 |
1924
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
35 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") |
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
36 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") |
0 | 37 |
38 struct IDirectDrawClipper *pDDrawClipper; | |
39 struct Render *pRenderer; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
40 struct RenderVertexD3D3 pVertices[50]; |
0 | 41 int uNumDecorationsDrawnThisFrame; // weak |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
42 RenderBillboard pBillboardRenderList[500]; |
0 | 43 unsigned int uNumBillboardsToDraw; |
44 int uNumSpritesDrawnThisFrame; // weak | |
45 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
46 RenderVertexSoft array_507D30[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
47 RenderVertexSoft array_50AC10[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
48 RenderVertexSoft array_73D150[20]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
49 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
50 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 51 |
52 /* 384 */ | |
53 #pragma pack(push, 1) | |
54 struct PCXHeader_1 | |
55 { | |
56 char manufacturer; | |
57 char version; | |
58 char encoding; | |
59 char bpp; | |
60 __int16 left; | |
61 __int16 up; | |
62 __int16 right; | |
63 __int16 bottom; | |
64 __int16 hdpi; | |
65 __int16 vdpi; | |
66 }; | |
67 #pragma pack(pop) | |
68 | |
69 /* 385 */ | |
70 #pragma pack(push, 1) | |
71 struct PCXHeader_2 | |
72 { | |
73 char reserved; | |
74 char planes; | |
75 __int16 pitch; | |
76 __int16 palette_info; | |
77 }; | |
78 #pragma pack(pop) | |
79 | |
80 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
81 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
82 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
83 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
84 | |
85 //----- (0049E79F) -------------------------------------------------------- | |
2154 | 86 bool Render::CheckTextureStages() |
0 | 87 { |
88 bool v0; // edi@1 | |
89 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
90 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
91 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
92 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
93 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
94 | |
95 v0 = false; | |
2154 | 96 pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); |
97 pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
98 | |
99 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
100 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
101 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2)); | |
102 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
103 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
104 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
105 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1)); | |
106 | |
107 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
108 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
109 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1)); | |
110 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7)); | |
111 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2)); | |
112 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1)); | |
113 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2)); | |
114 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2)); | |
115 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1)); | |
116 | |
117 if ( !pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
0 | 118 v0 = true; |
2154 | 119 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); |
0 | 120 pTexture1->Release(); |
121 pTexture2->Release(); | |
122 pSurface1->Release(); | |
123 pSurface2->Release(); | |
124 return v0; | |
125 } | |
126 | |
2002 | 127 |
0 | 128 //----- (00440CB8) -------------------------------------------------------- |
129 void Render::DrawBillboardList_BLV() | |
130 { | |
131 __int16 v2; // ax@3 | |
132 int v5; // eax@11 | |
133 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
134 | |
2002 | 135 soft_billboard.sParentBillboardID = -1; |
0 | 136 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; |
137 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
138 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
139 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
140 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
141 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
142 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
143 | |
1637 | 144 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw; |
617 | 145 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 146 { |
1980 | 147 RenderBillboard* p = &pBillboardRenderList[i]; |
0 | 148 |
149 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
2002 | 150 soft_billboard.sParentBillboardID = i; |
0 | 151 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
152 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
|
153 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 154 soft_billboard.sZValue = p->sZValue; |
155 soft_billboard.uFlags = p->field_1E; | |
2006 | 156 soft_billboard.sTintColor = p->sTintColor; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
157 v2 = p->HwSpriteID; |
0 | 158 if ( v2 != -1 ) |
159 { | |
160 if ( pRenderer->pRenderD3D ) | |
657 | 161 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 162 else |
163 { | |
657 | 164 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 165 if (p->field_1E & 0x0100) |
166 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
167 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
168 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
169 v5 = p->HwSpriteID; |
0 | 170 if ( v5 >= 0 ) |
733 | 171 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 172 } |
173 } | |
174 } | |
175 } | |
176 | |
177 //----- (004A16A5) -------------------------------------------------------- | |
2154 | 178 bool Render::AreRenderSurfacesOk() |
179 { | |
180 return pFrontBuffer4 && pBackBuffer4; | |
0 | 181 } |
182 | |
2152 | 183 |
184 //----- (004A19D8) -------------------------------------------------------- | |
185 unsigned int BlendColors(unsigned int a1, unsigned int a2) | |
186 { | |
187 /*signed __int64 v2; // ST10_8@1 | |
188 double v3; // st7@1 | |
189 float v4; // ST24_4@1 | |
190 double v5; // ST10_8@1 | |
191 int v6; // ST1C_4@1 | |
192 float v7; // ST24_4@1 | |
193 double v8; // ST10_8@1 | |
194 unsigned __int8 v9; // ST20_1@1 | |
195 float v10; // ST24_4@1 | |
196 double v11; // ST10_8@1 | |
197 float v12; // ST24_4@1 | |
198 double v13; // ST08_8@1*/ | |
199 | |
200 uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f * | |
201 (a2 >> 24) / 255.0f * 255.0f), | |
202 red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f * | |
203 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f), | |
204 green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f * | |
205 ((a2 >> 8) & 0xFF) / 255.0f * 255.0f), | |
206 blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f * | |
207 ((a2 >> 0) & 0xFF) / 255.0f * 255.0f); | |
208 return (alpha << 24) | (red << 16) | (green << 8) | blue; | |
209 /*v2 = a1 >> 24; | |
210 v3 = (double)v2 / 255.0f; | |
211 HIDWORD(v2) = 0; | |
212 LODWORD(v2) = a2 >> 24; | |
213 v4 = v3 * (double)v2 / 255.0f * 255.0; | |
214 v5 = v4 + 6.7553994e15; | |
215 v6 = LODWORD(v5); | |
216 v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0; | |
217 v8 = v7 + 6.7553994e15; | |
218 v9 = LOBYTE(v8); | |
219 v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0; | |
220 v11 = v10 + 6.7553994e15; | |
221 v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0; | |
222 v13 = v12 + 6.7553994e15; | |
223 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ | |
224 } | |
225 | |
226 | |
1338 | 227 void Render::RenderTerrainD3D() // New function |
86 | 228 { |
229 int v6; // ecx@8 | |
1427 | 230 struct Polygon *pTilePolygon; // ebx@8 |
2251 | 231 float a3a; |
186 | 232 |
233 //warning: the game uses CW culling by default, ccw is incosistent | |
234 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
235 | |
1338 | 236 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ |
237 | |
238 //Ãåíåðàöèÿ ìåñòîïîëîæåíèÿ âåðøèí------------------------------------------------------------------------- | |
239 //ðåø¸òêà âåðøèí äåëèòñÿ íà äâå ÷àñòè îò -64 äî 0 è îò 0 äî 64 | |
240 // | |
241 // -64 X 0 64 | |
242 // --------------- 64 | |
243 // | | | | |
244 // | | | | |
245 // | | | | |
246 // 0|------+------| Z | |
247 // | | | | |
248 // | | | | |
249 // | | | | |
250 // --------------- | |
251 // -64 | |
252 | |
253 int blockScale = 512; | |
254 int heightScale = 32; | |
255 for (unsigned int z = 0; z < 128; ++z) | |
256 { | |
257 for (unsigned int x = 0; x < 128; ++x) | |
258 { | |
259 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
260 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
261 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 262 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
263 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 264 } |
265 } | |
1338 | 266 //-------------------------------------------------------------------------------------------------------------------- |
267 | |
268 // | |
1344 | 269 for (unsigned int z = 0; z < 127; ++z) |
270 { | |
271 for (unsigned int x = 0; x < 127; ++x) | |
1338 | 272 { |
1637 | 273 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; |
1427 | 274 pTilePolygon->flags = 0; |
275 pTilePolygon->field_32 = 0; | |
276 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
277 pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; | |
278 if (pTilePolygon->uTileBitmapID == 0xFFFF) | |
106 | 279 continue; |
186 | 280 |
1338 | 281 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1427 | 282 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); |
283 pTilePolygon->field_32 = 0; | |
284 pTilePolygon->field_59 = 1; | |
285 pTilePolygon->sTextureDeltaU = 0; | |
286 pTilePolygon->sTextureDeltaV = 0; | |
1338 | 287 // x,z x+1,z |
288 // .____________. | |
289 // | | | |
290 // | | | |
291 // | | | |
292 // | | | |
293 // | | | |
294 // .____________. | |
295 // x,z+1 x+1,z+1 | |
296 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
106 | 297 array_73D150[0].u = 0; |
298 array_73D150[0].v = 0; | |
1338 | 299 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z |
106 | 300 array_73D150[1].u = 1; |
301 array_73D150[1].v = 0; | |
1338 | 302 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 |
106 | 303 array_73D150[2].u = 1; |
304 array_73D150[2].v = 1; | |
1338 | 305 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 |
106 | 306 array_73D150[3].u = 0; |
307 array_73D150[3].v = 1; | |
1338 | 308 //v58 = 0; |
309 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
310 //pTile->field_32 |= 0x0001; | |
1427 | 311 pTilePolygon->pODMFace = nullptr; |
312 pTilePolygon->uNumVertices = 4; | |
313 pTilePolygon->field_59 = 5; | |
1338 | 314 |
315 //shading (çàòåíåíèå)---------------------------------------------------------------------------- | |
316 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
1424 | 317 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; |
638 | 318 assert(norm_idx < uNumTerrainNormals); |
319 | |
1980 | 320 Vec3_float_* norm = &pTerrainNormals[norm_idx]; |
1338 | 321 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
322 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
323 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
1427 | 324 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); |
2274 | 325 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 ) |
326 norm = 0; | |
327 else | |
328 norm = &pTerrainNormals[norm_idx]; | |
329 //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &a3a, array_50AC10, 4, 1);//Ritor1: slows | |
2251 | 330 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &a3a, array_50AC10, 4, 1); |
1338 | 331 //----------------------------------------------------------------------------------------------- |
638 | 332 |
1637 | 333 ++pODMRenderParams->uNumPolygons; |
334 ++pODMRenderParams->field_44; | |
335 assert(pODMRenderParams->uNumPolygons < 20000); | |
265 | 336 |
1427 | 337 pTilePolygon->uBModelID = 0; |
338 pTilePolygon->uBModelFaceID = 0; | |
339 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
340 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
106 | 341 { |
342 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 343 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 344 } |
140 | 345 |
1338 | 346 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))---------------------- |
186 | 347 bool transparent = false; |
1427 | 348 if ( !( pTilePolygon->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable |
349 { | |
350 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id) | |
1338 | 351 { |
352 //transparent = false; | |
353 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
354 } | |
355 else | |
356 { | |
1427 | 357 v6 = pTilePolygon->uTileBitmapID; |
358 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) ) | |
1338 | 359 transparent = true; |
360 } | |
179 | 361 |
140 | 362 assert(v6 < 1000); // many random crashes here |
186 | 363 |
364 // for all shore tiles - draw a tile water under them since they're half-empty | |
1427 | 365 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX |
2153 | 366 DrawBorderTiles(pTilePolygon); |
1427 | 367 |
368 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1338 | 369 } |
370 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû | |
371 //pTile->DrawBorderTiles(); | |
372 //-------------------------------------------------------------------------------------------------------------------------------- | |
186 | 373 |
1637 | 374 --pODMRenderParams->uNumPolygons; |
375 --pODMRenderParams->field_44; | |
106 | 376 } |
377 } | |
378 } | |
0 | 379 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
380 |
2153 | 381 //----- (004811A3) -------------------------------------------------------- |
382 void Render::DrawBorderTiles(struct Polygon *poly) | |
383 { | |
384 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); | |
385 DrawTerrainPolygon(poly->uNumVertices, poly, | |
386 pBitmaps_LOD->pHardwareTextures[pHDWaterBitmapIDs[hd_water_current_frame]], false, true); | |
387 | |
388 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); | |
389 //DrawTerrainPolygon(poly->uNumVertices, poly, pBitmaps_LOD->pHardwareTextures[poly->uTileBitmapID], true, true); | |
390 } | |
391 | |
0 | 392 |
393 //----- (0047BACF) -------------------------------------------------------- | |
394 void Render::TransformBillboardsAndSetPalettesODM() | |
395 { | |
142 | 396 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
397 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
398 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
399 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
400 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
401 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
402 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
403 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
404 //int v8; // ebx@4 |
0 | 405 unsigned __int16 *v9; // eax@7 |
406 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
407 //DWORD v11; // eax@13 |
0 | 408 int v12; // eax@13 |
409 int v13; // eax@14 | |
410 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
411 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 412 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
413 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 414 int v18; // [sp+60h] [bp-4h]@13 |
415 | |
2002 | 416 billboard.sParentBillboardID = -1; |
0 | 417 billboard.pTarget = pRenderer->pTargetSurface; |
418 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
419 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 420 billboard.uViewportX = pViewport->uViewportTL_X; |
421 billboard.uViewportY = pViewport->uViewportTL_Y; | |
422 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
423 billboard.uViewportW = pViewport->uViewportBR_Y; | |
1637 | 424 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw; |
142 | 425 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
426 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 427 { |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
428 billboard.uScreenSpaceX = pBillboardRenderList[i].uScreenSpaceX; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
429 billboard.uScreenSpaceY = pBillboardRenderList[i].uScreenSpaceY; |
2002 | 430 billboard.sParentBillboardID = i; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
431 billboard._screenspace_x_scaler_packedfloat = pBillboardRenderList[i]._screenspace_x_scaler_packedfloat; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
432 billboard.sTintColor = pBillboardRenderList[i].sTintColor; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
433 billboard._screenspace_y_scaler_packedfloat = pBillboardRenderList[i]._screenspace_y_scaler_packedfloat; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
434 billboard.sZValue = pBillboardRenderList[i].sZValue; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
435 billboard.uFlags = pBillboardRenderList[i].field_1E; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
436 if (pBillboardRenderList[i].HwSpriteID != -1) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
437 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
438 if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
439 //if (pRenderer->pRenderD3D) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
440 pRenderer->TransformBillboard(&billboard, |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
441 &pSprites_LOD->pHardwareSprites[pBillboardRenderList[i].HwSpriteID], |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
442 pBillboardRenderList[i].dimming_level, &pBillboardRenderList[i]); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
443 /*else |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
444 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
445 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
446 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
447 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 448 if ( *(v1 - 10) & 2 ) |
449 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
450 else | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
451 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 452 v10 = (*(v1 - 9) & 1) == 0; |
453 billboard.pPalette = v9; | |
454 if ( !v10 ) | |
455 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
456 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
457 { | |
323 | 458 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 459 v15 = abs(v12); |
460 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
461 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
462 } | |
463 v13 = *((short *)v1 - 8); | |
464 if ( v13 >= 0 ) | |
733 | 465 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
466 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
467 } |
0 | 468 } |
469 } | |
470 | |
471 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
472 void Render::DrawSpriteObjects_ODM() |
0 | 473 { |
2206 | 474 SpriteFrame *frame; // eax@10 |
0 | 475 unsigned int v6; // eax@10 |
476 int v9; // ecx@10 | |
477 int v17; // ecx@25 | |
478 int v18; // eax@25 | |
479 int v22; // ST3C_4@29 | |
480 signed __int64 v23; // qtt@30 | |
481 int v26; // eax@31 | |
482 char v27; // zf@31 | |
483 int v30; // [sp+14h] [bp-2Ch]@23 | |
484 int v37; // [sp+1Ch] [bp-24h]@23 | |
485 int a6; // [sp+20h] [bp-20h]@10 | |
486 int v42; // [sp+2Ch] [bp-14h]@23 | |
487 int y; // [sp+30h] [bp-10h]@10 | |
488 int x; // [sp+34h] [bp-Ch]@10 | |
489 int z; // [sp+38h] [bp-8h]@10 | |
490 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
491 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
492 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
493 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
|
494 { |
1980 | 495 SpriteObject* object = &pSpriteObjects[i]; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
496 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
497 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
498 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
499 //{ |
430 | 500 if (!object->uObjectDescID) // item probably pciked up |
501 continue; | |
502 | |
503 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
1980 | 504 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID]; |
430 | 505 if (object_desc->NoSprite()) |
506 continue; | |
507 | |
508 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
509 //if ( !(v1->uFlags & 1) ) | |
510 //{ | |
511 //v2 = *((short *)v0 - 14) | |
2206 | 512 //v2 = object->uType; |
513 if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600) | |
514 || pGame->pStru6Instance->_4A81CA(object) ) | |
430 | 515 { |
516 //a5 = *(short *)v0; | |
517 x = object->vPosition.x; | |
518 y = object->vPosition.y; | |
519 z = object->vPosition.z; | |
2206 | 520 frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); |
521 a6 = frame->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
|
522 v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
430 | 523 //LOWORD(v7) = object->uFacing; |
524 //v8 = v36; | |
2206 | 525 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
526 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[v9]; |
2206 | 527 if ( frame->uFlags & 0x20 ) |
528 { | |
529 //v8 = v36; | |
530 z -= fixpoint_mul(frame->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)frame->pHwSpriteIDs[v9]].uHeight) / 2; | |
531 } | |
532 v46 = 0; | |
533 if ( frame->uFlags & 2 ) | |
534 v46 = 2; | |
535 //v11 = (int *)(256 << v9); | |
536 if ( (256 << v9) & frame->uFlags ) | |
537 v46 |= 4u; | |
538 if ( frame->uFlags & 0x40000 ) | |
539 v46 |= 0x40u; | |
540 if ( frame->uFlags & 0x20000 ) | |
541 LOBYTE(v46) = v46 | 0x80; | |
542 if ( a6 ) | |
543 { | |
544 //LOBYTE(v11) = _4E94D3_light_type; | |
545 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type); | |
546 } | |
547 if (pGame->pIndoorCameraD3D->sRotationX) | |
548 { | |
549 v30 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
550 + fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
551 v37 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
552 v42 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x) | |
553 + fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_cosine_x); | |
554 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
555 { | |
556 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - v37; | |
557 v18 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) | |
558 - fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_sine_x); | |
559 if ( abs(v42) >= abs(v17) ) | |
560 { | |
561 LODWORD(v23) = 0; | |
562 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
563 | |
564 object->uAttributes |= 1; | |
565 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
566 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
567 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
568 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
569 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
570 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
571 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
572 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
573 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
574 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
575 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
576 HIWORD(v26) = HIWORD(v42); | |
577 LOWORD(v26) = 0; | |
578 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
579 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
580 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
581 if ( !(object->uAttributes & 0x20) ) | |
0 | 582 { |
2206 | 583 if ( !pRenderer->pRenderD3D ) |
584 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
0 | 585 } |
2206 | 586 //if (::uNumBillboardsToDraw >= 500) |
587 // return; | |
588 assert(::uNumBillboardsToDraw < 500); | |
589 ++::uNumBillboardsToDraw; | |
590 ++uNumSpritesDrawnThisFrame; | |
0 | 591 } |
2206 | 592 } |
593 } | |
594 else | |
595 { | |
596 v42 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y) | |
597 + fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y); | |
598 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
599 { | |
600 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
601 - fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y); | |
602 v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; | |
603 if ( abs(v42) >= abs(v17) ) | |
604 { | |
605 LODWORD(v23) = 0; | |
606 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
607 | |
608 object->uAttributes |= 1; | |
609 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
610 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
611 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
612 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
613 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
614 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
615 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
616 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
617 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
618 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
619 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
620 HIWORD(v26) = HIWORD(v42); | |
621 LOWORD(v26) = 0; | |
622 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
623 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
624 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
625 if ( !(object->uAttributes & 0x20) ) | |
626 { | |
627 if ( !pRenderer->pRenderD3D ) | |
628 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
629 } | |
630 //if (::uNumBillboardsToDraw >= 500) | |
631 // return; | |
632 assert(::uNumBillboardsToDraw < 500); | |
633 ++::uNumBillboardsToDraw; | |
634 ++uNumSpritesDrawnThisFrame; | |
635 } | |
636 } | |
637 } | |
638 } | |
0 | 639 } |
640 } | |
641 | |
642 //----- (0049D9BC) -------------------------------------------------------- | |
643 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
644 { | |
645 size_t v4; // eax@1 | |
646 size_t v5; // eax@1 | |
647 IUnknown *v6; // eax@10 | |
648 size_t v7; // eax@13 | |
649 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
650 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
651 int v11; // [sp+430h] [bp-CCh]@16 | |
652 int v12; // [sp+434h] [bp-C8h]@16 | |
653 int v13; // [sp+438h] [bp-C4h]@16 | |
654 int v14; // [sp+474h] [bp-88h]@16*/ | |
655 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
656 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
657 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
658 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
659 int v19; // [sp+4C8h] [bp-34h]@16 | |
660 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
661 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
662 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
663 | |
664 v4 = strlen(lpDriverName); | |
665 v20.pDriverName = new char[v4 + 1]; | |
666 v5 = strlen(lpDevDesc); | |
667 v20.pDeviceDesc = new char[v5 + 1]; | |
668 strcpy(v20.pDriverName, lpDriverName); | |
669 strcpy(v20.pDeviceDesc, lpDevDesc); | |
670 if ( lpGUID ) | |
671 { | |
672 v20.pGUID = new GUID; | |
673 memcpy(v20.pGUID, lpGUID, 0x10u); | |
674 } | |
675 else | |
676 v20.pGUID = 0; | |
677 | |
678 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
679 { | |
680 delete [] v20.pDriverName; | |
681 delete [] v20.pDeviceDesc; | |
682 if ( v20.pGUID ) | |
683 delete v20.pGUID; | |
684 } | |
685 else | |
686 { | |
687 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
688 { | |
689 delete [] v20.pDriverName; | |
690 delete [] v20.pDeviceDesc; | |
691 if ( v20.pGUID ) | |
692 delete v20.pGUID; | |
693 v6 = (IUnknown *)pDirectDraw; | |
694 } | |
695 else | |
696 { | |
697 pDirectDraw->Release(); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
698 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1))) |
0 | 699 v20.pDDraw4DevDesc = 0; |
700 else | |
701 { | |
702 v7 = strlen(ddDevId.szDescription); | |
703 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
704 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
705 } | |
706 memset(&ddsCaps, 0, 0x10u); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
707 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem))) |
0 | 708 v20.uVideoMem = 0; |
709 memset(&v10, 0, 0x7Cu); | |
710 v10.dwSize = 124; | |
711 v10.dwFlags = 6; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
712 v10.dwHeight = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
713 v10.dwWidth = window->GetHeight(); |
0 | 714 v10.ddpfPixelFormat.dwSize = 32; |
715 | |
716 v19 = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
717 if ( FAILED(pDirectDraw4->EnumDisplayModes(0, 0, &v19, (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) |
0 | 718 || !v19 |
719 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
720 { | |
721 delete [] v20.pDriverName; | |
722 delete [] v20.pDeviceDesc; | |
723 if ( v20.pDDraw4DevDesc ) | |
724 free(v20.pDDraw4DevDesc); | |
725 if ( v20.pGUID ) | |
726 delete v20.pGUID; | |
727 v6 = (IUnknown *)pDirectDraw4; | |
728 } | |
729 else | |
730 { | |
731 aux.pInfo = pOut; | |
732 aux.ptr_4 = &v20; | |
733 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
734 delete [] v20.pDriverName; | |
735 delete [] v20.pDeviceDesc; | |
736 if ( v20.pDDraw4DevDesc ) | |
737 free(v20.pDDraw4DevDesc); | |
738 if ( v20.pGUID ) | |
739 delete v20.pGUID; | |
740 pDirectDraw4->Release(); | |
741 v6 = (IUnknown *)pDirect3D3; | |
742 pDirectDraw4 = 0; | |
743 } | |
744 } | |
745 v6->Release(); | |
746 } | |
747 return 1; | |
748 } | |
749 | |
750 //----- (0049D784) -------------------------------------------------------- | |
751 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
752 { | |
753 int v6; // eax@1 | |
754 signed int v7; // edi@1 | |
755 signed int v8; // edi@14 | |
756 size_t v9; // eax@30 | |
757 size_t v10; // eax@30 | |
758 size_t v11; // eax@30 | |
759 size_t v12; // eax@30 | |
760 size_t v13; // eax@30 | |
761 | |
762 v6 = pHWDesc->dwFlags; | |
763 v7 = -1; | |
764 if ( v6 ) | |
765 { | |
766 if ( !a6->ptr_4->pGUID ) | |
767 v7 = 0; | |
768 if ( v6 && a6->ptr_4->pGUID ) | |
769 v7 = 1; | |
770 } | |
771 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
772 v7 = 2; | |
773 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
774 v7 = 3; | |
775 if ( v7 != -1 ) | |
776 { | |
777 v8 = v7; | |
778 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
779 a6->pInfo[v8].uCaps = 0; | |
780 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
781 a6->pInfo[v8].uCaps |= 2u; | |
782 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
783 a6->pInfo[v8].uCaps |= 4u; | |
784 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
785 a6->pInfo[v8].uCaps |= 8u; | |
786 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
787 a6->pInfo[v8].uCaps |= 0x10u; | |
788 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
789 a6->pInfo[v8].uCaps |= 0x20u; | |
790 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
791 a6->pInfo[v8].uCaps |= 0x40u; | |
792 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
793 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
794 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
795 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
796 v9 = strlen(lpDeviceName); | |
797 a6->pInfo[v8].pName = new char[v9 + 1]; | |
798 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
799 v10 = strlen(lpDeviceDesc); | |
800 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
801 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
1631 | 802 a6->pInfo[v8].pGUID = new GUID; |
0 | 803 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); |
804 v11 = strlen(a6->ptr_4->pDriverName); | |
805 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
806 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
807 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
808 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
809 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
810 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
811 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
812 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
813 if ( a6->ptr_4->pGUID ) | |
814 { | |
815 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
816 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
817 } | |
818 else | |
819 { | |
820 a6->pInfo[v8].pDirectDrawGUID = 0; | |
821 } | |
822 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
823 } | |
824 return 1; | |
825 } | |
826 | |
827 //----- (0049D75C) -------------------------------------------------------- | |
828 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
829 { | |
830 HRESULT result; // eax@3 | |
831 | |
832 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
833 { | |
834 *a2 = 1; | |
835 result = 0; | |
836 } | |
837 else | |
838 result = 1; | |
839 return result; | |
840 } | |
841 | |
842 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
843 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
844 { |
0 | 845 unsigned int v6; // edi@9 |
846 int v7; // eax@9 | |
847 SpriteFrame *v8; // eax@9 | |
848 unsigned __int16 *v10; // eax@9 | |
849 int v13; // ecx@9 | |
850 int v14; // ecx@20 | |
851 char v15; // dl@20 | |
852 signed int v16; // eax@20 | |
853 int v17; // eax@23 | |
854 int v18; // ecx@24 | |
855 int v19; // eax@24 | |
856 int v20; // ecx@24 | |
857 int v21; // ebx@26 | |
858 int v22; // eax@26 | |
859 signed __int64 v24; // qtt@31 | |
860 int v25; // ebx@31 | |
861 __int16 v29; // cx@37 | |
862 int v30; // ecx@37 | |
863 int v31; // ebx@37 | |
619 | 864 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
0 | 865 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
866 int v38; // [sp+88h] [bp-1Ch]@9 | |
867 int v40; // [sp+90h] [bp-14h]@24 | |
868 int v41; // [sp+94h] [bp-10h]@24 | |
869 int v42; // [sp+98h] [bp-Ch]@9 | |
870 int b; // [sp+A0h] [bp-4h]@22 | |
871 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
872 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
873 { |
2274 | 874 //LevelDecoration* decor = &pLevelDecorations[i]; |
875 if ((!(pLevelDecorations[i].uFlags & LEVEL_DECORATION_OBELISK_CHEST) | |
876 || pLevelDecorations[i].IsObeliskChestActive()) && !(pLevelDecorations[i].uFlags & LEVEL_DECORATION_INVISIBLE)) | |
877 { | |
878 DecorationDesc* decor_desc = &pDecorationList->pDecorations[pLevelDecorations[i].uDecorationDescID]; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
879 if ( (char)decor_desc->uFlags >= 0 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
880 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
881 if ( !(decor_desc->uFlags & 0x22) ) |
0 | 882 { |
1490 | 883 v6 = pMiscTimer->uTotalGameTimeElapsed; |
2274 | 884 v7 = abs(pLevelDecorations[i].vPosition.x + pLevelDecorations[i].vPosition.y); |
1490 | 885 |
886 #pragma region "New: seasons change" | |
887 extern bool change_seasons; | |
888 if (change_seasons) | |
889 switch (pParty->uCurrentMonth) | |
890 { | |
891 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
892 case 11: case 0: case 1: // winter | |
893 switch (decor_desc->uSpriteID) | |
894 { | |
895 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
896 case 548: // flower10 | |
897 case 547: // flower09 | |
898 case 541: // flower03 | |
899 case 539: continue; // flower01 | |
900 | |
901 case 483: // tree01 | |
902 case 486: // tree04 | |
903 case 492: // tree10 | |
904 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); | |
905 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
906 break; | |
907 | |
908 default: | |
909 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
910 } | |
911 break; | |
912 | |
913 case 2: case 3: case 4: // spring | |
914 switch (decor_desc->uSpriteID) | |
915 { | |
916 } | |
917 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
918 break; | |
919 | |
920 case 8: case 9: case 10: // autumn | |
921 switch (decor_desc->uSpriteID) | |
922 { | |
923 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
924 case 548: // flower10 | |
925 case 547: // flower09 | |
926 case 541: // flower03 | |
927 case 539: continue; // flower01 | |
928 | |
929 case 483: // tree01 | |
930 case 486: // tree04 | |
931 case 492: // tree10 | |
932 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); | |
933 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
934 break; | |
935 | |
936 default: | |
937 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
938 } | |
939 break; | |
940 | |
941 case 5: case 6: case 7: // summer | |
942 //all green by default | |
943 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
944 break; | |
945 | |
946 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
947 } | |
948 else | |
949 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
950 #pragma endregion | |
951 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
952 | |
2274 | 953 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, |
954 pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); | |
1490 | 955 v38 = 0; |
2274 | 956 v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + pLevelDecorations[i].field_10_y_rot - (signed int)v10) >> 8) & 7; |
1490 | 957 v37 = (unsigned __int16 *)v13; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
958 if ( v8->uFlags & 2 ) |
1490 | 959 v38 = 2; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
960 if ( (256 << v13) & v8->uFlags ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
961 v38 |= 4; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
962 if ( v8->uFlags & 0x40000 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
963 v38 |= 0x40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
964 if ( v8->uFlags & 0x20000 ) |
1490 | 965 LOBYTE(v38) = v38 | 0x80; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
966 if ( v8->uGlowRadius ) |
0 | 967 { |
1490 | 968 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) |
0 | 969 { |
1490 | 970 v14 = decor_desc->uColoredLightRed; |
971 v15 = decor_desc->uColoredLightGreen; | |
972 v16 = decor_desc->uColoredLightBlue; | |
0 | 973 } |
974 else | |
975 { | |
1490 | 976 v16 = 255; |
977 v14 = 255; | |
978 v15 = 255; | |
979 } | |
2274 | 980 pStationaryLightsStack->AddLight(pLevelDecorations[i].vPosition.x, pLevelDecorations[i].vPosition.y, pLevelDecorations[i].vPosition.z + decor_desc->uDecorationHeight / 2, |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
981 v8->uGlowRadius, v14, v15, v16, _4E94D0_light_type); |
1490 | 982 } |
2274 | 983 v17 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
984 if (pGame->pIndoorCameraD3D->sRotationX) |
1490 | 985 { |
2274 | 986 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
2207 | 987 v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 988 v41 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 989 v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x); |
2274 | 990 v20 = v19 + fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 991 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 992 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
993 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 994 v22 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_sine_x); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
995 if ( 2 * abs(v20) >= abs(v21) ) |
0 | 996 { |
1490 | 997 LODWORD(v24) = 0; |
1637 | 998 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
999 v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1000 v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v22) + 0x8000) >> 16); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1001 v41 = fixpoint_mul(v8->scale, v24 / v20); |
1490 | 1002 if ( pRenderer->pRenderD3D ) |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1003 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41); |
1490 | 1004 else |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1005 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41); |
1490 | 1006 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
1007 { | |
1008 if (::uNumBillboardsToDraw >= 500) | |
1009 return; | |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1010 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1011 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1012 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
1490 | 1013 v29 = v38; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1014 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1015 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1016 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1017 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
2274 | 1018 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; |
1019 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1020 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1021 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1022 HIWORD(v30) = HIWORD(v20); |
1490 | 1023 v31 = PID(OBJECT_Decoration,i); |
1024 LOWORD(v30) = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1025 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1026 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1027 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1028 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1029 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1030 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1031 ++uNumDecorationsDrawnThisFrame; |
1490 | 1032 } |
0 | 1033 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1034 continue; |
1490 | 1035 } |
1036 } | |
1037 else | |
1038 { | |
2274 | 1039 v42 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
1040 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1041 v20 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2207 | 1042 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1043 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1044 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1045 v22 = (pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1046 v42 = v22; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1047 if ( 2 * abs(v20) >= abs(v21) ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1048 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1049 LODWORD(v24) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1050 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1051 v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1052 v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v42) + 0x8000) >> 16); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1053 v41 = fixpoint_mul(v8->scale, v24 / v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1054 if ( pRenderer->pRenderD3D ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1055 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1056 else |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1057 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1058 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1059 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1060 if (::uNumBillboardsToDraw >= 500) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1061 return; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1062 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1063 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1064 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1065 v29 = v38; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1066 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1067 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1068 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1069 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
2274 | 1070 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; |
1071 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1072 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1073 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1074 HIWORD(v30) = HIWORD(v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1075 v31 = PID(OBJECT_Decoration,i); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1076 LOWORD(v30) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1077 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1078 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1079 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1080 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1081 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1082 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1083 ++uNumDecorationsDrawnThisFrame; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1084 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1085 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1086 continue; |
0 | 1087 } |
1088 } | |
1089 } | |
1490 | 1090 } |
1091 else | |
1092 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1093 memset(&local_0, 0, 0x68); |
1490 | 1094 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
1095 local_0.uDiffuse = 0xFF3C1E; | |
2274 | 1096 local_0.x = (double)pLevelDecorations[i].vPosition.x; |
1097 local_0.y = (double)pLevelDecorations[i].vPosition.y; | |
1098 local_0.z = (double)pLevelDecorations[i].vPosition.z; | |
1490 | 1099 local_0.r = 0.0; |
1100 local_0.g = 0.0; | |
1101 local_0.b = 0.0; | |
1102 local_0.flt_28 = 1.0; | |
1103 local_0.timeToLive = (rand() & 0x80) + 128; | |
1104 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
1105 pGame->pParticleEngine->AddParticle(&local_0); | |
1106 } | |
1107 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1108 } |
0 | 1109 } |
1110 | |
1111 //----- (0049D717) -------------------------------------------------------- | |
1112 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1113 { | |
2069 | 1114 if ( Src->dwFlags & (0x400 | 0x2000)) |
0 | 1115 { |
1116 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1117 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1118 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1119 return 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1120 } |
0 | 1121 if ( !Dst->dwSize ) |
1122 { | |
2078 | 1123 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1124 return 1; |
0 | 1125 } |
1126 } | |
1127 return 1; | |
1128 } | |
1129 | |
1130 //----- (0049DC28) -------------------------------------------------------- | |
1131 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1132 { | |
1133 RenderD3D__DevInfo *v2; // eax@1 | |
1134 | |
1135 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1136 *pOutDevices = v2; | |
1137 memset(v2, 0, 0xA0u); | |
1985 | 1138 DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)RenderD3D__DeviceEnumerator, *pOutDevices, DDENUM_ATTACHEDSECONDARYDEVICES); |
0 | 1139 } |
1140 | |
1141 //----- (0049DC58) -------------------------------------------------------- | |
1142 RenderD3D::RenderD3D() | |
1143 { | |
1144 this->pHost = 0; | |
1145 this->pDirect3D = 0; | |
1146 this->pUnk = 0; | |
1147 this->pBackBuffer = 0; | |
1148 this->pFrontBuffer = 0; | |
1149 this->pZBuffer = 0; | |
1150 this->pDevice = 0; | |
1151 this->pViewport = 0; | |
1152 this->field_40 = 1; | |
1153 this->field_44 = 10; | |
1154 GetAvailableDevices(&this->pAvailableDevices); | |
1155 } | |
1156 | |
1157 //----- (0049DC90) -------------------------------------------------------- | |
1158 void RenderD3D::Release() | |
1159 { | |
1160 RenderD3D *v1; // esi@1 | |
1161 IDirectDraw4 *v2; // eax@2 | |
1162 signed int v3; // edi@4 | |
1163 IDirect3DViewport3 *v4; // eax@22 | |
1164 IUnknown *v5; // eax@24 | |
1165 IDirectDrawSurface4 *v6; // eax@26 | |
1166 IDirect3DDevice3 *v7; // eax@28 | |
1167 IDirect3D3 *v8; // eax@30 | |
1168 IDirectDrawSurface4 *v9; // eax@32 | |
1169 IDirectDrawSurface4 *v10; // eax@34 | |
1170 IDirectDraw4 *v11; // eax@36 | |
1171 | |
1172 v1 = this; | |
1173 if ( !this->bWindowed ) | |
1174 { | |
1175 v2 = this->pHost; | |
1176 if ( v2 ) | |
1177 { | |
1178 v2->RestoreDisplayMode(); | |
1179 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
1180 v1->pHost->FlipToGDISurface(); | |
1181 } | |
1182 } | |
1183 v3 = 0; | |
1184 do | |
1185 { | |
1186 if ( v1->pAvailableDevices[v3].pDriverName ) | |
1187 { | |
1188 free(v1->pAvailableDevices[v3].pDriverName); | |
1189 v1->pAvailableDevices[v3].pDriverName = 0; | |
1190 } | |
1191 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
1192 { | |
1193 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
1194 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
1195 } | |
1196 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
1197 { | |
1198 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
1199 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
1200 } | |
1201 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
1202 { | |
1203 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
1204 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
1205 } | |
1206 if ( v1->pAvailableDevices[v3].pName ) | |
1207 { | |
1208 free(v1->pAvailableDevices[v3].pName); | |
1209 v1->pAvailableDevices[v3].pName = 0; | |
1210 } | |
1211 if ( v1->pAvailableDevices[v3].pDescription ) | |
1212 { | |
1213 free(v1->pAvailableDevices[v3].pDescription); | |
1214 v1->pAvailableDevices[v3].pDescription = 0; | |
1215 } | |
1216 if ( v1->pAvailableDevices[v3].pGUID ) | |
1217 { | |
1218 free(v1->pAvailableDevices[v3].pGUID); | |
1219 v1->pAvailableDevices[v3].pGUID = 0; | |
1220 } | |
1221 ++v3; | |
1222 } | |
1223 while ( v3 < 4 ); | |
1224 if ( v1->pAvailableDevices ) | |
1225 { | |
1226 free(v1->pAvailableDevices); | |
1227 v1->pAvailableDevices = 0; | |
1228 } | |
1229 v4 = v1->pViewport; | |
1230 if ( v4 ) | |
1231 { | |
1232 v4->Release(); | |
1233 v1->pViewport = 0; | |
1234 } | |
1235 v5 = v1->pUnk; | |
1236 if ( v5 ) | |
1237 { | |
1238 v5->Release(); | |
1239 v1->pUnk = 0; | |
1240 } | |
1241 v6 = v1->pZBuffer; | |
1242 if ( v6 ) | |
1243 { | |
1244 v6->Release(); | |
1245 v1->pZBuffer = 0; | |
1246 } | |
1247 v7 = v1->pDevice; | |
1248 if ( v7 ) | |
1249 { | |
1250 v7->Release(); | |
1251 v1->pDevice = 0; | |
1252 } | |
1253 v8 = v1->pDirect3D; | |
1254 if ( v8 ) | |
1255 { | |
1256 v8->Release(); | |
1257 v1->pDirect3D = 0; | |
1258 } | |
1259 v9 = v1->pBackBuffer; | |
1260 if ( v9 ) | |
1261 { | |
1262 v9->Release(); | |
1263 v1->pBackBuffer = 0; | |
1264 } | |
1265 v10 = v1->pFrontBuffer; | |
1266 if ( v10 ) | |
1267 { | |
1268 v10->Release(); | |
1269 v1->pFrontBuffer = 0; | |
1270 } | |
1271 v11 = v1->pHost; | |
1272 if ( v11 ) | |
1273 { | |
1274 v11->Release(); | |
1275 v1->pHost = 0; | |
1276 } | |
1277 } | |
1278 | |
1279 //----- (0049DE14) -------------------------------------------------------- | |
2069 | 1280 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window) |
0 | 1281 { |
1282 //IDirectDraw4 *v8; // eax@12 | |
1283 //IDirectDraw4 *v9; // eax@16 | |
1284 //IDirectDraw4 *v10; // eax@20 | |
1285 //IDirectDraw4 *v13; // eax@35 | |
1286 const char *v23; // [sp-4h] [bp-DCh]@9 | |
1287 const char *v24; // [sp-4h] [bp-DCh]@13 | |
1288 const char *v25; // [sp-4h] [bp-DCh]@19 | |
1289 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1290 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1291 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1292 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1293 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
1294 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1295 | |
2069 | 1296 auto hWnd = window->GetApiHandle(); |
1297 int game_width = window->GetWidth(); | |
1298 int game_height = window->GetHeight(); | |
1299 | |
0 | 1300 this->bWindowed = bWindowed; |
1301 this->hWindow = hWnd; | |
1302 | |
1303 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
1304 { | |
1305 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1306 return 0; | |
1307 } | |
1308 | |
1309 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1310 { | |
1311 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1312 if (lpDD) | |
1313 lpDD->Release(); | |
1314 return 0; | |
1315 } | |
1316 lpDD->Release(); | |
1317 lpDD = 0; | |
1318 | |
1319 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1320 { | |
1321 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
1322 { | |
1323 v23 = "Init - Failed to set cooperative level.\n"; | |
1324 sprintf(pErrorMessage, v23); | |
1325 LABEL_65: | |
1326 if (pHost) | |
1327 { | |
1328 pHost->Release(); | |
1329 pHost = 0; | |
1330 } | |
1331 return 0; | |
1332 } | |
1333 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1334 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1335 ddsd2.dwFlags = DDSD_CAPS; | |
1336 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
1337 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1338 { | |
1339 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1340 pHost->GetDisplayMode(&ddsd2); | |
2069 | 1341 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) |
0 | 1342 { |
1343 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
1344 goto LABEL_14; | |
1345 } | |
1346 | |
1347 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
1348 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
2069 | 1349 ddsd2.dwWidth = game_width; |
1350 ddsd2.dwHeight = game_height; | |
0 | 1351 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) |
1352 { | |
1353 v24 = "Init - Failed to create back buffer.\n"; | |
1354 LABEL_14: | |
1355 sprintf(pErrorMessage, v24); | |
1356 if (pFrontBuffer) | |
1357 { | |
1358 pFrontBuffer->Release(); | |
1359 pFrontBuffer = 0; | |
1360 } | |
1361 goto LABEL_65; | |
1362 } | |
1363 if ( pHost->CreateClipper(0, &v30, 0) ) | |
1364 { | |
1365 v25 = "Init - Failed to create clipper.\n"; | |
1366 goto LABEL_45; | |
1367 } | |
1368 v30->SetHWnd(0, hWnd); | |
1369 pFrontBuffer->SetClipper(v30); | |
1370 | |
1371 v30->Release(); | |
1372 v30 = 0; | |
1373 | |
1374 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1375 | |
1376 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1377 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
2069 | 1378 ddsd2.dwWidth = game_width; |
1379 ddsd2.dwHeight = game_height; | |
0 | 1380 |
1381 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1382 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1383 &ddsd2.ddpfPixelFormat) ) | |
1384 goto LABEL_21; | |
1385 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1386 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
1387 | |
1388 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1389 { | |
1390 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
1391 { | |
1392 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1393 pBackBuffer, | |
1394 &pDevice, | |
1395 0) ) | |
1396 { | |
1397 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1398 d3dvp2.dvClipWidth = 2.0; | |
1399 d3dvp2.dvClipY = 1.0; | |
1400 d3dvp2.dvClipHeight = 2.0; | |
1401 d3dvp2.dvMaxZ = 1.0; | |
1402 d3dvp2.dvMinZ = 0.0; | |
1403 goto LABEL_54; | |
1404 } | |
1405 LABEL_51: | |
1406 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1407 if (pDirect3D) | |
1408 { | |
1409 pDirect3D->Release(); | |
1410 pDirect3D = 0; | |
1411 } | |
1412 goto LABEL_59; | |
1413 } | |
1414 LABEL_48: | |
1415 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1416 if (pZBuffer) | |
1417 { | |
1418 pZBuffer->Release(); | |
1419 pZBuffer = 0; | |
1420 } | |
1421 goto LABEL_61; | |
1422 } | |
1423 goto LABEL_44; | |
1424 } | |
1425 LABEL_36: | |
1426 v23 = "Init - Failed to create front buffer.\n"; | |
1427 sprintf(pErrorMessage, v23); | |
1428 goto LABEL_65; | |
1429 } | |
1430 if ( uDeviceID == 1 ) | |
1431 v26 = 1045; | |
1432 else | |
1433 v26 = 1041; | |
1434 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
1435 { | |
1436 v23 = "Init - Failed to set cooperative level.\n"; | |
1437 sprintf(pErrorMessage, v23); | |
1438 goto LABEL_65; | |
1439 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1440 if (pHost->SetDisplayMode(window->GetWidth(), window->GetHeight(), 16, 0, 0) ) |
0 | 1441 { |
1442 v23 = "Init - Failed to set display mode.\n"; | |
1443 sprintf(pErrorMessage, v23); | |
1444 goto LABEL_65; | |
1445 } | |
1446 | |
1447 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1448 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1449 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
1450 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
1451 ddsd2.dwBackBufferCount = 1; | |
1452 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1453 goto LABEL_36; | |
1454 //a3a = &pBackBuffer; | |
1455 //v14 = *v34; | |
1456 memset(&v27, 0, sizeof(DDSCAPS2)); | |
1457 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
1458 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
1459 //hWnda = &pDirect3D; | |
1460 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1461 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
1462 { | |
1463 v25 = "Init - Failed to get D3D interface.\n"; | |
1464 goto LABEL_45; | |
1465 } | |
1466 | |
1467 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1468 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1469 ddsd2.dwWidth = 640; | |
1470 ddsd2.dwHeight = 480; | |
1471 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1472 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1473 &ddsd2.ddpfPixelFormat) ) | |
1474 { | |
1475 LABEL_21: | |
1476 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
1477 goto LABEL_45; | |
1478 } | |
1479 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1480 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
1481 //uDeviceIDa = &pZBuffer; | |
1482 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1483 { | |
1484 LABEL_44: | |
1485 v25 = "Init - Failed to create z-buffer.\n"; | |
1486 LABEL_45: | |
1487 sprintf(pErrorMessage, v25); | |
1488 if (pBackBuffer) | |
1489 { | |
1490 pBackBuffer->Release(); | |
1491 pBackBuffer = 0; | |
1492 } | |
1493 LABEL_63: | |
1494 //v19 = &pFrontBuffer; | |
1495 if (pFrontBuffer) | |
1496 { | |
1497 pFrontBuffer->Release(); | |
1498 pFrontBuffer= 0; | |
1499 } | |
1500 goto LABEL_65; | |
1501 } | |
1502 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
1503 goto LABEL_48; | |
1504 //v33 = &pDevice; | |
1505 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1506 pBackBuffer, | |
1507 &pDevice, | |
1508 0) ) | |
1509 goto LABEL_51; | |
1510 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1511 d3dvp2.dvClipWidth = 2.0; | |
1512 d3dvp2.dvClipY = 1.0; | |
1513 d3dvp2.dvClipHeight = 2.0; | |
1514 d3dvp2.dvMaxZ = 1.0; | |
1515 | |
1516 LABEL_54: | |
1517 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
1518 //v17 = *hWnda; | |
2069 | 1519 d3dvp2.dwWidth = game_width; |
1520 d3dvp2.dwHeight = game_height; | |
0 | 1521 d3dvp2.dvClipX = -1.0; |
1522 //v18 = v17->lpVtbl; | |
1523 //v32 = &v4->pViewport; | |
1524 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
1525 { | |
1526 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
1527 if (pDevice) | |
1528 { | |
1529 pDevice->Release(); | |
1530 pDevice = 0; | |
1531 } | |
1532 if (pDirect3D) | |
1533 { | |
1534 pDirect3D->Release(); | |
1535 pDirect3D = 0; | |
1536 } | |
1537 LABEL_59: | |
1538 if (pZBuffer) | |
1539 { | |
1540 pZBuffer->Release(); | |
1541 pZBuffer = 0; | |
1542 } | |
1543 LABEL_61: | |
1544 if (pBackBuffer) | |
1545 { | |
1546 pBackBuffer->Release(); | |
1547 pBackBuffer = 0; | |
1548 } | |
1549 goto LABEL_63; | |
1550 } | |
1551 | |
1552 pDevice->AddViewport(pViewport); | |
1553 pViewport->SetViewport2(&d3dvp2); | |
1554 pDevice->SetCurrentViewport(pViewport); | |
1555 return 1; | |
1556 } | |
1557 | |
1558 //----- (0049E444) -------------------------------------------------------- | |
1559 unsigned int RenderD3D::GetDeviceCaps() | |
1560 { | |
1561 unsigned int v1; // ebx@1 | |
1562 RenderD3D *v2; // edi@1 | |
1563 IDirect3DDevice3 *v3; // eax@1 | |
1564 unsigned int result; // eax@2 | |
1565 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
1566 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
1567 | |
1568 v1 = 0; | |
1569 v2 = this; | |
1570 memset(&halCaps, 0, 0xFCu); | |
1571 halCaps.dwSize = 252; | |
1572 memset(&refCaps, 0, 0xFCu); | |
1573 v3 = v2->pDevice; | |
1574 refCaps.dwSize = 252; | |
1575 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
1576 { | |
1577 result = 1; | |
1578 } | |
1579 else | |
1580 { | |
2154 | 1581 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) ) |
0 | 1582 v1 = 2; |
2154 | 1583 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1584 v1 |= 4u; |
2154 | 1585 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) ) |
0 | 1586 v1 |= 8u; |
2154 | 1587 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) ) |
0 | 1588 v1 |= 0x10u; |
2154 | 1589 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1590 v1 |= 0x20u; |
2154 | 1591 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) ) |
0 | 1592 v1 |= 0x40u; |
2154 | 1593 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ) |
1594 v1 |= 0x80; | |
0 | 1595 result = v1; |
1596 } | |
1597 return result; | |
1598 } | |
1599 | |
1600 //----- (0049E4FC) -------------------------------------------------------- | |
1601 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
1602 { | |
1603 uint uClearFlags = 0; | |
1604 | |
1605 if (bClearColor) | |
1606 uClearFlags |= D3DCLEAR_TARGET; | |
1607 if (bClearDepth) | |
1608 uClearFlags |= D3DCLEAR_ZBUFFER; | |
1609 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1610 D3DRECT rects[] = {{0, 0, window->GetWidth(), window->GetHeight()}}; |
0 | 1611 if (uClearFlags) |
1612 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
1613 } | |
1614 | |
1615 //----- (0049E54D) -------------------------------------------------------- | |
1616 void RenderD3D::Present(bool bForceBlit) | |
1617 { | |
1618 RECT v5; // [sp+18h] [bp-18h]@1 | |
1619 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
1620 | |
1621 v5.left = 0; | |
1622 v5.top = 0; | |
2217 | 1623 v5.bottom = 480;//window->GetHeight(); //Ritor1: ïðîáëåìà ñ êíîïêîé "ðàçâåðíóòü" |
1624 v5.right = 640; //window->GetWidth(); | |
0 | 1625 |
1626 if (bWindowed || bForceBlit) | |
1627 { | |
1628 RECT rc; | |
1629 GetClientRect(hWindow, &rc); | |
1630 Point.y = 0; | |
1631 Point.x = 0; | |
1632 ClientToScreen(hWindow, &Point); | |
1633 OffsetRect(&rc, Point.x, Point.y); | |
1634 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
1635 } | |
1636 else | |
1637 pFrontBuffer->Flip(0, 1); | |
1638 } | |
1639 | |
1640 //----- (0049E5D4) -------------------------------------------------------- | |
1641 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
1642 { | |
1643 unsigned int v8; // edx@4 | |
1644 unsigned int v9; // ebx@5 | |
1645 unsigned int v10; // eax@5 | |
1646 DWORD v11; // edx@5 | |
1647 //int v12; // edx@7 | |
1648 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
1649 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
1650 | |
1651 //v15 = this; | |
1652 memset(&ddsd2, 0, 0x7Cu); | |
1653 ddsd2.dwSize = 0x7Cu; | |
1654 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1655 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
1656 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
1657 ddsd2.dwHeight = uTextureHeight; | |
1658 ddsd2.dwWidth = uTextureWidth; | |
1659 if ( bMipmaps ) | |
1660 { | |
1661 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
1662 { | |
1663 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
1664 LABEL_8: | |
1665 ddsd2.dwMipMapCount = v8; | |
1666 if ( !v8 ) | |
1667 goto LABEL_12; | |
1668 goto LABEL_11; | |
1669 } | |
1670 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
1671 { | |
1672 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
1673 goto LABEL_8; | |
1674 } | |
1675 v9 = GetMaxMipLevels(uTextureWidth); | |
1676 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
1677 ddsd2.dwMipMapCount = v9 - v10; | |
1678 if ( v9 == v10 ) | |
1679 { | |
1680 ddsd2.dwFlags = 0x1007u; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
1681 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used |
0 | 1682 ddsd2.ddsCaps.dwCaps = v11; |
1683 goto LABEL_12; | |
1684 } | |
1685 } | |
1686 else | |
1687 { | |
1688 ddsd2.dwMipMapCount = 1; | |
1689 } | |
1690 LABEL_11: | |
1691 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1692 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1693 LABEL_12: | |
1694 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
1695 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
1696 if (bAlphaChannel) | |
1697 { | |
1698 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
1699 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
1700 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
1701 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1702 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
1703 } | |
1704 else | |
1705 { | |
1706 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
1707 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
1708 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
1709 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1710 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
1711 } | |
1712 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
1713 return false; | |
1714 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
1715 { | |
1716 (*pOutSurface)->Release(); | |
1717 *pOutSurface = 0; | |
1718 return false; | |
1719 } | |
1720 return true; | |
1721 } | |
1722 | |
1723 //----- (004A5190) -------------------------------------------------------- | |
1724 void RenderD3D::HandleLostResources() | |
1725 { | |
1726 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
1727 pBitmaps_LOD->_410423_move_textures_to_device(); | |
1728 pSprites_LOD->ReleaseLostHardwareSprites(); | |
1729 } | |
1730 | |
1731 //----- (004A2050) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
1732 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) |
0 | 1733 { |
1734 Render *v5; // edi@1 | |
1735 unsigned int v6; // ebx@1 | |
1736 LightmapBuilder *v7; // esi@3 | |
1737 int v8; // eax@7 | |
1738 ODMFace *v9; // eax@12 | |
1739 char *v10; // esi@12 | |
1740 double v11; // st7@14 | |
1741 double v12; // st7@14 | |
1742 int v13; // eax@14 | |
1743 ODMFace *v14; // ecx@14 | |
1744 double v15; // st7@14 | |
1745 float v16; // ST48_4@15 | |
1746 int v17; // eax@15 | |
1747 char v18; // zf@17 | |
1748 HRESULT v19; // eax@18 | |
1749 HRESULT v20; // eax@18 | |
1750 HRESULT v21; // eax@20 | |
1751 HRESULT v22; // eax@20 | |
1752 unsigned int v23; // ecx@20 | |
1753 char *v24; // eax@21 | |
1754 HRESULT v25; // eax@23 | |
1755 HRESULT v26; // eax@23 | |
1756 HRESULT v27; // eax@24 | |
1757 HRESULT v28; // eax@25 | |
1758 HRESULT v29; // eax@25 | |
1759 HRESULT v30; // eax@25 | |
1760 HRESULT v31; // eax@25 | |
1761 HRESULT v32; // eax@26 | |
1762 unsigned int v33; // ecx@26 | |
1763 char *v34; // eax@27 | |
1764 int v35; // edx@28 | |
1765 HRESULT v36; // eax@29 | |
1766 HRESULT v37; // eax@29 | |
1767 HRESULT v38; // eax@29 | |
1768 HRESULT v39; // eax@29 | |
1769 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
1770 unsigned int v41; // eax@29 | |
1771 HRESULT v42; // eax@30 | |
1772 HRESULT v43; // eax@30 | |
1773 HRESULT v44; // eax@30 | |
1774 char *v45; // esi@34 | |
1775 int v46; // ecx@35 | |
1776 double v47; // st6@35 | |
1777 int v48; // eax@36 | |
1778 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
1779 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
1780 int v51; // [sp+50h] [bp-18h]@0 | |
1781 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
1782 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
1783 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
1784 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
1785 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
1786 int v57; // [sp+60h] [bp-8h]@34 | |
2006 | 1787 signed int a2; // [sp+64h] [bp-4h]@4 |
0 | 1788 |
1789 v5 = this; | |
1790 v6 = 0; | |
1791 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
1792 { | |
1793 v7 = pGame->pLightmapBuilder; | |
1794 v53 = v7; | |
1795 v54 = v7->std__vector_000004_size; | |
1796 if ( v7->std__vector_000004_size) | |
2006 | 1797 a2 = -1; |
638 | 1798 pGame->AlterGamma_ODM(a4, &a2); |
2155 | 1799 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 1800 { |
638 | 1801 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 1802 v7->DrawLightmaps(/*v8, 0*/); |
0 | 1803 } |
1804 else | |
1805 { | |
1806 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
1807 { | |
323 | 1808 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1809 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
1810 if (bUsingSpecular) | |
1811 { | |
186 | 1812 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
1813 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1814 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1815 } |
1073 | 1816 for (uint i = 0; i < uNumVertices; ++i) |
1817 { | |
1818 | |
1819 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1820 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1821 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1822 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1823 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1824 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
1825 | |
1826 if ( this->bUsingSpecular ) | |
0 | 1827 { |
2193
4842f58715ea
sub_47C3D7_get_fog_related_stuff to sub_47C3D7_get_fog_specular cleanup, IsTerrainSlopeTooHigh restoring commented out min,min/max,max implementation, some small changes in OnMapLoad, sub_4465DF_check_season attempted to pick the best readabilty/maintainability tradeoff
Grumpy7
parents:
2182
diff
changeset
|
1828 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1829 } |
1073 | 1830 else |
1831 { | |
1832 d3d_vertex_buffer[i].specular = 0; | |
1833 } | |
1834 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1835 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1836 | |
1837 } | |
323 | 1838 |
1839 if (a4->uAttributes & FACE_OUTLINED) | |
1840 { | |
1841 int color; | |
1842 if (GetTickCount() % 300 >= 150) | |
1843 color = 0xFFFF2020; | |
1844 else color = 0xFF901010; | |
1845 | |
1846 for (uint i = 0; i < uNumVertices; ++i) | |
1847 d3d_vertex_buffer[i].diffuse = color; | |
1848 } | |
1849 | |
0 | 1850 pRenderD3D->pDevice->SetTexture(0, pTexture); |
1851 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1852 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1853 d3d_vertex_buffer, |
0 | 1854 uNumVertices, |
1855 D3DDP_DONOTLIGHT); | |
1856 } | |
1857 else | |
1858 { | |
1073 | 1859 for (uint i = 0; i < uNumVertices; ++i) |
1860 { | |
1861 | |
1862 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1863 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1864 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1865 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1866 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1867 if ( this->bUsingSpecular ) | |
0 | 1868 { |
2193
4842f58715ea
sub_47C3D7_get_fog_related_stuff to sub_47C3D7_get_fog_specular cleanup, IsTerrainSlopeTooHigh restoring commented out min,min/max,max implementation, some small changes in OnMapLoad, sub_4465DF_check_season attempted to pick the best readabilty/maintainability tradeoff
Grumpy7
parents:
2182
diff
changeset
|
1869 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1870 } |
1073 | 1871 else |
1872 { | |
1873 d3d_vertex_buffer[i].specular = 0; | |
1874 } | |
1875 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1876 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1877 | |
1878 } | |
1879 | |
186 | 1880 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
1881 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 1882 if (bUsingSpecular) |
186 | 1883 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 1884 |
1885 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
1886 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1887 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1888 d3d_vertex_buffer, |
0 | 1889 uNumVertices, |
1890 D3DDP_DONOTLIGHT)); | |
1891 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
1892 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1893 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
1394 | 1894 v53->DrawLightmaps(/*-1, 0*/); |
1073 | 1895 for (uint i = 0; i < uNumVertices; ++i) |
1896 { | |
1897 d3d_vertex_buffer[i].diffuse = a2; | |
1898 } | |
0 | 1899 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 1900 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1901 if ( !pRenderer->bUsingSpecular ) |
186 | 1902 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
1903 | |
1904 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
1905 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
1906 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 1907 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1908 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1909 d3d_vertex_buffer, |
0 | 1910 uNumVertices, |
1911 D3DDP_DONOTLIGHT)); | |
1912 if (bUsingSpecular) | |
1913 { | |
186 | 1914 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 1915 |
1073 | 1916 for (uint i = 0; i < uNumVertices; ++i) |
1917 { | |
1918 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
1919 d3d_vertex_buffer[i].specular = 0; | |
1920 } | |
1921 | |
0 | 1922 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 1923 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
1924 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 1925 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1926 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1927 d3d_vertex_buffer, |
0 | 1928 uNumVertices, |
1929 D3DDP_DONOTLIGHT)); | |
186 | 1930 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 1931 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
1932 v41 = GetLevelFogColor(); | |
1933 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
1934 v6 = 0; | |
1935 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
1936 } | |
186 | 1937 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
1938 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1939 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
1940 } | |
1941 } | |
1942 } | |
1943 } | |
1944 // 4D864C: using guessed type char byte_4D864C; | |
1945 | |
1946 //----- (0049EB79) -------------------------------------------------------- | |
1947 Render::~Render() | |
1948 { | |
1949 Render *v1; // esi@1 | |
1950 | |
1951 v1 = this; | |
1583 | 1952 free(this->pDefaultZBuffer); |
0 | 1953 v1->pD3DBitmaps.Release(); |
1954 v1->pD3DSprites.Release(); | |
1955 Release(); | |
1956 v1->bWindowMode = 1; | |
1957 //nullsub_1(); | |
1958 //nullsub_1(); | |
1959 } | |
1960 | |
1961 | |
1962 //----- (0049E992) -------------------------------------------------------- | |
1963 Render::Render() | |
1964 { | |
2216 | 1965 //Render *v1; // esi@1 |
0 | 1966 int v2; // eax@1 |
1967 char v3; // zf@1 | |
1968 | |
2216 | 1969 //v1 = this; |
0 | 1970 this->pDirectDraw4 = 0; |
1971 this->pFrontBuffer4 = 0; | |
1972 this->pBackBuffer4 = 0; | |
2154 | 1973 //this->pColorKeySurface4 = 0; |
2152 | 1974 //this->pDirectDraw2 = 0; |
1975 //this->pFrontBuffer2 = 0; | |
1976 //this->pBackBuffer2 = 0; | |
1977 //this->pSomeSurface2 = 0; | |
0 | 1978 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); |
1979 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2216 | 1980 this->bWindowMode = 1; |
1981 //this->field_40054 = 0; | |
1982 //this->field_10 = 640; | |
1983 //this->field_14 = 480; | |
1984 //this->field_40030 = 0; | |
1985 //this->field_4002C = 0; | |
1986 this->pActiveZBuffer = 0; | |
1987 this->pDefaultZBuffer = 0; | |
1988 this->raster_clip_y = 0; | |
1989 this->raster_clip_x = 0; | |
1990 this->raster_clip_z = 639; | |
1991 this->raster_clip_w = 479; | |
1992 //this->field_4003C = 0x004EED80; | |
1993 //this->field_40040 = dword_4EED78; | |
1994 this->uClipZ = 640; | |
1995 //this->field_40044 = 2; | |
1996 //this->field_40048 = 6; | |
1997 this->pFrontBuffer4 = 0; | |
1998 this->pBackBuffer4 = 0; | |
1999 //this->pColorKeySurface4 = 0; | |
2000 this->pDirectDraw4 = 0; | |
2001 this->pRenderD3D = 0; | |
2002 this->uNumSceneBegins = 0; | |
2003 this->uNumD3DSceneBegins = 0; | |
2004 this->using_software_screen_buffer = 0; | |
2005 this->pTargetSurface = 0; | |
2006 this->uTargetSurfacePitch = 0; | |
2007 this->uClipY = 0; | |
2008 this->uClipX = 0; | |
2009 this->uClipW = 480; | |
2010 this->bClip = 1; | |
2011 //this->bColorKeySupported = 0; | |
2012 this->bRequiredTextureStagesAvailable = 0; | |
2013 this->bTinting = 1; | |
2014 //LOBYTE(this->field_103668) = 0; | |
0 | 2015 uNumBillboardsToDraw = 0; |
2016 bFogEnabled = false; | |
265 | 2017 |
2018 hd_water_tile_id = -1; | |
2019 hd_water_current_frame = 0; | |
0 | 2020 } |
2021 | |
2069 | 2022 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
0 | 2023 { |
1802 | 2024 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); |
2025 | |
2026 this->window = window; | |
2069 | 2027 //bStartInWindow = true; |
1802 | 2028 //windowed_mode_width = windowed_width; |
2029 //windowed_mode_height = windowed_height; | |
2030 | |
1985 | 2031 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0); |
0 | 2032 |
2033 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
2034 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
2035 | |
2036 this->bTinting = bTinting; | |
2037 | |
1980 | 2038 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); |
2039 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
0 | 2040 |
2041 return r1 && r2; | |
2042 } | |
2043 | |
2044 | |
2045 //----- (0049ECC4) -------------------------------------------------------- | |
2046 void Render::ClearBlack() | |
2047 { | |
2154 | 2048 //if (pRenderD3D) |
0 | 2049 { |
2069 | 2050 if (using_software_screen_buffer) |
0 | 2051 pRenderD3D->ClearTarget(true, 0, false, 0.0); |
2052 } | |
2154 | 2053 //else |
2054 //memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
0 | 2055 } |
2056 | |
2057 //----- (0049ED18) -------------------------------------------------------- | |
2058 void Render::PresentBlackScreen() | |
2059 { | |
2060 IDirectDrawSurface *v2; // eax@3 | |
2061 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
2062 RECT x; // [sp+68h] [bp-10h]@3 | |
2063 | |
2064 memset(&v3, 0, sizeof(DDBLTFX)); | |
1802 | 2065 GetWindowRect(window->GetApiHandle(), &x); |
2152 | 2066 |
0 | 2067 { |
2068 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
2069 } | |
2152 | 2070 |
0 | 2071 v3.dwFillColor = 0; |
2072 v3.dwSize = 100; | |
2073 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
2074 pRenderer->Present(); | |
2075 } | |
2076 | |
2077 //----- (0049EDB6) -------------------------------------------------------- | |
2078 void Render::SavePCXScreenshot() | |
2079 { | |
2080 int v5; // eax@8 | |
2132 | 2081 FILE *pOutFile; // edi@10 |
2133 | 2082 unsigned short *v8; // eax@11 |
0 | 2083 int v9; // eax@13 |
2084 int v10; // ecx@15 | |
2085 signed int v12; // eax@18 | |
2086 HRESULT v14; // eax@29 | |
2087 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
2088 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2089 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2090 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2132 | 2091 char *lineB; // [sp+11Ch] [bp-48h]@14 |
2092 char *lineG; // [sp+120h] [bp-44h]@14 | |
2093 //int v24; // [sp+124h] [bp-40h]@11 | |
0 | 2094 FILE *File; // [sp+128h] [bp-3Ch]@3 |
2095 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2096 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2132 | 2097 char *lineRGB; // [sp+148h] [bp-1Ch]@10 |
2098 void *surface; // [sp+14Ch] [bp-18h]@8 | |
2099 int image_width; // [sp+150h] [bp-14h]@4 | |
2100 int pitch; // [sp+154h] [bp-10h]@4 | |
0 | 2101 char v31; // [sp+15Ah] [bp-Ah]@25 |
2132 | 2102 unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17 |
2103 unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10 | |
2104 byte test_byte; // [sp+163h] [bp-1h]@17 | |
2105 | |
2106 int num_r_bits = 5; | |
2107 int num_g_bits = 6; | |
2108 int num_b_bits = 5; | |
2109 | |
2110 int r_mask = 0xF800; | |
2111 int g_mask = 0x7E0; | |
2112 int b_mask = 0x1F; | |
2113 | |
2069 | 2114 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2115 { |
2132 | 2116 sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100); |
0 | 2117 File = fopen(Filename, "wb"); |
2118 if ( File ) | |
2119 { | |
2154 | 2120 pitch = this->GetRenderWidth(); |
2121 if ( pitch & 1 ) | |
2122 pitch = pitch + 1; | |
2132 | 2123 if ( this->pRenderD3D ) |
2124 { | |
2125 memset(&Dst, 0, 0x7C); | |
0 | 2126 Dst.dwSize = 124; |
168 | 2127 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 2128 return; |
2132 | 2129 surface = Dst.lpSurface; |
2130 v5 = Dst.lPitch / 2; | |
0 | 2131 } |
2132 else | |
2133 { | |
2134 pRenderer->BeginScene(); | |
2132 | 2135 surface = pRenderer->pTargetSurface; |
0 | 2136 v5 = pRenderer->uTargetSurfacePitch; |
2137 } | |
2154 | 2138 header1.right = GetRenderWidth() - 1; |
2132 | 2139 header1.left = 0; |
2154 | 2140 header1.bottom = this->GetRenderHeight() - 1; |
2132 | 2141 header1.up = 0; |
2142 header2.pitch = pitch; | |
0 | 2143 memset(color_map, 0, sizeof(color_map)); |
2144 memset(v15, 0, sizeof(v15)); | |
2145 header2.reserved = 0; | |
2146 header1.manufacturer = 10; | |
2132 | 2147 pOutFile = File; |
0 | 2148 header1.version = 5; |
2149 header1.encoding = 1; | |
2150 header1.bpp = 8; | |
2151 header1.hdpi = 75; | |
2152 header1.vdpi = 75; | |
2153 header2.planes = 3; | |
2154 header2.palette_info = 1; | |
2132 | 2155 fwrite(&header1, 1, 1, File); |
2156 fwrite(&header1.version, 1, 1, pOutFile); | |
2157 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2158 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2159 fwrite(&header1.left, 2, 1, pOutFile); | |
2160 fwrite(&header1.up, 2, 1, pOutFile); | |
2161 fwrite(&header1.right, 2, 1, pOutFile); | |
2162 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2163 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2164 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2165 fwrite(color_map, 0x30u, 1, pOutFile); | |
2166 fwrite(&header2, 1, 1, pOutFile); | |
2167 fwrite(&header2.planes, 1, 1, pOutFile); | |
2168 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2169 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2170 fwrite(v15, 0x3Au, 1, pOutFile); | |
2154 | 2171 lineRGB = (char *)malloc(3 * GetRenderWidth() + 6); |
2172 if ( this->GetRenderHeight() > 0 ) | |
2132 | 2173 { |
2174 image_width = 3 * pitch; | |
2175 //v24 = 2 * v5; | |
2176 v8 = (unsigned short *)surface; | |
2154 | 2177 for ( int y = 0; y < this->GetRenderHeight(); y++ ) |
0 | 2178 { |
2132 | 2179 line_picture_data = v8; |
2154 | 2180 if ( GetRenderWidth() > 0 ) |
0 | 2181 { |
2132 | 2182 lineG = (char *)lineRGB + pitch; |
2183 lineB = (char *)lineRGB + 2 * pitch; | |
2154 | 2184 for ( uint x = 0; x < this->GetRenderWidth(); x++ ) |
0 | 2185 { |
2221 | 2186 //int p = *line_picture_data; //0x2818 |
2187 //int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits );//16 = 8 + 8 | |
2188 //int value = (pRenderer->uTargetRMask & *line_picture_data);//0 = 0xFF0000 & 0x2818 | |
2189 //int result = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits ); | |
2133 | 2190 lineRGB[x] = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits );// + pRenderer->uTargetRBits - 8); |
2191 lineG[x] = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits);// + pRenderer->uTargetGBits - 8); | |
2221 | 2192 //int value2 = (pRenderer->uTargetGMask & *line_picture_data); //10240 = 0xFF00 & 0x2818 |
2193 //int result2 = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits); | |
2133 | 2194 lineB[x] = (pRenderer->uTargetBMask & *line_picture_data);// << (8 - pRenderer->uTargetBBits); |
2221 | 2195 //int value3 = (pRenderer->uTargetBMask & *line_picture_data);//24 = 0xFF & 0x2818 |
2132 | 2196 line_picture_data += 2; |
0 | 2197 } |
2198 } | |
2132 | 2199 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2200 { |
2132 | 2201 pict_byte = lineRGB[i]; |
2202 for ( test_byte = 1; test_byte < 0x3F; ++test_byte ) | |
0 | 2203 { |
2132 | 2204 v12 = i + test_byte; |
2205 if ( lineRGB[v12] != pict_byte ) | |
0 | 2206 break; |
2132 | 2207 if ( !(v12 % pitch) ) |
0 | 2208 break; |
2209 } | |
2132 | 2210 if ( i + test_byte > image_width ) |
2211 test_byte = 3 * pitch - i; | |
2212 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
2213 { | |
2214 v31 = test_byte | 0xC0; | |
2215 fwrite(&v31, 1, 1, pOutFile); | |
2216 } | |
2217 fwrite(&pict_byte, 1, 1, pOutFile); | |
0 | 2218 } |
2132 | 2219 v8 += v5; |
0 | 2220 } |
2221 } | |
2132 | 2222 if ( this->pRenderD3D ) |
0 | 2223 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2224 else | |
2225 pRenderer->EndScene(); | |
2132 | 2226 |
2227 free(lineRGB); | |
2228 fclose(pOutFile); | |
0 | 2229 } |
2230 } | |
2231 } | |
2232 | |
2233 //----- (0049F1BC) -------------------------------------------------------- | |
2069 | 2234 void Render::SaveWinnersCertificate(const char *a1) |
0 | 2235 { |
2236 unsigned int v6; // eax@8 | |
2133 | 2237 //FILE *v7; // edi@10 |
0 | 2238 int v8; // ecx@11 |
2133 | 2239 unsigned short *v9; // eax@11 |
0 | 2240 int v10; // eax@13 |
2241 signed int v13; // eax@18 | |
2242 char v14; // zf@27 | |
2243 HRESULT v15; // eax@29 | |
2133 | 2244 char v16[56]; // [sp+Ch] [bp-12Ch]@10 |
0 | 2245 __int16 v17; // [sp+44h] [bp-F4h]@10 |
2133 | 2246 DDSURFACEDESC2 Dst; // [sp+48h] [bp-F0h]@7 |
0 | 2247 int v19; // [sp+58h] [bp-E0h]@8 |
2248 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
2133 | 2249 char color_map[48]; // [sp+C4h] [bp-74h]@10 |
0 | 2250 unsigned int v22; // [sp+F4h] [bp-44h]@11 |
2133 | 2251 char *lineB; // [sp+F8h] [bp-40h]@14 |
2252 int image_width; // [sp+FCh] [bp-3Ch]@11 | |
0 | 2253 int v25; // [sp+100h] [bp-38h]@4 |
2254 FILE *File; // [sp+104h] [bp-34h]@3 | |
2255 char Str; // [sp+108h] [bp-30h]@10 | |
2256 char v28; // [sp+109h] [bp-2Fh]@10 | |
2257 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
2258 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
2259 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
2260 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
2261 __int16 v33; // [sp+110h] [bp-28h]@10 | |
2262 __int16 v34; // [sp+112h] [bp-26h]@10 | |
2263 __int16 v35; // [sp+114h] [bp-24h]@10 | |
2264 __int16 v36; // [sp+116h] [bp-22h]@10 | |
2265 char v37; // [sp+118h] [bp-20h]@10 | |
2266 char v38; // [sp+119h] [bp-1Fh]@10 | |
2267 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
2268 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
2133 | 2269 char *lineRGB; // [sp+120h] [bp-18h]@10 |
2270 void *surface; // [sp+124h] [bp-14h]@8 | |
2271 int pitch; // [sp+128h] [bp-10h]@4 | |
0 | 2272 char v44; // [sp+12Fh] [bp-9h]@25 |
2133 | 2273 char *lineG; // [sp+130h] [bp-8h]@10 |
2274 unsigned char pict_byte; // [sp+137h] [bp-1h]@17 | |
2275 byte test_byte; | |
2276 | |
2277 int num_r_bits = 5; | |
2278 int num_g_bits = 6; | |
2279 int num_b_bits = 5; | |
2280 | |
2281 int r_mask = 0xF800; | |
2282 int g_mask = 0x7E0; | |
2283 int b_mask = 0x1F; | |
2284 | |
2069 | 2285 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2286 { |
2154 | 2287 static int _4EFA84_num_winners_certificates = 0; |
2288 ++_4EFA84_num_winners_certificates; | |
2289 | |
0 | 2290 File = fopen(a1, "wb"); |
2291 if ( File ) | |
2292 { | |
2154 | 2293 v25 = this->GetRenderWidth(); |
2294 pitch = v25; | |
2295 if ( pitch & 1 ) | |
2296 pitch = pitch + 1; | |
2133 | 2297 if ( this->pRenderD3D ) |
2298 { | |
2299 memset(&Dst, 0, 0x7C); | |
2300 Dst.dwSize = 124; | |
168 | 2301 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 2302 return; |
2133 | 2303 surface = Dst.lpSurface; |
2304 v6 = Dst.lPitch / 2; | |
0 | 2305 } |
2306 else | |
2307 { | |
2308 pRenderer->BeginScene(); | |
2133 | 2309 surface = pRenderer->pTargetSurface; |
0 | 2310 v6 = pRenderer->uTargetSurfacePitch; |
2311 } | |
2154 | 2312 v33 = this->GetRenderWidth() - 1; |
2133 | 2313 v31 = 0; |
2154 | 2314 v34 = (short)this->GetRenderHeight() - 1; |
2133 | 2315 v32 = 0; |
2316 v39 = pitch; | |
2317 memset(&color_map, 0, sizeof(color_map)); | |
2318 memset(&v16, 0, sizeof(v16)); | |
0 | 2319 v37 = 0; |
2320 Str = 10; | |
2321 v17 = 0; | |
2322 v28 = 5; | |
2323 v29 = 1; | |
2324 v30 = 8; | |
2325 v35 = 75; | |
2326 v36 = 75; | |
2327 v38 = 3; | |
2328 v40 = 1; | |
2133 | 2329 fwrite(&Str, 1, 1, File); |
2330 fwrite(&v28, 1, 1, File); | |
2331 fwrite(&v29, 1, 1, File); | |
2332 fwrite(&v30, 1, 1, File); | |
2333 fwrite(&v31, 2, 1, File); | |
2334 fwrite(&v32, 2, 1, File); | |
2335 fwrite(&v33, 2, 1, File); | |
2336 fwrite(&v34, 2, 1, File); | |
2337 fwrite(&v35, 2, 1, File); | |
2338 fwrite(&v36, 2, 1, File); | |
2339 fwrite(&color_map, 0x30, 1, File); | |
2340 fwrite(&v37, 1, 1, File); | |
2341 fwrite(&v38, 1, 1, File); | |
2342 fwrite(&v39, 2, 1, File); | |
2343 fwrite(&v40, 2, 1, File); | |
2344 fwrite(&v16, 0x3A, 1, File); | |
2345 lineRGB = (char *)malloc(3 * (v25 + 2)); | |
2154 | 2346 if ( (signed int)this->GetRenderHeight() > 0 ) |
2133 | 2347 { |
2348 image_width = 3 * pitch; | |
2349 v9 = (unsigned short *)surface; | |
2154 | 2350 for ( uint j = 0; j < this->GetRenderHeight(); j++) |
0 | 2351 { |
2352 a1 = (const char *)v9; | |
2353 if ( v25 > 0 ) | |
2354 { | |
2133 | 2355 lineG = (char *)lineRGB + pitch; |
2356 lineB = (char *)lineRGB + 2 * pitch; | |
2357 for ( v10 = 0; v10 < v25; v10++ ) | |
0 | 2358 { |
2133 | 2359 lineRGB[v10] = (signed int)(r_mask & *(short *)a1) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2360 lineG[v10] = (signed int)(g_mask & *(short *)a1) >> (num_b_bits + num_g_bits - 8); | |
2361 lineB[v10] = (b_mask & *(short *)a1) << (8 - num_b_bits); | |
0 | 2362 a1 += 2; |
2363 } | |
2364 } | |
2133 | 2365 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2366 { |
2133 | 2367 pict_byte = lineRGB[i]; |
2368 for ( test_byte = 1; test_byte < 0x3F; test_byte ) | |
0 | 2369 { |
2133 | 2370 v13 = i + test_byte; |
2371 if ( lineRGB[v13] != pict_byte ) | |
0 | 2372 break; |
2133 | 2373 if ( !(v13 % pitch) ) |
0 | 2374 break; |
2375 } | |
2133 | 2376 if ( i + test_byte > image_width ) |
2377 test_byte = 3 * pitch - i; | |
2378 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
0 | 2379 { |
2133 | 2380 v44 = test_byte | 0xC0; |
2381 fwrite(&v44, 1, 1, File); | |
0 | 2382 } |
2133 | 2383 fwrite(&pict_byte, 1, 1, File); |
0 | 2384 } |
2133 | 2385 v9 += pitch; |
0 | 2386 } |
2387 } | |
2133 | 2388 if ( this->pRenderD3D ) |
0 | 2389 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2390 else | |
2391 pRenderer->EndScene(); | |
2133 | 2392 free(lineRGB); |
2393 fclose(File); | |
0 | 2394 } |
2395 } | |
2396 } | |
2397 | |
2398 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 2399 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
2127 | 2400 { |
0 | 2401 void *v8; // esi@3 |
2402 void *v9; // esi@3 | |
810 | 2403 unsigned short* v11; // eax@4 |
0 | 2404 int v13; // eax@8 |
2405 int v14; // ecx@8 | |
2406 signed int v15; // eax@11 | |
2407 char v16; // zf@20 | |
2408 int result; // eax@21 | |
2409 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
2410 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 2411 char *lineG; // [sp+78h] [bp-40h]@7 |
2412 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 2413 int v23; // [sp+80h] [bp-38h]@4 |
2414 int v24; // [sp+84h] [bp-34h]@4 | |
2415 int v25; // [sp+88h] [bp-30h]@4 | |
2416 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 2417 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
2418 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
2419 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
2420 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 2421 char v43; // [sp+B3h] [bp-5h]@18 |
2422 int i; // [sp+B4h] [bp-4h]@6 | |
2132 | 2423 unsigned short* line_picture_data; |
810 | 2424 byte test_byte; |
2425 unsigned char pict_byte; | |
0 | 2426 |
2131 | 2427 int num_r_bits = 5; |
2428 int num_g_bits = 6; | |
2429 int num_b_bits = 5; | |
2430 | |
2431 int r_mask = 0xF800; | |
2432 int g_mask = 0x7E0; | |
2433 int b_mask = 0x1F; | |
2434 | |
810 | 2435 pitch = wight; |
2436 if ( wight & 1 ) | |
2437 pitch = wight + 1; | |
2438 Src.left = 0; | |
2439 Src.up = 0; | |
2440 Src.right = wight - 1; | |
2441 Src.bottom = heidth - 1; | |
2442 v27.pitch = pitch; | |
0 | 2443 memset(&v20, 0, 0x30u); |
2444 memset(&v18, 0, 0x38u); | |
810 | 2445 v8 = data_buff; |
2446 v27.reserved = 0; | |
0 | 2447 *(_WORD *)&v18[56] = 0; |
810 | 2448 Src.manufacturer = 10; |
2449 Src.version = 5; | |
2450 Src.encoding = 1; | |
2451 Src.bpp = 8; | |
2452 Src.hdpi = 75; | |
2453 Src.vdpi = 75; | |
2454 v27.planes = 3; | |
2455 v27.palette_info = 1; | |
2128 | 2456 memcpy(data_buff, &Src, 1); |
0 | 2457 v8 = (char *)v8 + 1; |
2128 | 2458 memcpy(v8, &Src.version, 1); |
0 | 2459 v8 = (char *)v8 + 1; |
2128 | 2460 memcpy(v8, &Src.encoding, 1); |
0 | 2461 v8 = (char *)v8 + 1; |
2128 | 2462 memcpy(v8, &Src.bpp, 1); |
0 | 2463 v8 = (char *)v8 + 1; |
2128 | 2464 memcpy(v8, &Src.left, 2); |
0 | 2465 v8 = (char *)v8 + 2; |
2128 | 2466 memcpy(v8, &Src.up, 2); |
0 | 2467 v8 = (char *)v8 + 2; |
2128 | 2468 memcpy(v8, &Src.right, 2); |
0 | 2469 v8 = (char *)v8 + 2; |
2128 | 2470 memcpy(v8, &Src.bottom, 2); |
0 | 2471 v8 = (char *)v8 + 2; |
2127 | 2472 memcpy(v8, &Src.hdpi, 2); |
0 | 2473 v8 = (char *)v8 + 2; |
2127 | 2474 memcpy(v8, &Src.vdpi, 2); |
0 | 2475 v8 = (char *)v8 + 2; |
2476 memcpy(v8, &v20, 0x30u); | |
2477 v8 = (char *)v8 + 48; | |
810 | 2478 memcpy(v8, &v27, 1u); |
0 | 2479 v8 = (char *)v8 + 1; |
2127 | 2480 memcpy(v8, &v27.planes, 1); |
0 | 2481 v8 = (char *)v8 + 1; |
2127 | 2482 memcpy(v8, &v27.pitch, 2); |
0 | 2483 v8 = (char *)v8 + 2; |
2127 | 2484 memcpy(v8, &v27.palette_info, 2); |
0 | 2485 v8 = (char *)v8 + 2; |
2486 memcpy(v8, &v18, 0x3Au); | |
2487 v9 = (char *)v8 + 58; | |
810 | 2488 |
1583 | 2489 lineRGB = (char*)malloc(3 * (wight + 2)); |
810 | 2490 if ( heidth > 0 ) |
2491 { | |
2492 v26 = 3 * pitch; | |
2493 v23 = 2 * wight; | |
2494 v11 = picture_data; | |
2495 v24 = (int)picture_data; | |
2127 | 2496 for ( v25 = heidth; v25; v25-- ) |
0 | 2497 { |
2132 | 2498 line_picture_data = v11; |
810 | 2499 if ( wight > 0 ) |
2500 { | |
2501 lineG = (char *)lineRGB + pitch; | |
2502 lineB = (char *)lineRGB + 2 * pitch; | |
2127 | 2503 for ( uint i = 0; i < wight; i++ ) |
0 | 2504 { |
2132 | 2505 lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2506 lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8); | |
2507 lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits); | |
2508 line_picture_data += 1; | |
810 | 2509 } |
0 | 2510 } |
2511 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
2512 { | |
2128 | 2513 pict_byte = lineRGB[i]; |
2127 | 2514 for ( test_byte = 1; test_byte < 63; ++test_byte ) |
0 | 2515 { |
810 | 2516 v15 = i + test_byte; |
2128 | 2517 if ( lineRGB[v15] != pict_byte ) |
0 | 2518 break; |
810 | 2519 if ( !(v15 % pitch) ) |
0 | 2520 break; |
810 | 2521 } |
2522 if ( i + test_byte > v26 ) | |
2523 test_byte = 3 * pitch - i; | |
2127 | 2524 if ( test_byte > 1 || pict_byte >= 192 ) |
810 | 2525 { |
2526 v43 = test_byte | 0xC0; | |
2127 | 2527 memcpy(v9, &v43, 1); |
0 | 2528 v9 = (char *)v9 + 1; |
2529 } | |
2127 | 2530 memcpy(v9, &pict_byte, 1); |
810 | 2531 i += test_byte; |
2532 } | |
2128 | 2533 v11 += wight; |
810 | 2534 } |
2535 } | |
1583 | 2536 free(lineRGB); |
810 | 2537 *(int *)packed_size = (char *)v9 - data_buff; |
0 | 2538 } |
2539 | |
2540 //----- (0049F8B5) -------------------------------------------------------- | |
2155 | 2541 void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) |
0 | 2542 { |
2543 FILE *result; // eax@1 | |
2127 | 2544 FILE *pOutFile; // edi@4 |
2128 | 2545 unsigned short* v9; // eax@5 |
0 | 2546 int v10; // eax@7 |
2547 signed int v12; // eax@12 | |
2548 char v13; // zf@21 | |
2549 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
2550 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
2551 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
2552 int v18; // [sp+74h] [bp-30h]@5 | |
2553 char *v19; // [sp+78h] [bp-2Ch]@5 | |
2127 | 2554 int image_width; // [sp+7Ch] [bp-28h]@5 |
0 | 2555 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 |
2556 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
2128 | 2557 char *lineRGB; // [sp+98h] [bp-Ch]@4 |
2558 int pitch; // [sp+9Ch] [bp-8h]@2 | |
2559 char *lineB; // [sp+A0h] [bp-4h]@8 | |
2560 char *lineG; | |
2561 unsigned short* line_pictute_data; | |
2562 byte test_byte; | |
2563 char v43; | |
2127 | 2564 |
2565 int num_r_bits = 5; | |
2566 int num_g_bits = 6; | |
2567 int num_b_bits = 5; | |
2568 | |
2569 int r_mask = 0xF800; | |
2570 int g_mask = 0x7E0; | |
2571 int b_mask = 0x1F; | |
0 | 2572 |
2573 result = fopen(Filename, "wb"); | |
2574 Filename = (const char *)result; | |
2575 if ( result ) | |
2576 { | |
2128 | 2577 pitch = width; |
2127 | 2578 if ( width & 1 ) |
2128 | 2579 pitch = width + 1; |
0 | 2580 header1.left = 0; |
2581 header1.up = 0; | |
2127 | 2582 header1.right = width - 1; |
2583 header1.bottom = height - 1; | |
2128 | 2584 header2.pitch = pitch; |
0 | 2585 memset(color_map, 0, sizeof(color_map)); |
2586 header2.reserved = 0; | |
2587 memset(v14, 0, sizeof(v14)); | |
2588 v15 = 0; | |
2589 header1.manufacturer = 10; | |
2590 header1.version = 5; | |
2591 header1.encoding = 1; | |
2592 header1.bpp = 8; | |
2593 header1.hdpi = 75; | |
2594 header1.vdpi = 75; | |
2595 header2.planes = 3; | |
2596 header2.palette_info = 1; | |
2127 | 2597 fwrite(&header1, 1, 1, (FILE *)Filename); |
2598 pOutFile = (FILE *)Filename; | |
2599 fwrite(&header1.version, 1, 1, (FILE *)Filename); | |
2600 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2601 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2602 fwrite(&header1.left, 2, 1, pOutFile); | |
2603 fwrite(&header1.up, 2, 1, pOutFile); | |
2604 fwrite(&header1.right, 2, 1, pOutFile); | |
2605 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2606 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2607 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2608 fwrite(color_map, 0x30u, 1, pOutFile); | |
2609 fwrite(&header2, 1, 1, pOutFile); | |
2610 fwrite(&header2.planes, 1, 1, pOutFile); | |
2611 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2612 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2613 fwrite(v14, 0x3Au, 1, pOutFile); | |
2128 | 2614 |
2615 lineRGB = (char *)malloc(3 * (width + 2)); | |
2131 | 2616 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ |
2617 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî. | |
2128 | 2618 image_width = 3 * pitch; |
2619 v9 = picture_data; | |
2127 | 2620 for ( v18 = 0; v18 < height; v18++ )//ñòîëáåö |
2621 { | |
2128 | 2622 line_pictute_data = v9; |
2623 lineG = (char *)lineRGB + pitch; | |
2624 lineB = (char *)lineRGB + 2 * pitch; | |
2625 | |
2626 for ( int i = 0; i < width; i++ )//ñòðîêà | |
2627 { | |
2628 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); | |
2629 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); | |
2630 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); | |
2131 | 2631 line_pictute_data += 1; |
2128 | 2632 } |
2633 test_byte = 1; | |
2131 | 2634 for ( int i = 0; (signed int)i < image_width; i += test_byte ) |
2128 | 2635 { |
2636 unsigned char pic_byte = lineRGB[i]; | |
2637 for ( test_byte; test_byte < 63; ++test_byte )// ðàñ÷¸ò êîëè÷åñòâà îäèíàêîâûõ öâåòîâ | |
0 | 2638 { |
2128 | 2639 v12 = i + test_byte; |
2640 if ( lineRGB[v12] != pic_byte ) | |
2127 | 2641 break; |
2128 | 2642 if ( !(v12 % pitch) ) |
2127 | 2643 break; |
0 | 2644 } |
2128 | 2645 if ( i + test_byte > image_width ) |
2646 test_byte = 3 * pitch - i; | |
2647 if ( test_byte > 1 || pic_byte >= 0xC0 ) | |
0 | 2648 { |
2128 | 2649 v43 = test_byte | 0xC0;//òåñò-áàéò îáúåäèíåíèÿ |
2650 fwrite(&v43, 1, 1, pOutFile); | |
0 | 2651 } |
2128 | 2652 fwrite(&pic_byte, 1, 1, pOutFile); |
2653 } | |
2654 v9 += width; | |
2131 | 2655 } |
2128 | 2656 free(lineRGB); |
2155 | 2657 fclose(pOutFile); |
2658 } | |
0 | 2659 } |
2660 | |
2661 //----- (0049FBCD) -------------------------------------------------------- | |
2662 void Render::ClearTarget(unsigned int uColor) | |
2663 { | |
2154 | 2664 //if (pRenderD3D) |
0 | 2665 { |
2069 | 2666 if (using_software_screen_buffer) |
0 | 2667 pRenderD3D->ClearTarget(true, uColor, false, 0.0); |
2668 } | |
2154 | 2669 //else |
2670 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
0 | 2671 } |
2672 | |
2673 | |
2674 //----- (0049FC37) -------------------------------------------------------- | |
2675 void Render::Present() | |
2676 { | |
2217 | 2677 //struct tagRECT Rect; // [sp+8h] [bp-28h]@11 |
2678 //RECT a4; // [sp+18h] [bp-18h]@11 | |
2679 //struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
2680 | |
2069 | 2681 if ( !pRenderer->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2682 { |
2683 this->pBeforePresentFunction(); | |
2217 | 2684 if ( this->pRenderD3D ) |
2685 { | |
2686 if ( this->using_software_screen_buffer ) | |
0 | 2687 pRenderD3D->Present(false); |
2217 | 2688 } |
2689 else | |
2690 __debugbreak(); // no sr | |
1802 | 2691 /*{ |
2217 | 2692 if ( this->bWindowMode ) |
0 | 2693 { |
2694 RestoreFrontBuffer(); | |
2217 | 2695 GetClientRect(this->hWnd, &Rect); |
0 | 2696 Point.y = 0; |
2697 Point.x = 0; | |
2217 | 2698 ClientToScreen(this->hWnd, &Point); |
0 | 2699 OffsetRect(&Rect, Point.x, Point.y); |
2700 a4.top = 0; | |
2701 a4.bottom = 480; | |
2702 a4.left = 0; | |
2703 a4.right = 640; | |
2704 PresentRect(&Rect, &a4); | |
2705 } | |
2706 else | |
2707 { | |
2708 RestoreFrontBuffer(); | |
2709 a4.top = 0; | |
2710 a4.bottom = 480; | |
2711 a4.left = 0; | |
2712 a4.right = 640; | |
2713 BltBackToFontFast(0, 0, &a4); | |
2714 } | |
1802 | 2715 }*/ |
0 | 2716 } |
2717 } | |
2718 | |
2719 //----- (0049FD3A) -------------------------------------------------------- | |
2154 | 2720 void Render::_49FD3A_fullscreen() |
0 | 2721 { |
2722 Render *v2; // esi@1 | |
2723 IDirectDrawSurface4 *v3; // eax@6 | |
2724 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
2725 RECT v5; // [sp+8h] [bp-10h]@6 | |
2726 | |
1980 | 2727 Render* a1 = this; |
0 | 2728 v2 = a1; |
2729 if ( a1->pRenderD3D ) | |
2730 { | |
2731 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
2732 pFrontBuffer4->Restore(); | |
2733 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
2734 pBackBuffer4->Restore(); | |
2735 v3 = v2->pBackBuffer4; | |
2736 v4 = v2->pFrontBuffer4; | |
2737 v5.top = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2738 v5.bottom = window->GetHeight(); |
0 | 2739 v5.left = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2740 v5.right = window->GetWidth(); |
0 | 2741 v3->BltFast(0, 0, v4, &v5, 16u); |
2742 } | |
2743 } | |
2744 | |
2745 //----- (0049FDBF) -------------------------------------------------------- | |
2746 void Render::CreateZBuffer() | |
2747 { | |
2748 if (!pDefaultZBuffer) | |
2749 { | |
2750 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
1583 | 2751 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); |
871 | 2752 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 2753 } |
2754 } | |
2755 | |
2756 //----- (0049FE05) -------------------------------------------------------- | |
2757 void Render::Release() | |
2758 { | |
2759 Render *v1; // esi@1 | |
1802 | 2760 //RenderD3D *v2; // ecx@1 |
2761 //char v3; // zf@4 | |
2762 //void *v4; // ebx@6 | |
0 | 2763 IDirectDraw *v5; // eax@10 |
2764 IDirectDrawSurface2 *v6; // eax@11 | |
2765 IDirectDrawSurface2 *v7; // eax@13 | |
2766 IDirectDrawSurface2 *v8; // eax@15 | |
2767 IDirectDraw2 *v9; // eax@17 | |
2768 IDirectDraw4 *v10; // eax@19 | |
2769 IDirectDrawSurface4 *v11; // eax@20 | |
2770 IDirectDrawSurface4 *v12; // eax@22 | |
2771 IDirectDrawSurface4 *v13; // eax@24 | |
2772 IDirectDraw4 *v14; // eax@26 | |
2773 unsigned __int16 **v15; // ebx@28 | |
2774 void **v16; // esi@29 | |
2775 | |
2776 v1 = this; | |
1802 | 2777 if (pRenderD3D) |
0 | 2778 { |
2069 | 2779 if ( v1->using_software_screen_buffer ) |
0 | 2780 { |
1802 | 2781 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2782 pRenderD3D->Present(0); |
1802 | 2783 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2784 } |
2154 | 2785 //v1->pColorKeySurface4 = 0; |
0 | 2786 v1->pBackBuffer4 = 0; |
2787 v1->pFrontBuffer4 = 0; | |
2788 v1->pDirectDraw4 = 0; | |
1802 | 2789 if (v1->pTargetSurface) |
0 | 2790 { |
2069 | 2791 delete [] v1->pTargetSurface_unaligned; |
0 | 2792 v1->pTargetSurface = 0; |
2069 | 2793 v1->pTargetSurface_unaligned = 0; |
0 | 2794 } |
1802 | 2795 if (pRenderD3D) |
0 | 2796 { |
2797 pRenderD3D->Release(); | |
1802 | 2798 delete pRenderD3D; |
2799 } | |
2800 pRenderD3D = 0; | |
0 | 2801 } |
2802 else | |
1802 | 2803 ;//__debugbreak(); // no sr |
2804 /*{ | |
0 | 2805 if ( bWinNT4_0 == 1 ) |
2806 { | |
2807 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
2808 if ( !v5 ) | |
2809 return; | |
2810 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
2811 v1->pDirectDraw2->FlipToGDISurface(); | |
2812 v6 = v1->pSomeSurface2; | |
2813 if ( v6 ) | |
2814 { | |
2815 v6->Release(); | |
2816 v1->pSomeSurface2 = 0; | |
2817 } | |
2818 v7 = v1->pBackBuffer2; | |
2819 if ( v7 ) | |
2820 { | |
2821 v7->Release(); | |
2822 v1->pBackBuffer2 = 0; | |
2823 } | |
2824 v8 = v1->pFrontBuffer2; | |
2825 if ( v8 ) | |
2826 { | |
2827 v8->Release(); | |
2828 v1->pFrontBuffer2 = 0; | |
2829 } | |
2830 v9 = v1->pDirectDraw2; | |
2831 if ( v9 ) | |
2832 { | |
2833 v9->Release(); | |
2834 v1->pDirectDraw2 = 0; | |
2835 } | |
2836 } | |
2837 else | |
2838 { | |
2839 v10 = v1->pDirectDraw4; | |
2840 if ( !v10 ) | |
2841 return; | |
2842 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
2843 v1->pDirectDraw4->FlipToGDISurface(); | |
2844 v11 = v1->pColorKeySurface4; | |
2845 if ( v11 ) | |
2846 { | |
2847 v11->Release(); | |
2848 v1->pColorKeySurface4 = 0; | |
2849 } | |
2850 v12 = v1->pBackBuffer4; | |
2851 if ( v12 ) | |
2852 { | |
2853 v12->Release(); | |
2854 v1->pBackBuffer4 = 0; | |
2855 } | |
2856 v13 = v1->pFrontBuffer4; | |
2857 if ( v13 ) | |
2858 { | |
2859 v13->Release(); | |
2860 v1->pFrontBuffer4 = 0; | |
2861 } | |
2862 v14 = v1->pDirectDraw4; | |
2863 if ( v14 ) | |
2864 { | |
2865 v14->Release(); | |
2866 v1->pDirectDraw4 = 0; | |
2867 } | |
2868 } | |
2869 v15 = &v1->pTargetSurface; | |
2870 if ( v1->pTargetSurface ) | |
2871 { | |
2872 v16 = (void **)&v1->ptr_400E8; | |
2873 free(*v16); | |
2874 *v15 = 0; | |
2875 *v16 = 0; | |
2876 } | |
1802 | 2877 }*/ |
0 | 2878 } |
2879 | |
2152 | 2880 |
2881 | |
2882 | |
2883 void Present32(unsigned __int32 *src, unsigned int src_pitch, | |
2884 unsigned __int32 *dst, unsigned int dst_pitch) | |
2885 { | |
2886 for (uint y = 0; y < 8; ++y) | |
2887 memcpy(dst + y * dst_pitch, | |
2888 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2889 | |
2890 for (uint y = 8; y < 352; ++y) | |
2891 { | |
2892 memcpy(dst + y * dst_pitch, | |
2893 src + y * src_pitch, 8 * sizeof(__int32)); | |
2894 memcpy(dst + 8 + game_viewport_width + y * dst_pitch, | |
2895 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32)); | |
2896 } | |
2897 | |
2898 for (uint y = 352; y < 480; ++y) | |
2899 memcpy(dst + y * dst_pitch, | |
2900 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2901 | |
2902 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
2903 { | |
2904 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
2905 { | |
2906 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) | |
2155 | 2907 if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) |
2152 | 2908 dst[x + y * dst_pitch] = src[x + y * src_pitch]; |
2909 } | |
2910 } | |
2911 } | |
2912 | |
2913 //----- (004A597D) -------------------------------------------------------- | |
2914 void Present_NoColorKey() | |
2915 { | |
2916 //unsigned __int16 *v0; // eax@4 | |
2917 unsigned __int16 *v1; // esi@4 | |
2918 void *v2; // edi@4 | |
2919 //signed int v4; // ebx@4 | |
2920 //signed int v5; // ebx@6 | |
2921 //void *v6; // edi@7 | |
2922 //const void *v7; // esi@7 | |
2923 signed int v8; // ebx@8 | |
2924 int v9; // eax@10 | |
2925 unsigned int v10; // esi@10 | |
2926 unsigned __int32 v11; // edi@10 | |
2927 //int v12; // ecx@10 | |
2928 unsigned int v13; // ebx@10 | |
2929 int v14; // eax@11 | |
2930 int v15; // eax@13 | |
2931 int v16; // eax@14 | |
2932 int v17; // eax@16 | |
2933 HRESULT v18; // eax@22 | |
2934 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 | |
2935 //int v20; // [sp+88h] [bp-1Ch]@10 | |
2936 int v21; // [sp+8Ch] [bp-18h]@10 | |
2937 __int32 v22; // [sp+90h] [bp-14h]@10 | |
2938 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10 | |
2939 unsigned int v24; // [sp+98h] [bp-Ch]@4 | |
2940 //unsigned int _this; // [sp+9Ch] [bp-8h]@10 | |
2941 //LPVOID v26; // [sp+A0h] [bp-4h]@4 | |
2942 | |
2943 int r_mask = 0xF800; | |
2944 int g_mask = 0x7E0; | |
2945 int b_mask = 0x1F; | |
2946 | |
2947 if ( !pRenderer->uNumSceneBegins ) | |
2948 { | |
2154 | 2949 //if ( pRenderer->using_software_screen_buffer ) |
2950 //{ | |
2152 | 2951 memset(&Dst, 0, 0x7Cu); |
2952 Dst.dwSize = 124; | |
2953 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
2954 { | |
2955 //v26 = Dst.lpSurface; | |
2956 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; | |
2957 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16); | |
2958 //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; | |
2959 //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; | |
2960 //v1 = pRenderer->pTargetSurface; | |
2961 v2 = Dst.lpSurface; | |
2962 | |
2963 | |
2964 /*for (uint y = 0; y < 480; ++y) | |
2965 { | |
2966 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch); | |
2967 for (uint x = 0; x < 640; ++x) | |
2968 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; | |
2969 }*/ | |
2970 | |
2971 if (!FORCE_16_BITS) | |
2972 Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4); | |
2973 else | |
2974 { | |
2975 ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface; | |
2976 short* pDst = (__int16 *)Dst.lpSurface; | |
2977 | |
2978 for (uint y = 0; y < 8; ++y) | |
2979 memcpy(pDst + y * Dst.lPitch / 2, | |
2980 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2981 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
2152 | 2982 |
2983 for (uint y = 8; y < 352; ++y) | |
2984 { | |
2985 memcpy(pDst + y * Dst.lPitch / 2, | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2986 pSrc + y * window->GetWidth(), 8 * sizeof(__int16)); |
2152 | 2987 memcpy(pDst + 8 + game_viewport_width/*462*/ + y * Dst.lPitch / 2, |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2988 pSrc + 8 + game_viewport_width/*462*/ + y * window->GetWidth(), 174/*172*/ * sizeof(__int16)); |
2152 | 2989 } |
2990 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2991 for (uint y = 352; y < window->GetHeight(); ++y) |
2152 | 2992 memcpy(pDst + y * Dst.lPitch / 2, |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2993 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2994 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2995 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2996 ushort* pSrc_x1y1 = pSrc + window->GetWidth() * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; |
2152 | 2997 //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)]; |
2998 short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; | |
2999 //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY)); | |
3000 v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1); | |
3001 //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1); | |
3002 v22 = 4 * ((Dst.lPitch / 4) + v9); | |
3003 v21 = 4 * v9 + 1280; | |
3004 | |
3005 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1; | |
3006 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1); | |
3007 v10 = (int)pSrc_x1y1; | |
3008 v11 = (int)pDst_x1y1; | |
3009 int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; | |
3010 v13 = v24; | |
3011 | |
3012 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
3013 { | |
3014 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, | |
3015 // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); | |
3016 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
3017 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3018 if (pSrc[y * window->GetWidth() + x] != (g_mask | b_mask)) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3019 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * window->GetWidth() + x]; |
2152 | 3020 } |
3021 } | |
3022 } | |
3023 | |
3024 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3025 | |
3026 /* while ( 1 ) | |
3027 { | |
3028 while ( 1 ) | |
3029 { | |
3030 v14 = *(int *)v10; | |
3031 v10 += 4; | |
3032 if ( v14 == v13 ) | |
3033 break; | |
3034 if ( (short)v14 == (short)v13 ) | |
3035 { | |
3036 *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000; | |
3037 v11 += 4; | |
3038 --uHalfWidth; | |
3039 if ( !uHalfWidth ) | |
3040 goto LABEL_21; | |
3041 } | |
3042 else | |
3043 { | |
3044 v15 = __ROL__(v14, 16); | |
3045 if ( (short)v15 == (short)v13 ) | |
3046 { | |
3047 v17 = __ROR__(v15, 16); | |
3048 *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17; | |
3049 v11 += 4; | |
3050 --uHalfWidth; | |
3051 if ( !uHalfWidth ) | |
3052 goto LABEL_21; | |
3053 } | |
3054 else | |
3055 { | |
3056 v16 = __ROR__(v15, 16); | |
3057 *(int *)v11 = v16; | |
3058 v11 += 4; | |
3059 --uHalfWidth; | |
3060 if ( !uHalfWidth ) | |
3061 goto LABEL_21; | |
3062 } | |
3063 } | |
3064 } | |
3065 v11 += 4; | |
3066 --uHalfWidth; | |
3067 if ( !uHalfWidth ) | |
3068 { | |
3069 LABEL_21: | |
3070 v10 += v21; | |
3071 v11 += v22; | |
3072 uHalfWidth = v20; | |
3073 if ( !--uNumLines ) | |
3074 { | |
3075 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3076 return; | |
3077 } | |
3078 } | |
3079 }*/ | |
3080 } | |
2154 | 3081 //} |
3082 } | |
3083 } | |
3084 | |
0 | 3085 |
3086 //----- (0049FFFB) -------------------------------------------------------- | |
1802 | 3087 bool Render::InitializeFullscreen() |
0 | 3088 { |
3089 //Render *v2; // esi@1 | |
3090 //HWND v3; // ebx@1 | |
3091 //void *v4; // eax@2 | |
3092 //RenderD3D *v5; // eax@3 | |
3093 unsigned int v6; // edx@5 | |
3094 RenderD3D__DevInfo *v7; // ecx@5 | |
3095 bool v8; // eax@6 | |
3096 RenderD3D *v9; // ecx@13 | |
3097 unsigned int v10; // eax@13 | |
3098 RenderD3D *v11; // eax@25 | |
3099 HRESULT v12; // eax@25 | |
3100 int v13; // ecx@25 | |
3101 int v14; // eax@27 | |
3102 signed int v15; // ebx@31 | |
2069 | 3103 //bool v16; // eax@35 |
3104 //char v17; // zf@35 | |
0 | 3105 IDirectDraw4 *v18; // eax@38 |
3106 HRESULT v19; // eax@38 | |
2069 | 3107 //int *v20; // eax@39 |
0 | 3108 int *v22; // eax@42 |
3109 int v23; // ecx@42 | |
3110 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3111 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3112 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
3113 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
3114 void *v28; // [sp+2FCh] [bp-10h]@2 | |
3115 int v29; // [sp+308h] [bp-4h]@2 | |
3116 | |
2069 | 3117 __debugbreak(); // Nomad |
3118 | |
0 | 3119 //v2 = this; |
2069 | 3120 this->using_software_screen_buffer = 0; |
2154 | 3121 //this->pColorKeySurface4 = 0; |
0 | 3122 this->pBackBuffer4 = 0; |
3123 this->pFrontBuffer4 = 0; | |
3124 this->pDirectDraw4 = 0; | |
2069 | 3125 //this->bColorKeySupported = 0; |
0 | 3126 Release(); |
3127 //v3 = hWnd; | |
1802 | 3128 this->window = window; |
0 | 3129 CreateZBuffer(); |
1802 | 3130 |
3131 /*if (!bUserDirect3D) | |
3132 { | |
3133 CreateDirectDraw(); | |
3134 SetDirectDrawCooperationMode(hWnd, 1); | |
3135 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3136 CreateDirectDrawPrimarySurface(); | |
3137 v15 = 1; | |
3138 } | |
3139 else | |
3140 {*/ | |
0 | 3141 pRenderD3D = new RenderD3D; |
3142 v28 = pRenderD3D; | |
3143 v6 = uDesiredDirect3DDevice; | |
3144 v29 = -1; | |
3145 v7 = pRenderD3D->pAvailableDevices; | |
3146 if ( v7[v6].bIsDeviceCompatible ) | |
3147 { | |
2069 | 3148 v8 = pRenderD3D->CreateDevice(v6, /*0*/true, window); |
0 | 3149 } |
3150 else | |
3151 { | |
3152 if ( v7[1].bIsDeviceCompatible ) | |
3153 { | |
2069 | 3154 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window); |
0 | 3155 } |
3156 else | |
3157 { | |
3158 if ( !v7->bIsDeviceCompatible ) | |
1545 | 3159 Error("There aren't any D3D devices to create."); |
3160 | |
2069 | 3161 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window); |
0 | 3162 } |
3163 } | |
3164 if ( !v8 ) | |
1545 | 3165 Error("D3Drend->Init failed."); |
3166 | |
0 | 3167 v9 = pRenderD3D; |
3168 pBackBuffer4 = v9->pBackBuffer; | |
3169 pFrontBuffer4 = v9->pFrontBuffer; | |
3170 pDirectDraw4 = v9->pHost; | |
3171 v10 = pRenderD3D->GetDeviceCaps(); | |
3172 if ( v10 & 1 ) | |
3173 { | |
3174 if ( pRenderD3D ) | |
3175 { | |
3176 pRenderD3D->Release(); | |
3177 delete pRenderD3D; | |
3178 } | |
3179 pRenderD3D = 0; | |
3180 pBackBuffer4 = 0; | |
3181 pFrontBuffer4 = 0; | |
3182 pDirectDraw4 = 0; | |
1545 | 3183 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3184 } |
3185 if ( v10 & 0x3E ) | |
3186 { | |
3187 if ( pRenderD3D ) | |
3188 { | |
3189 pRenderD3D->Release(); | |
3190 delete pRenderD3D; | |
3191 } | |
2154 | 3192 //pColorKeySurface4 = 0; |
0 | 3193 pRenderD3D = 0; |
3194 pBackBuffer4 = 0; | |
3195 pFrontBuffer4 = 0; | |
3196 pDirectDraw4 = 0; | |
1545 | 3197 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3198 } |
3199 if ( (v10 & 0x80u) != 0 ) | |
3200 { | |
3201 if ( pRenderD3D ) | |
3202 { | |
3203 pRenderD3D->Release(); | |
3204 delete pRenderD3D; | |
3205 } | |
3206 pRenderD3D = 0; | |
3207 pBackBuffer4 = 0; | |
3208 pFrontBuffer4 = 0; | |
3209 pDirectDraw4 = 0; | |
1545 | 3210 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3211 } |
2154 | 3212 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; |
0 | 3213 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3214 memset(&halCaps, 0, 0xFCu); | |
3215 halCaps.dwSize = 252; | |
3216 memset(&refCaps, 0, 0xFCu); | |
3217 v11 = pRenderD3D; | |
3218 refCaps.dwSize = 252; | |
3219 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
3220 v13 = halCaps.dwMinTextureWidth; | |
3221 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3222 v13 = halCaps.dwMinTextureHeight; | |
3223 v14 = halCaps.dwMaxTextureWidth; | |
3224 uMinDeviceTextureDim = v13; | |
3225 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
3226 v14 = halCaps.dwMaxTextureHeight; | |
3227 uMaxDeviceTextureDim = v14; | |
3228 if ( (unsigned int)v13 < 4 ) | |
3229 uMinDeviceTextureDim = 4; | |
3230 v15 = 1; | |
3231 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3232 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
2154 | 3233 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2)); |
0 | 3234 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); |
3235 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3236 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
2154 | 3237 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); |
3238 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
3239 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
3240 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3)); | |
3241 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2)); | |
0 | 3242 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); |
2154 | 3243 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2)); |
3244 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
0 | 3245 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); |
2154 | 3246 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4)); |
1802 | 3247 //} |
2069 | 3248 ddpfPrimarySuface.dwSize = 32; |
3249 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3250 ParseTargetPixelFormat(); |
2069 | 3251 |
3252 if (!pRenderD3D) | |
3253 { | |
3254 __debugbreak(); | |
3255 pBeforePresentFunction = 0;//nullsub_1; | |
3256 } | |
3257 //else | |
3258 //{ | |
3259 /*v16 = IsColorKeySupported(pDirectDraw4); | |
0 | 3260 v17 = uAcquiredDirect3DDevice == v15; |
3261 bColorKeySupported = v16; | |
3262 if ( !v17 ) | |
3263 bColorKeySupported = 0; | |
3264 if ( bColorKeySupported ) | |
3265 { | |
3266 memset(&ddsd2, 0, 0x7Cu); | |
3267 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3268 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3269 v18 = pDirectDraw4; | |
3270 ddsd2.dwSize = 124; | |
3271 ddsd2.dwFlags = 65543; | |
3272 ddsd2.ddsCaps.dwCaps = 2112; | |
3273 ddsd2.dwWidth = 640; | |
3274 ddsd2.dwHeight = 480; | |
3275 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3276 pBeforePresentFunction = Present_ColorKey; | |
3277 } | |
2069 | 3278 else*/ |
0 | 3279 { |
3280 pTargetSurface = 0; | |
2069 | 3281 pTargetSurface_unaligned = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3282 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32); |
2069 | 3283 if ( !pTargetSurface_unaligned |
0 | 3284 || (memset(&pDesc, 0, 0x7Cu), |
3285 pDesc.dwSize = 124, | |
3286 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
3287 return 0; | |
3288 pBackBuffer4->Unlock(0); | |
2069 | 3289 v22 = (int *)pTargetSurface_unaligned + 4; |
0 | 3290 v23 = (unsigned int)pDesc.lpSurface & 7; |
3291 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3292 uTargetSurfacePitch = window->GetWidth(); |
0 | 3293 pBeforePresentFunction = Present_NoColorKey; |
3294 v15 = 1; | |
2069 | 3295 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23); |
3296 } | |
3297 using_software_screen_buffer = v15; | |
3298 //} | |
0 | 3299 bWindowMode = 0; |
3300 pParty->uFlags |= 2u; | |
2151 | 3301 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
3302 return v15 != 0; |
0 | 3303 } |
3304 | |
3305 //----- (004A05F3) -------------------------------------------------------- | |
1802 | 3306 bool Render::SwitchToWindow() |
0 | 3307 { |
3308 //Render *v2; // esi@1 | |
3309 //void *v3; // eax@2 | |
3310 //RenderD3D *v4; // eax@3 | |
3311 //unsigned int v5; // edx@5 | |
3312 //RenderD3D__DevInfo *v6; // ecx@5 | |
3313 bool v7; // eax@7 | |
3314 //RenderD3D *v8; // ecx@12 | |
3315 unsigned int v9; // eax@12 | |
3316 RenderD3D *v10; // eax@24 | |
3317 HRESULT v11; // eax@24 | |
3318 int v12; // eax@24 | |
3319 int v13; // eax@26 | |
2069 | 3320 //bool v14; // eax@32 |
3321 //char v15; // zf@32 | |
0 | 3322 IDirectDraw4 *v16; // eax@35 |
3323 HRESULT v17; // eax@35 | |
2069 | 3324 //int *v18; // eax@36 |
0 | 3325 int *v19; // edx@38 |
3326 int v20; // eax@38 | |
3327 unsigned int v21; // ecx@38 | |
3328 int v22; // eax@41 | |
3329 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
3330 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3331 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
3332 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
3333 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
3334 int v29; // [sp+308h] [bp-4h]@2 | |
3335 | |
2069 | 3336 pParty->uFlags |= PARTY_FLAGS_1_0002; |
2151 | 3337 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
2069 | 3338 using_software_screen_buffer = 0; |
0 | 3339 Release(); |
2154 | 3340 //pColorKeySurface4 = 0; |
0 | 3341 pBackBuffer4 = 0; |
3342 pFrontBuffer4 = 0; | |
3343 pDirectDraw4 = 0; | |
2069 | 3344 //bColorKeySupported = 0; |
0 | 3345 CreateZBuffer(); |
1802 | 3346 /*if (!bUserDirect3D) |
3347 { | |
3348 CreateDirectDraw(); | |
3349 SetDirectDrawCooperationMode(hWnd, 0); | |
3350 field_4004C = 1; | |
3351 CreateFrontBuffer(); | |
3352 CreateClipper(hWnd); | |
3353 CreateBackBuffer(); | |
3354 field_40030 = 0; | |
3355 field_18_locked_pitch = 0; | |
3356 } | |
3357 else | |
3358 {*/ | |
1631 | 3359 /*v3 = malloc(0x148u); |
0 | 3360 thisa = (RenderD3D *)v3; |
3361 v29 = 0; | |
3362 if ( v3 ) | |
3363 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3364 else | |
3365 v4 = 0;*/ | |
3366 pRenderD3D = new RenderD3D; | |
3367 //v4 = pRenderD3D; | |
3368 //v5 = uDesiredDirect3DDevice; | |
3369 v29 = -1; | |
3370 //v6 = pRenderD3D->pAvailableDevices; | |
3371 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
3372 uDesiredDirect3DDevice != 1 ) | |
3373 { | |
2069 | 3374 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window); |
0 | 3375 } |
3376 else | |
3377 { | |
3378 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
1545 | 3379 Error("There aren't any D3D devices to init."); |
3380 | |
2069 | 3381 v7 = pRenderD3D->CreateDevice(0, true, window); |
0 | 3382 } |
3383 if ( !v7 ) | |
1545 | 3384 Error("D3Drend->Init failed."); |
0 | 3385 |
3386 //v8 = pRenderD3D; | |
2154 | 3387 //pColorKeySurface4 = 0; |
0 | 3388 pBackBuffer4 = pRenderD3D->pBackBuffer; |
3389 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3390 pDirectDraw4 = pRenderD3D->pHost; | |
3391 v9 = pRenderD3D->GetDeviceCaps(); | |
3392 if ( v9 & 1 ) | |
3393 { | |
3394 if (pRenderD3D) | |
3395 { | |
3396 pRenderD3D->Release(); | |
3397 delete pRenderD3D; | |
3398 } | |
3399 pRenderD3D = 0; | |
3400 pBackBuffer4 = 0; | |
3401 pFrontBuffer4 = 0; | |
3402 pDirectDraw4 = 0; | |
1545 | 3403 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3404 } |
3405 if ( v9 & 0x3E ) | |
3406 { | |
3407 if (pRenderD3D) | |
3408 { | |
3409 pRenderD3D->Release(); | |
3410 delete pRenderD3D; | |
3411 } | |
2154 | 3412 //pColorKeySurface4 = 0; |
0 | 3413 pRenderD3D = 0; |
3414 pBackBuffer4 = 0; | |
3415 pFrontBuffer4 = 0; | |
3416 pDirectDraw4 = 0; | |
1545 | 3417 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3418 } |
2154 | 3419 if (v9 & 0x80) |
0 | 3420 { |
3421 if (pRenderD3D) | |
3422 { | |
3423 pRenderD3D->Release(); | |
3424 delete pRenderD3D; | |
3425 } | |
3426 pRenderD3D = 0; | |
3427 pBackBuffer4 = 0; | |
3428 pFrontBuffer4 = 0; | |
3429 pDirectDraw4 = 0; | |
1545 | 3430 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3431 } |
2154 | 3432 //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; |
0 | 3433 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3434 memset(&halCaps, 0, 0xFCu); | |
3435 halCaps.dwSize = 252; | |
3436 memset(&refCaps, 0, 0xFCu); | |
3437 //v10 = v2->pRenderD3D; | |
3438 refCaps.dwSize = 252; | |
3439 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3440 v12 = halCaps.dwMinTextureWidth; | |
2069 | 3441 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight ) |
0 | 3442 v12 = halCaps.dwMinTextureHeight; |
3443 uMinDeviceTextureDim = v12; | |
3444 v13 = halCaps.dwMaxTextureWidth; | |
3445 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3446 v13 = halCaps.dwMaxTextureHeight; | |
3447 uMaxDeviceTextureDim = v13; | |
3448 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
3449 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
3450 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3451 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
3452 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
3453 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3454 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3455 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3456 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3457 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3458 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3459 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3460 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3461 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3462 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
1802 | 3463 //} |
3464 | |
2069 | 3465 ddpfPrimarySuface.dwSize = 32; |
3466 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3467 ParseTargetPixelFormat(); |
2069 | 3468 |
0 | 3469 if ( !pRenderD3D ) |
3470 { | |
2069 | 3471 __debugbreak(); |
3472 //pBeforePresentFunction = 0;//nullsub_1; | |
3473 //goto LABEL_47; | |
3474 } | |
3475 /*v14 = IsColorKeySupported(pDirectDraw4); | |
0 | 3476 v15 = uAcquiredDirect3DDevice == 1; |
3477 bColorKeySupported = v14; | |
3478 if ( !v15 ) | |
2069 | 3479 bColorKeySupported = 0;*/ |
3480 //if ( bColorKeySupported ) | |
3481 if (false) | |
3482 { | |
3483 /*memset(&ddsd2, 0, 0x7Cu); | |
0 | 3484 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; |
3485 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3486 v16 = pDirectDraw4; | |
3487 ddsd2.dwSize = 124; | |
3488 ddsd2.dwFlags = 65543; | |
3489 ddsd2.ddsCaps.dwCaps = 2112; | |
3490 ddsd2.dwWidth = 640; | |
3491 ddsd2.dwHeight = 480; | |
3492 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
2069 | 3493 pBeforePresentFunction = Present_ColorKey;*/ |
0 | 3494 LABEL_45: |
2069 | 3495 using_software_screen_buffer = 1; |
3496 //LABEL_47: | |
0 | 3497 bWindowMode = 1; |
1802 | 3498 //hWnd = hWnd; |
0 | 3499 return 0; |
3500 } | |
3501 pTargetSurface = 0; | |
2069 | 3502 pTargetSurface_unaligned = 0; |
3503 | |
3504 uint num_pixels = window->GetWidth() * window->GetHeight(); | |
3505 pTargetSurface_unaligned = new unsigned int[num_pixels]; | |
3506 | |
3507 if (!pTargetSurface_unaligned) | |
3508 return false; | |
3509 | |
3510 memset(&pDesc, 0, 0x7Cu); | |
3511 pDesc.dwSize = 124; | |
3512 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT)) | |
3513 { | |
3514 delete [] pTargetSurface_unaligned; | |
3515 return false; | |
3516 } | |
3517 | |
3518 memset32(pTargetSurface_unaligned, -1, num_pixels); | |
3519 | |
3520 | |
0 | 3521 pRenderer->pBackBuffer4->Unlock(0); |
2069 | 3522 /*v19 = pTargetSurface_unaligned; |
0 | 3523 v20 = (unsigned int)pDesc.lpSurface & 7; |
3524 v21 = (unsigned int)ptr_400E8 & 7; | |
3525 if ( v21 == v20 ) | |
3526 { | |
3527 pTargetSurface = (unsigned __int16 *)v19; | |
3528 } | |
3529 else | |
3530 { | |
3531 if ( (signed int)v21 >= v20 ) | |
3532 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
3533 else | |
3534 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
3535 pTargetSurface = (unsigned __int16 *)v22; | |
2069 | 3536 }*/ |
3537 pTargetSurface = pTargetSurface_unaligned; | |
3538 uTargetSurfacePitch = window->GetWidth(); | |
0 | 3539 pBeforePresentFunction = Present_NoColorKey; |
3540 goto LABEL_45; | |
3541 } | |
3542 | |
2154 | 3543 |
3544 //----- (0044F2B2) -------------------------------------------------------- | |
3545 bool Render::IsGammaSupported() | |
3546 { | |
3547 bool result; // eax@3 | |
3548 HRESULT v1; // eax@4 | |
3549 | |
3550 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
3551 { | |
3552 DDCAPS halCaps; // [sp+0h] [bp-180h]@4 | |
3553 memset(&halCaps, 0, sizeof(DDCAPS)); | |
3554 halCaps.dwSize = sizeof(DDCAPS); | |
3555 | |
3556 ErrD3D(pDirectDraw4->GetCaps(&halCaps, 0)); | |
3557 return (halCaps.dwCaps2 >> 17) & 1; | |
3558 } | |
3559 /*else | |
3560 return false;*/ | |
3561 } | |
3562 | |
0 | 3563 //----- (004A0BEE) -------------------------------------------------------- |
2102 | 3564 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) |
3565 { | |
2198 | 3566 signed int lower_bound; // eax@17 |
3567 signed int left_bound; | |
0 | 3568 unsigned int v21; // edi@46 |
3569 int v22; // esi@47 | |
3570 int v23; // ebx@47 | |
3571 signed int v24; // edx@50 | |
3572 signed int v25; // esi@52 | |
3573 unsigned __int16 *v26; // ecx@52 | |
3574 int v27; // ebx@54 | |
3575 int v28; // edi@55 | |
3576 int v29; // edx@55 | |
3577 int v30; // ebx@60 | |
3578 int v31; // edx@61 | |
3579 int v32; // edi@61 | |
2198 | 3580 signed int upper_bound; // [sp+18h] [bp-4h]@28 |
0 | 3581 unsigned int uXa; // [sp+24h] [bp+8h]@49 |
3582 int uYb; // [sp+28h] [bp+Ch]@47 | |
2245 | 3583 bool left_border_x = false; |
3584 bool right_border_x = false; | |
3585 bool left_border_z = false; | |
3586 bool right_border_z = false; | |
3587 bool upper_border_y = false; | |
3588 bool bottom_border_y = false; | |
3589 bool upper_border_w = false; | |
3590 bool bottom_border_w = false; | |
3591 | |
2101 | 3592 if ( uX < this->raster_clip_x )// x âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2245 | 3593 left_border_x = true; |
2101 | 3594 if ( uX > this->raster_clip_z )// x âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
2245 | 3595 right_border_x = true; |
2097 | 3596 |
2101 | 3597 if ( uZ < this->raster_clip_x )// z âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2245 | 3598 left_border_z = true; |
2101 | 3599 if ( uZ > this->raster_clip_z )// z âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
2245 | 3600 right_border_z = true; |
2101 | 3601 |
3602 if ( uY < this->raster_clip_y )// y âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
2245 | 3603 upper_border_y = true; |
2101 | 3604 if ( uY > this->raster_clip_w )// y âûõîäèò çà ðàìêè íèæíåé ãðàíèöû |
2245 | 3605 bottom_border_y = true; |
2101 | 3606 |
3607 if ( uW < this->raster_clip_y )// w âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
2245 | 3608 upper_border_w = true; |
2101 | 3609 if ( uW > this->raster_clip_w )// w âûõîäèò çà ðàìêè íèæíåé ãðàíèöû |
2245 | 3610 bottom_border_w = true; |
3611 | |
3612 if ( (left_border_x && left_border_z) || (right_border_x && right_border_z ) | |
3613 || (upper_border_y && upper_border_w) || (bottom_border_y && bottom_border_w)) | |
2102 | 3614 return; |
3615 | |
2245 | 3616 if ( left_border_x || left_border_z || right_border_x || right_border_z |
3617 || upper_border_y || upper_border_w || bottom_border_y || bottom_border_w) | |
3618 { | |
3619 if ( left_border_x || left_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left (ëåâàÿ ãðàíèöà) | |
3620 { | |
3621 if ( left_border_x )//left_border = true; õ ìåíüøå ëåâîé ãðàíèöû | |
3622 { | |
3623 uY += (uW - uY) * ((this->raster_clip_x - uX) / (uZ - uX));//t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
2199 | 3624 uX = this->raster_clip_x; |
3625 } | |
2245 | 3626 else if ( left_border_z )//z ìåíüøå ëåâîé ãðàíèöû |
2199 | 3627 { |
3628 uZ = this->raster_clip_x; | |
2245 | 3629 uW += (uY - uW) * ((this->raster_clip_x - uZ) / (uX - uZ)); |
3630 } | |
3631 } | |
3632 | |
3633 if ( right_border_x || right_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )//for right (ïðàâàÿ ãðàíèöà) | |
3634 { | |
3635 if ( right_border_x ) //right_border = true; õ áîëüøå ïðàâîé ãðàíèöû | |
3636 { | |
3637 uY += (uY - uW) * ((this->raster_clip_z - uX) / (uZ - uX)); | |
2199 | 3638 uX = this->raster_clip_z; |
0 | 3639 } |
2245 | 3640 else if ( right_border_z )//z áîëüøå ïðàâîé ãðàíèöû |
3641 { | |
3642 uW += (uW - uY) * ((this->raster_clip_z - uZ) / (uX - uZ)); | |
2199 | 3643 uZ = this->raster_clip_z; |
3644 } | |
3645 } | |
2245 | 3646 |
2199 | 3647 upper_bound = 0; |
3648 if ( uY < this->raster_clip_y ) | |
3649 upper_bound = 2; | |
3650 if ( uY > this->raster_clip_w ) | |
3651 upper_bound |= 1; | |
3652 | |
3653 lower_bound = 0; | |
3654 if ( uW < this->raster_clip_y ) | |
3655 lower_bound = 2; | |
3656 if ( uW > this->raster_clip_w ) | |
3657 lower_bound |= 1; | |
3658 | |
3659 if ( !(lower_bound & upper_bound) )//for up and down(äëÿ âåðõà è íèçà) | |
3660 { | |
3661 lower_bound ^= upper_bound; | |
3662 if ( lower_bound & 2 ) | |
3663 { | |
3664 if ( upper_bound & 2 ) | |
3665 { | |
2245 | 3666 uX += (uZ - uX) * ((this->raster_clip_y - uY) / (uW - uY)); |
2199 | 3667 uY = this->raster_clip_y; |
3668 } | |
3669 else | |
3670 { | |
2245 | 3671 uZ += (uX - uZ) * ((this->raster_clip_y - uW) / (uY - uW)); |
2199 | 3672 uW = this->raster_clip_y; |
3673 } | |
3674 } | |
3675 if ( lower_bound & 1 ) | |
3676 { | |
3677 if ( upper_bound & 1 ) | |
3678 { | |
2245 | 3679 uX += (uZ - uX) * ((this->raster_clip_w - uY) / (uW - uY)); |
2199 | 3680 uY = this->raster_clip_w; |
3681 } | |
3682 else | |
0 | 3683 { |
2245 | 3684 uZ += (uX - uZ) * ((this->raster_clip_w - uW) / (uY - uW)); |
2199 | 3685 uW = this->raster_clip_w; |
3686 } | |
3687 } | |
3688 } | |
3689 } | |
3690 v21 = pRenderer->uTargetSurfacePitch; | |
3691 if ( pRenderer->uTargetSurfacePitch ) | |
3692 { | |
3693 //v12 = uX + uY * pRenderer->uTargetSurfacePitch; | |
3694 v22 = uW - uY; | |
3695 v23 = v22; | |
3696 uYb = v22; | |
3697 if ( v22 < 0 ) | |
3698 { | |
3699 v23 = -v22; | |
3700 uYb = -v22; | |
3701 v21 = -pRenderer->uTargetSurfacePitch; | |
3702 } | |
3703 uXa = uZ - uX; | |
3704 if ((signed)(uZ - uX) >= 0) | |
3705 v24 = 1; | |
3706 else | |
3707 { | |
3708 uXa = -uXa; | |
3709 v24 = -1; | |
3710 } | |
3711 v25 = 0; | |
3712 | |
3713 v26 = (unsigned __int16 *)this->pTargetSurface; | |
3714 if ( v26 ) | |
3715 { | |
3716 if ( (signed int)uXa <= v23 )//ðèñóåì âåðòèêàëüíóþ ëèíèþ | |
3717 { | |
3718 v30 = v23 + 1; | |
3719 if ( v30 > 0 ) | |
3720 { | |
3721 v31 = 2 * v24; | |
3722 v32 = 2 * v21; | |
3723 //v12 = (int)&v26[v12]; | |
3724 int y = 0; | |
3725 int x = 0; | |
3726 for ( v30; v30; --v30 ) | |
0 | 3727 { |
2199 | 3728 v25 += uXa; |
3729 //*(short *)v12 = uColor; | |
3730 //v12 += v32; | |
3731 WritePixel16(uX + x, uY + y, uColor); | |
3732 if ( v32 >= 0 ) | |
3733 y += 1; | |
3734 else | |
3735 y -= 1; | |
3736 if ( v25 > 0 ) | |
0 | 3737 { |
2199 | 3738 v25 -= uYb; |
3739 //v12 += v31; | |
3740 if ( v31 >= 0 ) | |
2096 | 3741 x += 1; |
3742 else | |
3743 x -= 1; | |
0 | 3744 } |
3745 } | |
3746 } | |
3747 } | |
2199 | 3748 else//ðèñóåì ãîðèçîíòàëüíóþ ëèíèþ |
3749 { | |
3750 v27 = uXa + 1; | |
3751 if ( (signed int)(uXa + 1) > 0 ) | |
3752 { | |
3753 v28 = 2 * v21; | |
3754 v29 = 2 * v24; | |
3755 int y = 0; | |
3756 int x = 0; | |
3757 //v12 = (int)&v26[v12]; | |
3758 for ( v27; v27; --v27 ) | |
3759 { | |
3760 v25 += uYb; | |
3761 //*(short *)v12 = uColor; | |
3762 //v12 += v29; | |
3763 WritePixel16(uX + x, uY + y, uColor); | |
3764 if ( v29 >= 0 ) | |
3765 x += 1; | |
3766 else | |
3767 x -= 1; | |
3768 if ( v25 > (signed int)uXa ) | |
3769 { | |
3770 v25 -= uXa; | |
3771 //v12 += v28; | |
3772 if ( v28 >= 0 ) | |
3773 y += 1; | |
3774 else | |
3775 y -= 1; | |
3776 } | |
3777 } | |
3778 } | |
3779 } | |
3780 } | |
0 | 3781 } |
2102 | 3782 return; |
0 | 3783 } |
3784 | |
3785 //----- (004A0E80) -------------------------------------------------------- | |
3786 void Render::ClearZBuffer(int a2, int a3) | |
3787 { | |
2245 | 3788 memset32(this->pActiveZBuffer, -65536, 0x4B000); |
0 | 3789 } |
3790 | |
3791 //----- (004A0E97) -------------------------------------------------------- | |
709 | 3792 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
3793 { | |
3794 this->raster_clip_x = uX; | |
3795 this->raster_clip_y = uY; | |
3796 this->raster_clip_z = uZ; | |
3797 this->raster_clip_w = uW; | |
0 | 3798 } |
3799 | |
3800 //----- (004A0EB6) -------------------------------------------------------- | |
3801 void Render::ParseTargetPixelFormat() | |
3802 { | |
3803 signed int v2; // ecx@1 | |
3804 DWORD uRedMask; // edx@1 | |
3805 unsigned int uGreenMask; // esi@5 | |
3806 signed int v5; // ecx@5 | |
3807 unsigned int uBlueMask; // edx@9 | |
3808 signed int v7; // ecx@9 | |
2069 | 3809 //unsigned int v8; // ecx@13 |
0 | 3810 |
3811 v2 = 0; | |
2132 | 3812 uRedMask = this->ddpfPrimarySuface.dwRBitMask; |
3813 this->uTargetBBits = 0; | |
3814 this->uTargetGBits = 0; | |
3815 this->uTargetRBits = 0; | |
0 | 3816 do |
3817 { | |
3818 if ( (1 << v2) & uRedMask ) | |
2132 | 3819 ++this->uTargetRBits; |
0 | 3820 ++v2; |
3821 } | |
2069 | 3822 while ( v2 < 32 ); |
2132 | 3823 uGreenMask = this->ddpfPrimarySuface.dwGBitMask; |
0 | 3824 v5 = 0; |
3825 do | |
3826 { | |
3827 if ( (1 << v5) & uGreenMask ) | |
2132 | 3828 ++this->uTargetGBits; |
0 | 3829 ++v5; |
3830 } | |
2069 | 3831 while ( v5 < 32 ); |
2132 | 3832 uBlueMask = this->ddpfPrimarySuface.dwBBitMask; |
0 | 3833 v7 = 0; |
3834 do | |
3835 { | |
3836 if ( (1 << v7) & uBlueMask ) | |
2132 | 3837 ++this->uTargetBBits; |
0 | 3838 ++v7; |
3839 } | |
2069 | 3840 while ( v7 < 32 ); |
2132 | 3841 this->uTargetGMask = uGreenMask; |
3842 this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask; | |
3843 this->uTargetBMask = uBlueMask; | |
0 | 3844 } |
3845 | |
3846 //----- (004A0F40) -------------------------------------------------------- | |
3847 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
3848 { | |
2132 | 3849 //IDirectDrawSurface4 *v4; // esi@1 |
168 | 3850 HRESULT result; // eax@1 |
0 | 3851 HRESULT v6; // eax@4 |
3852 int v7; // [sp-8h] [bp-14h]@10 | |
3853 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
3854 char v9; // [sp+Bh] [bp-1h]@1 | |
3855 | |
2132 | 3856 //v4 = pSurface; |
0 | 3857 v9 = 1; |
3858 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
3859 if ( result == DDERR_SURFACELOST ) | |
3860 { | |
2132 | 3861 v6 = pSurface->Restore(); |
0 | 3862 if ( v6 ) |
3863 { | |
3864 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
3865 { | |
3866 LABEL_20: | |
3867 v9 = 0; | |
3868 result = (bool)memset(pDesc, 0, 4u); | |
3869 goto LABEL_21; | |
3870 } | |
3871 pRenderer->pFrontBuffer4->Restore(); | |
2132 | 3872 pSurface->Restore(); |
3873 } | |
3874 result = pSurface->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
0 | 3875 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) |
3876 goto LABEL_20; | |
3877 ErrD3D(result); | |
3878 if ( result ) | |
3879 { | |
3880 //v8 = 0; | |
3881 //v7 = 2161; | |
3882 LABEL_19: | |
3883 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
3884 goto LABEL_20; | |
3885 } | |
3886 if ( pRenderer->pRenderD3D ) | |
3887 pRenderD3D->HandleLostResources(); | |
3888 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
3889 } | |
3890 else | |
3891 { | |
3892 if ( result ) | |
3893 { | |
3894 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3895 goto LABEL_20; | |
3896 ErrD3D(result); | |
3897 //v8 = 0; | |
3898 //v7 = 2199; | |
3899 //goto LABEL_19; | |
3900 } | |
3901 } | |
3902 LABEL_21: | |
3903 LOBYTE(result) = v9; | |
3904 return result; | |
3905 } | |
3906 | |
3907 | |
3908 //----- (004A10E4) -------------------------------------------------------- | |
3909 void Render::CreateDirectDraw() | |
3910 { | |
3911 Render *v1; // edi@1 | |
3912 HRESULT v2; // eax@1 | |
3913 HRESULT v3; // eax@5 | |
3914 int v6; // [sp-Ch] [bp-20h]@3 | |
3915 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
3916 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
3917 | |
3918 v1 = this; | |
3919 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
3920 | |
3921 pDirectDraw4 = nullptr; | |
3922 | |
2152 | 3923 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); |
0 | 3924 |
3925 lpDD->Release(); | |
3926 lpDD = nullptr; | |
3927 } | |
3928 | |
3929 //----- (004A1169) -------------------------------------------------------- | |
3930 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
3931 { | |
3932 DWORD flags; // eax@1 | |
3933 IDirectDraw *v4; // ecx@3 | |
3934 HRESULT v5; // eax@5 | |
3935 int v6; // [sp-8h] [bp-8h]@3 | |
3936 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
3937 | |
3938 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
3939 DDSCL_NORMAL; | |
3940 | |
2152 | 3941 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); |
0 | 3942 } |
3943 | |
3944 //----- (004A11C6) -------------------------------------------------------- | |
3945 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
3946 { | |
2152 | 3947 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); |
0 | 3948 } |
3949 | |
3950 //----- (004A121C) -------------------------------------------------------- | |
3951 void Render::CreateFrontBuffer() | |
3952 { | |
3953 Render *v1; // esi@1 | |
3954 IDirectDraw *pDD; // eax@3 | |
3955 IDirectDrawSurface **pOutSurf; // esi@3 | |
3956 struct _DDSURFACEDESC *v4; // edx@3 | |
3957 HRESULT v5; // eax@5 | |
3958 int v6; // [sp-8h] [bp-8Ch]@3 | |
3959 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
3960 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
3961 | |
3962 v1 = this; | |
2152 | 3963 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
3964 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 3965 { |
3966 memset(&a2, 0, 0x7Cu); | |
3967 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
3968 a2.dwSize = 124; | |
3969 a2.dwFlags = 1; | |
3970 v7 = 0; | |
3971 a2.ddsCaps.dwCaps = 512; | |
3972 v6 = 2357; | |
3973 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
3974 v4 = (struct _DDSURFACEDESC *)&a2; | |
3975 } | |
2152 | 3976 /*else |
0 | 3977 { |
3978 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
3979 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
3980 a2.lPitch = 108; | |
3981 a2.dwBackBufferCount = 1; | |
3982 v7 = 0; | |
3983 a2.dwTextureStage = 512; | |
3984 v6 = 2346; | |
3985 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
3986 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
2152 | 3987 }*/ |
0 | 3988 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); |
3989 } | |
3990 | |
3991 //----- (004A12CD) -------------------------------------------------------- | |
3992 void Render::CreateBackBuffer() | |
3993 { | |
3994 Render *v1; // esi@1 | |
3995 IDirectDraw *v2; // eax@3 | |
3996 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
3997 struct _DDSURFACEDESC *v4; // edx@3 | |
3998 HRESULT v5; // eax@5 | |
3999 int v6; // [sp-8h] [bp-8Ch]@3 | |
4000 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4001 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4002 | |
4003 v1 = this; | |
2152 | 4004 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4005 // pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4006 { |
4007 memset(&a2, 0, 0x7Cu); | |
4008 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
4009 a2.dwSize = 124; | |
4010 a2.dwFlags = 7; | |
4011 v7 = 0; | |
4012 a2.ddsCaps.dwCaps = 2112; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
4013 a2.dwWidth = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
4014 a2.dwHeight = window->GetHeight(); |
0 | 4015 v6 = 2387; |
4016 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4017 v4 = (struct _DDSURFACEDESC *)&a2; | |
4018 } | |
2152 | 4019 /*else |
0 | 4020 { |
4021 memset(&a2.lPitch, 0, 0x6Cu); | |
4022 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4023 a2.lPitch = 108; | |
4024 a2.dwBackBufferCount = 7; | |
4025 v7 = 0; | |
4026 a2.dwTextureStage = 2112; | |
4027 a2.dwAlphaBitDepth = 640; | |
4028 a2.dwMipMapCount = 480; | |
4029 v6 = 2374; | |
4030 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4031 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
2152 | 4032 }*/ |
0 | 4033 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); |
4034 } | |
4035 | |
4036 //----- (004A139A) -------------------------------------------------------- | |
4037 void Render::CreateDirectDrawPrimarySurface() | |
4038 { | |
4039 Render *v1; // esi@1 | |
2154 | 4040 //int v2; // ebx@3 |
0 | 4041 IDirectDraw2 *v3; // eax@3 |
4042 HRESULT v4; // eax@3 | |
4043 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
4044 DDSCAPS2 *v6; // edx@3 | |
4045 IDirectDraw4 *v7; // eax@4 | |
4046 HRESULT v8; // eax@4 | |
4047 int v9; // ST14_4@5 | |
4048 IDirectDrawSurface *v10; // ST10_4@5 | |
4049 HRESULT v11; // eax@5 | |
4050 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
4051 const char *v13; // [sp+0h] [bp-A0h]@0 | |
4052 int v14; // [sp+4h] [bp-9Ch]@0 | |
4053 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
4054 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
4055 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
4056 int a4; // [sp+98h] [bp-8h]@3 | |
4057 | |
4058 v1 = this; | |
2152 | 4059 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4060 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4061 { |
2154 | 4062 //v2 = 0; |
4063 //this->field_4004C = 1; | |
0 | 4064 memset(&ddsd2, 0, 0x7Cu); |
4065 v7 = v1->pDirectDraw4; | |
4066 ddsd2.dwBackBufferCount = 1; | |
4067 ddsd2.dwSize = 0x7Cu; | |
4068 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4069 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4070 ErrD3D(v7->CreateSurface( | |
4071 &ddsd2, | |
4072 &pFrontBuffer4, | |
4073 0)); | |
4074 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
4075 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4076 } | |
2152 | 4077 /*else |
0 | 4078 { |
4079 v2 = 0; | |
4080 this->field_4004C = 1; | |
4081 | |
4082 DDSURFACEDESC ddsd; | |
4083 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4084 | |
4085 ddsd.lpSurface = (LPVOID)1; | |
4086 ddsd.lPitch = 108; | |
4087 ddsd.dwBackBufferCount = 33; | |
4088 ddsd.ddsCaps.dwCaps = 8728; | |
4089 ErrD3D(pDirectDraw2->CreateSurface( | |
4090 &ddsd, | |
4091 (IDirectDrawSurface **)&pFrontBuffer2, | |
4092 0)); | |
4093 | |
4094 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4095 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
2152 | 4096 }*/ |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4097 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used |
0 | 4098 v9 = (int)v6; |
4099 v10 = pFrontBuffer; // BUG | |
4100 | |
4101 v17.dwCaps = 4; | |
4102 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4103 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
2154 | 4104 //v1->field_40030 = v2; |
4105 //v1->field_18_locked_pitch = v2; | |
0 | 4106 } |
4107 | |
4108 //----- (004A14F4) -------------------------------------------------------- | |
4109 void Render::CreateClipper(HWND a2) | |
4110 { | |
2152 | 4111 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); |
4112 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4113 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
0 | 4114 } |
4115 | |
4116 //----- (004A15D8) -------------------------------------------------------- | |
4117 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4118 { | |
2152 | 4119 pFrontBuffer4->GetPixelFormat(pOut); |
0 | 4120 } |
4121 | |
4122 //----- (004A1605) -------------------------------------------------------- | |
4123 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4124 { | |
4125 signed int v4; // eax@3 | |
4126 | |
2152 | 4127 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4128 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4129 { |
4130 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4131 memset(&pDesc, 0, 0x7Cu); | |
4132 pDesc.dwSize = 124; | |
2132 | 4133 LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4134 *pOutSurfacePtr = pDesc.lpSurface; |
4135 v4 = pDesc.lPitch; | |
4136 } | |
2152 | 4137 /*else |
0 | 4138 { |
4139 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4140 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4141 pDesc.lPitch = 108; | |
2132 | 4142 LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1); |
0 | 4143 *pOutSurfacePtr = (void *)pDesc.lpSurface; |
4144 v4 = pDesc.dwReserved; | |
2152 | 4145 }*/ |
0 | 4146 *pOutPixelsPerRow = v4 >> 1; |
4147 } | |
4148 | |
4149 //----- (004A16E1) -------------------------------------------------------- | |
4150 void Render::UnlockBackBuffer() | |
4151 { | |
2152 | 4152 ErrD3D(pBackBuffer4->Unlock(0)); |
0 | 4153 } |
4154 | |
4155 //----- (004A172E) -------------------------------------------------------- | |
4156 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4157 { | |
4158 signed int v4; // eax@3 | |
4159 | |
2152 | 4160 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4161 { |
4162 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4163 memset(&pDesc, 0, 0x7Cu); | |
4164 pDesc.dwSize = 124; | |
2132 | 4165 LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4166 *pOutSurface = pDesc.lpSurface; |
4167 v4 = pDesc.lPitch; | |
4168 } | |
2152 | 4169 /*else |
0 | 4170 { |
4171 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4172 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4173 pDesc.lPitch = 108; | |
2132 | 4174 LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1); |
0 | 4175 *pOutSurface = (void *)pDesc.lpSurface; |
4176 v4 = pDesc.dwReserved; | |
2152 | 4177 }*/ |
0 | 4178 *pOutPixelsPerRow = v4 >> 1; |
4179 } | |
4180 | |
4181 //----- (004A17C7) -------------------------------------------------------- | |
4182 void Render::UnlockFrontBuffer() | |
4183 { | |
2152 | 4184 ErrD3D(pFrontBuffer4->Unlock(0)); |
0 | 4185 } |
4186 | |
4187 //----- (004A1814) -------------------------------------------------------- | |
4188 void Render::RestoreFrontBuffer() | |
4189 { | |
2152 | 4190 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST ) |
4191 pFrontBuffer4->Restore(); | |
0 | 4192 } |
4193 | |
4194 //----- (004A184C) -------------------------------------------------------- | |
2152 | 4195 void Render::RestoreBackBuffer() |
4196 { | |
4197 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST ) | |
4198 pBackBuffer4->Restore(); | |
0 | 4199 } |
4200 | |
4201 //----- (004A18F5) -------------------------------------------------------- | |
4202 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4203 { | |
2152 | 4204 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); |
0 | 4205 } |
4206 | |
4207 //----- (004A194A) -------------------------------------------------------- | |
4208 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
4209 { | |
4210 IDirectDrawSurface *pFront; // eax@3 | |
4211 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
4212 | |
2152 | 4213 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4214 { |
4215 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4216 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4217 } | |
2152 | 4218 /*else |
0 | 4219 { |
4220 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4221 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
2152 | 4222 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4223 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 4224 } |
4225 | |
4226 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4227 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4228 { |
0 | 4229 unsigned int v7; // edx@6 |
2166 | 4230 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4231 if (uNumBillboardsToDraw >= 999 ) |
0 | 4232 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4233 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4234 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4235 uNumBillboardsToDraw = 1; |
0 | 4236 return 0; |
4237 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4238 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4239 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4240 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4241 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4242 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4243 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4244 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4245 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4246 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4247 |
2166 | 4248 if (z > pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4249 { |
4250 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
4251 v7 = pRenderer->uNumBillboardsToDraw; | |
4252 else | |
4253 { | |
4254 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4255 { | |
2166 | 4256 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
0 | 4257 { |
2166 | 4258 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], |
4259 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - (i + 1)], | |
4260 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
0 | 4261 } |
4262 } | |
4263 ++v7; | |
4264 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4265 uNumBillboardsToDraw++; |
0 | 4266 return v7; |
4267 } | |
2166 | 4268 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4269 { |
4270 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4271 { | |
2166 | 4272 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
4273 { | |
4274 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], | |
4275 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw -(i + 1)], | |
4276 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
4277 } | |
4278 } | |
717 | 4279 uNumBillboardsToDraw++; |
4280 return v7; | |
0 | 4281 } |
4282 return v7; | |
4283 } | |
4284 | |
4285 //----- (004A1E9D) -------------------------------------------------------- | |
4286 unsigned int Render::GetBillboardDrawListSize() | |
4287 { | |
4288 return pRenderer->uNumBillboardsToDraw; | |
4289 } | |
4290 | |
4291 //----- (004A1EA3) -------------------------------------------------------- | |
4292 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
4293 { | |
2002 | 4294 return pRenderer->pBillboardRenderListD3D[uBillboardID].sParentBillboardID; |
0 | 4295 } |
4296 | |
4297 //----- (004A1EB6) -------------------------------------------------------- | |
4298 void Render::BeginSceneD3D() | |
4299 { | |
4300 if (!uNumD3DSceneBegins++) | |
4301 { | |
2154 | 4302 //if (pRenderD3D) |
0 | 4303 { |
4304 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
4305 pRenderer->uNumBillboardsToDraw = 0; | |
4306 pRenderD3D->pDevice->BeginScene(); | |
1390 | 4307 |
0 | 4308 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
4309 uFogColor = GetLevelFogColor(); | |
4310 else | |
4311 uFogColor = 0; | |
4312 | |
4313 if ( uFogColor & 0xFF000000 ) | |
4314 { | |
4315 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
4316 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
4317 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4318 bUsingSpecular = true; | |
4319 } | |
4320 else | |
4321 { | |
4322 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
4323 bUsingSpecular = 0; | |
4324 } | |
4325 } | |
2154 | 4326 /*else |
0 | 4327 { |
4328 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
4329 if (pTargetSurface) | |
4330 field_18_locked_pitch = uTargetSurfacePitch; | |
4331 else | |
4332 --uNumD3DSceneBegins; | |
2154 | 4333 }*/ |
0 | 4334 } |
4335 } | |
4336 | |
4337 //----- (004A1FE1) -------------------------------------------------------- | |
4338 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
4339 { | |
4340 --uNumD3DSceneBegins; | |
4341 if (uNumD3DSceneBegins) | |
4342 return; | |
4343 | |
4344 if (pRenderD3D) | |
4345 { | |
4346 pGame->draw_debug_outlines(); | |
161 | 4347 DoRenderBillboards_D3D(); |
0 | 4348 pGame->pStru6Instance->RenderSpecialEffects(); |
4349 pRenderD3D->pDevice->EndScene(); | |
4350 } | |
4351 else | |
4352 pGame->pStru6Instance->RenderSpecialEffects(); | |
4353 } | |
4354 | |
4355 //----- (004A2031) -------------------------------------------------------- | |
349 | 4356 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
4357 { | |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4358 // __debugbreak(); // should not fire outside decal builder |
349 | 4359 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 4360 } |
4361 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4362 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 4363 { |
4364 int v5; // ebx@1 | |
4365 int v6; // edi@1 | |
4366 int v8; // eax@7 | |
4367 float v9; // eax@12 | |
4368 float *v10; // esi@12 | |
4369 float v11; // ecx@14 | |
4370 double v12; // st7@14 | |
4371 double v13; // st7@14 | |
4372 double v14; // st7@14 | |
4373 signed int v15; // eax@14 | |
4374 int v16; // eax@15 | |
4375 float v17; // ST48_4@15 | |
4376 char v18; // zf@17 | |
4377 int v19; // eax@18 | |
4378 int v20; // eax@18 | |
4379 int v21; // edx@20 | |
4380 signed int v22; // ecx@20 | |
4381 int v23; // eax@20 | |
4382 const char *v24; // ST4C_4@20 | |
4383 unsigned int v25; // ST50_4@20 | |
4384 int v26; // ST54_4@20 | |
4385 int v27; // eax@20 | |
4386 _UNKNOWN *v28; // eax@21 | |
4387 int v29; // ecx@23 | |
4388 int v30; // eax@23 | |
4389 int v31; // eax@23 | |
4390 int v32; // eax@24 | |
4391 int v33; // eax@25 | |
4392 int v34; // eax@25 | |
4393 int v35; // eax@25 | |
4394 int v36; // eax@25 | |
4395 signed int v37; // ecx@26 | |
4396 int v38; // eax@26 | |
4397 _UNKNOWN *v39; // eax@27 | |
4398 int v40; // edx@28 | |
4399 int v41; // eax@29 | |
4400 int v42; // eax@29 | |
4401 int v43; // eax@29 | |
4402 int v44; // eax@29 | |
4403 unsigned int v46; // eax@29 | |
4404 int v47; // eax@30 | |
4405 int v48; // eax@30 | |
4406 int v49; // eax@30 | |
4407 double v52; // st6@35 | |
4408 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
4409 int v57; // [sp+5Ch] [bp-Ch]@3 | |
4410 signed int v59; // [sp+60h] [bp-8h]@12 | |
4411 int v61; // [sp+64h] [bp-4h]@4 | |
4412 int i; | |
4413 | |
4414 v6 = (int)this; | |
4415 v5 = 0; | |
4416 if (!this->uNumD3DSceneBegins) | |
4417 return; | |
4418 | |
4419 | |
4420 | |
4421 | |
186 | 4422 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 4423 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
4424 if (this->bUsingSpecular) | |
4425 { | |
186 | 4426 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4427 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4428 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 4429 } |
4430 | |
4431 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
4432 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
1637 | 4433 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4434 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); |
4435 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
4436 pVertices[0].specular = 0; | |
4437 pVertices[0].texcoord.x = array_50AC10[0].u; | |
4438 pVertices[0].texcoord.y = array_50AC10[0].v; | |
4439 | |
4440 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
4441 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
1637 | 4442 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4443 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); |
4444 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
4445 pVertices[1].specular = 0; | |
4446 pVertices[1].texcoord.x = array_50AC10[3].u; | |
4447 pVertices[1].texcoord.y = array_50AC10[3].v; | |
4448 | |
4449 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
4450 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
1637 | 4451 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4452 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); |
4453 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
4454 pVertices[2].specular = 0; | |
4455 pVertices[2].texcoord.x = array_50AC10[1].u; | |
4456 pVertices[2].texcoord.y = array_50AC10[1].v; | |
4457 | |
4458 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
4459 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
4460 | |
4461 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
4462 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
1637 | 4463 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4464 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); |
4465 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
4466 pVertices[5].specular = 0; | |
4467 pVertices[5].texcoord.x = array_50AC10[2].u; | |
4468 pVertices[5].texcoord.y = array_50AC10[2].v; | |
4469 | |
4470 | |
4471 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4472 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
4473 | |
186 | 4474 }*/ |
4475 | |
0 | 4476 //----- (004A26BC) -------------------------------------------------------- |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4477 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
186 | 4478 { |
4479 //RenderVertexSoft *pVertices; // esi@0 | |
4480 //int v7; // edi@1 | |
0 | 4481 unsigned int v8; // ebx@1 |
4482 LightmapBuilder *v9; // esi@3 | |
4483 unsigned int v10; // edx@3 | |
4484 int v11; // eax@5 | |
4485 int v12; // eax@11 | |
4486 char *v13; // esi@11 | |
4487 double v14; // st7@13 | |
4488 double v15; // st7@13 | |
4489 signed int v16; // eax@13 | |
4490 int v17; // ecx@13 | |
4491 double v18; // st7@13 | |
4492 float v19; // ST78_4@14 | |
4493 int v20; // eax@14 | |
4494 char v21; // zf@16 | |
4495 HRESULT v22; // eax@17 | |
4496 HRESULT v23; // eax@17 | |
4497 HRESULT v24; // eax@19 | |
4498 HRESULT v25; // eax@19 | |
4499 unsigned int v26; // ecx@19 | |
4500 char *v27; // eax@20 | |
4501 HRESULT v28; // eax@22 | |
4502 HRESULT v29; // eax@22 | |
4503 HRESULT v30; // eax@23 | |
4504 HRESULT v31; // eax@24 | |
4505 HRESULT v32; // eax@24 | |
4506 HRESULT v33; // eax@24 | |
4507 HRESULT v34; // eax@24 | |
4508 HRESULT v35; // eax@25 | |
4509 HRESULT v36; // eax@25 | |
4510 unsigned int v37; // ecx@25 | |
4511 char *v38; // eax@26 | |
4512 int v39; // edx@27 | |
4513 HRESULT v40; // eax@28 | |
4514 HRESULT v41; // eax@28 | |
4515 HRESULT v42; // eax@28 | |
4516 HRESULT v43; // eax@28 | |
4517 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
4518 unsigned int v45; // eax@28 | |
4519 HRESULT v46; // eax@29 | |
4520 HRESULT v47; // eax@29 | |
4521 HRESULT v48; // eax@29 | |
186 | 4522 //IDirect3DDevice3 *v49; // eax@35 |
0 | 4523 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
4524 int v51; // eax@40 | |
4525 char *v52; // esi@40 | |
4526 double v53; // st7@42 | |
4527 double v54; // st7@42 | |
4528 signed int v55; // eax@42 | |
4529 int v56; // ecx@42 | |
4530 double v57; // st7@42 | |
4531 float v58; // ST7C_4@43 | |
4532 int v59; // eax@43 | |
186 | 4533 //signed int v60; // [sp+78h] [bp-14h]@31 |
4534 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 4535 const char *v62; // [sp+80h] [bp-Ch]@0 |
4536 const char *v63; // [sp+80h] [bp-Ch]@19 | |
4537 int v64; // [sp+84h] [bp-8h]@0 | |
4538 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
4539 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
4540 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 4541 int a7; |
4542 | |
4543 //v7 = (int)this; | |
0 | 4544 v8 = 0; |
186 | 4545 if (!this->uNumD3DSceneBegins) |
75 | 4546 return; |
4547 if ( uNumVertices < 3) | |
4548 return; | |
4549 | |
186 | 4550 //v61 = pVertices; |
4551 | |
75 | 4552 /* v9 = pGame->pLightmapBuilder; |
0 | 4553 v65 = v9; |
75 | 4554 v10 = v9->std__vector_000004_size;*/ |
2155 | 4555 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 4556 { |
638 | 4557 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 4558 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); |
0 | 4559 } |
4560 else | |
4561 { | |
186 | 4562 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 4563 byte_4D864C && pGame->uFlags & 2 ) |
4564 { | |
186 | 4565 if (clampAtTextureBorders) |
4566 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 4567 else |
186 | 4568 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
4569 | |
4570 if (transparent || this->bUsingSpecular) | |
4571 { | |
4572 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4573 if (transparent) | |
0 | 4574 { |
186 | 4575 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
4576 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
4577 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
4578 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 4579 } |
4580 else | |
4581 { | |
186 | 4582 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
4583 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 4584 } |
186 | 4585 } |
1073 | 4586 |
4587 for (uint i = 0; i < uNumVertices; ++i) | |
4588 { | |
4589 | |
4590 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4591 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4592 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4593 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4594 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4595 if ( this->bUsingSpecular ) | |
0 | 4596 { |
2193
4842f58715ea
sub_47C3D7_get_fog_related_stuff to sub_47C3D7_get_fog_specular cleanup, IsTerrainSlopeTooHigh restoring commented out min,min/max,max implementation, some small changes in OnMapLoad, sub_4465DF_check_season attempted to pick the best readabilty/maintainability tradeoff
Grumpy7
parents:
2182
diff
changeset
|
4597 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4598 } |
1073 | 4599 else |
4600 { | |
4601 d3d_vertex_buffer[i].specular = 0; | |
4602 } | |
4603 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4604 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4605 } | |
4606 | |
4607 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4608 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
186 | 4609 if (transparent) |
4610 { | |
4611 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
4612 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4613 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4614 } |
4615 } | |
4616 else | |
4617 { | |
1073 | 4618 for (uint i = 0; i < uNumVertices; ++i) |
4619 { | |
4620 | |
4621 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4622 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4623 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4624 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4625 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4626 if ( this->bUsingSpecular ) | |
0 | 4627 { |
2193
4842f58715ea
sub_47C3D7_get_fog_related_stuff to sub_47C3D7_get_fog_specular cleanup, IsTerrainSlopeTooHigh restoring commented out min,min/max,max implementation, some small changes in OnMapLoad, sub_4465DF_check_season attempted to pick the best readabilty/maintainability tradeoff
Grumpy7
parents:
2182
diff
changeset
|
4628 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4629 } |
1073 | 4630 else |
4631 { | |
4632 d3d_vertex_buffer[i].specular = 0; | |
4633 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4634 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
1073 | 4635 d3d_vertex_buffer[i].specular = v20; |
4636 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4637 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4638 } | |
186 | 4639 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4640 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4641 if (pRenderer->bUsingSpecular) | |
4642 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 4643 |
4644 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 4645 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 4646 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4647 d3d_vertex_buffer, |
0 | 4648 uNumVertices, |
4649 16)); | |
4650 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 4651 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 4652 //(*(void (**)(void))(*(int *)v63 + 88))(); |
1394 | 4653 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
1073 | 4654 for (uint i = 0; i < uNumVertices; ++i) |
4655 { | |
4656 d3d_vertex_buffer[i].diffuse = -1; | |
4657 } | |
0 | 4658 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 4659 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4660 if ( !pRenderer->bUsingSpecular ) |
4661 { | |
186 | 4662 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4663 } | |
4664 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4665 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4666 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
4667 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4668 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4669 d3d_vertex_buffer, |
0 | 4670 uNumVertices, |
4671 16)); | |
4672 if ( pRenderer->bUsingSpecular ) | |
4673 { | |
186 | 4674 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4675 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 4676 for (uint i = 0; i < uNumVertices; ++i) |
4677 { | |
4678 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4679 d3d_vertex_buffer[i].specular = 0; | |
4680 } | |
4681 | |
75 | 4682 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 4683 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4684 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
4685 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4686 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4687 d3d_vertex_buffer, |
0 | 4688 uNumVertices, |
4689 16)); | |
186 | 4690 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4691 //v44 = pRenderer->pRenderD3D->pDevice; |
4692 v45 = GetLevelFogColor(); | |
4693 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
4694 v8 = 0; | |
4695 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
4696 } | |
186 | 4697 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4698 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4699 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
4700 } | |
4701 } | |
186 | 4702 |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
4703 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
1642 | 4704 if (pGame->pIndoorCameraD3D->debug_flags & ODM_RENDER_DRAW_TERRAIN_OUTLINES) |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4705 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 4706 } |
4707 // 4A26BC: could not find valid save-restore pair for esi | |
4708 // 4D864C: using guessed type char byte_4D864C; | |
4709 | |
4710 //----- (004A2DA3) -------------------------------------------------------- | |
1923 | 4711 void Render::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
852 | 4712 { |
67 | 4713 int v7; // eax@7 |
4714 | |
4715 if ( !this->uNumD3DSceneBegins ) | |
4716 return; | |
4717 if ( uNumVertices >= 3 ) | |
4718 { | |
186 | 4719 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 4720 if ( this->bUsingSpecular ) |
4721 { | |
186 | 4722 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4723 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4724 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 4725 } |
1427 | 4726 for ( uint i = 0; i < uNumVertices; ++i ) |
67 | 4727 { |
4728 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4729 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4730 pVertices[i].pos.z = 0.99989998; | |
168 | 4731 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 4732 |
840 | 4733 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 4734 v7 = 0; |
4735 if (this->bUsingSpecular) | |
2193
4842f58715ea
sub_47C3D7_get_fog_related_stuff to sub_47C3D7_get_fog_specular cleanup, IsTerrainSlopeTooHigh restoring commented out min,min/max,max implementation, some small changes in OnMapLoad, sub_4465DF_check_season attempted to pick the best readabilty/maintainability tradeoff
Grumpy7
parents:
2182
diff
changeset
|
4736 v7 = sub_47C3D7_get_fog_specular(0, 1, array_50AC10[i].vWorldViewPosition.x); |
67 | 4737 pVertices[i].specular = v7; |
4738 pVertices[i].texcoord.x = array_50AC10[i].u; | |
4739 pVertices[i].texcoord.y = array_50AC10[i].v; | |
4740 } | |
4741 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4742 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 4743 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 4744 } |
4745 } | |
4746 | |
4747 //----- (004A2ED5) -------------------------------------------------------- | |
1923 | 4748 void Render::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
0 | 4749 { |
4750 int v5; // eax@3 | |
4751 | |
4752 if ( this->uNumD3DSceneBegins ) | |
4753 { | |
1923 | 4754 if ( uNumVertices >= 3 ) |
0 | 4755 { |
186 | 4756 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1923 | 4757 v5 = 31 - (pSkyPolygon->dimming_level & 0x1F); |
638 | 4758 if ( v5 < pOutdoor->max_terrain_dimming_level ) |
4759 v5 = pOutdoor->max_terrain_dimming_level; | |
1937 | 4760 for (uint i = 0; i < uNumVertices; ++i) |
4761 { | |
4762 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
4763 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
1999 | 4764 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); |
1937 | 4765 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; |
4766 d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); | |
4767 d3d_vertex_buffer[i].specular = 0; | |
4768 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
4769 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
4770 } | |
1923 | 4771 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
1936 | 4772 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
4773 d3d_vertex_buffer, uNumVertices, 28)); | |
0 | 4774 } |
4775 } | |
4776 } | |
4777 | |
1390 | 4778 //----- (00479A53) -------------------------------------------------------- |
1923 | 4779 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID) |
1390 | 4780 { |
4781 BLVFace *pFace; // esi@1 | |
4782 double v5; // st7@3 | |
4783 signed __int64 v6; // qax@3 | |
4784 int v12; // edx@7 | |
4785 int v13; // eax@7 | |
4786 void *v15; // ecx@9 | |
4787 int v17; // edi@9 | |
4788 double v18; // st7@9 | |
4789 signed int v19; // ebx@9 | |
4790 void *v20; // ecx@9 | |
4791 int v21; // ebx@11 | |
4792 int v22; // eax@14 | |
4793 signed __int64 v23; // qtt@16 | |
4794 double v24; // st7@16 | |
4795 unsigned __int8 v25; // sf@16 | |
4796 unsigned __int8 v26; // of@16 | |
4797 double v28; // st7@20 | |
4798 char *v29; // ebx@20 | |
4799 char *v30; // edx@20 | |
4800 unsigned __int8 v31; // c0@21 | |
4801 unsigned __int8 v32; // c3@21 | |
4802 double v33; // st6@23 | |
4803 char *v34; // esi@30 | |
4804 const void *v35; // ecx@31 | |
4805 int v36; // eax@31 | |
4806 const void *v37; // edi@31 | |
4807 signed __int64 v38; // qax@31 | |
4808 int v39; // ecx@31 | |
4809 int v40; // ebx@33 | |
4810 int v41; // eax@36 | |
4811 signed __int64 v42; // qtt@39 | |
4812 int v43; // eax@39 | |
4813 char v44; // zf@39 | |
4814 double v45; // st7@39 | |
4815 double v46; // st7@39 | |
4816 unsigned int v47; // edx@40 | |
4817 double v48; // st7@41 | |
4818 RenderVertexSoft *v49; // ebx@41 | |
4819 void *v50; // edi@43 | |
4820 double v51; // st7@46 | |
4821 RenderVertexSoft *v52; // edx@46 | |
4822 void *v53; // edi@48 | |
4823 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
|
4824 struct Polygon *v60; // [sp+0h] [bp-174h]@17 |
1390 | 4825 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 |
1981 | 4826 struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6 |
1390 | 4827 unsigned int v63; // [sp+120h] [bp-54h]@7 |
4828 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
4829 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4830 //float v67; // [sp+130h] [bp-44h]@7 |
1390 | 4831 __int64 v69; // [sp+13Ch] [bp-38h]@3 |
4832 int v70; // [sp+144h] [bp-30h]@3 | |
4833 int X; // [sp+148h] [bp-2Ch]@9 | |
4834 int v72; // [sp+14Ch] [bp-28h]@7 | |
4835 float v73; // [sp+150h] [bp-24h]@16 | |
4836 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
1999 | 4837 unsigned int v74_; // [sp+154h] [bp-20h]@3 |
1390 | 4838 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 |
4839 float v76; // [sp+15Ch] [bp-18h]@9 | |
4840 int v77; // [sp+160h] [bp-14h]@9 | |
4841 int v78; // [sp+164h] [bp-10h]@7 | |
4842 void *v79; // [sp+168h] [bp-Ch]@9 | |
4843 float v80; // [sp+16Ch] [bp-8h]@3 | |
4844 const void *v81; // [sp+170h] [bp-4h]@7 | |
4845 | |
4846 pFace = &pIndoor->pFaces[uFaceID]; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4847 //for floor and wall(for example Selesta)------------------- |
1644 | 4848 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor) |
4849 { | |
4850 int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x; | |
4851 int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y; | |
4852 for (uint i = 0; i < uNumVertices; ++i) | |
4853 { | |
4854 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f; | |
4855 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f; | |
4856 } | |
4857 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0); | |
1390 | 4858 return; |
4859 } | |
1981 | 4860 //--------------------------------------- |
4861 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179 | |
1641 | 4862 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) |
1390 | 4863 * 65536.0) |
1922 | 4864 + (double)pBLVRenderParams->uViewportCenterY); |
1981 | 4865 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0 |
4866 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183 | |
1641 | 4867 - (double)pBLVRenderParams->fov_rad_fixpoint |
1644 | 4868 / ((cos(v5) * 16192.0 + 0.0000001) |
1390 | 4869 * 65535.0) |
1922 | 4870 * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); |
1644 | 4871 |
1999 | 4872 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); |
1981 | 4873 pSkyPolygon.Create_48607B(&stru_8019C8); |
4874 pSkyPolygon.uTileBitmapID = pFace->uBitmapID; | |
4875 | |
4876 pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID); | |
4877 if ( !pSkyPolygon.pTexture ) | |
1390 | 4878 return; |
1644 | 4879 |
1981 | 4880 pSkyPolygon.dimming_level = 0; |
4881 pSkyPolygon.uNumVertices = uNumVertices; | |
4882 | |
4883 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4884 pSkyPolygon.v_18.y = 0; | |
4885 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4886 | |
1644 | 4887 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices])); |
1981 | 4888 pSkyPolygon.field_24 = 0x2000000; |
1644 | 4889 |
4890 extern float _calc_fov(int viewport_width, int angle_degree); | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4891 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4892 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); |
1644 | 4893 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74); |
1981 | 4894 v12 = pSkyPolygon.pTexture->uWidthMinus1; |
4895 v13 = pSkyPolygon.pTexture->uHeightMinus1; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4896 //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth; |
1390 | 4897 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; |
4898 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
4899 v78 = 0; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4900 //v81 = 0; |
1981 | 4901 float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight; |
4902 if ( (signed int)pSkyPolygon.uNumVertices <= 0 ) | |
4903 return; | |
1644 | 4904 |
4905 int _507D30_idx = 0; | |
1999 | 4906 for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ ) |
1390 | 4907 { |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4908 //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)); |
2207 | 4909 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1981 | 4910 v74 = v77 + pSkyPolygon.ptr_38->angle_from_north; |
4911 | |
2207 | 4912 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1999 | 4913 v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east; |
1981 | 4914 |
2207 | 4915 v79 = (void *)(fixpoint_mul(pSkyPolygon.v_18.z, v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))); |
1644 | 4916 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX); |
4917 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0; | |
1981 | 4918 v19 = -pSkyPolygon.field_24; |
4919 v77 = -pSkyPolygon.field_24; | |
4920 X = (int)((char *)v79 + pSkyPolygon.v_18.x); | |
1390 | 4921 LODWORD(v76) = (signed __int64)v18; |
4922 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
4923 while ( 1 ) | |
4924 { | |
4925 v79 = v20; | |
4926 if ( !X ) | |
4927 goto LABEL_14; | |
4928 v21 = abs(v19 >> 14); | |
1999 | 4929 if ( v21 <= abs(X) )//0x800 <= 0x28652 |
1390 | 4930 break; |
4931 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
4932 break; | |
4933 v19 = v77; | |
4934 v20 = v79; | |
4935 LABEL_14: | |
2207 | 4936 v79 = (void *)fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); |
4937 v22 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); | |
1390 | 4938 --LODWORD(v76); |
4939 v20 = (char *)v20 + v72; | |
1981 | 4940 X = v22 + pSkyPolygon.v_18.x; |
1390 | 4941 v78 = 1; |
4942 } | |
4943 if ( !v78 ) | |
4944 { | |
4945 LODWORD(v23) = v77 << 16; | |
1981 | 4946 HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000 |
1997 | 4947 v79 = (void *)(v23 / X);//X = FFFF9014(-28652) |
1390 | 4948 v77 = v17; |
2207 | 4949 signed __int64 s = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v17);// s = 0xFFFFFFFF FFFF3EE6 |
4950 LODWORD(v80) = v66 + ((signed int)fixpoint_mul(SLODWORD(s), v23 / X) >> 4); | |
1981 | 4951 array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); |
4952 | |
2207 | 4953 signed __int64 s2 = v74_ + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v17); |
4954 LODWORD(v80) = v63 + ((signed int)fixpoint_mul(SLODWORD(s2), v23 / X) >> 4); | |
1981 | 4955 array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68; |
4956 | |
2207 | 4957 v77 = fixpoint_mul(SLODWORD(s), v23 / X); |
4958 LODWORD(v73) = fixpoint_mul(SLODWORD(s2), v23 / X); | |
1644 | 4959 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4960 |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4961 //if ( (int)v81 >= pSkyPolygon.uNumVertices ) |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4962 //{ |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4963 // pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4964 // pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4965 // return; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4966 //} |
1390 | 4967 continue; |
4968 } | |
4969 break; | |
4970 } | |
1999 | 4971 if ( _507D30_idx >= pSkyPolygon.uNumVertices ) |
4972 { | |
4973 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, | |
4974 pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
4975 return; | |
4976 } | |
1390 | 4977 LODWORD(v73) = 0; |
4978 v80 = v76; | |
1981 | 4979 if ( (signed int)pSkyPolygon.uNumVertices > 0 ) |
1390 | 4980 { |
4981 v28 = (double)SLODWORD(v76); | |
4982 LODWORD(v76) = (int)(char *)array_50AC10 + 28; | |
1997 | 4983 uint i = 0; |
4984 for ( v78 = pSkyPolygon.uNumVertices; v78; --v78 ) | |
4985 { | |
1390 | 4986 ++LODWORD(v73); |
1997 | 4987 memcpy(&array_50AC10[i], &array_507D30[i], 0x30u); |
1390 | 4988 LODWORD(v76) += 48; |
1997 | 4989 if ( v28 < array_507D30[i].vWorldViewProjY | v28 == array_507D30[i].vWorldViewProjY |
4990 || v28 >= array_507D30[i + 1].vWorldViewProjY ) | |
4991 { | |
4992 if ( v28 >= array_507D30[i].vWorldViewProjY || v28 <= array_507D30[i + 1].vWorldViewProjY ) | |
4993 { | |
4994 i++; | |
4995 continue; | |
4996 } | |
4997 v33 = (array_507D30[i + 1].vWorldViewProjX - array_507D30[i].vWorldViewProjX) * v28 / (array_507D30[i + 1].vWorldViewProjY - array_507D30[i].vWorldViewProjY) | |
4998 + array_507D30[i + 1].vWorldViewProjX; | |
1390 | 4999 } |
5000 else | |
5001 { | |
1997 | 5002 v33 = (array_507D30[i].vWorldViewProjX - array_507D30[i + 1].vWorldViewProjX) * v28 / (array_507D30[i].vWorldViewProjY - array_507D30[i + 1].vWorldViewProjY) |
5003 + array_507D30[i].vWorldViewProjX; | |
5004 } | |
5005 array_50AC10[i + 1].vWorldViewProjX = v33; | |
1390 | 5006 ++LODWORD(v73); |
5007 *(unsigned int *)LODWORD(v76) = v28; | |
5008 LODWORD(v76) += 48; | |
1997 | 5009 i++; |
5010 } | |
1390 | 5011 } |
5012 if ( SLODWORD(v73) <= 0 ) | |
5013 goto LABEL_40; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5014 //v34 = (char *)&array_50AC10[0].vWorldViewProjY; |
1997 | 5015 uint j = 0; |
1390 | 5016 v65 = v77 >> 14; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5017 //HIDWORD(v69) = LODWORD(v73); |
1997 | 5018 for ( int t = (int)LODWORD(v73); t > 1; t-- ) |
5019 { | |
5020 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjY)); | |
5021 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5022 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east; |
2207 | 5023 //v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v35); |
5024 v36 = (int)(fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, (int)v35) + pSkyPolygon.ptr_38->angle_from_north); | |
1997 | 5025 |
1390 | 5026 v81 = v35; |
5027 v74 = v36; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5028 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south; |
2207 | 5029 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, (int)v35); |
1390 | 5030 v78 = (int)v35; |
1981 | 5031 v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east); |
2207 | 5032 //v81 = (const void *)pSkyPolygon.v_18.z; |
5033 v78 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v35); | |
5034 v37 = (const void *)(v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX)); | |
1997 | 5035 v38 = (signed __int64)(array_50AC10[j].vWorldViewProjY - 1.0); |
1390 | 5036 v81 = 0; |
5037 LODWORD(v76) = v38; | |
5038 v39 = v72 * (v70 - v38); | |
5039 while ( 1 ) | |
5040 { | |
5041 v78 = v39; | |
5042 if ( !X ) | |
5043 goto LABEL_36; | |
5044 v40 = abs(X); | |
5045 if ( abs((signed __int64)v65) <= v40 ) | |
5046 break; | |
5047 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5048 break; | |
5049 v39 = v78; | |
5050 LABEL_36: | |
1981 | 5051 v78 = pSkyPolygon.v_18.z; |
2207 | 5052 v41 = fixpoint_mul(pSkyPolygon.v_18.z, v39); |
1390 | 5053 --LODWORD(v76); |
5054 v39 += v72; | |
1981 | 5055 X = v41 + pSkyPolygon.v_18.x; |
1390 | 5056 v81 = (const void *)1; |
5057 } | |
5058 if ( v81 ) | |
5059 { | |
1981 | 5060 v79 = (void *)pSkyPolygon.v_18.z; |
1390 | 5061 v78 = 2 * LODWORD(v76); |
2207 | 5062 v81 = (const void *)fixpoint_mul(pSkyPolygon.v_18.z, (((double)v70 - ((double)(2 * LODWORD(v76)) - array_50AC10[j].vWorldViewProjY)) |
5063 * (double)v72)); | |
1981 | 5064 X = (int)((char *)v81 + pSkyPolygon.v_18.x); |
1390 | 5065 } |
5066 LODWORD(v42) = v77 << 16; | |
5067 HIDWORD(v42) = v77 >> 16; | |
5068 v79 = (void *)(v42 / X); | |
5069 v81 = v37; | |
1997 | 5070 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5071 //v78 = pSkyPolygon.ptr_38->angle_from_west; |
2207 | 5072 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); |
5073 v43 = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); | |
1390 | 5074 v74 = (unsigned int)v37; |
5075 LODWORD(v76) = v43; | |
1997 | 5076 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5077 //v78 = pSkyPolygon.ptr_38->angle_from_south; |
2207 | 5078 v75 = (RenderVertexSoft *)((char *)v75 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, (int)v37)); |
5079 //v74 = fixpoint_mul(v43, v42 / X); | |
5080 v81 = (const void *)fixpoint_mul((int)v75, v42 / X); | |
1997 | 5081 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5082 //v34 += 48; |
2207 | 5083 //v78 = v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4); |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5084 //v44 = HIDWORD(v69)-- == 1; |
2207 | 5085 //v45 = (double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022; |
5086 //v78 = v63 + ((signed int)fixpoint_mul((int)v75, v42 / X) >> 4); | |
5087 array_50AC10[j].u = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); | |
5088 array_50AC10[j].v = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * v68; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5089 //v46 = (double)(signed int)v79; |
1997 | 5090 array_50AC10[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79; |
5091 array_50AC10[j]._rhw = 65536.0 / (double)(signed int)v79; | |
5092 ++j; | |
5093 } | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5094 //while ( !v44 ); |
1390 | 5095 LABEL_40: |
1997 | 5096 uint i = 0; |
1390 | 5097 if ( SLODWORD(v73) > 0 ) |
5098 { | |
5099 v48 = (double)SLODWORD(v80); | |
1997 | 5100 for ( HIDWORD(v69) = LODWORD(v73); HIDWORD(v69); --HIDWORD(v69) ) |
5101 { | |
5102 if ( v48 >= array_50AC10[i].vWorldViewProjY ) | |
5103 { | |
5104 ++i; | |
5105 memcpy(&array_507D30[i], &array_50AC10[i], 0x30u); | |
5106 } | |
5107 } | |
5108 } | |
5109 pSkyPolygon.uNumVertices = i; | |
5110 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5111 int pNumVertices = 0; | |
1390 | 5112 if ( SLODWORD(v73) > 0 ) |
5113 { | |
5114 v51 = (double)SLODWORD(v80); | |
1997 | 5115 for ( v80 = v73; v80 != 0.0; --LODWORD(v80) ) |
5116 { | |
5117 if ( v51 <= array_50AC10[pNumVertices].vWorldViewProjY ) | |
5118 { | |
5119 ++pNumVertices; | |
5120 memcpy(&array_507D30[pNumVertices], &array_50AC10[pNumVertices], 0x30u); | |
5121 } | |
5122 } | |
5123 } | |
5124 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
1390 | 5125 } |
5126 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5127 |
0 | 5128 //----- (004A2FC0) -------------------------------------------------------- |
5129 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
5130 { | |
5131 //Render *v8; // edi@1 | |
5132 //unsigned int v9; // esi@3 | |
1072 | 5133 RenderVertexSoft *v12; // ecx@9 |
5134 RenderVertexD3D3 *v13; // eax@9 | |
0 | 5135 double v14; // st6@10 |
5136 int v15; // edx@10 | |
5137 Texture *v16; // edx@10 | |
5138 double v17; // st6@10 | |
5139 //char v18; // zf@10 | |
5140 Texture *v19; // edx@10 | |
595 | 5141 //Texture *v23; // edx@16 |
5142 //char *v24; // ecx@16 | |
5143 //char *v25; // eax@16 | |
5144 //double v26; // st6@17 | |
5145 //int v27; // esi@17 | |
5146 //double v28; // st6@17 | |
5147 //unsigned int v33; // ecx@18 | |
5148 //char *v34; // eax@19 | |
0 | 5149 //Texture *v45; // edx@23 |
5150 //char *v46; // ecx@23 | |
5151 //char *v47; // eax@23 | |
5152 //double v48; // st6@24 | |
5153 //int v49; // esi@24 | |
5154 //double v50; // st6@24 | |
5155 const char *v53; // [sp-Ch] [bp-20h]@21 | |
5156 //int v54; // [sp-8h] [bp-1Ch]@21 | |
5157 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
5158 const char *v56; // [sp+0h] [bp-14h]@0 | |
5159 int v57; // [sp+4h] [bp-10h]@0 | |
5160 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
5161 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
5162 //int a3a; // [sp+10h] [bp-4h]@4 | |
5163 | |
5164 //v8 = this; | |
5165 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
5166 return; | |
5167 | |
5168 //auto a3 = pFace; | |
5169 //auto a6 = uPackedID; | |
5170 //v59 = pGame->pLightmapBuilder; | |
5171 //v9 = v59->std__vector_000004_size; | |
5172 | |
2006 | 5173 int sCorrectedColor = uColor; |
0 | 5174 if (pGame->pLightmapBuilder->std__vector_000004_size) |
2006 | 5175 sCorrectedColor = -1; |
5176 pGame->AlterGamma_BLV(pFace, &sCorrectedColor); | |
0 | 5177 |
792 | 5178 |
5179 if (pFace->uAttributes & FACE_OUTLINED) | |
5180 { | |
5181 int color; | |
5182 if (GetTickCount() % 300 >= 150) | |
2006 | 5183 uColor = sCorrectedColor = 0xFF20FF20; |
5184 else uColor = sCorrectedColor = 0xFF109010; | |
792 | 5185 } |
5186 | |
2155 | 5187 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 5188 { |
5189 __debugbreak(); | |
5190 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 5191 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 5192 for (uint i = 0; i < uNumVertices; ++i) |
5193 { | |
5194 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5195 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5196 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5197 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5198 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
1072 | 5199 d3d_vertex_buffer[i].specular = 0; |
5200 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5201 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5202 } | |
5203 | |
186 | 5204 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5205 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
5206 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
5207 D3DPT_TRIANGLEFAN, | |
5208 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5209 d3d_vertex_buffer, |
0 | 5210 uNumVertices, |
5211 28)); | |
1394 | 5212 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
0 | 5213 } |
5214 else | |
5215 { | |
5216 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
5217 byte_4D864C && pGame->uFlags & 2) | |
5218 { | |
5219 for (uint i = 0; i < uNumVertices; ++i) | |
5220 { | |
186 | 5221 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
5222 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5223 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5224 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5225 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
186 | 5226 d3d_vertex_buffer[i].specular = 0; |
5227 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5228 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5229 } | |
5230 | |
5231 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 5232 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
5233 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5234 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5235 d3d_vertex_buffer, |
0 | 5236 uNumVertices, |
5237 28)); | |
5238 } | |
5239 else | |
5240 { | |
595 | 5241 for (uint i = 0; i < uNumVertices; ++i) |
5242 { | |
5243 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5244 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5245 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5246 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5247 d3d_vertex_buffer[i].diffuse = uColor; | |
5248 d3d_vertex_buffer[i].specular = 0; | |
5249 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5250 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5251 } | |
5252 //__debugbreak(); | |
5253 //if ( (signed int)uNumVertices > 0 ) | |
5254 //{ | |
5255 //v23 = pTex; | |
5256 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
5257 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
5258 //pTex = (Texture *)uNumVertices; | |
5259 //uint v18; | |
5260 //do | |
5261 //{ | |
5262 //v26 = *(float *)v24 * 0.061758894; | |
5263 //v27 = *((int *)v24 + 3); | |
5264 //*((int *)v25 + 4) = 0; | |
5265 //*((int *)v25 - 1) = v27; | |
5266 //*(int *)v25 = *((int *)v24 + 4); | |
5267 //*((int *)v25 + 3) = uColor; | |
5268 //v25 += 32; | |
5269 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
5270 //v28 = 1.0 / *(float *)v24; | |
5271 //v24 += 48; | |
5272 //v18 = pTex == (Texture *)1; | |
5273 //pTex = (Texture *)((char *)pTex - 1); | |
5274 //*((float *)v25 - 6) = v28; | |
0 | 5275 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 5276 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 5277 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 5278 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
5279 //} | |
5280 //while ( !v18 ); | |
5281 //} | |
0 | 5282 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 5283 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5284 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 5285 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5286 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5287 d3d_vertex_buffer, |
0 | 5288 uNumVertices, |
5289 28)); | |
595 | 5290 |
5291 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1394 | 5292 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
595 | 5293 |
5294 for (uint i = 0; i < uNumVertices; ++i) | |
2006 | 5295 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
595 | 5296 /*v33 = uNumVertices; |
0 | 5297 if ( (signed int)uNumVertices > 0 ) |
5298 { | |
186 | 5299 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 5300 do |
5301 { | |
5302 *(int *)v34 = uCorrectedColor; | |
5303 v34 += 32; | |
5304 --v33; | |
5305 } | |
5306 while ( v33 ); | |
595 | 5307 }*/ |
0 | 5308 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5309 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
5310 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5311 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5312 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5313 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
5314 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 5315 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5316 d3d_vertex_buffer, |
0 | 5317 uNumVertices, |
5318 28)); | |
186 | 5319 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
5320 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5321 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 5322 } |
5323 } | |
5324 } | |
5325 // 4D864C: using guessed type char byte_4D864C; | |
5326 | |
5327 //----- (004A43B1) -------------------------------------------------------- | |
717 | 5328 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
5329 { | |
5330 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
5331 //double v5; // st7@2 | |
5332 //float v6; // ST08_4@2 | |
0 | 5333 unsigned int v7; // eax@2 |
717 | 5334 //int v8; // ecx@2 |
5335 //unsigned int v9; // esi@2 | |
5336 //Sprite *v10; // edi@5 | |
0 | 5337 signed int v11; // eax@9 |
5338 signed int v12; // eax@9 | |
717 | 5339 //double v13; // st7@12 |
5340 //double v14; // st6@12 | |
0 | 5341 double v15; // st5@12 |
5342 double v16; // st4@12 | |
5343 double v17; // st3@12 | |
5344 double v18; // st2@12 | |
5345 int v19; // ecx@14 | |
5346 double v20; // st3@14 | |
5347 int v21; // ecx@16 | |
5348 double v22; // st3@16 | |
717 | 5349 //IDirect3DTexture2 *v23; // eax@18 |
5350 //signed int v24; // [sp+18h] [bp-18h]@5 | |
5351 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
5352 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 5353 float v27; // [sp+24h] [bp-Ch]@5 |
5354 int v28; // [sp+28h] [bp-8h]@2 | |
5355 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 5356 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 5357 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 5358 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 5359 float a1; // [sp+40h] [bp+10h]@5 |
5360 | |
717 | 5361 //v26 = this; |
0 | 5362 if ( this->uNumD3DSceneBegins ) |
5363 { | |
717 | 5364 //v4 = pSoftBillboard; |
5365 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
5366 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
5367 //v6 = pSoftBillboard->zbuffer_depth; | |
5368 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
5369 //v8 = dimming_level; | |
5370 //v9 = v7; | |
657 | 5371 v28 = dimming_level & 0xFF000000; |
5372 if ( dimming_level & 0xFF000000 ) | |
2155 | 5373 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3; |
0 | 5374 else |
2155 | 5375 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent; |
717 | 5376 //v10 = a3; |
5377 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
5378 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
2002 | 5379 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID; |
717 | 5380 //v25 = pSoftBillboard->uScreenSpaceX; |
5381 //v24 = pSoftBillboard->uScreenSpaceY; | |
5382 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
5383 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
5384 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5385 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
5386 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5387 v31 = v31 * -1.0; |
2006 | 5388 if ( pSoftBillboard->sTintColor && this->bTinting ) |
717 | 5389 { |
5390 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
2006 | 5391 v12 = BlendColors(pSoftBillboard->sTintColor, v11); |
0 | 5392 if ( v28 ) |
5393 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
5394 } | |
5395 else | |
5396 { | |
717 | 5397 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
5398 } | |
5399 //v13 = (double)v25; | |
1390 | 5400 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; |
5401 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
5402 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
717 | 5403 //v14 = (double)v24; |
5404 //v32 = v14; | |
1390 | 5405 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; |
717 | 5406 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); |
1390 | 5407 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; |
717 | 5408 v16 = 1.0 / pSoftBillboard->zbuffer_depth; |
1390 | 5409 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; |
5410 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
5411 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
717 | 5412 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); |
5413 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
5414 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5415 v17 = v17 * -1.0; |
1390 | 5416 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; |
5417 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
5418 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
5419 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
5420 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
5421 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
5422 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
5423 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
717 | 5424 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; |
5425 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5426 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5427 v20 = v20 * -1.0; |
1390 | 5428 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; |
5429 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
5430 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
5431 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
5432 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
5433 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
5434 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
5435 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
717 | 5436 v21 = pSprite->uBufferHeight - pSprite->uAreaY; |
5437 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5438 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5439 v22 = v22 * -1.0; |
1390 | 5440 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; |
5441 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
5442 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
5443 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
5444 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
5445 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
5446 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
5447 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
717 | 5448 //v23 = pSprite->pTexture; |
5449 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
5450 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
5451 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 5452 } |
5453 } | |
5454 | |
5455 //----- (004A354F) -------------------------------------------------------- | |
5456 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5457 { | |
743 | 5458 //double v5; // st7@3 |
5459 //float v6; // ST20_4@3 | |
5460 //float v7; // ST00_4@3 | |
0 | 5461 unsigned int v8; // esi@3 |
743 | 5462 //int v9; // eax@3 |
5463 //int v10; // ebx@3 | |
0 | 5464 float v11; // ST28_4@3 |
743 | 5465 //double v12; // st7@3 |
5466 //float v13; // ST24_4@3 | |
5467 //double v14; // st6@3 | |
5468 //float v15; // ST1C_4@3 | |
0 | 5469 float v16; // ST2C_4@3 |
5470 float v17; // ST30_4@3 | |
5471 signed int v18; // ST18_4@3 | |
5472 signed int v19; // ST14_4@3 | |
5473 signed int v20; // ST10_4@3 | |
5474 signed int v21; // eax@3 | |
5475 double v22; // st6@3 | |
5476 float v23; // ST2C_4@3 | |
5477 float v24; // ST30_4@3 | |
5478 signed int v25; // ST10_4@3 | |
5479 signed int v26; // ST14_4@3 | |
5480 signed int v27; // ST18_4@3 | |
5481 signed int v28; // eax@3 | |
5482 double v29; // st6@3 | |
5483 float v30; // ecx@3 | |
5484 float v31; // ST2C_4@3 | |
5485 float v32; // ST30_4@3 | |
5486 signed int v33; // ST10_4@3 | |
5487 signed int v34; // ST14_4@3 | |
5488 signed int v35; // ST18_4@3 | |
5489 signed int v36; // eax@3 | |
5490 float v37; // ecx@3 | |
5491 double v38; // st6@3 | |
5492 float v39; // ST2C_4@3 | |
5493 float v40; // ST30_4@3 | |
5494 signed int v41; // ST10_4@3 | |
5495 signed int v42; // ST14_4@3 | |
5496 signed int v43; // ST18_4@3 | |
5497 signed int v44; // eax@3 | |
5498 double v45; // st6@3 | |
5499 float v46; // eax@3 | |
5500 | |
5501 if ( this->uNumD3DSceneBegins ) | |
5502 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5503 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5504 { |
743 | 5505 //v5 = (double)a2->zbuffer_depth; |
5506 //v6 = v5; | |
5507 //v7 = v5; | |
5508 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
2155 | 5509 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5510 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5511 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5512 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
743 | 5513 //v9 = a2->uScreenSpaceX; |
5514 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5515 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 5516 //v12 = (double) a2->uScreenSpaceX; |
5517 //v13 = v12; | |
5518 //v14 = (double)(a2->uScreenSpaceY - 12); | |
5519 //v15 = v14; | |
5520 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5521 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5522 v18 = stru_5C6E00->Cos(angle); |
5523 v19 = stru_5C6E00->Sin(angle); | |
5524 v20 = stru_5C6E00->Sin(angle); | |
5525 v21 = stru_5C6E00->Cos(angle); | |
1390 | 5526 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5527 + (double)(v18 >> 16)) |
5528 * v16 | |
5529 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
5530 + (double)(v19 >> 16)) | |
5531 * v17) | |
743 | 5532 * v11 + (double) a2->uScreenSpaceX; |
0 | 5533 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
5534 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
5535 - 12.0) | |
5536 * v11 | |
5537 + (double)a2->uScreenSpaceY; | |
1390 | 5538 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5539 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5540 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
5541 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
5542 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5543 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5544 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
743 | 5545 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5546 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5547 v25 = stru_5C6E00->Cos(angle); |
5548 v26 = stru_5C6E00->Sin(angle); | |
5549 v27 = stru_5C6E00->Sin(angle); | |
5550 v28 = stru_5C6E00->Cos(angle); | |
1390 | 5551 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
0 | 5552 + (double)(v25 >> 16)) |
740 | 5553 * v31 |
0 | 5554 - ((double)(unsigned __int16)v26 * 0.000015259022 |
5555 + (double)(v26 >> 16)) | |
740 | 5556 * v32) |
743 | 5557 * v11 + (double) a2->uScreenSpaceX; |
740 | 5558 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
5559 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 5560 - 12.0) |
5561 * v11 | |
5562 + (double)a2->uScreenSpaceY; | |
1390 | 5563 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5564 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5565 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
5566 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5567 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
5568 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5569 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5570 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
743 | 5571 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
5572 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5573 v33 = stru_5C6E00->Cos(angle); |
5574 v34 = stru_5C6E00->Sin(angle); | |
5575 v35 = stru_5C6E00->Sin(angle); | |
5576 v36 = stru_5C6E00->Cos(angle); | |
1390 | 5577 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
0 | 5578 + (double)(v33 >> 16)) |
740 | 5579 * v23 |
0 | 5580 - ((double)(unsigned __int16)v34 * 0.000015259022 |
5581 + (double)(v34 >> 16)) | |
740 | 5582 * v24) |
743 | 5583 * v11 + (double) a2->uScreenSpaceX; |
1390 | 5584 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
740 | 5585 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
5586 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 5587 - 12.0) |
5588 * v11 | |
5589 + (double)a2->uScreenSpaceY; | |
1390 | 5590 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5591 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
5592 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5593 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5594 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
5595 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5596 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
743 | 5597 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5598 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5599 v41 = stru_5C6E00->Cos(angle); |
5600 v42 = stru_5C6E00->Sin(angle); | |
5601 v43 = stru_5C6E00->Sin(angle); | |
5602 v44 = stru_5C6E00->Cos(angle); | |
1390 | 5603 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
0 | 5604 + (double)(v41 >> 16)) |
5605 * v39 | |
5606 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
5607 + (double)(v42 >> 16)) | |
5608 * v40) | |
743 | 5609 * v11 + (double) a2->uScreenSpaceX; |
0 | 5610 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
5611 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
5612 - 12.0) | |
5613 * v11 | |
5614 + (double)a2->uScreenSpaceY; | |
1390 | 5615 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5616 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5617 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
5618 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5619 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5620 pBillboardRenderListD3D[v8].pTexture = a3; |
743 | 5621 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 5622 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5623 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; |
5624 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5625 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5626 } |
5627 } | |
5628 } | |
5629 | |
5630 //----- (004A3AD9) -------------------------------------------------------- | |
5631 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5632 { | |
5633 double v5; // st7@2 | |
5634 float v6; // ST28_4@2 | |
5635 float v7; // ST00_4@2 | |
5636 unsigned int v8; // esi@2 | |
5637 int v9; // eax@2 | |
5638 int v10; // ebx@2 | |
5639 float v11; // ST34_4@2 | |
5640 double v12; // st7@2 | |
5641 float v13; // ST2C_4@2 | |
5642 double v14; // st6@2 | |
5643 float v15; // ST24_4@2 | |
5644 float v16; // ST38_4@2 | |
5645 float v17; // ST3C_4@2 | |
5646 signed int v18; // ST1C_4@2 | |
5647 int v19; // ST30_4@2 | |
5648 signed int v20; // ST20_4@2 | |
5649 signed int v21; // ST18_4@2 | |
5650 signed int v22; // eax@2 | |
5651 double v23; // st6@2 | |
5652 float v24; // ST20_4@2 | |
5653 float v25; // ST1C_4@2 | |
5654 float v26; // ST38_4@2 | |
5655 float v27; // ST3C_4@2 | |
5656 signed int v28; // ST18_4@2 | |
5657 signed int v29; // ST14_4@2 | |
5658 signed int v30; // ST10_4@2 | |
5659 signed int v31; // eax@2 | |
5660 double v32; // st6@2 | |
5661 float v33; // ST38_4@2 | |
5662 float v34; // ST3C_4@2 | |
5663 signed int v35; // ST10_4@2 | |
5664 signed int v36; // ST14_4@2 | |
5665 signed int v37; // ST18_4@2 | |
5666 signed int v38; // eax@2 | |
5667 double v39; // st6@2 | |
5668 float v40; // ST38_4@2 | |
5669 float v41; // ST3C_4@2 | |
5670 signed int v42; // ST10_4@2 | |
5671 signed int v43; // ST14_4@2 | |
5672 signed int v44; // ST18_4@2 | |
5673 signed int v45; // eax@2 | |
5674 double v46; // st6@2 | |
5675 | |
5676 if ( this->uNumD3DSceneBegins ) | |
5677 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5678 v5 = (double)a2->zbuffer_depth; |
0 | 5679 v6 = v5; |
5680 v7 = v5; | |
5681 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
2155 | 5682 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5683 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5684 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5685 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
0 | 5686 v9 = a2->uScreenSpaceX; |
5687 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5688 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 5689 v12 = (double)v9; |
5690 v13 = v12; | |
5691 v14 = (double)(v10 - 12); | |
5692 v15 = v14; | |
5693 v16 = (double)(v9 - 12) - v12; | |
5694 v17 = (double)(v10 - 25) - v14; | |
323 | 5695 v18 = stru_5C6E00->Cos(angle); |
0 | 5696 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 5697 v20 = stru_5C6E00->Sin(angle); |
5698 v21 = stru_5C6E00->Sin(angle); | |
5699 v22 = stru_5C6E00->Cos(angle); | |
1390 | 5700 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5701 + (double)(v18 >> 16)) |
5702 * v16 | |
5703 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
5704 + (double)(v20 >> 16)) | |
5705 * v17) | |
5706 * v11 + v13; | |
5707 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
5708 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
5709 - 12.0) | |
5710 * v11 | |
5711 + (double)a2->uScreenSpaceY; | |
1390 | 5712 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5713 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5714 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
1637 | 5715 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5716 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; |
0 | 5717 v25 = 1.0 / v6; |
1390 | 5718 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; |
5719 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5720 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
0 | 5721 v26 = (double)(a2->uScreenSpaceX - 12) - v13; |
5722 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 5723 v28 = stru_5C6E00->Cos(angle); |
5724 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5725 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5726 v31 = stru_5C6E00->Cos(angle); | |
1390 | 5727 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
0 | 5728 + (double)(v28 >> 16)) |
5729 * v26 | |
5730 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
5731 + (double)(v29 >> 16)) | |
5732 * v27) | |
5733 * v11 + v13; | |
5734 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
5735 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
5736 - 12.0) | |
5737 * v11 | |
5738 + (double)a2->uScreenSpaceY; | |
1390 | 5739 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; |
5740 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
5741 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5742 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
5743 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5744 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5745 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
0 | 5746 v33 = (double)(a2->uScreenSpaceX + 12) - v13; |
5747 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 5748 v35 = stru_5C6E00->Cos(angle); |
5749 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5750 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5751 v38 = stru_5C6E00->Cos(angle); | |
1390 | 5752 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
0 | 5753 + (double)(v35 >> 16)) |
5754 * v33 | |
5755 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
5756 + (double)(v36 >> 16)) | |
5757 * v34) | |
5758 * v11 + v13; | |
5759 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
5760 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
5761 - 12.0) | |
5762 * v11 | |
5763 + (double)a2->uScreenSpaceY; | |
1390 | 5764 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5765 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
5766 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
5767 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5768 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
5769 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5770 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
0 | 5771 v40 = (double)(a2->uScreenSpaceX + 12) - v13; |
5772 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 5773 v42 = stru_5C6E00->Cos(angle); |
5774 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5775 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5776 v45 = stru_5C6E00->Cos(angle); | |
1390 | 5777 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
0 | 5778 + (double)(v42 >> 16)) |
5779 * v40 | |
5780 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
5781 + (double)(v43 >> 16)) | |
5782 * v41) | |
5783 * v11 + v13; | |
5784 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
5785 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
5786 - 12.0) | |
5787 * v11 | |
5788 + (double)a2->uScreenSpaceY; | |
1390 | 5789 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; |
5790 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
5791 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
5792 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5793 pBillboardRenderListD3D[v8].pTexture = a3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5794 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 5795 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5796 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; |
5797 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5798 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5799 } |
5800 } | |
5801 | |
5802 //----- (004A4023) -------------------------------------------------------- | |
657 | 5803 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
|
5804 { |
0 | 5805 unsigned int v8; // esi@2 |
5806 double v14; // st6@14 | |
5807 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5808 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5809 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5810 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5811 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5812 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5813 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5814 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5815 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5816 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5817 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 5818 float v29; // [sp+28h] [bp-8h]@5 |
5819 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5820 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5821 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5822 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5823 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5824 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5825 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5826 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5827 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
|
5828 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
|
5829 |
657 | 5830 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); |
2006 | 5831 if (a2->sTintColor & 0x00FFFFFF && bTinting) |
5832 { | |
5833 diffuse = BlendColors(a2->sTintColor, diffuse); | |
5834 if (a2->sTintColor & 0xFF000000) | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5835 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5836 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5837 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5838 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5839 if (bUsingSpecular) |
2193
4842f58715ea
sub_47C3D7_get_fog_related_stuff to sub_47C3D7_get_fog_specular cleanup, IsTerrainSlopeTooHigh restoring commented out min,min/max,max implementation, some small changes in OnMapLoad, sub_4465DF_check_season attempted to pick the best readabilty/maintainability tradeoff
Grumpy7
parents:
2182
diff
changeset
|
5840 specular = sub_47C3D7_get_fog_specular(0, 0, a2->zbuffer_depth); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5841 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5842 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5843 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5844 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5845 v14 *= -1.0; |
1390 | 5846 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; |
5847 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5848 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5849 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5850 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; |
5851 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
5852 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5853 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5854 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5855 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5856 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5857 if ( a2->uFlags & 4 ) |
0 | 5858 v14 = v14 * -1.0; |
1390 | 5859 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; |
5860 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
5861 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5862 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5863 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5864 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; |
5865 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5866 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5867 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5868 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
|
5869 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5870 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5871 v14 *= -1.0; |
1390 | 5872 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; |
5873 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
5874 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5875 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5876 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5877 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; |
5878 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5879 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5880 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5881 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
|
5882 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5883 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5884 v14 *= -1.0; |
1390 | 5885 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; |
5886 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
5887 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5888 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5889 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5890 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; |
5891 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5892 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5893 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5894 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5895 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5896 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5897 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5898 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
2002 | 5899 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5900 |
2006 | 5901 if (a2->sTintColor & 0xFF000000) |
2155 | 5902 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5903 else |
2155 | 5904 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent; |
0 | 5905 } |
5906 | |
5907 | |
5908 //----- (004A49D0) -------------------------------------------------------- | |
5909 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
5910 { | |
1159 | 5911 int absXDifference; // eax@1 |
5912 int absYDifference; // eax@1 | |
5913 unsigned int smallerabsdiff; // ebx@1 | |
5914 unsigned int largerabsdiff; | |
0 | 5915 double v16; // st7@7 |
5916 double v17; // st7@7 | |
5917 double v18; // st6@7 | |
5918 double v20; // st4@8 | |
5919 double v21; // st4@10 | |
5920 double v22; // st4@10 | |
5921 double v23; // st4@10 | |
5922 double v25; // st4@11 | |
5923 double v26; // st4@13 | |
5924 double v28; // st4@13 | |
5925 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
1159 | 5926 int xDifference; // [sp+88h] [bp-Ch]@1 |
0 | 5927 signed int v32; // [sp+8Ch] [bp-8h]@1 |
1159 | 5928 int yDifference; // [sp+90h] [bp-4h]@1 |
5929 | |
5930 xDifference = bankersRounding(dstX - srcX); | |
5931 yDifference = bankersRounding(dstY - srcY); | |
5932 absYDifference = abs(yDifference); | |
5933 absXDifference = abs(xDifference); | |
5934 smallerabsdiff = min(absXDifference, absYDifference); | |
5935 largerabsdiff = max(absXDifference, absYDifference); | |
5936 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
0 | 5937 v16 = 1.0 / (double)v32; |
1159 | 5938 v17 = (double)yDifference * v16 * a4; |
5939 v18 = (double)xDifference * v16 * a4; | |
5940 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
5941 { | |
1637 | 5942 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
5943 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
1159 | 5944 } |
5945 else | |
5946 { | |
5947 v20 = a3 * 0.061758894; | |
5948 v25 = a7 * 0.061758894; | |
5949 } | |
5950 v21 = 1.0 / a3; | |
5951 v22 = (double)yDifference * v16 * a8; | |
5952 v23 = (double)xDifference * v16 * a8; | |
5953 v26 = 1.0 - 1.0 / v25; | |
5954 v28 = 1.0 / a7; | |
0 | 5955 v29[0].pos.x = srcX + v17; |
5956 v29[0].pos.y = srcY - v18; | |
1159 | 5957 v29[0].pos.z = 1.0 - 1.0 / v20; |
5958 v29[0].rhw = v21; | |
0 | 5959 v29[0].diffuse = -1; |
5960 v29[0].specular = 0; | |
5961 v29[0].texcoord.x = 1.0; | |
5962 v29[0].texcoord.y = 0.0; | |
1159 | 5963 |
0 | 5964 v29[1].pos.x = v22 + dstX; |
5965 v29[1].pos.y = dstY - v23; | |
1159 | 5966 v29[1].pos.z = v26; |
5967 v29[1].rhw = v28; | |
0 | 5968 v29[1].diffuse = -16711936; |
5969 v29[1].specular = 0; | |
5970 v29[1].texcoord.x = 1.0; | |
5971 v29[1].texcoord.y = 1.0; | |
1159 | 5972 |
5973 v29[2].pos.x = dstX - v22; | |
5974 v29[2].pos.y = v23 + dstY; | |
5975 v29[2].pos.z = v26; | |
0 | 5976 v29[2].rhw = v28; |
1159 | 5977 v29[2].diffuse = -1; |
5978 v29[2].specular = 0; | |
0 | 5979 v29[2].texcoord.x = 0.0; |
5980 v29[2].texcoord.y = 1.0; | |
1159 | 5981 |
0 | 5982 v29[3].pos.x = srcX - v17; |
5983 v29[3].pos.y = v18 + srcY; | |
1159 | 5984 v29[3].pos.z = v29[0].pos.z; |
5985 v29[3].rhw = v21; | |
5986 v29[3].diffuse = -1; | |
5987 v29[3].specular = 0; | |
0 | 5988 v29[3].texcoord.x = 0.0; |
5989 v29[3].texcoord.y = 0.0; | |
186 | 5990 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
5991 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
5992 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
5993 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
5994 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
5995 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 5996 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
5997 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
5998 D3DPT_TRIANGLEFAN, | |
5999 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6000 v29, | |
6001 4, | |
6002 24)); | |
186 | 6003 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
6004 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6005 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6006 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6007 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6008 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 6009 } |
6010 | |
6011 //----- (004A4CC9) -------------------------------------------------------- | |
1390 | 6012 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) |
6013 { | |
0 | 6014 unsigned int v5; // eax@7 |
6015 char *v7; // edx@8 | |
6016 double v10; // st6@9 | |
6017 double v11; // st6@10 | |
6018 int v12; // ebx@13 | |
1390 | 6019 |
6020 if (a1->uNumVertices < 3) | |
6021 return; | |
6022 | |
6023 float depth = 1000000.0; | |
6024 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6025 { | |
6026 if (a1->field_104[i].z < depth) | |
6027 depth = a1->field_104[i * 4].z; | |
6028 } | |
6029 | |
6030 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
6031 pBillboardRenderListD3D[v5].field_90 = 0; | |
2002 | 6032 pBillboardRenderListD3D[v5].sParentBillboardID = -1; |
2155 | 6033 pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2; |
1390 | 6034 pBillboardRenderListD3D[v5].pTexture = 0; |
6035 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
6036 pBillboardRenderListD3D[v5].z_order = depth; | |
6037 | |
6038 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6039 { | |
6040 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
6041 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
6042 | |
6043 v10 = a1->field_104[i].z; | |
6044 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
6045 v11 = v10 * 0.061758894; | |
6046 else | |
1637 | 6047 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
1390 | 6048 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; |
6049 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
6050 | |
6051 if (diffuse & 0xFF000000) | |
6052 v12 = a1->field_104[i].diffuse; | |
6053 else | |
6054 v12 = diffuse; | |
6055 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
6056 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
6057 | |
6058 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
6059 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
0 | 6060 } |
6061 } | |
6062 | |
6063 //----- (004A4DE1) -------------------------------------------------------- | |
6064 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
6065 { | |
6066 HRESULT v12; // eax@14 | |
6067 unsigned __int16 *v13; // ecx@19 | |
6068 unsigned __int16 *v14; // eax@19 | |
6069 DWORD v15; // edx@20 | |
6070 HRESULT v16; // eax@23 | |
6071 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
6072 | |
1980 | 6073 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); |
0 | 6074 if ( pHWLTexture ) |
6075 { | |
6076 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
6077 if ( !pRenderD3D->CreateTexture( | |
6078 pHWLTexture->uWidth, | |
6079 pHWLTexture->uHeight, | |
6080 pOutSurface, | |
6081 pOutTexture, | |
6082 true, | |
6083 bMipMaps, | |
6084 uMinDeviceTextureDim) ) | |
1545 | 6085 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6086 //v10 = *pOutSurface; |
6087 //v11 = 0; | |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1574
diff
changeset
|
6088 if (bMipMaps) |
0 | 6089 { |
6090 Dst._450DDE(); | |
6091 //v20 = 0; | |
6092 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
6093 | |
6094 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
6095 while ( 1 ) | |
6096 { | |
6097 DDSCAPS2 v19; | |
6098 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6099 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6100 | |
6101 DDSURFACEDESC2 desc; | |
6102 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6103 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6104 | |
168 | 6105 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6106 { |
1831 | 6107 Dst.sub_451007_scale_image_bicubic( |
0 | 6108 pHWLTexture->pPixels, |
6109 pHWLTexture->uWidth, | |
6110 pHWLTexture->uHeight, | |
6111 pHWLTexture->uWidth, | |
6112 (unsigned short *)desc.lpSurface, | |
6113 desc.dwWidth, | |
6114 desc.dwHeight, | |
6115 desc.lPitch >> 1, | |
6116 0, | |
1831 | 6117 0); |
0 | 6118 ErrD3D(pNextSurf->Unlock(0)); |
6119 //bMipMaps = 0x4D86ACu; | |
6120 } | |
6121 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
6122 break; | |
6123 //v10 = (IDirectDrawSurface4 *)pName; | |
6124 //v11 = 0; | |
6125 } | |
6126 //v20 = -1; | |
6127 //nullsub_1(); | |
6128 } | |
6129 else | |
6130 { | |
6131 DDSCAPS2 v19; | |
6132 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6133 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6134 | |
6135 DDSURFACEDESC2 desc; | |
6136 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6137 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6138 | |
168 | 6139 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6140 { |
6141 bMipMaps = 0; | |
6142 v13 = pHWLTexture->pPixels; | |
6143 v14 = (unsigned __int16 *)desc.lpSurface; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6144 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
|
6145 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6146 for (v15 = 0; v15 < desc.dwWidth; v15++) |
0 | 6147 { |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6148 *v14 = *v13; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6149 ++v14; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6150 ++v13; |
0 | 6151 } |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6152 v14 += (desc.lPitch >> 1) - desc.dwWidth; |
0 | 6153 } |
6154 ErrD3D((*pOutSurface)->Unlock(0)); | |
6155 } | |
6156 } | |
6157 delete [] pHWLTexture->pPixels; | |
6158 delete pHWLTexture; | |
6159 return true; | |
6160 } | |
6161 return false; | |
6162 } | |
6163 | |
6164 //----- (004A5048) -------------------------------------------------------- | |
670 | 6165 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
6166 { | |
6167 | |
6168 HWLTexture *sprite_texture; // eax@1 | |
0 | 6169 unsigned __int16 *v9; // edx@5 |
6170 LPVOID v10; // eax@5 | |
6171 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6172 | |
670 | 6173 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
6174 if ( sprite_texture ) | |
6175 { | |
6176 pSprite->uAreaX = sprite_texture->uAreaX; | |
6177 pSprite->uAreaY = sprite_texture->uAreaY; | |
6178 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
6179 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
6180 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
6181 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6182 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6183 //v7 = v3->pRenderD3D; |
670 | 6184 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
1545 | 6185 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6186 //pSprite = v2->pTextureSurface; |
6187 //pSprite = (Sprite *)pSprite->pName; | |
6188 //v8 = pSprite; | |
670 | 6189 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 6190 Dst.dwSize = 124; |
670 | 6191 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
6192 { | |
6193 v9 = sprite_texture->pPixels; | |
6194 v10 = Dst.lpSurface; | |
6195 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 6196 { |
670 | 6197 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
6198 { | |
0 | 6199 *(int *)v10 = *(int *)v9; |
6200 v9 += 2; | |
6201 v10 = (char *)v10 + 4; | |
670 | 6202 } |
6203 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 6204 } |
670 | 6205 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
6206 } | |
6207 free(sprite_texture->pPixels); | |
6208 free(sprite_texture); | |
6209 return true; | |
6210 } | |
6211 return false; | |
0 | 6212 } |
6213 | |
6214 //----- (004A51CB) -------------------------------------------------------- | |
6215 void Render::BeginScene() | |
6216 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6217 //Render *v1; // esi@1 |
0 | 6218 unsigned int v2; // eax@1 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6219 /*int v3; // eax@5 |
0 | 6220 unsigned __int16 **v4; // edi@6 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6221 char *v5; // ebx@7*/ |
0 | 6222 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 |
6223 | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6224 //v1 = this; |
0 | 6225 v2 = this->uNumSceneBegins; |
6226 this->uNumSceneBegins = v2 + 1; | |
6227 if ( !v2 ) | |
6228 { | |
6229 if ( this->pRenderD3D ) | |
6230 { | |
2069 | 6231 /*if ( this->bColorKeySupported ) |
0 | 6232 { |
6233 memset(&Dst, 0, 0x7Cu); | |
6234 Dst.dwSize = 124; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6235 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
|
6236 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6237 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6238 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6239 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
|
6240 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6241 --this->uNumSceneBegins; |
2069 | 6242 }*/ |
0 | 6243 } |
6244 else | |
6245 { | |
6246 if ( !this->pTargetSurface ) | |
6247 { | |
6248 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
2154 | 6249 /*if ( this->pTargetSurface ) |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6250 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6251 this->field_18_locked_pitch = this->uTargetSurfacePitch; |
2154 | 6252 }*/ |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6253 --this->uNumSceneBegins; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6254 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6255 } |
0 | 6256 RestoreFrontBuffer(); |
6257 } | |
6258 } | |
6259 | |
6260 //----- (004A527D) -------------------------------------------------------- | |
6261 void Render::EndScene() | |
6262 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6263 if ( this->uNumSceneBegins ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6264 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6265 this->uNumSceneBegins--; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6266 if ( !this->uNumSceneBegins ) |
0 | 6267 { |
6268 if ( this->pRenderD3D ) | |
6269 { | |
2069 | 6270 /*if ( this->bColorKeySupported ) |
0 | 6271 { |
6272 this->pTargetSurface = 0; | |
6273 this->uTargetSurfacePitch = 0; | |
6274 this->field_18_locked_pitch = 0; | |
6275 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
2069 | 6276 }*/ |
0 | 6277 } |
6278 else | |
6279 { | |
6280 this->pTargetSurface = 0; | |
6281 this->uTargetSurfacePitch = 0; | |
2154 | 6282 //this->field_18_locked_pitch = 0; |
0 | 6283 UnlockBackBuffer(); |
6284 } | |
6285 } | |
6286 } | |
6287 } | |
6288 | |
2155 | 6289 //----- (004A52F1) -------------------------------------------------------- |
6290 void Render::ScreenFade(unsigned int color, float t) | |
0 | 6291 { |
6292 unsigned int v3; // esi@1 | |
2155 | 6293 //double v4; // st7@2 |
6294 //double v5; // st7@6 | |
0 | 6295 double v6; // st6@6 |
6296 unsigned int v7; // eax@6 | |
6297 double v8; // st5@6 | |
6298 double v9; // st4@6 | |
6299 HRESULT v10; // eax@6 | |
6300 HRESULT v11; // eax@6 | |
6301 unsigned int result; // eax@6 | |
6302 unsigned int v13; // eax@7 | |
6303 unsigned __int16 *v14; // ecx@7 | |
6304 int *v15; // eax@7 | |
6305 unsigned int v16; // ecx@8 | |
6306 __int16 v17; // ax@10 | |
6307 int v18; // esi@10 | |
6308 float v19; // edi@10 | |
6309 void *v20; // esi@10 | |
6310 int v21; // edx@10 | |
6311 int v22; // ecx@11 | |
6312 int v23; // edx@12 | |
6313 __int16 v24; // ax@15 | |
6314 int v25; // esi@15 | |
6315 float v26; // edi@15 | |
6316 char *v27; // esi@15 | |
6317 int v28; // edx@15 | |
6318 int v29; // ecx@16 | |
6319 int v30; // edx@17 | |
6320 int v31; // [sp-Ch] [bp-ACh]@11 | |
6321 int v32; // [sp-Ch] [bp-ACh]@16 | |
6322 const char *v33; // [sp+0h] [bp-A0h]@0 | |
6323 int v34; // [sp+4h] [bp-9Ch]@0 | |
6324 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
6325 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
6326 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
6327 int v38; // [sp+90h] [bp-10h]@7 | |
6328 double v39; // [sp+94h] [bp-Ch]@6 | |
2155 | 6329 int v40; // [sp+9Ch] [bp-4h]@6 |
6330 | |
0 | 6331 v3 = 0; |
1574 | 6332 |
6333 //{ | |
2155 | 6334 if (t > 1.0f) |
6335 t = 1.0f; | |
6336 else if (t < 0.0f) | |
6337 t = 0.0f; | |
6338 | |
6339 v40 = (char)floorf(t * 255.0f + 0.5f); | |
6340 //v5 = (double)(signed int)pViewport->uViewportTL_X; | |
6341 v36[0].pos.x = pViewport->uViewportTL_X; | |
693 | 6342 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
2155 | 6343 v7 = color | (v40 << 24); |
6344 //this_ = pViewport->uViewportBR_Y + 1; | |
0 | 6345 v36[0].specular = 0; |
6346 v36[0].pos.y = v6; | |
6347 v36[0].diffuse = v7; | |
6348 v36[1].diffuse = v7; | |
6349 v36[0].pos.z = 0.0; | |
6350 v36[2].diffuse = v7; | |
6351 v36[3].diffuse = v7; | |
6352 v36[0].rhw = 1.0; | |
6353 v36[1].specular = 0; | |
6354 v36[0].texcoord.x = 0.0; | |
6355 v36[2].specular = 0; | |
6356 v36[3].specular = 0; | |
6357 v36[0].texcoord.y = 0.0; | |
2155 | 6358 v36[1].pos.x = pViewport->uViewportTL_X; |
693 | 6359 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 6360 v36[1].pos.y = v8; |
6361 v36[1].pos.z = 0.0; | |
6362 v36[1].rhw = 1.0; | |
6363 v36[1].texcoord.x = 0.0; | |
6364 v36[1].texcoord.y = 0.0; | |
693 | 6365 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 6366 v36[2].pos.x = v9; |
6367 v36[2].pos.y = v8; | |
6368 v36[2].pos.z = 0.0; | |
6369 v36[2].rhw = 1.0; | |
6370 v36[2].texcoord.x = 0.0; | |
6371 v36[2].texcoord.y = 0.0; | |
6372 v36[3].pos.x = v9; | |
6373 v36[3].pos.y = v6; | |
6374 v36[3].pos.z = 0.0; | |
6375 v36[3].rhw = 1.0; | |
6376 v36[3].texcoord.x = 0.0; | |
6377 v36[3].texcoord.y = 0.0; | |
6378 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 6379 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
6380 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6381 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6382 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
6383 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
6384 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6385 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 6386 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
6387 D3DPT_TRIANGLEFAN, | |
6388 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6389 v36, | |
6390 4, | |
6391 28)); | |
186 | 6392 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
6393 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6394 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
6395 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6396 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6397 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
1574 | 6398 /*} |
0 | 6399 else |
6400 { | |
6401 v40 = (1.0 - a3) * 65536.0; | |
6402 v39 = v40 + 6.7553994e15; | |
6403 LODWORD(a3) = LODWORD(v39); | |
693 | 6404 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
6405 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
6406 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
6407 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 6408 v37 = 2 * v13; |
6409 LODWORD(v40) = (int)v14; | |
6410 | |
6411 int __i = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
6412 v15 = dword_F1B430.data(); |
0 | 6413 do |
6414 { | |
6415 v16 = v3; | |
6416 v3 += LODWORD(a3); | |
6417 dword_F1B430[__i++] = v16 >> 16; | |
6418 } | |
6419 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
6420 while (__i < 32); | |
6421 | |
6422 if ( pRenderer->uTargetGBits == 6 ) | |
6423 { | |
1574 | 6424 v17 = sr_42690D_colors_cvt(this_); |
0 | 6425 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); |
6426 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); | |
6427 v19 = v40; | |
6428 v20 = off_4EFDB0; | |
6429 v21 = HIDWORD(v39); | |
6430 do | |
6431 { | |
6432 v22 = v38; | |
6433 v31 = v21; | |
6434 do | |
6435 { | |
6436 v23 = (*(int *)((char *)v20 | |
6437 + ((((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; | |
6438 result = this_ | |
6439 + (*((int *)v20 | |
6440 + (((unsigned __int8)(*((char *)v20 | |
6441 + ((((unsigned __int16)(*(short *)((char *)v20 | |
6442 + ((*(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); | |
6443 *(unsigned int *)LODWORD(v19) = result; | |
6444 LODWORD(v19) += 4; | |
6445 --v22; | |
6446 } | |
6447 while ( v22 ); | |
6448 LODWORD(v19) += v37; | |
6449 v21 = v31 - 1; | |
6450 } | |
6451 while ( v31 != 1 ); | |
6452 } | |
6453 else | |
6454 { | |
1574 | 6455 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_); |
0 | 6456 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); |
6457 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
6458 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
6459 v26 = v40; | |
6460 v27 = (char *)off_4EFDB0; | |
6461 v28 = HIDWORD(v39); | |
6462 do | |
6463 { | |
6464 v29 = v38; | |
6465 v32 = v28; | |
6466 do | |
6467 { | |
6468 v30 = 32 | |
6469 * *(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; | |
6470 result = this_ | |
6471 + (*(int *)&v27[4 | |
6472 * (((unsigned __int8)(32 | |
6473 * 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); | |
6474 *(unsigned int *)LODWORD(v26) = result; | |
6475 LODWORD(v26) += 4; | |
6476 --v29; | |
6477 } | |
6478 while ( v29 ); | |
6479 LODWORD(v26) += v37; | |
6480 v28 = v32 - 1; | |
6481 } | |
6482 while ( v32 != 1 ); | |
6483 } | |
1574 | 6484 }*/ |
0 | 6485 } |
6486 | |
6487 //----- (004A5B81) -------------------------------------------------------- | |
727 | 6488 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 6489 { |
6490 this->bClip = 1; | |
6491 this->uClipY = uY; | |
6492 this->uClipX = uX; | |
6493 this->uClipW = uW; | |
6494 this->uClipZ = uZ; | |
6495 } | |
6496 | |
6497 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 6498 void Render::ResetTextureClipRect() |
0 | 6499 { |
6500 this->uClipY = 0; | |
6501 this->uClipX = 0; | |
6502 this->bClip = 1; | |
6503 this->uClipW = 480; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
6504 this->uClipZ = window->GetWidth(); |
0 | 6505 } |
6506 | |
2069 | 6507 unsigned __int32 Color32(unsigned __int16 color16) |
6508 { | |
6509 unsigned __int32 c = color16; | |
6510 unsigned int b = (c & 31) * 8; | |
6511 unsigned int g = ((c >> 5) & 63) * 4; | |
6512 unsigned int r = ((c >> 11) & 31) * 8; | |
6513 | |
2078 | 6514 return (r << 16) | (g << 8) | b;// |
2069 | 6515 } |
6516 | |
6517 //----- (0040DEF3) -------------------------------------------------------- | |
6518 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b) | |
6519 { | |
6520 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + | |
6521 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + | |
6522 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
6523 return (b >> (8 - 5)) | | |
6524 0x7E0 & (g << (6 + 5 - 8)) | | |
6525 0xF800 & (r << (6 + 5 + 5 - 8)); | |
6526 } | |
6527 | |
6528 | |
0 | 6529 //----- (004A5BE3) -------------------------------------------------------- |
6530 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
6531 { | |
6532 int v4; // edi@3 | |
2069 | 6533 //unsigned __int16 *v5; // edx@3 |
0 | 6534 unsigned __int16 *v6; // esi@3 |
6535 unsigned int v8; // eax@5 | |
6536 unsigned int v9; // ebx@5 | |
6537 unsigned int v11; // eax@7 | |
6538 unsigned int v12; // ebx@8 | |
6539 unsigned int v15; // eax@14 | |
6540 int v19; // [sp+10h] [bp-8h]@3 | |
6541 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
6542 int v23; // [sp+28h] [bp+10h]@3 | |
6543 | |
6544 if ( this->uNumSceneBegins && a4 ) | |
6545 { | |
6546 v4 = a4->uWidth; | |
2069 | 6547 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6548 v6 = a4->pPixels; |
6549 v23 = a4->uHeight; | |
6550 v19 = v4; | |
6551 if ( this->bClip ) | |
6552 { | |
1152 | 6553 if ( (signed int)uOutX < (signed int)this->uClipX ) |
6554 { | |
6555 v8 = this->uClipX - uOutX; | |
6556 v9 = uOutX - this->uClipX; | |
0 | 6557 v8 *= 2; |
6558 v4 += v9; | |
6559 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
2069 | 6560 //v5 = (unsigned __int16 *)((char *)v5 + v8); |
0 | 6561 } |
1152 | 6562 if ( (signed int)uOutY < (signed int)this->uClipY ) |
6563 { | |
6564 v11 = this->uClipY - uOutY; | |
0 | 6565 v6 += v19 * v11; |
6566 v23 += uOutY - this->uClipY; | |
2069 | 6567 //v5 += this->uTargetSurfacePitch * v11; |
0 | 6568 } |
1152 | 6569 v12 = max(this->uClipX, uOutX); |
6570 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | |
6571 { | |
6572 v4 = this->uClipZ - max(this->uClipX, uOutX); | |
6573 } | |
6574 v15 = max(this->uClipY, uOutY); | |
6575 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) | |
6576 { | |
6577 v23 = this->uClipW - max(this->uClipY, uOutY); | |
6578 } | |
6579 } | |
6580 | |
2069 | 6581 for (int y = 0; y < v23; y++) |
6582 { | |
6583 for (int x = 0; x < v4; x++) | |
6584 { | |
6585 WritePixel16(uOutX + x, uOutY + y, *v6); | |
6586 //*v5 = *v6; | |
6587 //++v5; | |
1152 | 6588 ++v6; |
6589 } | |
6590 v6 += v19 - v4; | |
2069 | 6591 //v5 += this->uTargetSurfacePitch - v4; |
0 | 6592 } |
6593 } | |
6594 } | |
6595 | |
6596 //----- (004A5D33) -------------------------------------------------------- | |
1675 | 6597 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) |
0 | 6598 { |
2069 | 6599 //unsigned __int16 *v7; // ebx@3 |
1675 | 6600 int full_width; // ecx@3 |
6601 int full_height; // edi@3 | |
2069 | 6602 //int v23; // edi@23 |
0 | 6603 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 |
6604 | |
6605 if ( this->uNumSceneBegins && pTexture ) | |
6606 { | |
2069 | 6607 /*auto v7 = this->pTargetSurface; |
6608 if (FORCE_16_BITS) | |
6609 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2); | |
6610 else | |
6611 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/ | |
1675 | 6612 full_width = pTexture->uWidth - move_X; |
6613 full_height = pTexture->uHeight - move_Y; | |
6614 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth]; | |
6615 if ( this->bClip ) | |
6616 { | |
6617 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó | |
6618 { | |
6619 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX))); | |
6620 full_width += pX - this->uClipX; | |
2069 | 6621 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX))); |
1675 | 6622 } |
6623 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó | |
6624 { | |
6625 pTexturea += pTexture->uWidth * (this->uClipY - pY); | |
6626 full_height += pY - this->uClipY; | |
2069 | 6627 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY)); |
1675 | 6628 } |
6629 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà | |
6630 this->uClipX = pX; | |
6631 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà | |
6632 this->uClipY = pY; | |
6633 if ( (full_width + this->uClipX) > this->uClipZ )//åñëè øèðèíà êàäðà âûõîäèò çà ïðàâóþ ãðàíèöó | |
6634 { | |
6635 if ( this->uClipX < pX ) | |
6636 this->uClipX = pX; | |
6637 full_width = this->uClipZ - this->uClipX; | |
6638 } | |
6639 if ( (full_height + this->uClipY) > this->uClipW )//åñëè âûñîòà êàäðà âûõîäèò çà íèæíþþ ãðàíèöó | |
6640 { | |
6641 if ( this->uClipY < pY ) | |
6642 this->uClipY = pY; | |
6643 full_height = this->uClipW - this->uClipY; | |
6644 } | |
6645 } | |
2069 | 6646 |
6647 for (int y = 0; y < full_height; ++y) | |
6648 { | |
6649 for (int x = 0; x < full_width; ++x) | |
6650 { | |
6651 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) ) | |
6652 { | |
6653 WritePixel16(pX + x, pY + y, *pTexturea); | |
6654 /*if (FORCE_16_BITS) | |
6655 *(unsigned __int16 *)v7 = *pTexturea; | |
6656 else | |
6657 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/ | |
6658 } | |
0 | 6659 ++pTexturea; |
2069 | 6660 //++v7; |
0 | 6661 } |
2069 | 6662 //v7 += this->uTargetSurfacePitch - full_width; |
1675 | 6663 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width)); |
2069 | 6664 } |
0 | 6665 } |
6666 } | |
6667 | |
6668 //----- (004A6E7E) -------------------------------------------------------- | |
2155 | 6669 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 6670 { |
2069 | 6671 //unsigned __int16 *v4; // eax@4 |
0 | 6672 int v5; // edx@4 |
6673 unsigned int v6; // edi@4 | |
6674 unsigned int v7; // edx@5 | |
6675 unsigned int v8; // edx@6 | |
6676 unsigned int v9; // edx@7 | |
6677 unsigned int v10; // edx@8 | |
6678 unsigned int v11; // ebx@9 | |
6679 unsigned int v12; // esi@11 | |
6680 unsigned int v13; // edx@12 | |
6681 unsigned int v14; // ebx@15 | |
6682 unsigned int v15; // esi@17 | |
6683 unsigned int v16; // edi@18 | |
6684 char v17; // zf@29 | |
6685 int v18; // [sp+14h] [bp-Ch]@4 | |
6686 int v19; // [sp+18h] [bp-8h]@4 | |
6687 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
6688 int v21; // [sp+28h] [bp+8h]@25 | |
6689 int v22; // [sp+28h] [bp+8h]@34 | |
6690 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
6691 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
6692 | |
6693 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
6694 { | |
2069 | 6695 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
710 | 6696 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 6697 v5 = a4->uTextureWidth; |
6698 v6 = a4->uTextureHeight; | |
6699 v19 = a4->uTextureWidth; | |
6700 v18 = a4->uTextureWidth; | |
2069 | 6701 int clipped_out_x = a2; |
6702 int clipped_out_y = a3; | |
0 | 6703 if ( this->bClip ) |
6704 { | |
6705 v7 = this->uClipX; | |
6706 if ( (signed int)a2 < (signed int)v7 ) | |
6707 { | |
6708 v8 = v7 - a2; | |
6709 v20 += v8; | |
6710 v19 += a2 - this->uClipX; | |
2069 | 6711 //v4 += v8; |
6712 clipped_out_x = uClipX; | |
0 | 6713 } |
6714 v9 = this->uClipY; | |
6715 if ( (signed int)a3 < (signed int)v9 ) | |
6716 { | |
6717 v10 = v9 - a3; | |
6718 v20 += v18 * v10; | |
6719 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
2069 | 6720 //v4 += this->uTargetSurfacePitch * v10; |
6721 clipped_out_y = uClipY; | |
0 | 6722 } |
6723 v11 = this->uClipX; | |
6724 v5 = v19; | |
6725 if ( (signed int)v11 < (signed int)a2 ) | |
6726 v11 = a2; | |
6727 v12 = this->uClipZ; | |
6728 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
6729 { | |
6730 v13 = this->uClipX; | |
6731 if ( (signed int)v13 < (signed int)a2 ) | |
6732 v13 = a2; | |
6733 v5 = v12 - v13; | |
6734 } | |
6735 v14 = this->uClipY; | |
6736 if ( (signed int)v14 < (signed int)a3 ) | |
6737 v14 = a3; | |
6738 v15 = this->uClipW; | |
6739 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
6740 { | |
6741 v16 = this->uClipY; | |
6742 if ( (signed int)v16 < (signed int)a3 ) | |
6743 v16 = a3; | |
6744 v6 = v15 - v16; | |
6745 } | |
6746 } | |
2069 | 6747 |
6748 for (int y = 0; y < v6; ++y) | |
6749 { | |
6750 for (int x = 0; x < v5; ++x) | |
6751 { | |
6752 if ( *v20 ) | |
6753 WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF); | |
6754 ++v20; | |
6755 } | |
6756 v20 += v18 - v5; | |
6757 } | |
6758 | |
6759 /*if ( pRenderer->uTargetGBits == 5 ) | |
0 | 6760 { |
6761 if ( (signed int)v6 > 0 ) | |
6762 { | |
6763 v23 = v6; | |
6764 do | |
6765 { | |
6766 if ( v5 > 0 ) | |
6767 { | |
6768 v21 = v5; | |
6769 do | |
6770 { | |
6771 if ( *v20 ) | |
6772 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
6773 ++v4; | |
6774 ++v20; | |
6775 --v21; | |
6776 } | |
6777 while ( v21 ); | |
6778 } | |
6779 v20 += v18 - v5; | |
6780 v17 = v23-- == 1; | |
6781 v4 += this->uTargetSurfacePitch - v5; | |
6782 } | |
6783 while ( !v17 ); | |
6784 } | |
6785 } | |
6786 else | |
6787 { | |
6788 if ( (signed int)v6 > 0 ) | |
6789 { | |
6790 v24 = v6; | |
6791 do | |
6792 { | |
6793 if ( v5 > 0 ) | |
6794 { | |
6795 v22 = v5; | |
6796 do | |
6797 { | |
6798 if ( *v20 ) | |
6799 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
6800 ++v4; | |
6801 ++v20; | |
6802 --v22; | |
6803 } | |
6804 while ( v22 ); | |
6805 } | |
6806 v20 += v18 - v5; | |
6807 v17 = v24-- == 1; | |
6808 v4 += this->uTargetSurfacePitch - v5; | |
6809 } | |
6810 while ( !v17 ); | |
6811 } | |
2069 | 6812 }*/ |
0 | 6813 } |
6814 } | |
6815 | |
6816 //----- (004A6DF5) -------------------------------------------------------- | |
2069 | 6817 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) |
0 | 6818 { |
2219 | 6819 int width; // ecx@3 |
6820 unsigned __int16 *pixels; // ebx@4 | |
6821 int height; // esi@4 | |
0 | 6822 |
2069 | 6823 if ( !pBitmap || !pTarget) |
6824 return; | |
6825 | |
2219 | 6826 width = a7->z - a7->x; |
6827 height = a7->w - a7->y; | |
6828 pixels = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; | |
6829 for ( int y = 0; y < height; ++y ) | |
6830 { | |
6831 for ( int x = 0; x < width; ++x ) | |
6832 { | |
6833 WritePixel16(a7->x + x, a7->y + y, *pixels); | |
6834 ++pixels; | |
6835 } | |
6836 pixels += uTargetPitch - width; | |
2093 | 6837 } |
0 | 6838 } |
6839 | |
6840 //----- (004A6D87) -------------------------------------------------------- | |
6841 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
6842 { | |
6843 if (!uNumSceneBegins) | |
6844 return; | |
6845 | |
6846 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
6847 for (uint y = 0; y < uHeight; ++y) | |
6848 { | |
2069 | 6849 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch); |
6850 | |
6851 memset32(pDst, | |
2098 | 6852 FORCE_16_BITS ? twoColors : 0xFF000000 | Color32(uColor16), // two colors per int (16bit) or 1 (32bit) |
2069 | 6853 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit) |
6854 | |
6855 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit | |
6856 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16; | |
0 | 6857 } |
6858 } | |
6859 | |
6860 //----- (004A6C4F) -------------------------------------------------------- | |
2073 | 6861 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, |
6862 unsigned int uCharHeight, unsigned __int16 *pFontPalette, | |
6863 unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
0 | 6864 { |
6865 unsigned int v9; // edi@2 | |
6866 unsigned int v10; // esi@2 | |
2069 | 6867 //unsigned __int16 *v11; // eax@2 |
0 | 6868 unsigned int v12; // ebx@3 |
6869 signed int v13; // edx@5 | |
6870 int v14; // edx@6 | |
6871 signed int v15; // ebx@7 | |
6872 unsigned int v16; // edx@9 | |
6873 signed int v17; // edi@10 | |
6874 signed int v18; // ebx@13 | |
6875 unsigned int v19; // edx@15 | |
6876 signed int v20; // esi@16 | |
2069 | 6877 //unsigned int v21; // esi@22 |
0 | 6878 unsigned __int16 v22; // dx@24 |
2069 | 6879 //char v23; // zf@28 |
0 | 6880 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 |
2069 | 6881 //unsigned int uOutXa; // [sp+18h] [bp+8h]@20 |
6882 | |
6883 if (!this->uNumSceneBegins) | |
6884 return; | |
6885 | |
0 | 6886 v9 = uCharWidth; |
6887 v10 = uCharHeight; | |
2069 | 6888 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6889 v24 = pFontPixels; |
2069 | 6890 |
6891 int clipped_out_x = uOutX, clipped_out_y = uOutY; | |
0 | 6892 if ( this->bClip ) |
6893 { | |
6894 v12 = this->uClipX; | |
6895 if ( uOutX < (signed int)v12 ) | |
6896 { | |
6897 v24 = &pFontPixels[v12 - uOutX]; | |
2069 | 6898 //v11 += v12 - uOutX; |
6899 clipped_out_x = uClipX; | |
0 | 6900 v9 = uCharWidth + uOutX - v12; |
6901 } | |
6902 v13 = this->uClipY; | |
6903 if ( uOutY < v13 ) | |
6904 { | |
6905 v14 = v13 - uOutY; | |
6906 v24 += uCharWidth * v14; | |
6907 v10 = uCharHeight + uOutY - this->uClipY; | |
2069 | 6908 //v11 += this->uTargetSurfacePitch * v14; |
6909 clipped_out_y = uClipY; | |
0 | 6910 } |
6911 v15 = this->uClipX; | |
6912 if ( v15 < uOutX ) | |
6913 v15 = uOutX; | |
6914 v16 = this->uClipZ; | |
6915 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
6916 { | |
6917 v17 = this->uClipX; | |
6918 if ( v17 < uOutX ) | |
6919 v17 = uOutX; | |
6920 v9 = v16 - v17; | |
6921 } | |
6922 v18 = this->uClipY; | |
6923 if ( v18 < uOutY ) | |
6924 v18 = uOutY; | |
6925 v19 = this->uClipW; | |
6926 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
6927 { | |
6928 v20 = this->uClipY; | |
6929 if ( v20 < uOutY ) | |
6930 v20 = uOutY; | |
6931 v10 = v19 - v20; | |
6932 } | |
6933 } | |
2069 | 6934 |
6935 for (int y = 0; y < v10; ++y) | |
6936 { | |
6937 for (int x = 0; x < v9; ++x) | |
6938 { | |
6939 if (*v24) | |
0 | 6940 { |
2069 | 6941 v22 = uShadowColor; |
6942 if ( *v24 != 1 ) | |
6943 v22 = uFaceColor; | |
2073 | 6944 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22); |
0 | 6945 } |
2073 | 6946 ++v24; |
6947 } | |
6948 v24 += uCharWidth - v9; | |
2069 | 6949 //v23 = uOutXa-- == 1; |
6950 //v11 += this->uTargetSurfacePitch - v9; | |
6951 } | |
0 | 6952 } |
6953 | |
6954 //----- (004A6A68) -------------------------------------------------------- | |
1496 | 6955 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) |
6956 { | |
0 | 6957 Texture tex; // [sp+Ch] [bp-48h]@1 |
1496 | 6958 |
0 | 6959 memcpy(&tex, a4, sizeof(tex)); |
1496 | 6960 tex.uTextureHeight = a4->uTextureHeight - height; |
6961 if ( (signed __int16)tex.uTextureHeight > 0 ) | |
0 | 6962 DrawTextureIndexed(a2, a3, &tex); |
6963 } | |
6964 | |
6965 //----- (004A6AB1) -------------------------------------------------------- | |
1268 | 6966 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
6967 { | |
0 | 6968 int v8; // edi@2 |
6969 unsigned int v9; // esi@2 | |
2069 | 6970 //unsigned __int16 *v10; // eax@2 |
0 | 6971 unsigned char *v11; // edx@2 |
6972 unsigned int v12; // ebx@3 | |
6973 signed int v13; // edx@5 | |
6974 int v14; // edx@6 | |
6975 signed int v15; // ebx@7 | |
6976 unsigned int v16; // edx@9 | |
6977 signed int v17; // edi@10 | |
6978 signed int v18; // ebx@13 | |
6979 unsigned int v19; // edx@15 | |
6980 signed int v20; // esi@16 | |
6981 int v21; // ebx@22 | |
6982 char v22; // zf@28 | |
6983 int v23; // ebx@31 | |
6984 unsigned __int16 v24; // si@35 | |
6985 int v25; // [sp+Ch] [bp-4h]@2 | |
6986 int v26; // [sp+1Ch] [bp+Ch]@24 | |
6987 int v27; // [sp+1Ch] [bp+Ch]@33 | |
6988 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
6989 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
6990 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
6991 | |
1980 | 6992 int a2 = x; |
6993 int a3 = y; | |
6994 uint a6 = uFontHeight; | |
2069 | 6995 if (!this->uNumSceneBegins) |
6996 return; | |
6997 | |
0 | 6998 v8 = a5; |
6999 v9 = a6; | |
2069 | 7000 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; |
1268 | 7001 v11 = (unsigned char *)font_pixels; |
7002 v25 = (int)font_pixels; | |
2069 | 7003 int clipped_out_x = x; |
7004 int clipped_out_y = y; | |
0 | 7005 if ( this->bClip ) |
7006 { | |
7007 v12 = this->uClipX; | |
7008 if ( a2 < (signed int)v12 ) | |
7009 { | |
1268 | 7010 v25 = v12 - a2 + (int)font_pixels; |
2069 | 7011 //v10 += v12 - a2; |
0 | 7012 v8 = a5 + a2 - v12; |
2069 | 7013 clipped_out_x = uClipX; |
0 | 7014 } |
7015 v13 = this->uClipY; | |
7016 if ( a3 < v13 ) | |
7017 { | |
7018 v14 = v13 - a3; | |
7019 v25 += a5 * v14; | |
7020 v9 = a6 + a3 - this->uClipY; | |
2069 | 7021 //v10 += this->uTargetSurfacePitch * v14; |
7022 clipped_out_y = uClipY; | |
0 | 7023 } |
7024 v15 = this->uClipX; | |
7025 if ( v15 < a2 ) | |
7026 v15 = a2; | |
7027 v16 = this->uClipZ; | |
7028 if ( v8 + v15 > (signed int)v16 ) | |
7029 { | |
7030 v17 = this->uClipX; | |
7031 if ( v17 < a2 ) | |
7032 v17 = a2; | |
7033 v8 = v16 - v17; | |
7034 } | |
7035 v18 = this->uClipY; | |
7036 if ( v18 < a3 ) | |
7037 v18 = a3; | |
7038 v19 = this->uClipW; | |
7039 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
7040 { | |
7041 v20 = this->uClipY; | |
7042 if ( v20 < a3 ) | |
7043 v20 = a3; | |
7044 v9 = v19 - v20; | |
7045 } | |
7046 v11 = (unsigned char *)v25; | |
7047 } | |
2069 | 7048 |
0 | 7049 if ( a8 ) |
7050 { | |
2069 | 7051 v28 = 0x7FF; // 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask; |
7052 for (int dy = 0; dy < v9; ++dy) | |
7053 { | |
7054 for (int dx = 0; dx < v8; ++dx) | |
7055 { | |
7056 if ( *v11 ) | |
7057 v24 = pPalette[*v11]; | |
7058 else | |
7059 v24 = v28; | |
7060 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24); | |
7061 //*v10 = v24; | |
7062 //++v10; | |
2074 | 7063 ++v11; |
2069 | 7064 //--v27; |
2074 | 7065 |
2069 | 7066 } |
7067 v11 += a5 - v8; | |
7068 } | |
7069 /*if ( (signed int)v9 > 0 ) | |
0 | 7070 { |
7071 v23 = a5; | |
7072 v30 = v9; | |
7073 do | |
7074 { | |
7075 if ( v8 > 0 ) | |
7076 { | |
7077 v27 = v8; | |
7078 do | |
7079 { | |
7080 if ( *v11 ) | |
7081 v24 = pPalette[*v11]; | |
7082 else | |
7083 v24 = v28; | |
7084 *v10 = v24; | |
7085 ++v10; | |
7086 ++v11; | |
7087 --v27; | |
7088 } | |
7089 while ( v27 ); | |
7090 } | |
7091 v11 += v23 - v8; | |
7092 v22 = v30-- == 1; | |
7093 v10 += this->uTargetSurfacePitch - v8; | |
7094 } | |
7095 while ( !v22 ); | |
2069 | 7096 }*/ |
0 | 7097 } |
7098 else | |
7099 { | |
2069 | 7100 for (int dy = 0; dy < v9; ++dy) |
7101 { | |
7102 for (int dx = 0; dx < v8; ++dx) | |
7103 { | |
2074 | 7104 if ( *v11 ) |
2069 | 7105 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]); |
7106 //*v10 = v24; | |
7107 //++v10; | |
2074 | 7108 ++v11; |
2069 | 7109 //--v27; |
7110 } | |
7111 v11 += a5 - v8; | |
7112 } | |
7113 | |
7114 /*if ( (signed int)v9 > 0 ) | |
0 | 7115 { |
7116 v21 = a5; | |
7117 v29 = v9; | |
7118 do | |
7119 { | |
7120 if ( v8 > 0 ) | |
7121 { | |
7122 v26 = v8; | |
7123 do | |
7124 { | |
7125 if ( *v11 ) | |
7126 *v10 = pPalette[*v11]; | |
7127 ++v10; | |
7128 ++v11; | |
7129 --v26; | |
7130 } | |
7131 while ( v26 ); | |
7132 } | |
7133 v11 += v21 - v8; | |
7134 v22 = v29-- == 1; | |
7135 v10 += this->uTargetSurfacePitch - v8; | |
7136 } | |
7137 while ( !v22 ); | |
2069 | 7138 }*/ |
7139 } | |
0 | 7140 } |
7141 | |
7142 //----- (004A68EF) -------------------------------------------------------- | |
7143 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
7144 { | |
2069 | 7145 DrawMasked(a2, a3, pTexture, 0x07E0); |
7146 } | |
7147 | |
0 | 7148 |
7149 //----- (004A6776) -------------------------------------------------------- | |
315 | 7150 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 7151 { |
2069 | 7152 DrawMasked(a2, a3, a4, 0xF800); |
7153 /*Texture *v4; // edi@2 | |
0 | 7154 unsigned int v5; // ebx@4 |
7155 unsigned __int16 *v6; // eax@4 | |
7156 unsigned int v7; // edx@5 | |
7157 unsigned int v8; // edx@6 | |
7158 unsigned int v9; // edx@7 | |
7159 unsigned int v10; // edx@8 | |
7160 unsigned int v11; // edx@9 | |
7161 unsigned int v12; // esi@12 | |
7162 unsigned int v13; // esi@15 | |
7163 unsigned int v14; // edx@17 | |
7164 unsigned int v15; // esi@18 | |
7165 unsigned __int8 *v16; // ebx@22 | |
7166 char v17; // zf@28 | |
7167 int v18; // [sp+10h] [bp-10h]@4 | |
7168 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7169 int v20; // [sp+1Ch] [bp-4h]@4 | |
7170 int a2a; // [sp+28h] [bp+8h]@24 | |
7171 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
7172 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
7173 | |
7174 if ( this->uNumSceneBegins ) | |
7175 { | |
7176 v4 = a4; | |
7177 if ( a4 ) | |
7178 { | |
7179 if ( a4->pPalette16 ) | |
7180 { | |
7181 v5 = a4->uTextureHeight; | |
7182 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7183 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7184 v20 = a4->uTextureWidth; |
7185 v18 = a4->uTextureWidth; | |
7186 if ( this->bClip ) | |
7187 { | |
7188 v7 = this->uClipX; | |
7189 if ( (signed int)a2 < (signed int)v7 ) | |
7190 { | |
7191 v8 = v7 - a2; | |
7192 v19 += v8; | |
7193 v20 += a2 - this->uClipX; | |
7194 v6 += v8; | |
7195 } | |
7196 v9 = this->uClipY; | |
7197 v5 = a4->uTextureHeight; | |
7198 if ( (signed int)a3 < (signed int)v9 ) | |
7199 { | |
7200 v10 = v9 - a3; | |
7201 v19 += v18 * v10; | |
7202 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
7203 v4 = a4; | |
7204 v6 += this->uTargetSurfacePitch * v10; | |
7205 } | |
7206 v11 = this->uClipX; | |
7207 if ( (signed int)v11 < (signed int)a2 ) | |
7208 v11 = a2; | |
7209 a4a = this->uClipZ; | |
7210 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
7211 { | |
7212 v12 = this->uClipX; | |
7213 if ( (signed int)v12 < (signed int)a2 ) | |
7214 v12 = a2; | |
7215 v20 = a4a - v12; | |
7216 } | |
7217 v13 = this->uClipY; | |
7218 if ( (signed int)v13 < (signed int)a3 ) | |
7219 v13 = a3; | |
7220 v14 = this->uClipW; | |
7221 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7222 { | |
7223 v15 = this->uClipY; | |
7224 if ( (signed int)v15 < (signed int)a3 ) | |
7225 v15 = a3; | |
7226 v5 = v14 - v15; | |
7227 } | |
7228 } | |
7229 if ( (signed int)v5 > 0 ) | |
7230 { | |
7231 a3a = v5; | |
7232 v16 = v19; | |
7233 do | |
7234 { | |
7235 if ( v20 > 0 ) | |
7236 { | |
7237 a2a = v20; | |
7238 do | |
7239 { | |
7240 if ( *v16 ) | |
7241 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
7242 ++v6; | |
7243 ++v16; | |
7244 --a2a; | |
7245 } | |
7246 while ( a2a ); | |
7247 } | |
7248 v16 += v18 - v20; | |
7249 v17 = a3a-- == 1; | |
7250 v6 += this->uTargetSurfacePitch - v20; | |
7251 } | |
7252 while ( !v17 ); | |
7253 } | |
7254 } | |
7255 } | |
2069 | 7256 }*/ |
7257 } | |
7258 | |
7259 //----- (004A68EF) -------------------------------------------------------- | |
7260 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask) | |
7261 { | |
7262 Texture *v4; // edi@2 | |
7263 unsigned int v5; // ebx@4 | |
7264 //unsigned __int16 *v6; // eax@4 | |
7265 signed int v7; // edx@5 | |
7266 int v8; // edx@6 | |
7267 signed int v9; // edx@7 | |
7268 int v10; // edx@8 | |
7269 signed int v11; // edx@9 | |
7270 signed int v12; // esi@12 | |
7271 signed int v13; // esi@15 | |
7272 unsigned int v14; // edx@17 | |
7273 signed int v15; // esi@18 | |
7274 unsigned __int8 *v16; // ebx@22 | |
7275 char v17; // zf@28 | |
7276 int v18; // [sp+10h] [bp-10h]@4 | |
7277 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7278 int v20; // [sp+1Ch] [bp-4h]@4 | |
7279 int v21; // [sp+28h] [bp+8h]@24 | |
7280 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
7281 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7282 | |
7283 if (!uNumSceneBegins || !pTexture) | |
7284 return; | |
7285 | |
7286 v4 = pTexture; | |
7287 | |
7288 if ( pTexture->pPalette16 ) | |
7289 { | |
7290 v5 = pTexture->uTextureHeight; | |
7291 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
7292 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; | |
7293 v20 = pTexture->uTextureWidth; | |
7294 v18 = pTexture->uTextureWidth; | |
7295 int clipped_out_x = a2; | |
7296 int clipped_out_y = a3; | |
7297 if ( this->bClip ) | |
7298 { | |
7299 v7 = this->uClipX; | |
7300 if ( a2 < v7 ) | |
7301 { | |
7302 v8 = v7 - a2; | |
7303 v19 += v8; | |
7304 v20 += a2 - this->uClipX; | |
7305 //v6 += v8; | |
7306 clipped_out_x = uClipX; | |
7307 } | |
7308 v9 = this->uClipY; | |
7309 v5 = pTexture->uTextureHeight; | |
7310 if ( a3 < v9 ) | |
7311 { | |
7312 v10 = v9 - a3; | |
7313 v19 += v18 * v10; | |
7314 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7315 v4 = pTexture; | |
7316 //v6 += this->uTargetSurfacePitch * v10; | |
7317 clipped_out_y = uClipY; | |
7318 } | |
7319 v11 = this->uClipX; | |
7320 if ( v11 < a2 ) | |
7321 v11 = a2; | |
7322 pTexturea = this->uClipZ; | |
7323 if ( v11 + v20 > (signed int)pTexturea ) | |
7324 { | |
7325 v12 = this->uClipX; | |
7326 if ( v12 < a2 ) | |
7327 v12 = a2; | |
7328 v20 = pTexturea - v12; | |
7329 } | |
7330 v13 = this->uClipY; | |
7331 if ( v13 < a3 ) | |
7332 v13 = a3; | |
7333 v14 = this->uClipW; | |
7334 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7335 { | |
7336 v15 = this->uClipY; | |
7337 if ( v15 < a3 ) | |
7338 v15 = a3; | |
7339 v5 = v14 - v15; | |
7340 } | |
7341 } | |
7342 | |
7343 v16 = v19; | |
7344 for (int y = 0; y < v5; ++y) | |
7345 { | |
7346 for (int x = 0; x < v20; ++x) | |
7347 { | |
7348 if ( *v16 ) | |
7349 WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16] & mask); | |
7350 ++v16; | |
7351 } | |
7352 v16 += v18 - v20; | |
7353 } | |
7354 | |
7355 /*if ( (signed int)v5 > 0 ) | |
7356 { | |
7357 v22 = v5; | |
7358 v16 = v19; | |
7359 do | |
7360 { | |
7361 if ( v20 > 0 ) | |
7362 { | |
7363 v21 = v20; | |
7364 do | |
7365 { | |
7366 if ( *v16 ) | |
7367 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7368 ++v6; | |
7369 ++v16; | |
7370 --v21; | |
7371 } | |
7372 while ( v21 ); | |
7373 } | |
7374 v16 += v18 - v20; | |
7375 v17 = v22-- == 1; | |
7376 v6 += this->uTargetSurfacePitch - v20; | |
7377 } | |
7378 while ( !v17 ); | |
7379 }*/ | |
7380 } | |
7381 } | |
7382 | |
0 | 7383 |
7384 //----- (004A65CC) -------------------------------------------------------- | |
7385 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
7386 { | |
2198 | 7387 unsigned int uHeight; // edi@6 |
0 | 7388 unsigned int v14; // edx@11 |
7389 unsigned int v16; // edx@14 | |
7390 unsigned int v17; // edx@17 | |
7391 unsigned int v19; // edx@20 | |
7392 int v20; // eax@27 | |
7393 int v21; // edx@29 | |
7394 int v23; // [sp+Ch] [bp-Ch]@24 | |
7395 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
7396 int xa; // [sp+20h] [bp+8h]@26 | |
7397 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
2198 | 7398 int Width; // [sp+2Ch] [bp+14h]@6 |
0 | 7399 |
7400 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
7401 { | |
710 | 7402 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7403 Width = a4->uTextureWidth; |
7404 uHeight = a4->uTextureHeight; | |
2069 | 7405 int clipped_out_x = x; |
7406 int clipped_out_y = y; | |
0 | 7407 if ( this->bClip ) |
7408 { | |
2198 | 7409 if ( (signed int)x < (signed int)this->uClipX ) |
7410 { | |
7411 v24 += this->uClipX - x; | |
7412 Width += x - this->uClipX; | |
2069 | 7413 clipped_out_x = uClipX; |
0 | 7414 } |
2198 | 7415 if ( (signed int)y < (signed int)this->uClipY ) |
7416 { | |
7417 v24 += a4->uTextureWidth * (this->uClipY - y); | |
7418 uHeight = y - this->uClipY + a4->uTextureHeight; | |
2069 | 7419 clipped_out_y = uClipY; |
0 | 7420 } |
7421 v14 = this->uClipX; | |
2198 | 7422 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7423 v14 = x; |
2198 | 7424 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7425 { |
7426 v16 = this->uClipX; | |
2198 | 7427 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7428 v16 = x; |
2198 | 7429 Width = this->uClipZ - v16; |
0 | 7430 } |
7431 v17 = this->uClipY; | |
2198 | 7432 if ( (signed int)this->uClipY < (signed int)y ) |
0 | 7433 v17 = y; |
2198 | 7434 if ( (signed int)(uHeight + v17) > (signed int)this->uClipW ) |
0 | 7435 { |
7436 v19 = this->uClipY; | |
7437 if ( (signed int)v19 < (signed int)y ) | |
7438 v19 = y; | |
2198 | 7439 uHeight = this->uClipW - v19; |
7440 } | |
7441 } | |
7442 | |
7443 for (int dy = 0; dy < uHeight; ++dy) | |
7444 { | |
7445 for (int dx = 0; dx < Width; ++dx) | |
7446 { | |
7447 v20 = *v24; | |
7448 if ( v20 >= a7 && v20 <= a8 ) | |
7449 { | |
7450 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7451 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7452 v21 = 2 * a8 - v21 - a7; | |
7453 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]); | |
7454 } | |
7455 ++v24; | |
7456 } | |
7457 v24 += a4->uTextureWidth - Width; | |
2069 | 7458 } |
7459 /*if ( (signed int)v9 > 0 ) | |
0 | 7460 { |
7461 ya = v9; | |
7462 v23 = v22 - v27; | |
7463 do | |
7464 { | |
7465 if ( v27 > 0 ) | |
7466 { | |
7467 xa = v27; | |
7468 do | |
7469 { | |
7470 v20 = *v24; | |
7471 if ( v20 >= a7 && v20 <= a8 ) | |
7472 { | |
7473 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7474 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7475 v21 = 2 * a8 - v21 - a7; | |
7476 *v8 = a4->pPalette16[v21]; | |
7477 } | |
7478 ++v8; | |
7479 ++v24; | |
7480 --xa; | |
7481 } | |
7482 while ( xa ); | |
7483 } | |
7484 v8 += this->uTargetSurfacePitch - v27; | |
7485 v24 += v23; | |
7486 --ya; | |
7487 } | |
7488 while ( ya ); | |
2069 | 7489 }*/ |
0 | 7490 } |
7491 } | |
7492 | |
7493 //----- (004A63E6) -------------------------------------------------------- | |
1455 | 7494 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) |
0 | 7495 { |
7496 unsigned int v14; // edx@11 | |
7497 unsigned int v16; // edx@14 | |
7498 unsigned int v17; // edx@17 | |
7499 unsigned int v19; // edx@20 | |
7500 int v20; // eax@27 | |
7501 int v21; // edx@29 | |
7502 int v23; // [sp+Ch] [bp-Ch]@24 | |
2198 | 7503 int Height; // [sp+10h] [bp-8h]@6 |
7504 int Width; // [sp+14h] [bp-4h]@6 | |
0 | 7505 int v27; // [sp+24h] [bp+Ch]@23 |
7506 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
7507 | |
7508 if ( this->uNumSceneBegins ) | |
7509 { | |
7510 if ( a4 ) | |
7511 { | |
7512 if ( a4->pPalette16 ) | |
7513 { | |
7514 if ( a5 ) | |
7515 { | |
7516 if ( a5->pPalette16 ) | |
7517 { | |
710 | 7518 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7519 Width = a4->uTextureWidth; |
7520 Height = a4->uTextureHeight; | |
2069 | 7521 int clipped_out_x = a2; |
7522 int clipped_out_y = a3; | |
0 | 7523 if ( this->bClip ) |
7524 { | |
2198 | 7525 if ( (signed int)a2 < (signed int)this->uClipX ) |
0 | 7526 { |
2198 | 7527 v28 += this->uClipX - a2; |
7528 Width += a2 - this->uClipX; | |
2069 | 7529 clipped_out_x = uClipX; |
0 | 7530 } |
2198 | 7531 |
7532 if ( (signed int)a3 < (signed int)this->uClipY ) | |
0 | 7533 { |
2198 | 7534 v28 += a4->uTextureWidth * (this->uClipY - a3); |
7535 Height += a3 - this->uClipY; | |
2069 | 7536 clipped_out_y = uClipY; |
0 | 7537 } |
2198 | 7538 |
0 | 7539 v14 = this->uClipX; |
2198 | 7540 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7541 v14 = a2; |
2198 | 7542 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7543 { |
7544 v16 = this->uClipX; | |
2198 | 7545 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7546 v16 = a2; |
2198 | 7547 Width = this->uClipZ - v16; |
0 | 7548 } |
2198 | 7549 |
0 | 7550 v17 = this->uClipY; |
2198 | 7551 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7552 v17 = a3; |
2198 | 7553 if ( (signed int)(Height + v17) > (signed int)this->uClipW ) |
0 | 7554 { |
7555 v19 = this->uClipY; | |
2198 | 7556 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7557 v19 = a3; |
2198 | 7558 Height = this->uClipW - v19; |
0 | 7559 } |
7560 } | |
2069 | 7561 |
0 | 7562 v27 = 0; |
2198 | 7563 for (int y = 0; y < Height; ++y) |
2069 | 7564 { |
2198 | 7565 for (int x = 0; x < Width; ++x) |
2069 | 7566 { |
7567 if ( *v28 ) | |
7568 { | |
2101 | 7569 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); |
2069 | 7570 if ( v20 >= a7 ) |
7571 { | |
7572 if ( v20 <= a8 ) | |
7573 { | |
7574 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7575 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7576 v21 = 2 * a8 - v21 - a7; | |
7577 //v9 = a5; | |
7578 //*v10 = a5->pPalette16[v21]; | |
7579 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]); | |
7580 } | |
7581 } | |
7582 } | |
7583 v28++; | |
7584 } | |
2198 | 7585 v28 += a4->uTextureWidth - Width; |
2069 | 7586 } |
7587 | |
7588 /*if ( v24 > 0 ) | |
0 | 7589 { |
7590 v23 = v22 - v25; | |
7591 do | |
7592 { | |
7593 for ( i = 0; i < v25; ++v28 ) | |
7594 { | |
7595 if ( *v28 ) | |
7596 { | |
710 | 7597 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 7598 if ( v20 >= a7 ) |
7599 { | |
7600 if ( v20 <= a8 ) | |
7601 { | |
7602 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7603 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7604 v21 = 2 * a8 - v21 - a7; | |
7605 v9 = a5; | |
7606 *v10 = a5->pPalette16[v21]; | |
7607 } | |
7608 } | |
7609 } | |
7610 ++i; | |
7611 ++v10; | |
7612 } | |
7613 ++v27; | |
7614 v10 += this->uTargetSurfacePitch - v25; | |
7615 v28 += v23; | |
7616 } | |
7617 while ( v27 < v24 ); | |
2069 | 7618 }*/ |
7619 | |
0 | 7620 } |
7621 } | |
7622 } | |
7623 } | |
7624 } | |
7625 } | |
7626 | |
7627 //----- (004A6274) -------------------------------------------------------- | |
7628 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
7629 { | |
7630 int uHeight; // ebx@4 | |
7631 unsigned int v11; // edx@9 | |
7632 unsigned int v12; // esi@12 | |
7633 unsigned int v13; // esi@15 | |
7634 unsigned int v15; // esi@18 | |
7635 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7636 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
7637 | |
7638 if ( this->uNumSceneBegins ) | |
7639 { | |
7640 if ( pTexture ) | |
7641 { | |
7642 if ( pTexture->pPalette16 ) | |
7643 { | |
7644 uHeight = pTexture->uTextureHeight; | |
710 | 7645 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7646 uWidth = pTexture->uTextureWidth; |
2069 | 7647 |
7648 int clipped_out_x = uX; | |
7649 int clipped_out_y = uY; | |
0 | 7650 if ( this->bClip ) |
7651 { | |
2198 | 7652 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 7653 { |
2198 | 7654 v19 += this->uClipX - uX; |
0 | 7655 uWidth += uX - this->uClipX; |
2069 | 7656 clipped_out_x = uClipX; |
0 | 7657 } |
2198 | 7658 |
0 | 7659 uHeight = pTexture->uTextureHeight; |
2198 | 7660 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 7661 { |
2198 | 7662 v19 += pTexture->uTextureWidth * (this->uClipY - uY); |
0 | 7663 uHeight = uY - this->uClipY + pTexture->uTextureHeight; |
2069 | 7664 clipped_out_y = uClipY; |
0 | 7665 } |
7666 v11 = this->uClipX; | |
2198 | 7667 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7668 v11 = uX; |
2198 | 7669 |
7670 if ( (signed int)(v11 + uWidth) > (signed int)this->uClipZ ) | |
0 | 7671 { |
7672 v12 = this->uClipX; | |
2198 | 7673 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7674 v12 = uX; |
2198 | 7675 uWidth = this->uClipZ - v12; |
0 | 7676 } |
7677 v13 = this->uClipY; | |
2198 | 7678 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7679 v13 = uY; |
2198 | 7680 |
7681 if ( (signed int)(uHeight + v13) > (signed int)this->uClipW ) | |
0 | 7682 { |
7683 v15 = this->uClipY; | |
2198 | 7684 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7685 v15 = uY; |
2198 | 7686 uHeight = this->uClipW - v15; |
0 | 7687 } |
7688 } | |
2198 | 7689 |
2069 | 7690 for (int y = 0; y < uHeight; ++y) |
7691 { | |
7692 for (int x = 0; x < uWidth; ++x) | |
7693 { | |
2198 | 7694 if ( *v19 ) |
7695 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); | |
7696 ++v19; | |
2069 | 7697 } |
2198 | 7698 v19 += pTexture->uTextureWidth - uWidth; |
2069 | 7699 } |
7700 /*if ( (signed int)uHeight > 0 ) | |
0 | 7701 { |
7702 uYa = uHeight; | |
7703 v16 = v19; | |
7704 do | |
7705 { | |
7706 if ( uWidth > 0 ) | |
7707 { | |
7708 uXa = uWidth; | |
7709 do | |
7710 { | |
7711 if ( *v16 ) | |
7712 *v6 = pCurrentTexture->pPalette16[*v16]; | |
7713 ++v6; | |
7714 ++v16; | |
7715 } | |
7716 while ( uXa-- !=1 ); | |
7717 } | |
7718 v16 += v18 - uWidth; | |
7719 uFlag = uYa-- == 1; | |
7720 v6 += this->uTargetSurfacePitch - uWidth; | |
7721 } | |
7722 while ( !uFlag ); | |
2069 | 7723 }*/ |
0 | 7724 } |
7725 } | |
7726 } | |
7727 } | |
7728 | |
7729 //----- (004A612A) -------------------------------------------------------- | |
710 | 7730 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 7731 { |
7732 Texture *v5; // eax@2 | |
7733 unsigned int v6; // edx@3 | |
7734 int v7; // ebx@3 | |
7735 int v8; // edi@3 | |
7736 signed int v9; // eax@4 | |
7737 int v10; // eax@5 | |
7738 unsigned int v11; // esi@6 | |
7739 signed int v12; // esi@8 | |
7740 unsigned int v13; // eax@10 | |
7741 signed int v14; // esi@11 | |
7742 unsigned int v15; // esi@14 | |
7743 unsigned int v16; // eax@16 | |
7744 unsigned int v17; // ecx@17 | |
7745 int v18; // edx@23 | |
7746 int v19; // [sp+Ch] [bp-Ch]@3 | |
7747 int v20; // [sp+10h] [bp-8h]@3 | |
7748 int uOutXa; // [sp+20h] [bp+8h]@21 | |
7749 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
7750 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
7751 | |
7752 if ( this->uNumSceneBegins ) | |
7753 { | |
7754 v5 = pTexture; | |
7755 if ( pTexture ) | |
7756 { | |
7757 v6 = uOutY; | |
7758 v7 = pTexture->uTextureHeight; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7759 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; |
710 | 7760 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7761 v8 = v5->uTextureWidth; |
7762 v20 = v5->uTextureWidth; | |
7763 v19 = v5->uTextureWidth; | |
7764 if ( this->bClip ) | |
7765 { | |
7766 v9 = this->uClipX; | |
7767 if ( uOutX < v9 ) | |
7768 { | |
7769 v10 = v9 - uOutX; | |
7770 uOutYa += v10; | |
7771 v8 += uOutX - this->uClipX; | |
7772 v20 = v8; | |
7773 pZBuffer += v10; | |
7774 } | |
7775 v11 = this->uClipY; | |
7776 if ( (signed int)v6 < (signed int)v11 ) | |
7777 { | |
7778 uOutYa += v19 * (v11 - v6); | |
7779 v7 += v6 - v11; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7780 pZBuffer += window->GetWidth() * (v11 - v6); |
0 | 7781 v8 = v20; |
7782 } | |
7783 v12 = this->uClipX; | |
7784 if ( v12 < uOutX ) | |
7785 v12 = uOutX; | |
7786 v13 = this->uClipZ; | |
7787 if ( v8 + v12 > (signed int)v13 ) | |
7788 { | |
7789 v14 = this->uClipX; | |
7790 if ( v14 < uOutX ) | |
7791 v14 = uOutX; | |
7792 v8 = v13 - v14; | |
7793 } | |
7794 v15 = this->uClipY; | |
7795 if ( (signed int)v15 < (signed int)v6 ) | |
7796 v15 = v6; | |
7797 v16 = this->uClipW; | |
7798 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
7799 { | |
7800 v17 = this->uClipY; | |
7801 if ( (signed int)v17 >= (signed int)v6 ) | |
7802 v6 = v17; | |
7803 v7 = v16 - v6; | |
7804 } | |
7805 } | |
7806 if ( v7 > 0 ) | |
7807 { | |
7808 uOutXa = v7; | |
7809 do | |
7810 { | |
7811 if ( v8 > 0 ) | |
7812 { | |
7813 v18 = v8; | |
7814 do | |
7815 { | |
7816 if ( *uOutYa ) | |
7817 *pZBuffer = zVal; | |
7818 ++pZBuffer; | |
7819 ++uOutYa; | |
7820 --v18; | |
7821 } | |
7822 while ( v18 ); | |
7823 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7824 pZBuffer += window->GetWidth() - v8; |
0 | 7825 uOutYa += v19 - v8; |
7826 --uOutXa; | |
7827 } | |
7828 while ( uOutXa ); | |
7829 } | |
7830 } | |
7831 } | |
7832 } | |
7833 | |
7834 //----- (004A601E) -------------------------------------------------------- | |
991 | 7835 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 7836 { |
7837 signed int v5; // edx@3 | |
7838 int v6; // ebx@3 | |
7839 int v7; // esi@3 | |
7840 void *v8; // esi@3 | |
7841 unsigned int v9; // eax@4 | |
7842 unsigned int v10; // eax@6 | |
7843 signed int v11; // edi@8 | |
7844 unsigned int v12; // eax@10 | |
7845 signed int v13; // edi@11 | |
7846 unsigned int v14; // edi@14 | |
7847 unsigned int v15; // eax@16 | |
7848 unsigned int v16; // ecx@17 | |
7849 int v17; // [sp+18h] [bp+Ch]@3 | |
7850 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
7851 | |
7852 if ( this->uNumSceneBegins && pTexture ) | |
7853 { | |
7854 v5 = a3; | |
7855 v6 = pTexture->uTextureHeight; | |
7856 v7 = 5 * a3; | |
7857 v17 = pTexture->uTextureHeight; | |
7858 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
7859 pTexturea = pTexture->uTextureWidth; | |
7860 if ( this->bClip ) | |
7861 { | |
7862 v9 = this->uClipX; | |
7863 if ( a2 < (signed int)v9 ) | |
7864 { | |
7865 pTexturea += a2 - v9; | |
7866 v8 = (char *)v8 + 4 * (v9 - a2); | |
7867 } | |
7868 v10 = this->uClipY; | |
7869 if ( v5 < (signed int)v10 ) | |
7870 { | |
7871 v17 += v5 - v10; | |
7872 v8 = (char *)v8 + 2560 * (v10 - v5); | |
7873 } | |
7874 v11 = this->uClipX; | |
7875 if ( v11 < a2 ) | |
7876 v11 = a2; | |
7877 v12 = this->uClipZ; | |
7878 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
7879 { | |
7880 v13 = this->uClipX; | |
7881 if ( v13 < a2 ) | |
7882 v13 = a2; | |
7883 pTexturea = v12 - v13; | |
7884 } | |
7885 v14 = this->uClipY; | |
7886 if ( (signed int)v14 < v5 ) | |
7887 v14 = v5; | |
7888 v6 = v17; | |
7889 v15 = this->uClipW; | |
7890 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
7891 { | |
7892 v16 = this->uClipY; | |
7893 if ( (signed int)v16 < v5 ) | |
7894 v16 = v5; | |
7895 v6 = v15 - v16; | |
7896 } | |
7897 } | |
7898 if ( v6 > 0 ) | |
7899 { | |
7900 do | |
7901 { | |
7902 if ( (signed int)pTexturea > 0 ) | |
7903 { | |
7904 memset32(v8, a5, pTexturea); | |
7905 v8 = (char *)v8 + 4 * pTexturea; | |
7906 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7907 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea); |
0 | 7908 --v6; |
7909 } | |
7910 while ( v6 ); | |
7911 } | |
7912 } | |
7913 } | |
7914 | |
7915 //----- (004A5EB2) -------------------------------------------------------- | |
7916 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
7917 { | |
2069 | 7918 int v5; // ebx@4 |
0 | 7919 unsigned int v8; // edx@6 |
7920 unsigned int v10; // edx@8 | |
7921 unsigned int v11; // edx@9 | |
7922 unsigned int v12; // esi@12 | |
7923 unsigned int v13; // esi@15 | |
7924 unsigned int v15; // esi@18 | |
7925 char v17; // zf@26 | |
7926 int v18; // [sp+10h] [bp-10h]@4 | |
7927 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7928 int v20; // [sp+1Ch] [bp-4h]@4 | |
7929 int uXa; // [sp+28h] [bp+8h]@24 | |
7930 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
7931 | |
7932 if ( this->uNumSceneBegins ) | |
7933 { | |
7934 if ( a4 ) | |
7935 { | |
7936 if ( a4->pPalette16 ) | |
7937 { | |
7938 v5 = a4->uTextureHeight; | |
2069 | 7939 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
710 | 7940 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7941 v20 = a4->uTextureWidth; |
7942 v18 = a4->uTextureWidth; | |
2069 | 7943 |
7944 int clipped_out_x = uX; | |
7945 int clipped_out_y = uY; | |
0 | 7946 if ( this->bClip ) |
7947 { | |
2198 | 7948 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 7949 { |
2198 | 7950 v8 = this->uClipX - uX; |
0 | 7951 v19 += v8; |
7952 v20 += uX - this->uClipX; | |
2069 | 7953 clipped_out_x = uClipX; |
0 | 7954 } |
2198 | 7955 |
0 | 7956 v5 = a4->uTextureHeight; |
2198 | 7957 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 7958 { |
2198 | 7959 v10 = this->uClipY - uY; |
0 | 7960 v19 += v18 * v10; |
7961 v5 = uY - this->uClipY + a4->uTextureHeight; | |
2198 | 7962 //v4 = a4; |
2069 | 7963 clipped_out_y = uClipY; |
0 | 7964 } |
2198 | 7965 |
0 | 7966 v11 = this->uClipX; |
7967 if ( (signed int)v11 < (signed int)uX ) | |
7968 v11 = uX; | |
2198 | 7969 |
7970 if ( (signed int)(v11 + v20) > (signed int)this->uClipZ ) | |
0 | 7971 { |
7972 v12 = this->uClipX; | |
7973 if ( (signed int)v12 < (signed int)uX ) | |
7974 v12 = uX; | |
2198 | 7975 v20 = this->uClipZ - v12; |
0 | 7976 } |
2198 | 7977 |
0 | 7978 v13 = this->uClipY; |
7979 if ( (signed int)v13 < (signed int)uY ) | |
7980 v13 = uY; | |
2069 | 7981 |
7982 if ( (signed int)(v5 + v13) > (signed int)uClipW ) | |
0 | 7983 { |
7984 v15 = this->uClipY; | |
7985 if ( (signed int)v15 < (signed int)uY ) | |
7986 v15 = uY; | |
2069 | 7987 v5 = uClipW - v15; |
0 | 7988 } |
7989 } | |
2198 | 7990 |
2069 | 7991 for (int y = 0; y < v5; ++y) |
7992 { | |
7993 for (int x = 0; x < v20; ++x) | |
7994 { | |
2198 | 7995 if ( a4->pPalette16[*v19] != 0x7FF )// 2047 |
7996 WritePixel16(clipped_out_x + x, clipped_out_y + y, a4->pPalette16[*v19]); | |
7997 ++v19; | |
2069 | 7998 } |
2198 | 7999 v19 += v18 - v20; |
2069 | 8000 } |
8001 /*if ( (signed int)v5 > 0 ) | |
0 | 8002 { |
8003 uYa = v5; | |
8004 v16 = v19; | |
8005 do | |
8006 { | |
8007 if ( v20 > 0 ) | |
8008 { | |
8009 uXa = v20; | |
8010 do | |
8011 { | |
8012 *pTarget = v4->pPalette16[*v16]; | |
8013 ++pTarget; | |
8014 ++v16; | |
8015 --uXa; | |
8016 } | |
8017 while ( uXa ); | |
8018 } | |
8019 v16 += v18 - v20; | |
8020 v17 = uYa-- == 1; | |
8021 pTarget += this->uTargetSurfacePitch - v20; | |
8022 } | |
8023 while ( !v17 ); | |
2069 | 8024 }*/ |
0 | 8025 } |
8026 } | |
8027 } | |
8028 } | |
8029 | |
8030 //----- (004667E9) -------------------------------------------------------- | |
8031 void Render::ChangeBetweenWinFullscreenModes() | |
8032 { | |
8033 float v0; // ST14_4@17 | |
8034 int v4; // edx@26 | |
8035 ObjectDesc *v5; // eax@26 | |
8036 RGBTexture *v6; // esi@33 | |
8037 const char *v8; // [sp-4h] [bp-28h]@33 | |
8038 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
8039 | |
2061 | 8040 /*if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) |
0 | 8041 { |
1458 | 8042 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 | 8043 return; |
2061 | 8044 }*/ |
2154 | 8045 if ( pRenderer->bWindowMode || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8046 { |
0 | 8047 if ( pEventTimer->bPaused ) |
2061 | 8048 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0800; |
0 | 8049 else |
8050 pEventTimer->Pause(); | |
8051 if ( pMiscTimer->bPaused ) | |
2061 | 8052 dword_6BE364_game_settings_1 |= GAME_SETTINGS_1000; |
0 | 8053 else |
8054 pMiscTimer->Pause(); | |
8055 pMouse->bActive = 0; | |
8056 if ( pRenderer->pRenderD3D ) | |
8057 { | |
8058 pBitmaps_LOD->ReleaseHardwareTextures(); | |
8059 pSprites_LOD->ReleaseAll(); | |
8060 } | |
8061 if ( pRenderer->bWindowMode ) | |
8062 { | |
1802 | 8063 //SetMenu(hWnd, 0); |
8064 //SetWindowLongA(hWnd, -20, 0); | |
8065 //SetWindowLongA(hWnd, -16, 0x10000000u); | |
8066 window->SetFullscreenMode(); | |
8067 pRenderer->InitializeFullscreen(); | |
0 | 8068 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; |
8069 pGame->pGammaController->Initialize(v0); | |
8070 } | |
8071 else | |
8072 { | |
1802 | 8073 //ClipCursor(0); |
8074 window->SetWindowedMode(window->GetWidth(), window->GetHeight()); | |
8075 pRenderer->SwitchToWindow(); | |
0 | 8076 } |
8077 if ( pRenderer->pRenderD3D ) | |
8078 { | |
8079 pBitmaps_LOD->_410423_move_textures_to_device(); | |
8080 pSprites_LOD->MoveSpritesToVideoMemory(); | |
8081 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8082 if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits |
0 | 8083 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8084 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8085 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8086 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8087 pPaletteManager->RecalculateAll(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8088 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8089 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8090 for (int i = 0; i < pObjectList->uNumObjects; i++) |
0 | 8091 { |
8092 BYTE3(v4) = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8093 v5 = &pObjectList->pObjects[i]; |
0 | 8094 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; |
8095 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
8096 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8097 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8098 SetUserInterface(pParty->alignment, true); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8099 if ( pVideoPlayer->pVideoFrame.pPixels ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8100 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); |
2006 | 8101 if ( sCurrentMenuID != MENU_CREATEPARTY ) |
8102 { | |
8103 if ( sCurrentMenuID == MENU_CREDITSPROC ) | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8104 dword_A74C88 = 1; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8105 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8106 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8107 { |
2006 | 8108 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8109 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8110 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8111 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8112 v8 = "makeme.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8113 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8114 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8115 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8116 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8117 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8118 v8 = "title.pcx"; |
2006 | 8119 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8120 v8 = "lsave640.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8121 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8122 v6->Load(v8, 0); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8123 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8124 } |
0 | 8125 viewparams->bRedrawGameUI = 1; |
688 | 8126 viewparams->InitGrayPalette(); |
0 | 8127 pMouse->SetCurrentCursorBitmap(); |
1802 | 8128 /*if ( pRenderer->bWindowMode ) |
0 | 8129 { |
1655 | 8130 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); |
8131 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); | |
1586 | 8132 ShowWindow(hWnd, SW_SHOWNORMAL); |
1802 | 8133 }*/ |
8134 pMouse->bActive = true; | |
0 | 8135 if ( pVideoPlayer->AnyMovieLoaded() ) |
898 | 8136 pVideoPlayer->SelectMovieType(); |
2061 | 8137 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0800) |
8138 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0800; | |
0 | 8139 else |
8140 pEventTimer->Resume(); | |
2061 | 8141 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_1000) |
8142 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_1000; | |
0 | 8143 else |
8144 pMiscTimer->Resume(); | |
8145 } | |
8146 } | |
8147 | |
8148 | |
8149 //----- (004524D8) -------------------------------------------------------- | |
8150 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
8151 { | |
1583 | 8152 //int v11; // eax@13 |
8153 //int v12; // ecx@13 | |
0 | 8154 void *v13; // eax@13 |
1583 | 8155 //unsigned __int8 v14; // zf@13 |
8156 //unsigned __int8 v15; // sf@13 | |
0 | 8157 int v16; // esi@14 |
8158 int v17; // ecx@16 | |
8159 int v18; // esi@16 | |
8160 unsigned __int16 *v19; // eax@16 | |
8161 int v20; // edx@16 | |
8162 int v21; // ecx@16 | |
8163 int v22; // eax@16 | |
8164 int v23; // esi@16 | |
8165 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
8166 int v27; // [sp+28h] [bp-Ch]@14 | |
8167 int v28; // [sp+2Ch] [bp-8h]@13 | |
8168 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
8169 | |
8170 //v3 = this; | |
8171 //sprintf(Str1, "%s", pName); | |
8172 //v4 = uNumItems; | |
8173 if (!uNumItems) | |
8174 return nullptr; | |
8175 | |
8176 //{ | |
8177 //v5 = 0, pDesta = uNumItems; | |
8178 uint idx1 = 0, | |
8179 idx2 = uNumItems; | |
8180 while (true) | |
8181 { | |
1980 | 8182 uint i = idx1 + (idx2 - idx1) / 2; |
8183 | |
8184 int res = _stricmp(pName, pSpriteNames[i]); | |
0 | 8185 if (!res) |
8186 { | |
8187 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
8188 break; | |
8189 } | |
8190 else if (res < 0) | |
8191 idx2 = idx1 + (idx2 - idx1) / 2; | |
8192 else | |
8193 idx1 = i + 1; | |
8194 | |
8195 if ( idx1 >= idx2 ) | |
8196 return false; | |
8197 } | |
8198 | |
8199 | |
8200 uint uCompressedSize = 0; | |
8201 fread(&uCompressedSize, 4, 1, pFile); | |
8202 | |
1980 | 8203 HWLTexture* pTex = new HWLTexture; |
670 | 8204 fread(&pTex->uBufferWidth, 4, 1, pFile); |
8205 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
8206 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
8207 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 8208 fread(&pTex->uWidth, 4, 1, pFile); |
8209 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 8210 fread(&pTex->uAreaX, 4, 1, pFile); |
8211 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 8212 |
8213 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
8214 if (uCompressedSize) | |
8215 { | |
1980 | 8216 char* pCompressedData = new char[uCompressedSize]; |
0 | 8217 { |
8218 fread(pCompressedData, 1, uCompressedSize, pFile); | |
1980 | 8219 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); |
0 | 8220 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); |
8221 } | |
8222 delete [] pCompressedData; | |
8223 } | |
8224 else | |
8225 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
8226 | |
1583 | 8227 if ( scale_hwls_to_half ) |
8228 { | |
8229 pTex->uHeight /= 2; | |
8230 pTex->uWidth /= 2; | |
8231 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
0 | 8232 v28 = 0; |
8233 v26 = (unsigned __int16 *)v13; | |
1583 | 8234 if ( pTex->uHeight > 0 ) |
0 | 8235 { |
8236 v16 = pTex->uWidth; | |
8237 v27 = 1; | |
8238 do | |
8239 { | |
8240 pDestb = 0; | |
8241 if ( v16 > 0 ) | |
8242 { | |
8243 do | |
8244 { | |
8245 v17 = v16 * v27; | |
8246 v18 = v28 * v16; | |
8247 v19 = pTex->pPixels; | |
8248 v20 = pDestb + 2 * v18; | |
8249 v21 = (int)&v19[2 * (pDestb + v17)]; | |
8250 v22 = (int)&v19[2 * v20]; | |
8251 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
8252 LOWORD(v21) = *(unsigned short *)v21; | |
8253 v23 = pDestb++ + v18; | |
1583 | 8254 extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); |
8255 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
0 | 8256 v16 = pTex->uWidth; |
8257 } | |
8258 while (pDestb < pTex->uWidth); | |
8259 } | |
8260 ++v28; | |
8261 v27 += 2; | |
8262 } | |
8263 while ( v28 < (signed int)pTex->uHeight ); | |
8264 } | |
8265 delete [] pTex->pPixels; | |
8266 pTex->pPixels = v26; | |
8267 } | |
8268 return pTex; | |
8269 } | |
8270 | |
8271 //----- (0045271F) -------------------------------------------------------- | |
8272 bool RenderHWLContainer::Release() | |
8273 { | |
8274 __int32 v4; // eax@6 | |
8275 FILE *v5; // ST24_4@6 | |
8276 FILE *File; // [sp+4h] [bp-4h]@6 | |
8277 | |
1162 | 8278 if ( this->bDumpDebug) |
0 | 8279 { |
8280 File = fopen("logd3d.txt", "w"); | |
1162 | 8281 v4 = ftell(this->pFile); |
8282 v5 = this->pFile; | |
8283 this->uDataOffset = v4; | |
8284 fwrite(&this->uNumItems, 4u, 1u, v5); | |
8285 for (int i = 0; i < this->uNumItems; i++) | |
8286 { | |
8287 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
8288 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
8289 } | |
8290 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
8291 fseek(this->pFile, 4, 0); | |
8292 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
8293 fclose(this->pFile); | |
0 | 8294 fclose(File); |
8295 } | |
8296 else | |
8297 { | |
8298 fclose(this->pFile); | |
1162 | 8299 for (int i = 0; i < this->uNumItems; i++) |
8300 { | |
8301 free(this->pSpriteNames[i]); | |
0 | 8302 } |
8303 } | |
1093 | 8304 return true; |
0 | 8305 } |
8306 | |
8307 //----- (00452347) -------------------------------------------------------- | |
8308 RenderHWLContainer::RenderHWLContainer(): | |
8309 bDumpDebug(false) | |
8310 { | |
8311 this->pFile = 0; | |
8312 uSignature = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8313 this->uDataOffset = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8314 memset(&this->uNumItems, 0, 0x61A84u); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8315 this->uNumItems = 0; |
1583 | 8316 this->scale_hwls_to_half = false; |
0 | 8317 } |
8318 | |
8319 //----- (0045237F) -------------------------------------------------------- | |
8320 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
8321 { | |
8322 pFile = _wfopen(pFilename, L"rb"); | |
8323 if (!pFile) | |
8324 { | |
8325 Log::Warning(L"Failed to open file: %s", pFilename); | |
8326 return false; | |
8327 } | |
8328 | |
8329 fread(&uSignature, 1, 4, pFile); | |
8330 if (uSignature != 'TD3D') | |
8331 { | |
8332 Log::Warning(L"Invalid format: %s", pFilename); | |
8333 return false; | |
8334 } | |
8335 | |
8336 fread(&uDataOffset, 4, 1, pFile); | |
8337 fseek(pFile, uDataOffset, SEEK_SET); | |
8338 fread(&uNumItems, 4, 1, pFile); | |
8339 | |
8340 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
8341 for (uint i = 0; i < uNumItems; ++i) | |
8342 { | |
8343 pSpriteNames[i] = new char[20]; | |
8344 fread(pSpriteNames[i], 1, 20, pFile); | |
8345 } | |
8346 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
8347 | |
8348 return true; | |
8349 } | |
8350 | |
8351 //----- (004A1C1E) -------------------------------------------------------- | |
2153 | 8352 void Render::DoRenderBillboards_D3D() |
8353 { | |
8354 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
8355 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8356 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8357 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8358 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8359 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8360 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8361 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8362 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8363 { |
1390 | 8364 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; |
8365 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
8366 } | |
8367 p->pQuads[0].pos.x = 10; | |
8368 p->pQuads[0].pos.y = 10; | |
8369 | |
8370 p->pQuads[1].pos.x = 10; | |
8371 p->pQuads[1].pos.y = 200; | |
8372 | |
8373 p->pQuads[2].pos.x = 100; | |
8374 p->pQuads[2].pos.y = 200; | |
8375 | |
8376 p->pQuads[3].pos.x = 100; | |
8377 p->pQuads[3].pos.y = 10; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8378 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8379 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8380 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8381 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8382 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8383 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8384 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8385 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8386 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8387 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8388 }*/ |
0 | 8389 |
2153 | 8390 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) |
8391 { | |
2155 | 8392 if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend) |
8393 SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity); | |
2114 | 8394 |
2153 | 8395 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture); |
8396 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
8397 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8398 pBillboardRenderListD3D[i].pQuads, pBillboardRenderListD3D[i].uNumVertices, | |
8399 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); | |
8400 } | |
8401 | |
8402 if (bFogEnabled) | |
8403 { | |
8404 bFogEnabled = false; | |
8405 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8406 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8407 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8408 } | |
8409 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
8410 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8411 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8412 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8413 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8414 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8415 } |
8416 | |
8417 //----- (004A1DA8) -------------------------------------------------------- | |
2153 | 8418 void Render::SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) |
0 | 8419 { |
8420 switch (a1) | |
8421 { | |
8422 case RenderBillboardD3D::Transparent: | |
8423 { | |
2153 | 8424 if (bFogEnabled) |
8425 { | |
8426 bFogEnabled = false; | |
8427 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8428 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8429 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8430 } | |
8431 | |
8432 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
8433 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
8434 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8435 } |
8436 break; | |
8437 | |
8438 case RenderBillboardD3D::Opaque_1: | |
8439 case RenderBillboardD3D::Opaque_2: | |
8440 case RenderBillboardD3D::Opaque_3: | |
8441 { | |
2153 | 8442 if (bUsingSpecular) |
8443 { | |
8444 if (!bFogEnabled) | |
0 | 8445 { |
2153 | 8446 bFogEnabled = true; |
8447 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
186 | 8448 } |
8449 } | |
8450 | |
2153 | 8451 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
8452 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8453 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 8454 } |
8455 break; | |
8456 | |
8457 default: | |
8458 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8459 assert(false); |
0 | 8460 break; |
8461 } | |
1787 | 8462 } |
1903 | 8463 //----- (00424CD7) -------------------------------------------------------- |
8464 int ODM_NearClip(unsigned int num_vertices) | |
8465 { | |
8466 bool current_vertices_flag; // edi@1 | |
8467 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 | |
8468 double t; // st6@10 | |
8469 int pNextVertices; | |
8470 | |
8471 if (!num_vertices) | |
8472 return 0; | |
8473 | |
8474 memcpy(&array_50AC10[num_vertices], array_50AC10, sizeof(array_50AC10[0])); | |
8475 current_vertices_flag = 0; | |
8476 if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 ) | |
8477 current_vertices_flag = 1; | |
8478 | |
8479 int out_num_vertices = 0; | |
8480 for (int i = 0; i < num_vertices; ++i) | |
8481 { | |
8482 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= 8.0; | |
8483 if ( current_vertices_flag != next_vertices_flag ) | |
8484 { | |
8485 if ( next_vertices_flag ) | |
8486 { | |
2191 | 8487 //t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) |
1903 | 8488 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
2268 | 8489 array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; |
8490 array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; | |
8491 array_507D30[out_num_vertices].u = (array_50AC10[i + 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; | |
8492 array_507D30[out_num_vertices].v = (array_50AC10[i + 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; | |
1903 | 8493 } |
8494 else | |
8495 { | |
8496 t = (8.0 - array_50AC10[i + 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); | |
2268 | 8497 array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t + array_50AC10[i + 1].vWorldViewPosition.y; |
8498 array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t + array_50AC10[i + 1].vWorldViewPosition.z; | |
8499 array_507D30[out_num_vertices].u = (array_50AC10[i].u - array_50AC10[i + 1].u) * t + array_50AC10[i + 1].u; | |
8500 array_507D30[out_num_vertices].v = (array_50AC10[i].v - array_50AC10[i + 1].v) * t + array_50AC10[i + 1].v; | |
1903 | 8501 } |
8502 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; | |
8503 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
1904 | 8504 //array_507D30[out_num_vertices]._rhw = 0x3E000000u; |
1903 | 8505 ++out_num_vertices; |
8506 } | |
8507 if ( next_vertices_flag ) | |
8508 { | |
8509 pNextVertices = out_num_vertices++; | |
8510 memcpy(&array_507D30[pNextVertices], &array_50AC10[i + 1], 0x30); | |
8511 } | |
8512 current_vertices_flag = next_vertices_flag; | |
8513 } | |
8514 return out_num_vertices >= 3 ? out_num_vertices : 0; | |
8515 } | |
1787 | 8516 //----- (00424EE0) -------------------------------------------------------- |
1903 | 8517 int ODM_FarClip(unsigned int uNumVertices) |
1787 | 8518 { |
8519 signed int previous_vertices_flag; // edi@1 | |
8520 double t; // st6@10 | |
8521 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 | |
8522 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 | |
8523 int pNextVertices; | |
8524 //Äîï èíôî "Ïðîãðàììèðîâàíèå òð¸õìåðíûõ èãð äëÿ windows" Ëàìîò ñòð 910 | |
8525 | |
8526 memcpy(&array_50AC10[uNumVertices], array_50AC10, sizeof(array_50AC10[uNumVertices])); | |
8527 depth_num_vertices = 0; | |
8528 previous_vertices_flag = 0; | |
8529 if ( array_50AC10[0].vWorldViewPosition.x <= pODMRenderParams->shading_dist_mist ) | |
8530 previous_vertices_flag = 1;//ïðåäûäóùàÿ ãðàíü ìåíüøå ãðàíèöû âèäèìîñòè | |
8531 if ( (signed int)uNumVertices <= 0 ) | |
8532 return 0; | |
8533 for ( uint i = 1; i <= uNumVertices; ++i ) | |
8534 { | |
8535 current_vertices_flag = pODMRenderParams->shading_dist_mist >= array_50AC10[i].vWorldViewPosition.x; | |
8536 if ( previous_vertices_flag != current_vertices_flag )//îäíà èç ãðàíåé çà ãðàíèöåé âèäèìîñòè | |
8537 { | |
8538 if ( current_vertices_flag )//òåêóùàÿ ãðàíü ìåíüøå ãðàíèöû âèäèìîñòè(ïðåäûäóùàÿ ãðàíü çà ïðåäåëàìè âèäèìîñòè) | |
8539 { | |
8540 //t = far_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
8541 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i - 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i - 1].vWorldViewPosition.x); | |
8542 array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i - 1].vWorldViewPosition.y) * t + array_50AC10[i - 1].vWorldViewPosition.y; | |
8543 array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i - 1].vWorldViewPosition.z) * t + array_50AC10[i - 1].vWorldViewPosition.z; | |
8544 array_507D30[depth_num_vertices].u = (array_50AC10[i].u - array_50AC10[i - 1].u) * t + array_50AC10[i - 1].u; | |
8545 array_507D30[depth_num_vertices].v = (array_50AC10[i].v - array_50AC10[i - 1].v) * t + array_50AC10[i - 1].v; | |
8546 } | |
8547 else//ïðåäûäóùàÿ ãðàíü ìåíüøå ãðàíèöû âèäèìîñòè(òåêóùàÿ ãðàíü âûøëà çà ïðåäåëû âèäèìîñòè) | |
8548 { | |
8549 //t = far_clip - v1.x / v0.x - v1.x | |
8550 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i - 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); | |
8551 array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i - 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; | |
8552 array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i - 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; | |
8553 array_507D30[depth_num_vertices].u = (array_50AC10[i - 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; | |
8554 array_507D30[depth_num_vertices].v = (array_50AC10[i - 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; | |
8555 } | |
8556 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; | |
8557 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; | |
8558 ++depth_num_vertices; | |
8559 } | |
8560 if ( current_vertices_flag )//îáà â ãðàíèöå âèäèìîñòè | |
8561 { | |
8562 pNextVertices = depth_num_vertices++; | |
8563 memcpy(&array_507D30[pNextVertices], &array_50AC10[i], 0x30); | |
1799 | 8564 //array_507D30[pNextVertices]._rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
8565 //array_507D30[pNextVertices].flt_2C = array_50AC10[i].flt_2C; | |
1787 | 8566 } |
8567 previous_vertices_flag = current_vertices_flag; | |
8568 } | |
8569 if ( depth_num_vertices < 3 ) | |
8570 return 0; | |
8571 return depth_num_vertices; | |
8572 } | |
8573 | |
8574 //----- (0047840D) -------------------------------------------------------- | |
8575 void Render::DrawBuildingsD3D() | |
8576 { | |
8577 int v9; // ecx@8 | |
8578 Texture *pFaceTexture; // eax@10 | |
8579 unsigned int v16; // edi@22 | |
8580 int v27; // eax@57 | |
8581 int vertex_id; // eax@58 | |
8582 unsigned int v34; // eax@80 | |
8583 int v40; // [sp-4h] [bp-5Ch]@2 | |
8584 int v49; // [sp+2Ch] [bp-2Ch]@10 | |
8585 int v50; // [sp+30h] [bp-28h]@34 | |
8586 int v51; // [sp+34h] [bp-24h]@35 | |
8587 int v52; // [sp+38h] [bp-20h]@36 | |
8588 int v53; // [sp+3Ch] [bp-1Ch]@8 | |
8589 int uNumVertices; // [sp+4Ch] [bp-Ch]@34 | |
8590 int unused; // [sp+50h] [bp-8h]@3 | |
8591 | |
8592 if ( !pRenderer->pRenderD3D ) | |
8593 { | |
8594 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); | |
8595 } | |
8596 | |
8597 unused = 0; | |
8598 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
8599 { | |
8600 for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++ ) | |
8601 { | |
8602 if ( IsBModelVisible(model_id, &unused) ) | |
8603 { | |
8604 pOutdoor->pBModels[model_id].field_40 |= 1; | |
8605 if ( pOutdoor->pBModels[model_id].uNumFaces > 0 ) | |
8606 { | |
8607 for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ ) | |
8608 { | |
8609 if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible()) | |
8610 { | |
8611 v53 = 0; | |
8612 array_77EC08[pODMRenderParams->uNumPolygons].flags = 0; | |
8613 array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0; | |
8614 v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID; | |
8615 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME) | |
8616 v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); | |
8617 pFaceTexture = pBitmaps_LOD->GetTexture(v9); | |
8618 array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture; | |
8619 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID) | |
8620 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2; | |
1922 | 8621 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_INDOOR_SKY ) |
1787 | 8622 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
2166 | 8623 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW8 ) |
1787 | 8624 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
8625 else | |
8626 { | |
2166 | 8627 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW9 ) |
1787 | 8628 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8; |
8629 } | |
2166 | 8630 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW10) |
1787 | 8631 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000; |
8632 else | |
8633 { | |
8634 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE) | |
8635 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10u; | |
8636 } | |
8637 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU; | |
8638 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV; | |
8639 v16 = GetTickCount() >> 4; | |
8640 if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 ) | |
8641 { | |
8642 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8643 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8644 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8645 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8646 } | |
8647 else | |
8648 { | |
8649 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8650 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8651 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8652 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8653 } | |
8654 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 ) | |
8655 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8656 else | |
8657 { | |
8658 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 ) | |
8659 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8660 } | |
8661 v50 = 0; | |
8662 v49 = 0; | |
8663 uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8664 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 ) | |
8665 { | |
8666 for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ ) | |
8667 { | |
8668 array_73D150[vertex_id - 1].vWorldPosition.x = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].x; | |
8669 array_73D150[vertex_id - 1].vWorldPosition.y = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].y; | |
8670 array_73D150[vertex_id - 1].vWorldPosition.z = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].z; | |
8671 array_73D150[vertex_id - 1].u = (array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU + (signed __int16)pOutdoor->pBModels[model_id].pFaces[face_id].pTextureUIDs[vertex_id - 1]) * (1.0 / (double)pFaceTexture->uTextureWidth); | |
8672 array_73D150[vertex_id - 1].v = (array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV + (signed __int16)pOutdoor->pBModels[model_id].pFaces[face_id].pTextureVIDs[vertex_id - 1]) * (1.0 / (double)pFaceTexture->uTextureHeight); | |
8673 } | |
8674 for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ ) | |
8675 { | |
8676 if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z ) | |
8677 ++v53; | |
8678 pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); | |
8679 if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) | |
8680 { | |
8681 if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 ) | |
8682 v49 = 1; | |
8683 else | |
8684 v50 = 1; | |
8685 } | |
8686 else | |
8687 pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); | |
8688 } | |
8689 } | |
8690 if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices ) | |
8691 LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1; | |
8692 array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8693 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8694 array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5; | |
2207 | 8695 v51 = fixpoint_mul(-pOutdoor->vSunlight.x, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x); |
8696 v53 = fixpoint_mul(-pOutdoor->vSunlight.y, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y); | |
8697 v52 = fixpoint_mul(-pOutdoor->vSunlight.z, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z); | |
8698 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - fixpoint_mul(20, v51 + v53 + v52); | |
1787 | 8699 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 ) |
8700 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0; | |
8701 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 ) | |
8702 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31; | |
8703 if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) | |
8704 return; | |
2169 | 8705 if ( ODMFace::IsBackfaceCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) |
1787 | 8706 { |
8707 pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1; | |
8708 array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id; | |
8709 array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id; | |
8710 v27 = 8 * (face_id | (model_id << 6)); | |
8711 LOBYTE(v27) = v27 | 6; | |
8712 array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27; | |
8713 for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id) | |
8714 { | |
8715 memcpy(&array_50AC10[vertex_id], &array_73D150[vertex_id], sizeof(array_50AC10[vertex_id])); | |
8716 array_50AC10[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001); | |
8717 } | |
8718 static stru154 static_RenderBuildingsD3D_stru_73C834; | |
8719 /*static bool __init_flag = false; | |
8720 if (!__init_flag) | |
8721 { | |
8722 __init_flag = true; | |
8723 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; | |
8724 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); | |
8725 atexit(loc_4789D4); | |
8726 }*/ | |
8727 | |
8728 v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8729 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8730 pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8731 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
8732 int v31 = 0; | |
8733 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
8734 { | |
8735 v31 = v50 ? 3 : v49 != 0 ? 5 : 0; | |
8736 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices); | |
8737 if ( pDecalBuilder->uNumDecals > 0 ) | |
8738 { | |
8739 v40 = -1; | |
8740 pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834, | |
8741 pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, array_50AC10, 0, (char)v31, -1); | |
8742 } | |
8743 } | |
8744 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
8745 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); | |
8746 if ( v50 ) | |
8747 { | |
1903 | 8748 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8749 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8750 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8751 } | |
8752 if ( v49 ) | |
8753 { | |
1903 | 8754 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8755 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8756 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8757 } | |
8758 if ( uNumVertices ) | |
8759 { | |
8760 if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 ) | |
8761 { | |
8762 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C ) | |
8763 v34 = pRenderer->pHDWaterBitmapIDs[0]; | |
8764 else | |
8765 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
8766 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; | |
8767 } | |
8768 else | |
8769 v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; | |
8770 pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40); | |
8771 } | |
8772 } | |
8773 } | |
8774 } | |
8775 } | |
8776 } | |
8777 } | |
8778 } | |
8779 return; | |
1911 | 8780 } |
8781 //----- (00479543) -------------------------------------------------------- | |
1923 | 8782 void Render::DrawOutdoorSkyD3D() |
1911 | 8783 { |
8784 int v9; // eax@4 | |
8785 int v10; // ebx@4 | |
8786 int v13; // edi@6 | |
8787 int v14; // ecx@6 | |
8788 int v15; // eax@8 | |
8789 int v16; // eax@12 | |
8790 signed __int64 v17; // qtt@13 | |
8791 signed int v18; // ecx@13 | |
8792 struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1 | |
8793 int v30; // [sp+134h] [bp-30h]@1 | |
8794 int v32; // [sp+13Ch] [bp-28h]@6 | |
8795 int v33; // [sp+140h] [bp-24h]@2 | |
8796 signed __int64 v34; // [sp+144h] [bp-20h]@1 | |
8797 int v35; // [sp+148h] [bp-1Ch]@4 | |
8798 int v36; // [sp+14Ch] [bp-18h]@2 | |
8799 int v37; // [sp+154h] [bp-10h]@8 | |
8800 int v38; // [sp+158h] [bp-Ch]@1 | |
8801 int v39; // [sp+15Ch] [bp-8h]@4 | |
2120 | 8802 |
8803 v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z) | |
1911 | 8804 / ((double)pODMRenderParams->int_fov_rad + 8192.0) |
2119 | 8805 + (double)(pViewport->uScreenCenterY)); |
8806 v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192 | |
2120 | 8807 v38 = (signed __int64)((double)(pViewport->uScreenCenterY) |
1911 | 8808 - (double)pODMRenderParams->int_fov_rad |
8809 / (v34 + 0.0000001) | |
8810 * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) | |
8811 * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist | |
8812 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); | |
8813 pSkyPolygon.Create_48607B(&stru_8019C8);//çàïîëíÿåòñÿ ptr_38 | |
8814 pSkyPolygon.ptr_38->_48694B_frustum_sky(); | |
2006 | 8815 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166) |
8816 pSkyPolygon.pTexture = (Texture *)(SLOWORD(pOutdoor->sSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->sSky_TextureID)] : 0); | |
1911 | 8817 if ( pSkyPolygon.pTexture ) |
8818 { | |
8819 pSkyPolygon.dimming_level = 0; | |
8820 pSkyPolygon.uNumVertices = 4; | |
2119 | 8821 //centering(öåíòðóåì)----------------------------------------------------------------- |
2120 | 8822 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8823 pSkyPolygon.v_18.y = 0; |
2120 | 8824 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8825 |
8826 //sky wiew position(ïîëîæåíèå íåáà íà ýêðàíå)------------------------------------------ | |
8827 // X | |
8828 // 0._____________________________.3 | |
8829 // |8,8 468,8 | | |
8830 // | | | |
8831 // | | | |
8832 // Y| | | |
8833 // | | | |
8834 // |8,351 468,351 | | |
8835 // 1._____________________________.2 | |
8836 // | |
2119 | 8837 array_50AC10[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 |
8838 array_50AC10[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8839 | |
8840 array_50AC10[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 | |
8841 array_50AC10[1].vWorldViewProjY = (double)v38;//247 | |
8842 | |
8843 array_50AC10[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8844 array_50AC10[2].vWorldViewProjY = (double)v38;//247 | |
8845 | |
8846 array_50AC10[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8847 array_50AC10[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8848 | |
8849 pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8850 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8851 | |
8852 pSkyPolygon.field_24 = 0x2000000u;//maybe attributes | |
2120 | 8853 v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2) / tan(0.6457717418670654) + 0.5); |
1911 | 8854 for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i ) |
8855 { | |
8856 //rotate skydome(âðàùåíèå êóïîëà íåáà)-------------------------------------- | |
8857 //  èãðå ïðèíÿòà ñâîÿ ñèñòåìà èçìåðåíèÿ óãëîâ. Ïîëíûé óãîë (180). Çíà÷åíèþ óãëà 0 ñîîòâåòñòâóåò | |
8858 // íàïðàâëåíèå íà ñåâåð è/èëè þã (ëèáî íà âîñòîê è/èëè çàïàä), çíà÷åíèþ 65536 åäåíèöàì(0õ10000) ñîîòâåòñòâóåò óãîë 90. | |
2119 | 8859 // äâå ïåðåìåííûå õðàíÿò äàííûå ïî óãëó îáçîðà. field_14 ïî çàïàäó è âîñòîêó. field_20 ïî þãó è ñåâåðó |
1911 | 8860 // îò -25080 äî 25080 |
2207 | 8861 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8862 v35 = v39 + pSkyPolygon.ptr_38->angle_from_north; |
8863 | |
2207 | 8864 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f))); |
2120 | 8865 v36 = v39 + pSkyPolygon.ptr_38->angle_from_east; |
8866 | |
2207 | 8867 v9 = fixpoint_mul(pSkyPolygon.v_18.z, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8868 v10 = pSkyPolygon.v_18.x + v9; |
2119 | 8869 if ( v10 > 0 ) |
1911 | 8870 v10 = 0; |
2120 | 8871 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX); |
8872 v34 = -pSkyPolygon.field_24; | |
8873 v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0; | |
8874 v14 = v33 * (v30 - v32); | |
1911 | 8875 while ( 1 ) |
8876 { | |
2120 | 8877 if ( v10 ) |
1911 | 8878 { |
2120 | 8879 v37 = abs((int)v34 >> 14); |
8880 v15 = abs(v10); | |
8881 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportTL_Y ) | |
8882 { | |
8883 if ( v10 <= 0 ) | |
8884 break; | |
8885 } | |
1911 | 8886 } |
2207 | 8887 v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14); |
1911 | 8888 --v32; |
8889 v14 += v33; | |
8890 v10 = pSkyPolygon.v_18.x + v16; | |
8891 } | |
8892 LODWORD(v17) = LODWORD(v34) << 16; | |
2120 | 8893 HIDWORD(v17) = v34 >> 16; |
8894 v18 = v17 / v10; | |
1911 | 8895 if ( v18 < 0 ) |
8896 v18 = pODMRenderParams->shading_dist_mist; | |
2207 | 8897 v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v13); |
8898 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v37, v18) >> 3); | |
2120 | 8899 array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0); |
8900 | |
2207 | 8901 v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v13); |
8902 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v36, v18) >> 3); | |
2120 | 8903 array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0); |
2119 | 8904 |
8905 array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192 | |
2120 | 8906 array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16); |
1911 | 8907 } |
1923 | 8908 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
2120 | 8909 array_50AC10[0].vWorldViewProjY = (double)v10; |
1911 | 8910 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; |
8911 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; | |
2120 | 8912 array_50AC10[3].vWorldViewProjY = (double)v10; |
1923 | 8913 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
1911 | 8914 return; |
8915 } | |
1913 | 8916 } |
8917 //----- (004226C2) -------------------------------------------------------- | |
8918 bool PauseGameDrawing() | |
8919 { | |
8920 if ( pCurrentScreen != SCREEN_GAME | |
8921 && pCurrentScreen != SCREEN_NPC_DIALOGUE | |
8922 && pCurrentScreen != SCREEN_CHANGE_LOCATION ) | |
8923 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2135
diff
changeset
|
8924 if (pCurrentScreen == SCREEN_INPUT_BLV) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2135
diff
changeset
|
8925 return pVideoPlayer->pMovie;//pSmackerMovie != 0; |
1913 | 8926 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) |
8927 return true; | |
8928 } | |
8929 return false; | |
2154 | 8930 } |
8931 | |
8932 | |
8933 //----- (0045E03A) -------------------------------------------------------- | |
8934 unsigned short *Render::MakeScreenshot(signed int width, signed int height) | |
8935 { | |
8936 unsigned __int16 *v3; // ebx@1 | |
8937 int v4; // edx@7 | |
8938 unsigned __int8 v5; // cf@9 | |
8939 unsigned int v6; // ecx@9 | |
8940 unsigned __int16 *v7; // edi@9 | |
8941 int j; // ecx@9 | |
8942 unsigned int screen_x; // qax@18 | |
8943 HRESULT v14; // eax@21 | |
8944 int v15; // edi@29 | |
8945 signed __int64 v16; // qax@30 | |
8946 signed int v17; // edx@34 | |
8947 unsigned __int16 *v18; // edi@36 | |
8948 int k; // ecx@36 | |
8949 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 | |
8950 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 | |
8951 float interval_x; // [sp+84h] [bp-20h]@1 | |
8952 unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 | |
8953 float interval_y; // [sp+8Ch] [bp-18h]@1 | |
8954 unsigned int screen_y; // [sp+90h] [bp-14h]@17 | |
8955 int v28; // [sp+98h] [bp-Ch]@16 | |
8956 int v29; // [sp+9Ch] [bp-8h]@15 | |
8957 | |
8958 interval_x = game_viewport_width / (double)width; | |
8959 interval_y = game_viewport_height / (double)height; | |
8960 | |
8961 pPixels = (unsigned __int16 *)malloc(2 * height * width); | |
8962 memset(pPixels, 0 , 2 * height * width); | |
8963 | |
8964 v3 = pPixels; | |
8965 | |
2182 | 8966 BeginSceneD3D(); |
8967 | |
8968 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
8969 pIndoor->Draw(); | |
8970 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
8971 pOutdoor->Draw(); | |
8972 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
8973 memset(&Dst, 0, 0x7C); | |
8974 Dst.dwSize = sizeof(Dst); | |
8975 | |
8976 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
8977 { | |
8978 for (uint y = 0; y < height; ++y) | |
8979 { | |
8980 for (uint x = 0; x < width; ++x) | |
8981 { | |
8982 //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)]; | |
2207 | 8983 /* |
8984 if (ddpfPrimarySuface.dwRGBBitCount == 32) | |
8985 { | |
8986 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
8987 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
8988 } | |
8989 else if (ddpfPrimarySuface.dwRGBBitCount == 16) | |
8990 { | |
8991 auto p = (unsigned __int16 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
8992 *v3 = *p; | |
8993 } | |
8994 */ | |
8995 pRenderer->pTargetSurface; | |
2182 | 8996 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) |
2154 | 8997 { |
2182 | 8998 auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch; |
8999 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
9000 } | |
9001 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) | |
9002 { | |
9003 auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; | |
9004 *v3 = *p; | |
2154 | 9005 } |
2182 | 9006 else __debugbreak(); |
9007 ++v3; | |
9008 } | |
9009 } | |
9010 ErrD3D(pBackBuffer4->Unlock(0)); | |
9011 } | |
9012 else | |
9013 { | |
9014 __debugbreak(); // unrefactored - black screenshot | |
9015 v4 = height; | |
9016 if ( height > 0 ) | |
9017 { | |
9018 do | |
9019 { | |
9020 if ( width > 0 ) | |
2154 | 9021 { |
2182 | 9022 v5 = width & 1; |
9023 v6 = (unsigned int)width / 2; | |
9024 memset(v3, 0, 4 * ((unsigned int)width / 2)); | |
9025 v7 = &v3[2 * v6]; | |
9026 for ( j = v5; j; --j ) | |
2154 | 9027 { |
2182 | 9028 *v7 = 0; |
9029 ++v7; | |
2154 | 9030 } |
2182 | 9031 v3 += width; |
2154 | 9032 } |
2182 | 9033 --v4; |
9034 } | |
9035 while ( v4 ); | |
9036 } | |
9037 } | |
9038 | |
2154 | 9039 /*if (!pRenderer->pRenderD3D) |
9040 { | |
9041 pRenderer->BeginScene(); | |
9042 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
9043 { | |
9044 pIndoor->Draw(); | |
9045 } | |
9046 else | |
9047 { | |
9048 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
9049 pOutdoor->Draw(); | |
9050 } | |
9051 _this = pRenderer->pTargetSurface; | |
9052 v26 = pRenderer->uTargetSurfacePitch; | |
9053 if ( pRenderer->pTargetSurface ) | |
9054 { | |
9055 if ( height > 0 ) | |
9056 { | |
9057 for ( v29 = 0; v29 < height; ++v29 ) | |
9058 { | |
9059 if ( width > 0 ) | |
9060 { | |
9061 v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); | |
9062 for ( v28 = 0; v28 < width; v28++ ) | |
9063 { | |
9064 *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)]; | |
9065 ++v3; | |
9066 } | |
9067 } | |
9068 } | |
9069 } | |
9070 } | |
9071 else | |
9072 { | |
9073 if ( height > 0 ) | |
9074 { | |
9075 for ( v17 = height; v17; --v17 ) | |
9076 { | |
9077 if ( width > 0 ) | |
9078 { | |
9079 memset(v3, 0, 4 * ((unsigned int)width >> 1)); | |
9080 v18 = &v3[2 * ((unsigned int)width >> 1)]; | |
9081 for ( k = width & 1; k; --k ) | |
9082 { | |
9083 *v18 = 0; | |
9084 ++v18; | |
9085 } | |
9086 v3 += width; | |
9087 } | |
9088 } | |
9089 } | |
9090 } | |
9091 pRenderer->EndScene(); | |
9092 }*/ | |
9093 return pPixels; | |
9094 } | |
9095 //----- (0045E26C) -------------------------------------------------------- | |
9096 void Render::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height) | |
9097 { | |
9098 auto pixels = pRenderer->MakeScreenshot(width, height); | |
9099 pRenderer->SavePCXImage(pFilename, pixels, width, height); | |
9100 free(pixels); | |
9101 } | |
9102 | |
9103 void Render::PackScreenshot(unsigned int width, unsigned int height, void *data, unsigned int data_size, unsigned int *out_screenshot_size) | |
9104 { | |
9105 auto pixels = pRenderer->MakeScreenshot(150, 112); | |
9106 pRenderer->PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size); | |
9107 free(pixels); | |
9108 } | |
2155 | 9109 |
9110 | |
9111 //----- (0046A7C8) -------------------------------------------------------- | |
2182 | 9112 int Render::_46À6ÀÑ_GetActorsInViewport(int pDepth) |
9113 { | |
9114 unsigned int v3; // eax@2 ïðèìåíÿåòñÿ â çàêëå Æàð ïå÷è äëÿ ïîäñ÷¸òà êîë-âà ìîíñòðîâ âèäèìûõ ãðóïïå è çàïîëíåíèÿ ìàññèâà id âèäèìûõ ìîíñòðîâ | |
2155 | 9115 unsigned int v5; // eax@2 |
9116 unsigned int v6; // eax@4 | |
9117 unsigned int v12; // [sp+10h] [bp-14h]@1 | |
2182 | 9118 int mon_num; // [sp+1Ch] [bp-8h]@1 |
2155 | 9119 unsigned int a1a; // [sp+20h] [bp-4h]@1 |
9120 | |
2182 | 9121 mon_num = 0; |
2155 | 9122 v12 = GetBillboardDrawListSize(); |
9123 if ( (signed int)GetBillboardDrawListSize() > 0 ) | |
9124 { | |
9125 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) | |
9126 { | |
9127 v3 = GetParentBillboardID(a1a); | |
9128 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; | |
9129 if ( PID_TYPE(v5) == OBJECT_Actor) | |
9130 { | |
2182 | 9131 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) ) |
2155 | 9132 { |
9133 v6 = PID_ID(v5); | |
9134 if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed | |
9135 && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) | |
9136 { | |
2182 | 9137 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) ) |
2155 | 9138 { |
2182 | 9139 if ( mon_num < 100 ) |
2155 | 9140 { |
2182 | 9141 _50BF30_actors_in_viewport_ids[mon_num] = v6; |
9142 mon_num++; | |
2155 | 9143 } |
9144 } | |
9145 } | |
9146 } | |
9147 } | |
9148 } | |
9149 } | |
2182 | 9150 return mon_num; |
2155 | 9151 } |
9152 | |
9153 | |
9154 | |
9155 | |
9156 void Render::BeginLightmaps() | |
9157 { | |
9158 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9159 | |
9160 if (bUsingSpecular) | |
9161 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); | |
9162 | |
9163 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9164 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9165 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9166 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9167 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9168 } | |
9169 | |
9170 void Render::EndLightmaps() | |
9171 { | |
9172 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9173 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9174 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9175 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9176 | |
9177 if (bUsingSpecular) | |
9178 { | |
9179 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9180 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor)); | |
9181 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
9182 } | |
9183 } | |
9184 | |
9185 | |
9186 void Render::BeginLightmaps2() | |
9187 { | |
9188 if (bUsingSpecular) | |
9189 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9190 | |
9191 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9192 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9193 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9194 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9195 | |
9196 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9197 | |
9198 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9199 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9200 } | |
9201 | |
9202 | |
9203 void Render::EndLightmaps2() | |
9204 { | |
9205 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9206 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9207 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9208 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9209 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9210 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9211 | |
9212 if (bUsingSpecular) | |
9213 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9214 } | |
9215 | |
9216 | |
9217 | |
9218 //----- (00437C96) -------------------------------------------------------- | |
9219 void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) | |
9220 { | |
9221 double v6; // st7@2 | |
9222 //IDirect3DDevice3 *v7; // eax@2 | |
9223 HRESULT v8; // eax@2 | |
9224 std::string v9; // [sp-18h] [bp-60h]@3 | |
9225 const char *v10; // [sp-Ch] [bp-54h]@2 | |
9226 const char *v11; // [sp-8h] [bp-50h]@2 | |
9227 int v12; // [sp-4h] [bp-4Ch]@2 | |
9228 RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2 | |
9229 | |
9230 //if ( pRenderer->pRenderD3D ) | |
9231 { | |
9232 v6 = 0.001 - z_stuff; | |
9233 memcpy(v13, pLineBegin, 0x20u); | |
9234 memcpy(&v13[1], pLineEnd, sizeof(v13[1])); | |
9235 v13[0].pos.z = v6; | |
9236 v13[1].pos.z = v6; | |
9237 v13[0].diffuse = sDiffuseBegin; | |
9238 v13[1].diffuse = sDiffuseEnd; | |
9239 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9240 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
9241 D3DPT_LINELIST, | |
9242 452, | |
9243 v13, | |
9244 2, | |
9245 16)); | |
9246 } | |
9247 } | |
9248 | |
9249 | |
9250 void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9251 { | |
9252 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9253 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, | |
9254 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9255 (void *)vertices, | |
9256 num_vertices, | |
9257 D3DDP_DONOTLIGHT)); | |
9258 } | |
9259 | |
9260 | |
9261 void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9262 { | |
9263 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
9264 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); | |
9265 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9266 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9267 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9268 | |
9269 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9270 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9271 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9272 (void *)vertices, | |
9273 num_vertices, | |
9274 28)); | |
9275 | |
9276 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9277 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9278 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9279 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); | |
9280 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9281 } | |
9282 | |
9283 | |
9284 void Render::BeginDecals() | |
9285 { | |
9286 // code chunk from 0049C304 | |
9287 if (bUsingSpecular) | |
9288 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9289 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9290 | |
9291 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9292 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9293 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9294 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9295 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9296 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9297 | |
9298 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); | |
9299 } | |
9300 | |
9301 | |
9302 void Render::EndDecals() | |
9303 { | |
9304 // code chunk from 0049C304 | |
9305 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9306 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9307 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9308 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9309 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9310 | |
9311 if (bUsingSpecular) | |
9312 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9313 } | |
9314 | |
9315 | |
9316 | |
9317 //----- (0049C095) -------------------------------------------------------- | |
9318 void Render::DrawDecal(Decal *pDecal, float z_bias) | |
9319 { | |
9320 signed int v21; // [sp+Ch] [bp-864h]@15 | |
9321 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6 | |
9322 | |
9323 if (pDecal->uNumVertices < 3) | |
9324 { | |
9325 Log::Warning(L"Decal has < 3 vertices"); | |
9326 return; | |
9327 } | |
9328 | |
9329 float color_mult; | |
9330 if ( pDecal->field_C1C & 1 ) | |
9331 color_mult = 1.0; | |
9332 else | |
9333 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time(); | |
9334 | |
9335 for (uint i = 0; i < pDecal->uNumVertices; ++i) | |
9336 { | |
9337 uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr); | |
9338 | |
9339 uint uTintR = (uTint >> 16) & 0xFF, | |
9340 uTintG = (uTint >> 8) & 0xFF, | |
9341 uTintB = uTint & 0xFF; | |
9342 | |
9343 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF, | |
9344 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF, | |
9345 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF; | |
9346 | |
9347 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f), | |
9348 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f), | |
9349 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f); | |
9350 | |
9351 | |
9352 float v15; | |
9353 if (fabs(z_bias) < 1e-5) | |
9354 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); | |
9355 else | |
9356 { | |
9357 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; | |
9358 if (v15 < 0.000099999997) | |
9359 v15 = 0.000099999997; | |
9360 } | |
9361 | |
9362 pVerticesD3D[i].pos.z = v15; | |
9363 | |
9364 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX; | |
9365 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY; | |
9366 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u; | |
9367 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v; | |
9368 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB; | |
9369 pVerticesD3D[i].specular = 0; | |
9370 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x; | |
9371 } | |
9372 | |
9373 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9374 v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; | |
9375 else | |
9376 v21 = D3DDP_DONOTLIGHT; | |
9377 | |
9378 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9379 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9380 pVerticesD3D, | |
9381 pDecal->uNumVertices, | |
9382 v21)); | |
9383 } | |
9384 | |
9385 | |
9386 void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) | |
9387 { | |
9388 ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture)); | |
9389 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9390 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9391 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9392 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9393 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9394 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9395 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
9396 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9397 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9398 (void *)vertices, 4, 28)); | |
9399 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9400 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9401 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9402 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9403 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9404 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
9405 } |