Mercurial > mm7
annotate Render.cpp @ 2226:5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
author | Ritor1 |
---|---|
date | Thu, 20 Feb 2014 12:20:49 +0600 |
parents | c69013c186c7 |
children | 8817c398b792 |
rev | line source |
---|---|
2153 | 1 #include "Render.h" |
1277 | 2 #include "Outdoor_stuff.h" |
1016 | 3 #include "VideoPlayer.h" |
4 #include "Sprites.h" | |
5 #include "Mouse.h" | |
6 #include "GammaControl.h" | |
7 #include "stru6.h" | |
1183 | 8 #include "GUIWindow.h" |
1016 | 9 #include "DecalBuilder.h" |
10 #include "ParticleEngine.h" | |
0 | 11 #include "Outdoor.h" |
12 #include "Party.h" | |
13 #include "LOD.h" | |
14 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2016
diff
changeset
|
15 #include "OurMath.h" |
0 | 16 #include "PaletteManager.h" |
2044 | 17 #include "Timer.h" |
0 | 18 #include "Game.h" |
19 #include "LightmapBuilder.h" | |
20 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
21 #include "SpriteObject.h" |
0 | 22 #include "DecorationList.h" |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
23 #include "Actor.h" |
0 | 24 #include "Log.h" |
179 | 25 #include "TileFrameTable.h" |
189 | 26 #include "texts.h" |
0 | 27 #include "mm7_data.h" |
860 | 28 #include "MM7.h" |
1262 | 29 #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
|
30 #include "Level/Decoration.h" |
2155 | 31 #include "Vis.h" |
0 | 32 |
1924
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
33 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") |
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
34 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") |
0 | 35 |
36 struct IDirectDrawClipper *pDDrawClipper; | |
37 struct Render *pRenderer; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
38 struct RenderVertexD3D3 pVertices[50]; |
0 | 39 int uNumDecorationsDrawnThisFrame; // weak |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
40 RenderBillboard pBillboardRenderList[500]; |
0 | 41 unsigned int uNumBillboardsToDraw; |
42 int uNumSpritesDrawnThisFrame; // weak | |
43 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
44 RenderVertexSoft array_507D30[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
45 RenderVertexSoft array_50AC10[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
46 RenderVertexSoft array_73D150[20]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
47 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
48 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 49 |
50 /* 384 */ | |
51 #pragma pack(push, 1) | |
52 struct PCXHeader_1 | |
53 { | |
54 char manufacturer; | |
55 char version; | |
56 char encoding; | |
57 char bpp; | |
58 __int16 left; | |
59 __int16 up; | |
60 __int16 right; | |
61 __int16 bottom; | |
62 __int16 hdpi; | |
63 __int16 vdpi; | |
64 }; | |
65 #pragma pack(pop) | |
66 | |
67 /* 385 */ | |
68 #pragma pack(push, 1) | |
69 struct PCXHeader_2 | |
70 { | |
71 char reserved; | |
72 char planes; | |
73 __int16 pitch; | |
74 __int16 palette_info; | |
75 }; | |
76 #pragma pack(pop) | |
77 | |
78 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
79 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
80 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
81 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
82 | |
83 //----- (0049E79F) -------------------------------------------------------- | |
2154 | 84 bool Render::CheckTextureStages() |
0 | 85 { |
86 bool v0; // edi@1 | |
87 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
88 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
89 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
90 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
91 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
92 | |
93 v0 = false; | |
2154 | 94 pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); |
95 pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
96 | |
97 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
98 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
99 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2)); | |
100 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
101 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
102 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
103 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1)); | |
104 | |
105 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
106 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
107 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1)); | |
108 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7)); | |
109 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2)); | |
110 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1)); | |
111 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2)); | |
112 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2)); | |
113 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1)); | |
114 | |
115 if ( !pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
0 | 116 v0 = true; |
2154 | 117 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); |
0 | 118 pTexture1->Release(); |
119 pTexture2->Release(); | |
120 pSurface1->Release(); | |
121 pSurface2->Release(); | |
122 return v0; | |
123 } | |
124 | |
2002 | 125 |
0 | 126 //----- (00440CB8) -------------------------------------------------------- |
127 void Render::DrawBillboardList_BLV() | |
128 { | |
129 __int16 v2; // ax@3 | |
130 int v5; // eax@11 | |
131 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
132 | |
2002 | 133 soft_billboard.sParentBillboardID = -1; |
0 | 134 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; |
135 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
136 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
137 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
138 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
139 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
140 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
141 | |
1637 | 142 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw; |
617 | 143 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 144 { |
1980 | 145 RenderBillboard* p = &pBillboardRenderList[i]; |
0 | 146 |
147 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
2002 | 148 soft_billboard.sParentBillboardID = i; |
0 | 149 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
150 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
|
151 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 152 soft_billboard.sZValue = p->sZValue; |
153 soft_billboard.uFlags = p->field_1E; | |
2006 | 154 soft_billboard.sTintColor = p->sTintColor; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
155 v2 = p->HwSpriteID; |
0 | 156 if ( v2 != -1 ) |
157 { | |
158 if ( pRenderer->pRenderD3D ) | |
657 | 159 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 160 else |
161 { | |
657 | 162 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 163 if (p->field_1E & 0x0100) |
164 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
165 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
166 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
|
167 v5 = p->HwSpriteID; |
0 | 168 if ( v5 >= 0 ) |
733 | 169 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 170 } |
171 } | |
172 } | |
173 } | |
174 | |
175 //----- (004A16A5) -------------------------------------------------------- | |
2154 | 176 bool Render::AreRenderSurfacesOk() |
177 { | |
178 return pFrontBuffer4 && pBackBuffer4; | |
0 | 179 } |
180 | |
2152 | 181 |
182 //----- (004A19D8) -------------------------------------------------------- | |
183 unsigned int BlendColors(unsigned int a1, unsigned int a2) | |
184 { | |
185 /*signed __int64 v2; // ST10_8@1 | |
186 double v3; // st7@1 | |
187 float v4; // ST24_4@1 | |
188 double v5; // ST10_8@1 | |
189 int v6; // ST1C_4@1 | |
190 float v7; // ST24_4@1 | |
191 double v8; // ST10_8@1 | |
192 unsigned __int8 v9; // ST20_1@1 | |
193 float v10; // ST24_4@1 | |
194 double v11; // ST10_8@1 | |
195 float v12; // ST24_4@1 | |
196 double v13; // ST08_8@1*/ | |
197 | |
198 uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f * | |
199 (a2 >> 24) / 255.0f * 255.0f), | |
200 red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f * | |
201 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f), | |
202 green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f * | |
203 ((a2 >> 8) & 0xFF) / 255.0f * 255.0f), | |
204 blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f * | |
205 ((a2 >> 0) & 0xFF) / 255.0f * 255.0f); | |
206 return (alpha << 24) | (red << 16) | (green << 8) | blue; | |
207 /*v2 = a1 >> 24; | |
208 v3 = (double)v2 / 255.0f; | |
209 HIDWORD(v2) = 0; | |
210 LODWORD(v2) = a2 >> 24; | |
211 v4 = v3 * (double)v2 / 255.0f * 255.0; | |
212 v5 = v4 + 6.7553994e15; | |
213 v6 = LODWORD(v5); | |
214 v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0; | |
215 v8 = v7 + 6.7553994e15; | |
216 v9 = LOBYTE(v8); | |
217 v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0; | |
218 v11 = v10 + 6.7553994e15; | |
219 v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0; | |
220 v13 = v12 + 6.7553994e15; | |
221 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ | |
222 } | |
223 | |
224 | |
1338 | 225 void Render::RenderTerrainD3D() // New function |
86 | 226 { |
227 int v6; // ecx@8 | |
1427 | 228 struct Polygon *pTilePolygon; // ebx@8 |
186 | 229 |
230 //warning: the game uses CW culling by default, ccw is incosistent | |
231 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
232 | |
1338 | 233 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ |
234 | |
235 //Ãåíåðàöèÿ ìåñòîïîëîæåíèÿ âåðøèí------------------------------------------------------------------------- | |
236 //ðåø¸òêà âåðøèí äåëèòñÿ íà äâå ÷àñòè îò -64 äî 0 è îò 0 äî 64 | |
237 // | |
238 // -64 X 0 64 | |
239 // --------------- 64 | |
240 // | | | | |
241 // | | | | |
242 // | | | | |
243 // 0|------+------| Z | |
244 // | | | | |
245 // | | | | |
246 // | | | | |
247 // --------------- | |
248 // -64 | |
249 | |
250 int blockScale = 512; | |
251 int heightScale = 32; | |
252 for (unsigned int z = 0; z < 128; ++z) | |
253 { | |
254 for (unsigned int x = 0; x < 128; ++x) | |
255 { | |
256 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
257 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
258 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 259 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
260 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 261 } |
262 } | |
1338 | 263 //-------------------------------------------------------------------------------------------------------------------- |
264 | |
265 // | |
1344 | 266 for (unsigned int z = 0; z < 127; ++z) |
267 { | |
268 for (unsigned int x = 0; x < 127; ++x) | |
1338 | 269 { |
1637 | 270 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; |
1427 | 271 pTilePolygon->flags = 0; |
272 pTilePolygon->field_32 = 0; | |
273 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
274 pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; | |
275 if (pTilePolygon->uTileBitmapID == 0xFFFF) | |
106 | 276 continue; |
186 | 277 |
1338 | 278 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1427 | 279 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); |
280 pTilePolygon->field_32 = 0; | |
281 pTilePolygon->field_59 = 1; | |
282 pTilePolygon->sTextureDeltaU = 0; | |
283 pTilePolygon->sTextureDeltaV = 0; | |
1338 | 284 // x,z x+1,z |
285 // .____________. | |
286 // | | | |
287 // | | | |
288 // | | | |
289 // | | | |
290 // | | | |
291 // .____________. | |
292 // x,z+1 x+1,z+1 | |
293 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
106 | 294 array_73D150[0].u = 0; |
295 array_73D150[0].v = 0; | |
1338 | 296 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z |
106 | 297 array_73D150[1].u = 1; |
298 array_73D150[1].v = 0; | |
1338 | 299 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 |
106 | 300 array_73D150[2].u = 1; |
301 array_73D150[2].v = 1; | |
1338 | 302 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 |
106 | 303 array_73D150[3].u = 0; |
304 array_73D150[3].v = 1; | |
1338 | 305 //v58 = 0; |
306 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
307 //pTile->field_32 |= 0x0001; | |
1427 | 308 pTilePolygon->pODMFace = nullptr; |
309 pTilePolygon->uNumVertices = 4; | |
310 pTilePolygon->field_59 = 5; | |
1338 | 311 |
312 //shading (çàòåíåíèå)---------------------------------------------------------------------------- | |
313 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
1424 | 314 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; |
638 | 315 assert(norm_idx < uNumTerrainNormals); |
316 | |
1980 | 317 Vec3_float_* norm = &pTerrainNormals[norm_idx]; |
1338 | 318 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
319 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
320 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
1427 | 321 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); |
1338 | 322 //----------------------------------------------------------------------------------------------- |
638 | 323 |
1637 | 324 ++pODMRenderParams->uNumPolygons; |
325 ++pODMRenderParams->field_44; | |
326 assert(pODMRenderParams->uNumPolygons < 20000); | |
265 | 327 |
1427 | 328 pTilePolygon->uBModelID = 0; |
329 pTilePolygon->uBModelFaceID = 0; | |
330 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
331 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
106 | 332 { |
333 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 334 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 335 } |
140 | 336 |
1338 | 337 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))---------------------- |
186 | 338 bool transparent = false; |
1427 | 339 if ( !( pTilePolygon->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable |
340 { | |
341 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id) | |
1338 | 342 { |
343 //transparent = false; | |
344 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
345 } | |
346 else | |
347 { | |
1427 | 348 v6 = pTilePolygon->uTileBitmapID; |
349 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) ) | |
1338 | 350 transparent = true; |
351 } | |
179 | 352 |
140 | 353 assert(v6 < 1000); // many random crashes here |
186 | 354 |
355 // for all shore tiles - draw a tile water under them since they're half-empty | |
1427 | 356 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX |
2153 | 357 DrawBorderTiles(pTilePolygon); |
1427 | 358 |
359 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1338 | 360 } |
361 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû | |
362 //pTile->DrawBorderTiles(); | |
363 //-------------------------------------------------------------------------------------------------------------------------------- | |
186 | 364 |
1637 | 365 --pODMRenderParams->uNumPolygons; |
366 --pODMRenderParams->field_44; | |
106 | 367 } |
368 } | |
369 } | |
0 | 370 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
371 |
2153 | 372 //----- (004811A3) -------------------------------------------------------- |
373 void Render::DrawBorderTiles(struct Polygon *poly) | |
374 { | |
375 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); | |
376 DrawTerrainPolygon(poly->uNumVertices, poly, | |
377 pBitmaps_LOD->pHardwareTextures[pHDWaterBitmapIDs[hd_water_current_frame]], false, true); | |
378 | |
379 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); | |
380 //DrawTerrainPolygon(poly->uNumVertices, poly, pBitmaps_LOD->pHardwareTextures[poly->uTileBitmapID], true, true); | |
381 } | |
382 | |
0 | 383 |
384 //----- (0047BACF) -------------------------------------------------------- | |
385 void Render::TransformBillboardsAndSetPalettesODM() | |
386 { | |
142 | 387 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
388 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
389 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
390 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
391 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
392 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
393 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
394 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
395 //int v8; // ebx@4 |
0 | 396 unsigned __int16 *v9; // eax@7 |
397 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
398 //DWORD v11; // eax@13 |
0 | 399 int v12; // eax@13 |
400 int v13; // eax@14 | |
401 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
402 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 403 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
404 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 405 int v18; // [sp+60h] [bp-4h]@13 |
406 | |
2002 | 407 billboard.sParentBillboardID = -1; |
0 | 408 billboard.pTarget = pRenderer->pTargetSurface; |
409 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
410 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 411 billboard.uViewportX = pViewport->uViewportTL_X; |
412 billboard.uViewportY = pViewport->uViewportTL_Y; | |
413 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
414 billboard.uViewportW = pViewport->uViewportBR_Y; | |
1637 | 415 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw; |
142 | 416 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
417 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 418 { |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
419 billboard.uScreenSpaceX = pBillboardRenderList[i].uScreenSpaceX; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
420 billboard.uScreenSpaceY = pBillboardRenderList[i].uScreenSpaceY; |
2002 | 421 billboard.sParentBillboardID = i; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
422 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
|
423 billboard.sTintColor = pBillboardRenderList[i].sTintColor; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
424 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
|
425 billboard.sZValue = pBillboardRenderList[i].sZValue; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
426 billboard.uFlags = pBillboardRenderList[i].field_1E; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
427 if (pBillboardRenderList[i].HwSpriteID != -1) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
428 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
429 if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
430 //if (pRenderer->pRenderD3D) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
431 pRenderer->TransformBillboard(&billboard, |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
432 &pSprites_LOD->pHardwareSprites[pBillboardRenderList[i].HwSpriteID], |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
433 pBillboardRenderList[i].dimming_level, &pBillboardRenderList[i]); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
434 /*else |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
435 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
436 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
437 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
438 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 439 if ( *(v1 - 10) & 2 ) |
440 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
441 else | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
442 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 443 v10 = (*(v1 - 9) & 1) == 0; |
444 billboard.pPalette = v9; | |
445 if ( !v10 ) | |
446 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
447 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
448 { | |
323 | 449 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 450 v15 = abs(v12); |
451 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
452 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
453 } | |
454 v13 = *((short *)v1 - 8); | |
455 if ( v13 >= 0 ) | |
733 | 456 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
457 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
458 } |
0 | 459 } |
460 } | |
461 | |
462 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
463 void Render::DrawSpriteObjects_ODM() |
0 | 464 { |
2206 | 465 SpriteFrame *frame; // eax@10 |
0 | 466 unsigned int v6; // eax@10 |
467 int v9; // ecx@10 | |
468 int v17; // ecx@25 | |
469 int v18; // eax@25 | |
470 int v22; // ST3C_4@29 | |
471 signed __int64 v23; // qtt@30 | |
472 int v26; // eax@31 | |
473 char v27; // zf@31 | |
474 int v30; // [sp+14h] [bp-2Ch]@23 | |
475 int v37; // [sp+1Ch] [bp-24h]@23 | |
476 int a6; // [sp+20h] [bp-20h]@10 | |
477 int v42; // [sp+2Ch] [bp-14h]@23 | |
478 int y; // [sp+30h] [bp-10h]@10 | |
479 int x; // [sp+34h] [bp-Ch]@10 | |
480 int z; // [sp+38h] [bp-8h]@10 | |
481 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
482 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
483 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
484 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
|
485 { |
1980 | 486 SpriteObject* object = &pSpriteObjects[i]; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
487 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
488 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
489 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
490 //{ |
430 | 491 if (!object->uObjectDescID) // item probably pciked up |
492 continue; | |
493 | |
494 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
1980 | 495 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID]; |
430 | 496 if (object_desc->NoSprite()) |
497 continue; | |
498 | |
499 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
500 //if ( !(v1->uFlags & 1) ) | |
501 //{ | |
502 //v2 = *((short *)v0 - 14) | |
2206 | 503 //v2 = object->uType; |
504 if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600) | |
505 || pGame->pStru6Instance->_4A81CA(object) ) | |
430 | 506 { |
507 //a5 = *(short *)v0; | |
508 x = object->vPosition.x; | |
509 y = object->vPosition.y; | |
510 z = object->vPosition.z; | |
2206 | 511 frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); |
512 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
|
513 v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
430 | 514 //LOWORD(v7) = object->uFacing; |
515 //v8 = v36; | |
2206 | 516 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
|
517 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[v9]; |
2206 | 518 if ( frame->uFlags & 0x20 ) |
519 { | |
520 //v8 = v36; | |
521 z -= fixpoint_mul(frame->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)frame->pHwSpriteIDs[v9]].uHeight) / 2; | |
522 } | |
523 v46 = 0; | |
524 if ( frame->uFlags & 2 ) | |
525 v46 = 2; | |
526 //v11 = (int *)(256 << v9); | |
527 if ( (256 << v9) & frame->uFlags ) | |
528 v46 |= 4u; | |
529 if ( frame->uFlags & 0x40000 ) | |
530 v46 |= 0x40u; | |
531 if ( frame->uFlags & 0x20000 ) | |
532 LOBYTE(v46) = v46 | 0x80; | |
533 if ( a6 ) | |
534 { | |
535 //LOBYTE(v11) = _4E94D3_light_type; | |
536 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type); | |
537 } | |
538 if (pGame->pIndoorCameraD3D->sRotationX) | |
539 { | |
540 v30 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
541 + fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
542 v37 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
543 v42 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x) | |
544 + fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_cosine_x); | |
545 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
546 { | |
547 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - v37; | |
548 v18 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) | |
549 - fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_sine_x); | |
550 if ( abs(v42) >= abs(v17) ) | |
551 { | |
552 LODWORD(v23) = 0; | |
553 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
554 | |
555 object->uAttributes |= 1; | |
556 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
557 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
558 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
559 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
560 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
561 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
562 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
563 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
564 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
565 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
566 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
567 HIWORD(v26) = HIWORD(v42); | |
568 LOWORD(v26) = 0; | |
569 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
570 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
571 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
572 if ( !(object->uAttributes & 0x20) ) | |
0 | 573 { |
2206 | 574 if ( !pRenderer->pRenderD3D ) |
575 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
0 | 576 } |
2206 | 577 //if (::uNumBillboardsToDraw >= 500) |
578 // return; | |
579 assert(::uNumBillboardsToDraw < 500); | |
580 ++::uNumBillboardsToDraw; | |
581 ++uNumSpritesDrawnThisFrame; | |
0 | 582 } |
2206 | 583 } |
584 } | |
585 else | |
586 { | |
587 v42 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y) | |
588 + fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y); | |
589 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
590 { | |
591 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
592 - fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y); | |
593 v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; | |
594 if ( abs(v42) >= abs(v17) ) | |
595 { | |
596 LODWORD(v23) = 0; | |
597 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
598 | |
599 object->uAttributes |= 1; | |
600 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
601 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
602 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
603 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
604 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
605 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
606 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
607 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
608 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
609 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
610 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
611 HIWORD(v26) = HIWORD(v42); | |
612 LOWORD(v26) = 0; | |
613 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
614 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
615 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
616 if ( !(object->uAttributes & 0x20) ) | |
617 { | |
618 if ( !pRenderer->pRenderD3D ) | |
619 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
620 } | |
621 //if (::uNumBillboardsToDraw >= 500) | |
622 // return; | |
623 assert(::uNumBillboardsToDraw < 500); | |
624 ++::uNumBillboardsToDraw; | |
625 ++uNumSpritesDrawnThisFrame; | |
626 } | |
627 } | |
628 } | |
629 } | |
0 | 630 } |
631 } | |
632 | |
633 //----- (0049D9BC) -------------------------------------------------------- | |
634 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
635 { | |
636 size_t v4; // eax@1 | |
637 size_t v5; // eax@1 | |
638 IUnknown *v6; // eax@10 | |
639 size_t v7; // eax@13 | |
640 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
641 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
642 int v11; // [sp+430h] [bp-CCh]@16 | |
643 int v12; // [sp+434h] [bp-C8h]@16 | |
644 int v13; // [sp+438h] [bp-C4h]@16 | |
645 int v14; // [sp+474h] [bp-88h]@16*/ | |
646 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
647 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
648 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
649 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
650 int v19; // [sp+4C8h] [bp-34h]@16 | |
651 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
652 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
653 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
654 | |
655 v4 = strlen(lpDriverName); | |
656 v20.pDriverName = new char[v4 + 1]; | |
657 v5 = strlen(lpDevDesc); | |
658 v20.pDeviceDesc = new char[v5 + 1]; | |
659 strcpy(v20.pDriverName, lpDriverName); | |
660 strcpy(v20.pDeviceDesc, lpDevDesc); | |
661 if ( lpGUID ) | |
662 { | |
663 v20.pGUID = new GUID; | |
664 memcpy(v20.pGUID, lpGUID, 0x10u); | |
665 } | |
666 else | |
667 v20.pGUID = 0; | |
668 | |
669 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
670 { | |
671 delete [] v20.pDriverName; | |
672 delete [] v20.pDeviceDesc; | |
673 if ( v20.pGUID ) | |
674 delete v20.pGUID; | |
675 } | |
676 else | |
677 { | |
678 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
679 { | |
680 delete [] v20.pDriverName; | |
681 delete [] v20.pDeviceDesc; | |
682 if ( v20.pGUID ) | |
683 delete v20.pGUID; | |
684 v6 = (IUnknown *)pDirectDraw; | |
685 } | |
686 else | |
687 { | |
688 pDirectDraw->Release(); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
689 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1))) |
0 | 690 v20.pDDraw4DevDesc = 0; |
691 else | |
692 { | |
693 v7 = strlen(ddDevId.szDescription); | |
694 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
695 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
696 } | |
697 memset(&ddsCaps, 0, 0x10u); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
698 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem))) |
0 | 699 v20.uVideoMem = 0; |
700 memset(&v10, 0, 0x7Cu); | |
701 v10.dwSize = 124; | |
702 v10.dwFlags = 6; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
703 v10.dwHeight = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
704 v10.dwWidth = window->GetHeight(); |
0 | 705 v10.ddpfPixelFormat.dwSize = 32; |
706 | |
707 v19 = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
708 if ( FAILED(pDirectDraw4->EnumDisplayModes(0, 0, &v19, (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) |
0 | 709 || !v19 |
710 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
711 { | |
712 delete [] v20.pDriverName; | |
713 delete [] v20.pDeviceDesc; | |
714 if ( v20.pDDraw4DevDesc ) | |
715 free(v20.pDDraw4DevDesc); | |
716 if ( v20.pGUID ) | |
717 delete v20.pGUID; | |
718 v6 = (IUnknown *)pDirectDraw4; | |
719 } | |
720 else | |
721 { | |
722 aux.pInfo = pOut; | |
723 aux.ptr_4 = &v20; | |
724 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
725 delete [] v20.pDriverName; | |
726 delete [] v20.pDeviceDesc; | |
727 if ( v20.pDDraw4DevDesc ) | |
728 free(v20.pDDraw4DevDesc); | |
729 if ( v20.pGUID ) | |
730 delete v20.pGUID; | |
731 pDirectDraw4->Release(); | |
732 v6 = (IUnknown *)pDirect3D3; | |
733 pDirectDraw4 = 0; | |
734 } | |
735 } | |
736 v6->Release(); | |
737 } | |
738 return 1; | |
739 } | |
740 | |
741 //----- (0049D784) -------------------------------------------------------- | |
742 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
743 { | |
744 int v6; // eax@1 | |
745 signed int v7; // edi@1 | |
746 signed int v8; // edi@14 | |
747 size_t v9; // eax@30 | |
748 size_t v10; // eax@30 | |
749 size_t v11; // eax@30 | |
750 size_t v12; // eax@30 | |
751 size_t v13; // eax@30 | |
752 | |
753 v6 = pHWDesc->dwFlags; | |
754 v7 = -1; | |
755 if ( v6 ) | |
756 { | |
757 if ( !a6->ptr_4->pGUID ) | |
758 v7 = 0; | |
759 if ( v6 && a6->ptr_4->pGUID ) | |
760 v7 = 1; | |
761 } | |
762 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
763 v7 = 2; | |
764 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
765 v7 = 3; | |
766 if ( v7 != -1 ) | |
767 { | |
768 v8 = v7; | |
769 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
770 a6->pInfo[v8].uCaps = 0; | |
771 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
772 a6->pInfo[v8].uCaps |= 2u; | |
773 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
774 a6->pInfo[v8].uCaps |= 4u; | |
775 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
776 a6->pInfo[v8].uCaps |= 8u; | |
777 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
778 a6->pInfo[v8].uCaps |= 0x10u; | |
779 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
780 a6->pInfo[v8].uCaps |= 0x20u; | |
781 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
782 a6->pInfo[v8].uCaps |= 0x40u; | |
783 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
784 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
785 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
786 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
787 v9 = strlen(lpDeviceName); | |
788 a6->pInfo[v8].pName = new char[v9 + 1]; | |
789 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
790 v10 = strlen(lpDeviceDesc); | |
791 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
792 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
1631 | 793 a6->pInfo[v8].pGUID = new GUID; |
0 | 794 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); |
795 v11 = strlen(a6->ptr_4->pDriverName); | |
796 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
797 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
798 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
799 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
800 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
801 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
802 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
803 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
804 if ( a6->ptr_4->pGUID ) | |
805 { | |
806 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
807 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
808 } | |
809 else | |
810 { | |
811 a6->pInfo[v8].pDirectDrawGUID = 0; | |
812 } | |
813 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
814 } | |
815 return 1; | |
816 } | |
817 | |
818 //----- (0049D75C) -------------------------------------------------------- | |
819 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
820 { | |
821 HRESULT result; // eax@3 | |
822 | |
823 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
824 { | |
825 *a2 = 1; | |
826 result = 0; | |
827 } | |
828 else | |
829 result = 1; | |
830 return result; | |
831 } | |
832 | |
833 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
834 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
835 { |
0 | 836 unsigned int v6; // edi@9 |
837 int v7; // eax@9 | |
838 SpriteFrame *v8; // eax@9 | |
839 unsigned __int16 *v10; // eax@9 | |
840 int v13; // ecx@9 | |
841 int v14; // ecx@20 | |
842 char v15; // dl@20 | |
843 signed int v16; // eax@20 | |
844 int v17; // eax@23 | |
845 int v18; // ecx@24 | |
846 int v19; // eax@24 | |
847 int v20; // ecx@24 | |
848 int v21; // ebx@26 | |
849 int v22; // eax@26 | |
850 signed __int64 v24; // qtt@31 | |
851 int v25; // ebx@31 | |
852 __int16 v29; // cx@37 | |
853 int v30; // ecx@37 | |
854 int v31; // ebx@37 | |
619 | 855 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
0 | 856 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
857 int v38; // [sp+88h] [bp-1Ch]@9 | |
858 int v40; // [sp+90h] [bp-14h]@24 | |
859 int v41; // [sp+94h] [bp-10h]@24 | |
860 int v42; // [sp+98h] [bp-Ch]@9 | |
861 int b; // [sp+A0h] [bp-4h]@22 | |
862 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
863 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
864 { |
1980 | 865 LevelDecoration* decor = &pLevelDecorations[i]; |
1491
6d21ef91cb2d
Rename LevelDecoration::_47A825 to LevelDecoration::IsObeliskChestActive().
yoctozepto
parents:
1490
diff
changeset
|
866 if ((!(decor->uFlags & LEVEL_DECORATION_OBELISK_CHEST) || decor->IsObeliskChestActive()) && !(decor->uFlags & LEVEL_DECORATION_INVISIBLE)) |
1490 | 867 { |
1980 | 868 DecorationDesc* decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
869 if ( (char)decor_desc->uFlags >= 0 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
870 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
871 if ( !(decor_desc->uFlags & 0x22) ) |
0 | 872 { |
1490 | 873 v6 = pMiscTimer->uTotalGameTimeElapsed; |
874 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
875 | |
876 #pragma region "New: seasons change" | |
877 extern bool change_seasons; | |
878 if (change_seasons) | |
879 switch (pParty->uCurrentMonth) | |
880 { | |
881 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
882 case 11: case 0: case 1: // winter | |
883 switch (decor_desc->uSpriteID) | |
884 { | |
885 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
886 case 548: // flower10 | |
887 case 547: // flower09 | |
888 case 541: // flower03 | |
889 case 539: continue; // flower01 | |
890 | |
891 case 483: // tree01 | |
892 case 486: // tree04 | |
893 case 492: // tree10 | |
894 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); | |
895 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
896 break; | |
897 | |
898 default: | |
899 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
900 } | |
901 break; | |
902 | |
903 case 2: case 3: case 4: // spring | |
904 switch (decor_desc->uSpriteID) | |
905 { | |
906 } | |
907 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
908 break; | |
909 | |
910 case 8: case 9: case 10: // autumn | |
911 switch (decor_desc->uSpriteID) | |
912 { | |
913 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
914 case 548: // flower10 | |
915 case 547: // flower09 | |
916 case 541: // flower03 | |
917 case 539: continue; // flower01 | |
918 | |
919 case 483: // tree01 | |
920 case 486: // tree04 | |
921 case 492: // tree10 | |
922 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); | |
923 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
924 break; | |
925 | |
926 default: | |
927 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
928 } | |
929 break; | |
930 | |
931 case 5: case 6: case 7: // summer | |
932 //all green by default | |
933 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
934 break; | |
935 | |
936 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
937 } | |
938 else | |
939 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
940 #pragma endregion | |
941 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
942 | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
943 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
944 decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
1490 | 945 v38 = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
946 v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + decor->field_10_y_rot - (signed int)v10) >> 8) & 7; |
1490 | 947 v37 = (unsigned __int16 *)v13; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
948 if ( v8->uFlags & 2 ) |
1490 | 949 v38 = 2; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
950 if ( (256 << v13) & v8->uFlags ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
951 v38 |= 4; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
952 if ( v8->uFlags & 0x40000 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
953 v38 |= 0x40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
954 if ( v8->uFlags & 0x20000 ) |
1490 | 955 LOBYTE(v38) = v38 | 0x80; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
956 if ( v8->uGlowRadius ) |
0 | 957 { |
1490 | 958 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) |
0 | 959 { |
1490 | 960 v14 = decor_desc->uColoredLightRed; |
961 v15 = decor_desc->uColoredLightGreen; | |
962 v16 = decor_desc->uColoredLightBlue; | |
0 | 963 } |
964 else | |
965 { | |
1490 | 966 v16 = 255; |
967 v14 = 255; | |
968 v15 = 255; | |
969 } | |
2207 | 970 pStationaryLightsStack->AddLight(decor->vPosition.x, decor->vPosition.y, decor->vPosition.z + decor_desc->uDecorationHeight / 2, |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
971 v8->uGlowRadius, v14, v15, v16, _4E94D0_light_type); |
1490 | 972 } |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
973 v17 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
974 if (pGame->pIndoorCameraD3D->sRotationX) |
1490 | 975 { |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
976 v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
2207 | 977 v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
978 v41 = fixpoint_mul((decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 979 v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
980 v20 = v19 + fixpoint_mul((decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 981 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 982 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
983 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
984 v22 = fixpoint_mul((decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_sine_x); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
985 if ( 2 * abs(v20) >= abs(v21) ) |
0 | 986 { |
1490 | 987 LODWORD(v24) = 0; |
1637 | 988 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
989 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
|
990 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
|
991 v41 = fixpoint_mul(v8->scale, v24 / v20); |
1490 | 992 if ( pRenderer->pRenderD3D ) |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
993 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41); |
1490 | 994 else |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
995 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41); |
1490 | 996 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
997 { | |
998 if (::uNumBillboardsToDraw >= 500) | |
999 return; | |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1000 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1001 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1002 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
1490 | 1003 v29 = v38; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1004 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1005 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1006 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1007 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1008 pBillboardRenderList[::uNumBillboardsToDraw].world_x = decor->vPosition.x; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1009 pBillboardRenderList[::uNumBillboardsToDraw].world_y = decor->vPosition.y; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1010 pBillboardRenderList[::uNumBillboardsToDraw].world_z = decor->vPosition.z; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1011 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1012 HIWORD(v30) = HIWORD(v20); |
1490 | 1013 v31 = PID(OBJECT_Decoration,i); |
1014 LOWORD(v30) = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1015 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1016 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1017 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1018 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1019 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1020 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1021 ++uNumDecorationsDrawnThisFrame; |
1490 | 1022 } |
0 | 1023 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1024 continue; |
1490 | 1025 } |
1026 } | |
1027 else | |
1028 { | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1029 v42 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1030 v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1031 v20 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2207 | 1032 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1033 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1034 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y); |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1035 v22 = (decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1036 v42 = v22; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1037 if ( 2 * abs(v20) >= abs(v21) ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1038 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1039 LODWORD(v24) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1040 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1041 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
|
1042 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
|
1043 v41 = fixpoint_mul(v8->scale, v24 / v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1044 if ( pRenderer->pRenderD3D ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1045 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
|
1046 else |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1047 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
|
1048 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
|
1049 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1050 if (::uNumBillboardsToDraw >= 500) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1051 return; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1052 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1053 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1054 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1055 v29 = v38; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1056 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1057 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1058 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1059 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1060 pBillboardRenderList[::uNumBillboardsToDraw].world_x = decor->vPosition.x; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1061 pBillboardRenderList[::uNumBillboardsToDraw].world_y = decor->vPosition.y; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1062 pBillboardRenderList[::uNumBillboardsToDraw].world_z = decor->vPosition.z; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1063 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1064 HIWORD(v30) = HIWORD(v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1065 v31 = PID(OBJECT_Decoration,i); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1066 LOWORD(v30) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1067 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1068 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1069 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1070 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1071 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1072 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1073 ++uNumDecorationsDrawnThisFrame; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1074 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1075 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1076 continue; |
0 | 1077 } |
1078 } | |
1079 } | |
1490 | 1080 } |
1081 else | |
1082 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1083 memset(&local_0, 0, 0x68); |
1490 | 1084 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
1085 local_0.uDiffuse = 0xFF3C1E; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1086 local_0.x = (double)decor->vPosition.x; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1087 local_0.y = (double)decor->vPosition.y; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1088 local_0.z = (double)decor->vPosition.z; |
1490 | 1089 local_0.r = 0.0; |
1090 local_0.g = 0.0; | |
1091 local_0.b = 0.0; | |
1092 local_0.flt_28 = 1.0; | |
1093 local_0.timeToLive = (rand() & 0x80) + 128; | |
1094 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
1095 pGame->pParticleEngine->AddParticle(&local_0); | |
1096 } | |
1097 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1098 } |
0 | 1099 } |
1100 | |
1101 //----- (0049D717) -------------------------------------------------------- | |
1102 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1103 { | |
2069 | 1104 if ( Src->dwFlags & (0x400 | 0x2000)) |
0 | 1105 { |
1106 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1107 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1108 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1109 return 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1110 } |
0 | 1111 if ( !Dst->dwSize ) |
1112 { | |
2078 | 1113 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1114 return 1; |
0 | 1115 } |
1116 } | |
1117 return 1; | |
1118 } | |
1119 | |
1120 //----- (0049DC28) -------------------------------------------------------- | |
1121 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1122 { | |
1123 RenderD3D__DevInfo *v2; // eax@1 | |
1124 | |
1125 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1126 *pOutDevices = v2; | |
1127 memset(v2, 0, 0xA0u); | |
1985 | 1128 DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)RenderD3D__DeviceEnumerator, *pOutDevices, DDENUM_ATTACHEDSECONDARYDEVICES); |
0 | 1129 } |
1130 | |
1131 //----- (0049DC58) -------------------------------------------------------- | |
1132 RenderD3D::RenderD3D() | |
1133 { | |
1134 this->pHost = 0; | |
1135 this->pDirect3D = 0; | |
1136 this->pUnk = 0; | |
1137 this->pBackBuffer = 0; | |
1138 this->pFrontBuffer = 0; | |
1139 this->pZBuffer = 0; | |
1140 this->pDevice = 0; | |
1141 this->pViewport = 0; | |
1142 this->field_40 = 1; | |
1143 this->field_44 = 10; | |
1144 GetAvailableDevices(&this->pAvailableDevices); | |
1145 } | |
1146 | |
1147 //----- (0049DC90) -------------------------------------------------------- | |
1148 void RenderD3D::Release() | |
1149 { | |
1150 RenderD3D *v1; // esi@1 | |
1151 IDirectDraw4 *v2; // eax@2 | |
1152 signed int v3; // edi@4 | |
1153 IDirect3DViewport3 *v4; // eax@22 | |
1154 IUnknown *v5; // eax@24 | |
1155 IDirectDrawSurface4 *v6; // eax@26 | |
1156 IDirect3DDevice3 *v7; // eax@28 | |
1157 IDirect3D3 *v8; // eax@30 | |
1158 IDirectDrawSurface4 *v9; // eax@32 | |
1159 IDirectDrawSurface4 *v10; // eax@34 | |
1160 IDirectDraw4 *v11; // eax@36 | |
1161 | |
1162 v1 = this; | |
1163 if ( !this->bWindowed ) | |
1164 { | |
1165 v2 = this->pHost; | |
1166 if ( v2 ) | |
1167 { | |
1168 v2->RestoreDisplayMode(); | |
1169 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
1170 v1->pHost->FlipToGDISurface(); | |
1171 } | |
1172 } | |
1173 v3 = 0; | |
1174 do | |
1175 { | |
1176 if ( v1->pAvailableDevices[v3].pDriverName ) | |
1177 { | |
1178 free(v1->pAvailableDevices[v3].pDriverName); | |
1179 v1->pAvailableDevices[v3].pDriverName = 0; | |
1180 } | |
1181 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
1182 { | |
1183 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
1184 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
1185 } | |
1186 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
1187 { | |
1188 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
1189 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
1190 } | |
1191 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
1192 { | |
1193 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
1194 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
1195 } | |
1196 if ( v1->pAvailableDevices[v3].pName ) | |
1197 { | |
1198 free(v1->pAvailableDevices[v3].pName); | |
1199 v1->pAvailableDevices[v3].pName = 0; | |
1200 } | |
1201 if ( v1->pAvailableDevices[v3].pDescription ) | |
1202 { | |
1203 free(v1->pAvailableDevices[v3].pDescription); | |
1204 v1->pAvailableDevices[v3].pDescription = 0; | |
1205 } | |
1206 if ( v1->pAvailableDevices[v3].pGUID ) | |
1207 { | |
1208 free(v1->pAvailableDevices[v3].pGUID); | |
1209 v1->pAvailableDevices[v3].pGUID = 0; | |
1210 } | |
1211 ++v3; | |
1212 } | |
1213 while ( v3 < 4 ); | |
1214 if ( v1->pAvailableDevices ) | |
1215 { | |
1216 free(v1->pAvailableDevices); | |
1217 v1->pAvailableDevices = 0; | |
1218 } | |
1219 v4 = v1->pViewport; | |
1220 if ( v4 ) | |
1221 { | |
1222 v4->Release(); | |
1223 v1->pViewport = 0; | |
1224 } | |
1225 v5 = v1->pUnk; | |
1226 if ( v5 ) | |
1227 { | |
1228 v5->Release(); | |
1229 v1->pUnk = 0; | |
1230 } | |
1231 v6 = v1->pZBuffer; | |
1232 if ( v6 ) | |
1233 { | |
1234 v6->Release(); | |
1235 v1->pZBuffer = 0; | |
1236 } | |
1237 v7 = v1->pDevice; | |
1238 if ( v7 ) | |
1239 { | |
1240 v7->Release(); | |
1241 v1->pDevice = 0; | |
1242 } | |
1243 v8 = v1->pDirect3D; | |
1244 if ( v8 ) | |
1245 { | |
1246 v8->Release(); | |
1247 v1->pDirect3D = 0; | |
1248 } | |
1249 v9 = v1->pBackBuffer; | |
1250 if ( v9 ) | |
1251 { | |
1252 v9->Release(); | |
1253 v1->pBackBuffer = 0; | |
1254 } | |
1255 v10 = v1->pFrontBuffer; | |
1256 if ( v10 ) | |
1257 { | |
1258 v10->Release(); | |
1259 v1->pFrontBuffer = 0; | |
1260 } | |
1261 v11 = v1->pHost; | |
1262 if ( v11 ) | |
1263 { | |
1264 v11->Release(); | |
1265 v1->pHost = 0; | |
1266 } | |
1267 } | |
1268 | |
1269 //----- (0049DE14) -------------------------------------------------------- | |
2069 | 1270 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window) |
0 | 1271 { |
1272 //IDirectDraw4 *v8; // eax@12 | |
1273 //IDirectDraw4 *v9; // eax@16 | |
1274 //IDirectDraw4 *v10; // eax@20 | |
1275 //IDirectDraw4 *v13; // eax@35 | |
1276 const char *v23; // [sp-4h] [bp-DCh]@9 | |
1277 const char *v24; // [sp-4h] [bp-DCh]@13 | |
1278 const char *v25; // [sp-4h] [bp-DCh]@19 | |
1279 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1280 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1281 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1282 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1283 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
1284 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1285 | |
2069 | 1286 auto hWnd = window->GetApiHandle(); |
1287 int game_width = window->GetWidth(); | |
1288 int game_height = window->GetHeight(); | |
1289 | |
0 | 1290 this->bWindowed = bWindowed; |
1291 this->hWindow = hWnd; | |
1292 | |
1293 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
1294 { | |
1295 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1296 return 0; | |
1297 } | |
1298 | |
1299 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1300 { | |
1301 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1302 if (lpDD) | |
1303 lpDD->Release(); | |
1304 return 0; | |
1305 } | |
1306 lpDD->Release(); | |
1307 lpDD = 0; | |
1308 | |
1309 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1310 { | |
1311 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
1312 { | |
1313 v23 = "Init - Failed to set cooperative level.\n"; | |
1314 sprintf(pErrorMessage, v23); | |
1315 LABEL_65: | |
1316 if (pHost) | |
1317 { | |
1318 pHost->Release(); | |
1319 pHost = 0; | |
1320 } | |
1321 return 0; | |
1322 } | |
1323 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1324 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1325 ddsd2.dwFlags = DDSD_CAPS; | |
1326 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
1327 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1328 { | |
1329 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1330 pHost->GetDisplayMode(&ddsd2); | |
2069 | 1331 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) |
0 | 1332 { |
1333 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
1334 goto LABEL_14; | |
1335 } | |
1336 | |
1337 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
1338 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
2069 | 1339 ddsd2.dwWidth = game_width; |
1340 ddsd2.dwHeight = game_height; | |
0 | 1341 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) |
1342 { | |
1343 v24 = "Init - Failed to create back buffer.\n"; | |
1344 LABEL_14: | |
1345 sprintf(pErrorMessage, v24); | |
1346 if (pFrontBuffer) | |
1347 { | |
1348 pFrontBuffer->Release(); | |
1349 pFrontBuffer = 0; | |
1350 } | |
1351 goto LABEL_65; | |
1352 } | |
1353 if ( pHost->CreateClipper(0, &v30, 0) ) | |
1354 { | |
1355 v25 = "Init - Failed to create clipper.\n"; | |
1356 goto LABEL_45; | |
1357 } | |
1358 v30->SetHWnd(0, hWnd); | |
1359 pFrontBuffer->SetClipper(v30); | |
1360 | |
1361 v30->Release(); | |
1362 v30 = 0; | |
1363 | |
1364 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1365 | |
1366 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1367 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
2069 | 1368 ddsd2.dwWidth = game_width; |
1369 ddsd2.dwHeight = game_height; | |
0 | 1370 |
1371 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1372 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1373 &ddsd2.ddpfPixelFormat) ) | |
1374 goto LABEL_21; | |
1375 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1376 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
1377 | |
1378 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1379 { | |
1380 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
1381 { | |
1382 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1383 pBackBuffer, | |
1384 &pDevice, | |
1385 0) ) | |
1386 { | |
1387 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1388 d3dvp2.dvClipWidth = 2.0; | |
1389 d3dvp2.dvClipY = 1.0; | |
1390 d3dvp2.dvClipHeight = 2.0; | |
1391 d3dvp2.dvMaxZ = 1.0; | |
1392 d3dvp2.dvMinZ = 0.0; | |
1393 goto LABEL_54; | |
1394 } | |
1395 LABEL_51: | |
1396 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1397 if (pDirect3D) | |
1398 { | |
1399 pDirect3D->Release(); | |
1400 pDirect3D = 0; | |
1401 } | |
1402 goto LABEL_59; | |
1403 } | |
1404 LABEL_48: | |
1405 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1406 if (pZBuffer) | |
1407 { | |
1408 pZBuffer->Release(); | |
1409 pZBuffer = 0; | |
1410 } | |
1411 goto LABEL_61; | |
1412 } | |
1413 goto LABEL_44; | |
1414 } | |
1415 LABEL_36: | |
1416 v23 = "Init - Failed to create front buffer.\n"; | |
1417 sprintf(pErrorMessage, v23); | |
1418 goto LABEL_65; | |
1419 } | |
1420 if ( uDeviceID == 1 ) | |
1421 v26 = 1045; | |
1422 else | |
1423 v26 = 1041; | |
1424 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
1425 { | |
1426 v23 = "Init - Failed to set cooperative level.\n"; | |
1427 sprintf(pErrorMessage, v23); | |
1428 goto LABEL_65; | |
1429 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1430 if (pHost->SetDisplayMode(window->GetWidth(), window->GetHeight(), 16, 0, 0) ) |
0 | 1431 { |
1432 v23 = "Init - Failed to set display mode.\n"; | |
1433 sprintf(pErrorMessage, v23); | |
1434 goto LABEL_65; | |
1435 } | |
1436 | |
1437 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1438 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1439 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
1440 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
1441 ddsd2.dwBackBufferCount = 1; | |
1442 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1443 goto LABEL_36; | |
1444 //a3a = &pBackBuffer; | |
1445 //v14 = *v34; | |
1446 memset(&v27, 0, sizeof(DDSCAPS2)); | |
1447 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
1448 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
1449 //hWnda = &pDirect3D; | |
1450 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1451 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
1452 { | |
1453 v25 = "Init - Failed to get D3D interface.\n"; | |
1454 goto LABEL_45; | |
1455 } | |
1456 | |
1457 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1458 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1459 ddsd2.dwWidth = 640; | |
1460 ddsd2.dwHeight = 480; | |
1461 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1462 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1463 &ddsd2.ddpfPixelFormat) ) | |
1464 { | |
1465 LABEL_21: | |
1466 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
1467 goto LABEL_45; | |
1468 } | |
1469 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1470 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
1471 //uDeviceIDa = &pZBuffer; | |
1472 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1473 { | |
1474 LABEL_44: | |
1475 v25 = "Init - Failed to create z-buffer.\n"; | |
1476 LABEL_45: | |
1477 sprintf(pErrorMessage, v25); | |
1478 if (pBackBuffer) | |
1479 { | |
1480 pBackBuffer->Release(); | |
1481 pBackBuffer = 0; | |
1482 } | |
1483 LABEL_63: | |
1484 //v19 = &pFrontBuffer; | |
1485 if (pFrontBuffer) | |
1486 { | |
1487 pFrontBuffer->Release(); | |
1488 pFrontBuffer= 0; | |
1489 } | |
1490 goto LABEL_65; | |
1491 } | |
1492 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
1493 goto LABEL_48; | |
1494 //v33 = &pDevice; | |
1495 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1496 pBackBuffer, | |
1497 &pDevice, | |
1498 0) ) | |
1499 goto LABEL_51; | |
1500 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1501 d3dvp2.dvClipWidth = 2.0; | |
1502 d3dvp2.dvClipY = 1.0; | |
1503 d3dvp2.dvClipHeight = 2.0; | |
1504 d3dvp2.dvMaxZ = 1.0; | |
1505 | |
1506 LABEL_54: | |
1507 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
1508 //v17 = *hWnda; | |
2069 | 1509 d3dvp2.dwWidth = game_width; |
1510 d3dvp2.dwHeight = game_height; | |
0 | 1511 d3dvp2.dvClipX = -1.0; |
1512 //v18 = v17->lpVtbl; | |
1513 //v32 = &v4->pViewport; | |
1514 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
1515 { | |
1516 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
1517 if (pDevice) | |
1518 { | |
1519 pDevice->Release(); | |
1520 pDevice = 0; | |
1521 } | |
1522 if (pDirect3D) | |
1523 { | |
1524 pDirect3D->Release(); | |
1525 pDirect3D = 0; | |
1526 } | |
1527 LABEL_59: | |
1528 if (pZBuffer) | |
1529 { | |
1530 pZBuffer->Release(); | |
1531 pZBuffer = 0; | |
1532 } | |
1533 LABEL_61: | |
1534 if (pBackBuffer) | |
1535 { | |
1536 pBackBuffer->Release(); | |
1537 pBackBuffer = 0; | |
1538 } | |
1539 goto LABEL_63; | |
1540 } | |
1541 | |
1542 pDevice->AddViewport(pViewport); | |
1543 pViewport->SetViewport2(&d3dvp2); | |
1544 pDevice->SetCurrentViewport(pViewport); | |
1545 return 1; | |
1546 } | |
1547 | |
1548 //----- (0049E444) -------------------------------------------------------- | |
1549 unsigned int RenderD3D::GetDeviceCaps() | |
1550 { | |
1551 unsigned int v1; // ebx@1 | |
1552 RenderD3D *v2; // edi@1 | |
1553 IDirect3DDevice3 *v3; // eax@1 | |
1554 unsigned int result; // eax@2 | |
1555 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
1556 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
1557 | |
1558 v1 = 0; | |
1559 v2 = this; | |
1560 memset(&halCaps, 0, 0xFCu); | |
1561 halCaps.dwSize = 252; | |
1562 memset(&refCaps, 0, 0xFCu); | |
1563 v3 = v2->pDevice; | |
1564 refCaps.dwSize = 252; | |
1565 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
1566 { | |
1567 result = 1; | |
1568 } | |
1569 else | |
1570 { | |
2154 | 1571 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) ) |
0 | 1572 v1 = 2; |
2154 | 1573 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1574 v1 |= 4u; |
2154 | 1575 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) ) |
0 | 1576 v1 |= 8u; |
2154 | 1577 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) ) |
0 | 1578 v1 |= 0x10u; |
2154 | 1579 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1580 v1 |= 0x20u; |
2154 | 1581 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) ) |
0 | 1582 v1 |= 0x40u; |
2154 | 1583 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ) |
1584 v1 |= 0x80; | |
0 | 1585 result = v1; |
1586 } | |
1587 return result; | |
1588 } | |
1589 | |
1590 //----- (0049E4FC) -------------------------------------------------------- | |
1591 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
1592 { | |
1593 uint uClearFlags = 0; | |
1594 | |
1595 if (bClearColor) | |
1596 uClearFlags |= D3DCLEAR_TARGET; | |
1597 if (bClearDepth) | |
1598 uClearFlags |= D3DCLEAR_ZBUFFER; | |
1599 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1600 D3DRECT rects[] = {{0, 0, window->GetWidth(), window->GetHeight()}}; |
0 | 1601 if (uClearFlags) |
1602 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
1603 } | |
1604 | |
1605 //----- (0049E54D) -------------------------------------------------------- | |
1606 void RenderD3D::Present(bool bForceBlit) | |
1607 { | |
1608 RECT v5; // [sp+18h] [bp-18h]@1 | |
1609 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
1610 | |
1611 v5.left = 0; | |
1612 v5.top = 0; | |
2217 | 1613 v5.bottom = 480;//window->GetHeight(); //Ritor1: ïðîáëåìà ñ êíîïêîé "ðàçâåðíóòü" |
1614 v5.right = 640; //window->GetWidth(); | |
0 | 1615 |
1616 if (bWindowed || bForceBlit) | |
1617 { | |
1618 RECT rc; | |
1619 GetClientRect(hWindow, &rc); | |
1620 Point.y = 0; | |
1621 Point.x = 0; | |
1622 ClientToScreen(hWindow, &Point); | |
1623 OffsetRect(&rc, Point.x, Point.y); | |
1624 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
1625 } | |
1626 else | |
1627 pFrontBuffer->Flip(0, 1); | |
1628 } | |
1629 | |
1630 //----- (0049E5D4) -------------------------------------------------------- | |
1631 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
1632 { | |
1633 unsigned int v8; // edx@4 | |
1634 unsigned int v9; // ebx@5 | |
1635 unsigned int v10; // eax@5 | |
1636 DWORD v11; // edx@5 | |
1637 //int v12; // edx@7 | |
1638 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
1639 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
1640 | |
1641 //v15 = this; | |
1642 memset(&ddsd2, 0, 0x7Cu); | |
1643 ddsd2.dwSize = 0x7Cu; | |
1644 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1645 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
1646 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
1647 ddsd2.dwHeight = uTextureHeight; | |
1648 ddsd2.dwWidth = uTextureWidth; | |
1649 if ( bMipmaps ) | |
1650 { | |
1651 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
1652 { | |
1653 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
1654 LABEL_8: | |
1655 ddsd2.dwMipMapCount = v8; | |
1656 if ( !v8 ) | |
1657 goto LABEL_12; | |
1658 goto LABEL_11; | |
1659 } | |
1660 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
1661 { | |
1662 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
1663 goto LABEL_8; | |
1664 } | |
1665 v9 = GetMaxMipLevels(uTextureWidth); | |
1666 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
1667 ddsd2.dwMipMapCount = v9 - v10; | |
1668 if ( v9 == v10 ) | |
1669 { | |
1670 ddsd2.dwFlags = 0x1007u; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
1671 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used |
0 | 1672 ddsd2.ddsCaps.dwCaps = v11; |
1673 goto LABEL_12; | |
1674 } | |
1675 } | |
1676 else | |
1677 { | |
1678 ddsd2.dwMipMapCount = 1; | |
1679 } | |
1680 LABEL_11: | |
1681 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1682 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1683 LABEL_12: | |
1684 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
1685 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
1686 if (bAlphaChannel) | |
1687 { | |
1688 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
1689 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
1690 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
1691 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1692 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
1693 } | |
1694 else | |
1695 { | |
1696 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
1697 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
1698 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
1699 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1700 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
1701 } | |
1702 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
1703 return false; | |
1704 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
1705 { | |
1706 (*pOutSurface)->Release(); | |
1707 *pOutSurface = 0; | |
1708 return false; | |
1709 } | |
1710 return true; | |
1711 } | |
1712 | |
1713 //----- (004A5190) -------------------------------------------------------- | |
1714 void RenderD3D::HandleLostResources() | |
1715 { | |
1716 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
1717 pBitmaps_LOD->_410423_move_textures_to_device(); | |
1718 pSprites_LOD->ReleaseLostHardwareSprites(); | |
1719 } | |
1720 | |
1721 //----- (004A2050) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
1722 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) |
0 | 1723 { |
1724 Render *v5; // edi@1 | |
1725 unsigned int v6; // ebx@1 | |
1726 LightmapBuilder *v7; // esi@3 | |
1727 int v8; // eax@7 | |
1728 ODMFace *v9; // eax@12 | |
1729 char *v10; // esi@12 | |
1730 double v11; // st7@14 | |
1731 double v12; // st7@14 | |
1732 int v13; // eax@14 | |
1733 ODMFace *v14; // ecx@14 | |
1734 double v15; // st7@14 | |
1735 float v16; // ST48_4@15 | |
1736 int v17; // eax@15 | |
1737 char v18; // zf@17 | |
1738 HRESULT v19; // eax@18 | |
1739 HRESULT v20; // eax@18 | |
1740 HRESULT v21; // eax@20 | |
1741 HRESULT v22; // eax@20 | |
1742 unsigned int v23; // ecx@20 | |
1743 char *v24; // eax@21 | |
1744 HRESULT v25; // eax@23 | |
1745 HRESULT v26; // eax@23 | |
1746 HRESULT v27; // eax@24 | |
1747 HRESULT v28; // eax@25 | |
1748 HRESULT v29; // eax@25 | |
1749 HRESULT v30; // eax@25 | |
1750 HRESULT v31; // eax@25 | |
1751 HRESULT v32; // eax@26 | |
1752 unsigned int v33; // ecx@26 | |
1753 char *v34; // eax@27 | |
1754 int v35; // edx@28 | |
1755 HRESULT v36; // eax@29 | |
1756 HRESULT v37; // eax@29 | |
1757 HRESULT v38; // eax@29 | |
1758 HRESULT v39; // eax@29 | |
1759 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
1760 unsigned int v41; // eax@29 | |
1761 HRESULT v42; // eax@30 | |
1762 HRESULT v43; // eax@30 | |
1763 HRESULT v44; // eax@30 | |
1764 char *v45; // esi@34 | |
1765 int v46; // ecx@35 | |
1766 double v47; // st6@35 | |
1767 int v48; // eax@36 | |
1768 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
1769 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
1770 int v51; // [sp+50h] [bp-18h]@0 | |
1771 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
1772 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
1773 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
1774 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
1775 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
1776 int v57; // [sp+60h] [bp-8h]@34 | |
2006 | 1777 signed int a2; // [sp+64h] [bp-4h]@4 |
0 | 1778 |
1779 v5 = this; | |
1780 v6 = 0; | |
1781 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
1782 { | |
1783 v7 = pGame->pLightmapBuilder; | |
1784 v53 = v7; | |
1785 v54 = v7->std__vector_000004_size; | |
1786 if ( v7->std__vector_000004_size) | |
2006 | 1787 a2 = -1; |
638 | 1788 pGame->AlterGamma_ODM(a4, &a2); |
2155 | 1789 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 1790 { |
638 | 1791 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 1792 v7->DrawLightmaps(/*v8, 0*/); |
0 | 1793 } |
1794 else | |
1795 { | |
1796 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
1797 { | |
323 | 1798 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1799 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
1800 if (bUsingSpecular) | |
1801 { | |
186 | 1802 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
1803 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1804 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1805 } |
1073 | 1806 for (uint i = 0; i < uNumVertices; ++i) |
1807 { | |
1808 | |
1809 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1810 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1811 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1812 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1813 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1814 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
1815 | |
1816 if ( this->bUsingSpecular ) | |
0 | 1817 { |
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
|
1818 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1819 } |
1073 | 1820 else |
1821 { | |
1822 d3d_vertex_buffer[i].specular = 0; | |
1823 } | |
1824 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1825 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1826 | |
1827 } | |
323 | 1828 |
1829 if (a4->uAttributes & FACE_OUTLINED) | |
1830 { | |
1831 int color; | |
1832 if (GetTickCount() % 300 >= 150) | |
1833 color = 0xFFFF2020; | |
1834 else color = 0xFF901010; | |
1835 | |
1836 for (uint i = 0; i < uNumVertices; ++i) | |
1837 d3d_vertex_buffer[i].diffuse = color; | |
1838 } | |
1839 | |
0 | 1840 pRenderD3D->pDevice->SetTexture(0, pTexture); |
1841 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1842 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1843 d3d_vertex_buffer, |
0 | 1844 uNumVertices, |
1845 D3DDP_DONOTLIGHT); | |
1846 } | |
1847 else | |
1848 { | |
1073 | 1849 for (uint i = 0; i < uNumVertices; ++i) |
1850 { | |
1851 | |
1852 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1853 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1854 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1855 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1856 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1857 if ( this->bUsingSpecular ) | |
0 | 1858 { |
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
|
1859 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1860 } |
1073 | 1861 else |
1862 { | |
1863 d3d_vertex_buffer[i].specular = 0; | |
1864 } | |
1865 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1866 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1867 | |
1868 } | |
1869 | |
186 | 1870 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
1871 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 1872 if (bUsingSpecular) |
186 | 1873 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 1874 |
1875 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
1876 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1877 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1878 d3d_vertex_buffer, |
0 | 1879 uNumVertices, |
1880 D3DDP_DONOTLIGHT)); | |
1881 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
1882 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1883 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
1394 | 1884 v53->DrawLightmaps(/*-1, 0*/); |
1073 | 1885 for (uint i = 0; i < uNumVertices; ++i) |
1886 { | |
1887 d3d_vertex_buffer[i].diffuse = a2; | |
1888 } | |
0 | 1889 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 1890 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1891 if ( !pRenderer->bUsingSpecular ) |
186 | 1892 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
1893 | |
1894 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
1895 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
1896 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 1897 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1898 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1899 d3d_vertex_buffer, |
0 | 1900 uNumVertices, |
1901 D3DDP_DONOTLIGHT)); | |
1902 if (bUsingSpecular) | |
1903 { | |
186 | 1904 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 1905 |
1073 | 1906 for (uint i = 0; i < uNumVertices; ++i) |
1907 { | |
1908 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
1909 d3d_vertex_buffer[i].specular = 0; | |
1910 } | |
1911 | |
0 | 1912 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 1913 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
1914 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 1915 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1916 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1917 d3d_vertex_buffer, |
0 | 1918 uNumVertices, |
1919 D3DDP_DONOTLIGHT)); | |
186 | 1920 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 1921 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
1922 v41 = GetLevelFogColor(); | |
1923 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
1924 v6 = 0; | |
1925 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
1926 } | |
186 | 1927 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
1928 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1929 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
1930 } | |
1931 } | |
1932 } | |
1933 } | |
1934 // 4D864C: using guessed type char byte_4D864C; | |
1935 | |
1936 //----- (0049EB79) -------------------------------------------------------- | |
1937 Render::~Render() | |
1938 { | |
1939 Render *v1; // esi@1 | |
1940 | |
1941 v1 = this; | |
1583 | 1942 free(this->pDefaultZBuffer); |
0 | 1943 v1->pD3DBitmaps.Release(); |
1944 v1->pD3DSprites.Release(); | |
1945 Release(); | |
1946 v1->bWindowMode = 1; | |
1947 //nullsub_1(); | |
1948 //nullsub_1(); | |
1949 } | |
1950 | |
1951 | |
1952 //----- (0049E992) -------------------------------------------------------- | |
1953 Render::Render() | |
1954 { | |
2216 | 1955 //Render *v1; // esi@1 |
0 | 1956 int v2; // eax@1 |
1957 char v3; // zf@1 | |
1958 | |
2216 | 1959 //v1 = this; |
0 | 1960 this->pDirectDraw4 = 0; |
1961 this->pFrontBuffer4 = 0; | |
1962 this->pBackBuffer4 = 0; | |
2154 | 1963 //this->pColorKeySurface4 = 0; |
2152 | 1964 //this->pDirectDraw2 = 0; |
1965 //this->pFrontBuffer2 = 0; | |
1966 //this->pBackBuffer2 = 0; | |
1967 //this->pSomeSurface2 = 0; | |
0 | 1968 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); |
1969 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2216 | 1970 this->bWindowMode = 1; |
1971 //this->field_40054 = 0; | |
1972 //this->field_10 = 640; | |
1973 //this->field_14 = 480; | |
1974 //this->field_40030 = 0; | |
1975 //this->field_4002C = 0; | |
1976 this->pActiveZBuffer = 0; | |
1977 this->pDefaultZBuffer = 0; | |
1978 this->raster_clip_y = 0; | |
1979 this->raster_clip_x = 0; | |
1980 this->raster_clip_z = 639; | |
1981 this->raster_clip_w = 479; | |
1982 //this->field_4003C = 0x004EED80; | |
1983 //this->field_40040 = dword_4EED78; | |
1984 this->uClipZ = 640; | |
1985 //this->field_40044 = 2; | |
1986 //this->field_40048 = 6; | |
1987 this->pFrontBuffer4 = 0; | |
1988 this->pBackBuffer4 = 0; | |
1989 //this->pColorKeySurface4 = 0; | |
1990 this->pDirectDraw4 = 0; | |
1991 this->pRenderD3D = 0; | |
1992 this->uNumSceneBegins = 0; | |
1993 this->uNumD3DSceneBegins = 0; | |
1994 this->using_software_screen_buffer = 0; | |
1995 this->pTargetSurface = 0; | |
1996 this->uTargetSurfacePitch = 0; | |
1997 this->uClipY = 0; | |
1998 this->uClipX = 0; | |
1999 this->uClipW = 480; | |
2000 this->bClip = 1; | |
2001 //this->bColorKeySupported = 0; | |
2002 this->bRequiredTextureStagesAvailable = 0; | |
2003 this->bTinting = 1; | |
2004 //LOBYTE(this->field_103668) = 0; | |
0 | 2005 uNumBillboardsToDraw = 0; |
2006 bFogEnabled = false; | |
265 | 2007 |
2008 hd_water_tile_id = -1; | |
2009 hd_water_current_frame = 0; | |
0 | 2010 } |
2011 | |
2069 | 2012 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
0 | 2013 { |
1802 | 2014 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); |
2015 | |
2016 this->window = window; | |
2069 | 2017 //bStartInWindow = true; |
1802 | 2018 //windowed_mode_width = windowed_width; |
2019 //windowed_mode_height = windowed_height; | |
2020 | |
1985 | 2021 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0); |
0 | 2022 |
2023 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
2024 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
2025 | |
2026 this->bTinting = bTinting; | |
2027 | |
1980 | 2028 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); |
2029 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
0 | 2030 |
2031 return r1 && r2; | |
2032 } | |
2033 | |
2034 | |
2035 //----- (0049ECC4) -------------------------------------------------------- | |
2036 void Render::ClearBlack() | |
2037 { | |
2154 | 2038 //if (pRenderD3D) |
0 | 2039 { |
2069 | 2040 if (using_software_screen_buffer) |
0 | 2041 pRenderD3D->ClearTarget(true, 0, false, 0.0); |
2042 } | |
2154 | 2043 //else |
2044 //memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
0 | 2045 } |
2046 | |
2047 //----- (0049ED18) -------------------------------------------------------- | |
2048 void Render::PresentBlackScreen() | |
2049 { | |
2050 IDirectDrawSurface *v2; // eax@3 | |
2051 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
2052 RECT x; // [sp+68h] [bp-10h]@3 | |
2053 | |
2054 memset(&v3, 0, sizeof(DDBLTFX)); | |
1802 | 2055 GetWindowRect(window->GetApiHandle(), &x); |
2152 | 2056 |
0 | 2057 { |
2058 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
2059 } | |
2152 | 2060 |
0 | 2061 v3.dwFillColor = 0; |
2062 v3.dwSize = 100; | |
2063 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
2064 pRenderer->Present(); | |
2065 } | |
2066 | |
2067 //----- (0049EDB6) -------------------------------------------------------- | |
2068 void Render::SavePCXScreenshot() | |
2069 { | |
2070 int v5; // eax@8 | |
2132 | 2071 FILE *pOutFile; // edi@10 |
2133 | 2072 unsigned short *v8; // eax@11 |
0 | 2073 int v9; // eax@13 |
2074 int v10; // ecx@15 | |
2075 signed int v12; // eax@18 | |
2076 HRESULT v14; // eax@29 | |
2077 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
2078 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2079 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2080 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2132 | 2081 char *lineB; // [sp+11Ch] [bp-48h]@14 |
2082 char *lineG; // [sp+120h] [bp-44h]@14 | |
2083 //int v24; // [sp+124h] [bp-40h]@11 | |
0 | 2084 FILE *File; // [sp+128h] [bp-3Ch]@3 |
2085 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2086 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2132 | 2087 char *lineRGB; // [sp+148h] [bp-1Ch]@10 |
2088 void *surface; // [sp+14Ch] [bp-18h]@8 | |
2089 int image_width; // [sp+150h] [bp-14h]@4 | |
2090 int pitch; // [sp+154h] [bp-10h]@4 | |
0 | 2091 char v31; // [sp+15Ah] [bp-Ah]@25 |
2132 | 2092 unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17 |
2093 unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10 | |
2094 byte test_byte; // [sp+163h] [bp-1h]@17 | |
2095 | |
2096 int num_r_bits = 5; | |
2097 int num_g_bits = 6; | |
2098 int num_b_bits = 5; | |
2099 | |
2100 int r_mask = 0xF800; | |
2101 int g_mask = 0x7E0; | |
2102 int b_mask = 0x1F; | |
2103 | |
2069 | 2104 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2105 { |
2132 | 2106 sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100); |
0 | 2107 File = fopen(Filename, "wb"); |
2108 if ( File ) | |
2109 { | |
2154 | 2110 pitch = this->GetRenderWidth(); |
2111 if ( pitch & 1 ) | |
2112 pitch = pitch + 1; | |
2132 | 2113 if ( this->pRenderD3D ) |
2114 { | |
2115 memset(&Dst, 0, 0x7C); | |
0 | 2116 Dst.dwSize = 124; |
168 | 2117 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 2118 return; |
2132 | 2119 surface = Dst.lpSurface; |
2120 v5 = Dst.lPitch / 2; | |
0 | 2121 } |
2122 else | |
2123 { | |
2124 pRenderer->BeginScene(); | |
2132 | 2125 surface = pRenderer->pTargetSurface; |
0 | 2126 v5 = pRenderer->uTargetSurfacePitch; |
2127 } | |
2154 | 2128 header1.right = GetRenderWidth() - 1; |
2132 | 2129 header1.left = 0; |
2154 | 2130 header1.bottom = this->GetRenderHeight() - 1; |
2132 | 2131 header1.up = 0; |
2132 header2.pitch = pitch; | |
0 | 2133 memset(color_map, 0, sizeof(color_map)); |
2134 memset(v15, 0, sizeof(v15)); | |
2135 header2.reserved = 0; | |
2136 header1.manufacturer = 10; | |
2132 | 2137 pOutFile = File; |
0 | 2138 header1.version = 5; |
2139 header1.encoding = 1; | |
2140 header1.bpp = 8; | |
2141 header1.hdpi = 75; | |
2142 header1.vdpi = 75; | |
2143 header2.planes = 3; | |
2144 header2.palette_info = 1; | |
2132 | 2145 fwrite(&header1, 1, 1, File); |
2146 fwrite(&header1.version, 1, 1, pOutFile); | |
2147 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2148 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2149 fwrite(&header1.left, 2, 1, pOutFile); | |
2150 fwrite(&header1.up, 2, 1, pOutFile); | |
2151 fwrite(&header1.right, 2, 1, pOutFile); | |
2152 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2153 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2154 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2155 fwrite(color_map, 0x30u, 1, pOutFile); | |
2156 fwrite(&header2, 1, 1, pOutFile); | |
2157 fwrite(&header2.planes, 1, 1, pOutFile); | |
2158 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2159 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2160 fwrite(v15, 0x3Au, 1, pOutFile); | |
2154 | 2161 lineRGB = (char *)malloc(3 * GetRenderWidth() + 6); |
2162 if ( this->GetRenderHeight() > 0 ) | |
2132 | 2163 { |
2164 image_width = 3 * pitch; | |
2165 //v24 = 2 * v5; | |
2166 v8 = (unsigned short *)surface; | |
2154 | 2167 for ( int y = 0; y < this->GetRenderHeight(); y++ ) |
0 | 2168 { |
2132 | 2169 line_picture_data = v8; |
2154 | 2170 if ( GetRenderWidth() > 0 ) |
0 | 2171 { |
2132 | 2172 lineG = (char *)lineRGB + pitch; |
2173 lineB = (char *)lineRGB + 2 * pitch; | |
2154 | 2174 for ( uint x = 0; x < this->GetRenderWidth(); x++ ) |
0 | 2175 { |
2221 | 2176 //int p = *line_picture_data; //0x2818 |
2177 //int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits );//16 = 8 + 8 | |
2178 //int value = (pRenderer->uTargetRMask & *line_picture_data);//0 = 0xFF0000 & 0x2818 | |
2179 //int result = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits ); | |
2133 | 2180 lineRGB[x] = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits );// + pRenderer->uTargetRBits - 8); |
2181 lineG[x] = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits);// + pRenderer->uTargetGBits - 8); | |
2221 | 2182 //int value2 = (pRenderer->uTargetGMask & *line_picture_data); //10240 = 0xFF00 & 0x2818 |
2183 //int result2 = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits); | |
2133 | 2184 lineB[x] = (pRenderer->uTargetBMask & *line_picture_data);// << (8 - pRenderer->uTargetBBits); |
2221 | 2185 //int value3 = (pRenderer->uTargetBMask & *line_picture_data);//24 = 0xFF & 0x2818 |
2132 | 2186 line_picture_data += 2; |
0 | 2187 } |
2188 } | |
2132 | 2189 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2190 { |
2132 | 2191 pict_byte = lineRGB[i]; |
2192 for ( test_byte = 1; test_byte < 0x3F; ++test_byte ) | |
0 | 2193 { |
2132 | 2194 v12 = i + test_byte; |
2195 if ( lineRGB[v12] != pict_byte ) | |
0 | 2196 break; |
2132 | 2197 if ( !(v12 % pitch) ) |
0 | 2198 break; |
2199 } | |
2132 | 2200 if ( i + test_byte > image_width ) |
2201 test_byte = 3 * pitch - i; | |
2202 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
2203 { | |
2204 v31 = test_byte | 0xC0; | |
2205 fwrite(&v31, 1, 1, pOutFile); | |
2206 } | |
2207 fwrite(&pict_byte, 1, 1, pOutFile); | |
0 | 2208 } |
2132 | 2209 v8 += v5; |
0 | 2210 } |
2211 } | |
2132 | 2212 if ( this->pRenderD3D ) |
0 | 2213 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2214 else | |
2215 pRenderer->EndScene(); | |
2132 | 2216 |
2217 free(lineRGB); | |
2218 fclose(pOutFile); | |
0 | 2219 } |
2220 } | |
2221 } | |
2222 | |
2223 //----- (0049F1BC) -------------------------------------------------------- | |
2069 | 2224 void Render::SaveWinnersCertificate(const char *a1) |
0 | 2225 { |
2226 unsigned int v6; // eax@8 | |
2133 | 2227 //FILE *v7; // edi@10 |
0 | 2228 int v8; // ecx@11 |
2133 | 2229 unsigned short *v9; // eax@11 |
0 | 2230 int v10; // eax@13 |
2231 signed int v13; // eax@18 | |
2232 char v14; // zf@27 | |
2233 HRESULT v15; // eax@29 | |
2133 | 2234 char v16[56]; // [sp+Ch] [bp-12Ch]@10 |
0 | 2235 __int16 v17; // [sp+44h] [bp-F4h]@10 |
2133 | 2236 DDSURFACEDESC2 Dst; // [sp+48h] [bp-F0h]@7 |
0 | 2237 int v19; // [sp+58h] [bp-E0h]@8 |
2238 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
2133 | 2239 char color_map[48]; // [sp+C4h] [bp-74h]@10 |
0 | 2240 unsigned int v22; // [sp+F4h] [bp-44h]@11 |
2133 | 2241 char *lineB; // [sp+F8h] [bp-40h]@14 |
2242 int image_width; // [sp+FCh] [bp-3Ch]@11 | |
0 | 2243 int v25; // [sp+100h] [bp-38h]@4 |
2244 FILE *File; // [sp+104h] [bp-34h]@3 | |
2245 char Str; // [sp+108h] [bp-30h]@10 | |
2246 char v28; // [sp+109h] [bp-2Fh]@10 | |
2247 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
2248 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
2249 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
2250 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
2251 __int16 v33; // [sp+110h] [bp-28h]@10 | |
2252 __int16 v34; // [sp+112h] [bp-26h]@10 | |
2253 __int16 v35; // [sp+114h] [bp-24h]@10 | |
2254 __int16 v36; // [sp+116h] [bp-22h]@10 | |
2255 char v37; // [sp+118h] [bp-20h]@10 | |
2256 char v38; // [sp+119h] [bp-1Fh]@10 | |
2257 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
2258 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
2133 | 2259 char *lineRGB; // [sp+120h] [bp-18h]@10 |
2260 void *surface; // [sp+124h] [bp-14h]@8 | |
2261 int pitch; // [sp+128h] [bp-10h]@4 | |
0 | 2262 char v44; // [sp+12Fh] [bp-9h]@25 |
2133 | 2263 char *lineG; // [sp+130h] [bp-8h]@10 |
2264 unsigned char pict_byte; // [sp+137h] [bp-1h]@17 | |
2265 byte test_byte; | |
2266 | |
2267 int num_r_bits = 5; | |
2268 int num_g_bits = 6; | |
2269 int num_b_bits = 5; | |
2270 | |
2271 int r_mask = 0xF800; | |
2272 int g_mask = 0x7E0; | |
2273 int b_mask = 0x1F; | |
2274 | |
2069 | 2275 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2276 { |
2154 | 2277 static int _4EFA84_num_winners_certificates = 0; |
2278 ++_4EFA84_num_winners_certificates; | |
2279 | |
0 | 2280 File = fopen(a1, "wb"); |
2281 if ( File ) | |
2282 { | |
2154 | 2283 v25 = this->GetRenderWidth(); |
2284 pitch = v25; | |
2285 if ( pitch & 1 ) | |
2286 pitch = pitch + 1; | |
2133 | 2287 if ( this->pRenderD3D ) |
2288 { | |
2289 memset(&Dst, 0, 0x7C); | |
2290 Dst.dwSize = 124; | |
168 | 2291 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 2292 return; |
2133 | 2293 surface = Dst.lpSurface; |
2294 v6 = Dst.lPitch / 2; | |
0 | 2295 } |
2296 else | |
2297 { | |
2298 pRenderer->BeginScene(); | |
2133 | 2299 surface = pRenderer->pTargetSurface; |
0 | 2300 v6 = pRenderer->uTargetSurfacePitch; |
2301 } | |
2154 | 2302 v33 = this->GetRenderWidth() - 1; |
2133 | 2303 v31 = 0; |
2154 | 2304 v34 = (short)this->GetRenderHeight() - 1; |
2133 | 2305 v32 = 0; |
2306 v39 = pitch; | |
2307 memset(&color_map, 0, sizeof(color_map)); | |
2308 memset(&v16, 0, sizeof(v16)); | |
0 | 2309 v37 = 0; |
2310 Str = 10; | |
2311 v17 = 0; | |
2312 v28 = 5; | |
2313 v29 = 1; | |
2314 v30 = 8; | |
2315 v35 = 75; | |
2316 v36 = 75; | |
2317 v38 = 3; | |
2318 v40 = 1; | |
2133 | 2319 fwrite(&Str, 1, 1, File); |
2320 fwrite(&v28, 1, 1, File); | |
2321 fwrite(&v29, 1, 1, File); | |
2322 fwrite(&v30, 1, 1, File); | |
2323 fwrite(&v31, 2, 1, File); | |
2324 fwrite(&v32, 2, 1, File); | |
2325 fwrite(&v33, 2, 1, File); | |
2326 fwrite(&v34, 2, 1, File); | |
2327 fwrite(&v35, 2, 1, File); | |
2328 fwrite(&v36, 2, 1, File); | |
2329 fwrite(&color_map, 0x30, 1, File); | |
2330 fwrite(&v37, 1, 1, File); | |
2331 fwrite(&v38, 1, 1, File); | |
2332 fwrite(&v39, 2, 1, File); | |
2333 fwrite(&v40, 2, 1, File); | |
2334 fwrite(&v16, 0x3A, 1, File); | |
2335 lineRGB = (char *)malloc(3 * (v25 + 2)); | |
2154 | 2336 if ( (signed int)this->GetRenderHeight() > 0 ) |
2133 | 2337 { |
2338 image_width = 3 * pitch; | |
2339 v9 = (unsigned short *)surface; | |
2154 | 2340 for ( uint j = 0; j < this->GetRenderHeight(); j++) |
0 | 2341 { |
2342 a1 = (const char *)v9; | |
2343 if ( v25 > 0 ) | |
2344 { | |
2133 | 2345 lineG = (char *)lineRGB + pitch; |
2346 lineB = (char *)lineRGB + 2 * pitch; | |
2347 for ( v10 = 0; v10 < v25; v10++ ) | |
0 | 2348 { |
2133 | 2349 lineRGB[v10] = (signed int)(r_mask & *(short *)a1) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2350 lineG[v10] = (signed int)(g_mask & *(short *)a1) >> (num_b_bits + num_g_bits - 8); | |
2351 lineB[v10] = (b_mask & *(short *)a1) << (8 - num_b_bits); | |
0 | 2352 a1 += 2; |
2353 } | |
2354 } | |
2133 | 2355 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2356 { |
2133 | 2357 pict_byte = lineRGB[i]; |
2358 for ( test_byte = 1; test_byte < 0x3F; test_byte ) | |
0 | 2359 { |
2133 | 2360 v13 = i + test_byte; |
2361 if ( lineRGB[v13] != pict_byte ) | |
0 | 2362 break; |
2133 | 2363 if ( !(v13 % pitch) ) |
0 | 2364 break; |
2365 } | |
2133 | 2366 if ( i + test_byte > image_width ) |
2367 test_byte = 3 * pitch - i; | |
2368 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
0 | 2369 { |
2133 | 2370 v44 = test_byte | 0xC0; |
2371 fwrite(&v44, 1, 1, File); | |
0 | 2372 } |
2133 | 2373 fwrite(&pict_byte, 1, 1, File); |
0 | 2374 } |
2133 | 2375 v9 += pitch; |
0 | 2376 } |
2377 } | |
2133 | 2378 if ( this->pRenderD3D ) |
0 | 2379 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2380 else | |
2381 pRenderer->EndScene(); | |
2133 | 2382 free(lineRGB); |
2383 fclose(File); | |
0 | 2384 } |
2385 } | |
2386 } | |
2387 | |
2388 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 2389 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
2127 | 2390 { |
0 | 2391 void *v8; // esi@3 |
2392 void *v9; // esi@3 | |
810 | 2393 unsigned short* v11; // eax@4 |
0 | 2394 int v13; // eax@8 |
2395 int v14; // ecx@8 | |
2396 signed int v15; // eax@11 | |
2397 char v16; // zf@20 | |
2398 int result; // eax@21 | |
2399 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
2400 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 2401 char *lineG; // [sp+78h] [bp-40h]@7 |
2402 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 2403 int v23; // [sp+80h] [bp-38h]@4 |
2404 int v24; // [sp+84h] [bp-34h]@4 | |
2405 int v25; // [sp+88h] [bp-30h]@4 | |
2406 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 2407 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
2408 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
2409 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
2410 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 2411 char v43; // [sp+B3h] [bp-5h]@18 |
2412 int i; // [sp+B4h] [bp-4h]@6 | |
2132 | 2413 unsigned short* line_picture_data; |
810 | 2414 byte test_byte; |
2415 unsigned char pict_byte; | |
0 | 2416 |
2131 | 2417 int num_r_bits = 5; |
2418 int num_g_bits = 6; | |
2419 int num_b_bits = 5; | |
2420 | |
2421 int r_mask = 0xF800; | |
2422 int g_mask = 0x7E0; | |
2423 int b_mask = 0x1F; | |
2424 | |
810 | 2425 pitch = wight; |
2426 if ( wight & 1 ) | |
2427 pitch = wight + 1; | |
2428 Src.left = 0; | |
2429 Src.up = 0; | |
2430 Src.right = wight - 1; | |
2431 Src.bottom = heidth - 1; | |
2432 v27.pitch = pitch; | |
0 | 2433 memset(&v20, 0, 0x30u); |
2434 memset(&v18, 0, 0x38u); | |
810 | 2435 v8 = data_buff; |
2436 v27.reserved = 0; | |
0 | 2437 *(_WORD *)&v18[56] = 0; |
810 | 2438 Src.manufacturer = 10; |
2439 Src.version = 5; | |
2440 Src.encoding = 1; | |
2441 Src.bpp = 8; | |
2442 Src.hdpi = 75; | |
2443 Src.vdpi = 75; | |
2444 v27.planes = 3; | |
2445 v27.palette_info = 1; | |
2128 | 2446 memcpy(data_buff, &Src, 1); |
0 | 2447 v8 = (char *)v8 + 1; |
2128 | 2448 memcpy(v8, &Src.version, 1); |
0 | 2449 v8 = (char *)v8 + 1; |
2128 | 2450 memcpy(v8, &Src.encoding, 1); |
0 | 2451 v8 = (char *)v8 + 1; |
2128 | 2452 memcpy(v8, &Src.bpp, 1); |
0 | 2453 v8 = (char *)v8 + 1; |
2128 | 2454 memcpy(v8, &Src.left, 2); |
0 | 2455 v8 = (char *)v8 + 2; |
2128 | 2456 memcpy(v8, &Src.up, 2); |
0 | 2457 v8 = (char *)v8 + 2; |
2128 | 2458 memcpy(v8, &Src.right, 2); |
0 | 2459 v8 = (char *)v8 + 2; |
2128 | 2460 memcpy(v8, &Src.bottom, 2); |
0 | 2461 v8 = (char *)v8 + 2; |
2127 | 2462 memcpy(v8, &Src.hdpi, 2); |
0 | 2463 v8 = (char *)v8 + 2; |
2127 | 2464 memcpy(v8, &Src.vdpi, 2); |
0 | 2465 v8 = (char *)v8 + 2; |
2466 memcpy(v8, &v20, 0x30u); | |
2467 v8 = (char *)v8 + 48; | |
810 | 2468 memcpy(v8, &v27, 1u); |
0 | 2469 v8 = (char *)v8 + 1; |
2127 | 2470 memcpy(v8, &v27.planes, 1); |
0 | 2471 v8 = (char *)v8 + 1; |
2127 | 2472 memcpy(v8, &v27.pitch, 2); |
0 | 2473 v8 = (char *)v8 + 2; |
2127 | 2474 memcpy(v8, &v27.palette_info, 2); |
0 | 2475 v8 = (char *)v8 + 2; |
2476 memcpy(v8, &v18, 0x3Au); | |
2477 v9 = (char *)v8 + 58; | |
810 | 2478 |
1583 | 2479 lineRGB = (char*)malloc(3 * (wight + 2)); |
810 | 2480 if ( heidth > 0 ) |
2481 { | |
2482 v26 = 3 * pitch; | |
2483 v23 = 2 * wight; | |
2484 v11 = picture_data; | |
2485 v24 = (int)picture_data; | |
2127 | 2486 for ( v25 = heidth; v25; v25-- ) |
0 | 2487 { |
2132 | 2488 line_picture_data = v11; |
810 | 2489 if ( wight > 0 ) |
2490 { | |
2491 lineG = (char *)lineRGB + pitch; | |
2492 lineB = (char *)lineRGB + 2 * pitch; | |
2127 | 2493 for ( uint i = 0; i < wight; i++ ) |
0 | 2494 { |
2132 | 2495 lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2496 lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8); | |
2497 lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits); | |
2498 line_picture_data += 1; | |
810 | 2499 } |
0 | 2500 } |
2501 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
2502 { | |
2128 | 2503 pict_byte = lineRGB[i]; |
2127 | 2504 for ( test_byte = 1; test_byte < 63; ++test_byte ) |
0 | 2505 { |
810 | 2506 v15 = i + test_byte; |
2128 | 2507 if ( lineRGB[v15] != pict_byte ) |
0 | 2508 break; |
810 | 2509 if ( !(v15 % pitch) ) |
0 | 2510 break; |
810 | 2511 } |
2512 if ( i + test_byte > v26 ) | |
2513 test_byte = 3 * pitch - i; | |
2127 | 2514 if ( test_byte > 1 || pict_byte >= 192 ) |
810 | 2515 { |
2516 v43 = test_byte | 0xC0; | |
2127 | 2517 memcpy(v9, &v43, 1); |
0 | 2518 v9 = (char *)v9 + 1; |
2519 } | |
2127 | 2520 memcpy(v9, &pict_byte, 1); |
810 | 2521 i += test_byte; |
2522 } | |
2128 | 2523 v11 += wight; |
810 | 2524 } |
2525 } | |
1583 | 2526 free(lineRGB); |
810 | 2527 *(int *)packed_size = (char *)v9 - data_buff; |
0 | 2528 } |
2529 | |
2530 //----- (0049F8B5) -------------------------------------------------------- | |
2155 | 2531 void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) |
0 | 2532 { |
2533 FILE *result; // eax@1 | |
2127 | 2534 FILE *pOutFile; // edi@4 |
2128 | 2535 unsigned short* v9; // eax@5 |
0 | 2536 int v10; // eax@7 |
2537 signed int v12; // eax@12 | |
2538 char v13; // zf@21 | |
2539 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
2540 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
2541 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
2542 int v18; // [sp+74h] [bp-30h]@5 | |
2543 char *v19; // [sp+78h] [bp-2Ch]@5 | |
2127 | 2544 int image_width; // [sp+7Ch] [bp-28h]@5 |
0 | 2545 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 |
2546 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
2128 | 2547 char *lineRGB; // [sp+98h] [bp-Ch]@4 |
2548 int pitch; // [sp+9Ch] [bp-8h]@2 | |
2549 char *lineB; // [sp+A0h] [bp-4h]@8 | |
2550 char *lineG; | |
2551 unsigned short* line_pictute_data; | |
2552 byte test_byte; | |
2553 char v43; | |
2127 | 2554 |
2555 int num_r_bits = 5; | |
2556 int num_g_bits = 6; | |
2557 int num_b_bits = 5; | |
2558 | |
2559 int r_mask = 0xF800; | |
2560 int g_mask = 0x7E0; | |
2561 int b_mask = 0x1F; | |
0 | 2562 |
2563 result = fopen(Filename, "wb"); | |
2564 Filename = (const char *)result; | |
2565 if ( result ) | |
2566 { | |
2128 | 2567 pitch = width; |
2127 | 2568 if ( width & 1 ) |
2128 | 2569 pitch = width + 1; |
0 | 2570 header1.left = 0; |
2571 header1.up = 0; | |
2127 | 2572 header1.right = width - 1; |
2573 header1.bottom = height - 1; | |
2128 | 2574 header2.pitch = pitch; |
0 | 2575 memset(color_map, 0, sizeof(color_map)); |
2576 header2.reserved = 0; | |
2577 memset(v14, 0, sizeof(v14)); | |
2578 v15 = 0; | |
2579 header1.manufacturer = 10; | |
2580 header1.version = 5; | |
2581 header1.encoding = 1; | |
2582 header1.bpp = 8; | |
2583 header1.hdpi = 75; | |
2584 header1.vdpi = 75; | |
2585 header2.planes = 3; | |
2586 header2.palette_info = 1; | |
2127 | 2587 fwrite(&header1, 1, 1, (FILE *)Filename); |
2588 pOutFile = (FILE *)Filename; | |
2589 fwrite(&header1.version, 1, 1, (FILE *)Filename); | |
2590 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2591 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2592 fwrite(&header1.left, 2, 1, pOutFile); | |
2593 fwrite(&header1.up, 2, 1, pOutFile); | |
2594 fwrite(&header1.right, 2, 1, pOutFile); | |
2595 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2596 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2597 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2598 fwrite(color_map, 0x30u, 1, pOutFile); | |
2599 fwrite(&header2, 1, 1, pOutFile); | |
2600 fwrite(&header2.planes, 1, 1, pOutFile); | |
2601 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2602 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2603 fwrite(v14, 0x3Au, 1, pOutFile); | |
2128 | 2604 |
2605 lineRGB = (char *)malloc(3 * (width + 2)); | |
2131 | 2606 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ |
2607 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî. | |
2128 | 2608 image_width = 3 * pitch; |
2609 v9 = picture_data; | |
2127 | 2610 for ( v18 = 0; v18 < height; v18++ )//ñòîëáåö |
2611 { | |
2128 | 2612 line_pictute_data = v9; |
2613 lineG = (char *)lineRGB + pitch; | |
2614 lineB = (char *)lineRGB + 2 * pitch; | |
2615 | |
2616 for ( int i = 0; i < width; i++ )//ñòðîêà | |
2617 { | |
2618 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); | |
2619 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); | |
2620 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); | |
2131 | 2621 line_pictute_data += 1; |
2128 | 2622 } |
2623 test_byte = 1; | |
2131 | 2624 for ( int i = 0; (signed int)i < image_width; i += test_byte ) |
2128 | 2625 { |
2626 unsigned char pic_byte = lineRGB[i]; | |
2627 for ( test_byte; test_byte < 63; ++test_byte )// ðàñ÷¸ò êîëè÷åñòâà îäèíàêîâûõ öâåòîâ | |
0 | 2628 { |
2128 | 2629 v12 = i + test_byte; |
2630 if ( lineRGB[v12] != pic_byte ) | |
2127 | 2631 break; |
2128 | 2632 if ( !(v12 % pitch) ) |
2127 | 2633 break; |
0 | 2634 } |
2128 | 2635 if ( i + test_byte > image_width ) |
2636 test_byte = 3 * pitch - i; | |
2637 if ( test_byte > 1 || pic_byte >= 0xC0 ) | |
0 | 2638 { |
2128 | 2639 v43 = test_byte | 0xC0;//òåñò-áàéò îáúåäèíåíèÿ |
2640 fwrite(&v43, 1, 1, pOutFile); | |
0 | 2641 } |
2128 | 2642 fwrite(&pic_byte, 1, 1, pOutFile); |
2643 } | |
2644 v9 += width; | |
2131 | 2645 } |
2128 | 2646 free(lineRGB); |
2155 | 2647 fclose(pOutFile); |
2648 } | |
0 | 2649 } |
2650 | |
2651 //----- (0049FBCD) -------------------------------------------------------- | |
2652 void Render::ClearTarget(unsigned int uColor) | |
2653 { | |
2154 | 2654 //if (pRenderD3D) |
0 | 2655 { |
2069 | 2656 if (using_software_screen_buffer) |
0 | 2657 pRenderD3D->ClearTarget(true, uColor, false, 0.0); |
2658 } | |
2154 | 2659 //else |
2660 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
0 | 2661 } |
2662 | |
2663 | |
2664 //----- (0049FC37) -------------------------------------------------------- | |
2665 void Render::Present() | |
2666 { | |
2217 | 2667 //struct tagRECT Rect; // [sp+8h] [bp-28h]@11 |
2668 //RECT a4; // [sp+18h] [bp-18h]@11 | |
2669 //struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
2670 | |
2069 | 2671 if ( !pRenderer->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2672 { |
2673 this->pBeforePresentFunction(); | |
2217 | 2674 if ( this->pRenderD3D ) |
2675 { | |
2676 if ( this->using_software_screen_buffer ) | |
0 | 2677 pRenderD3D->Present(false); |
2217 | 2678 } |
2679 else | |
2680 __debugbreak(); // no sr | |
1802 | 2681 /*{ |
2217 | 2682 if ( this->bWindowMode ) |
0 | 2683 { |
2684 RestoreFrontBuffer(); | |
2217 | 2685 GetClientRect(this->hWnd, &Rect); |
0 | 2686 Point.y = 0; |
2687 Point.x = 0; | |
2217 | 2688 ClientToScreen(this->hWnd, &Point); |
0 | 2689 OffsetRect(&Rect, Point.x, Point.y); |
2690 a4.top = 0; | |
2691 a4.bottom = 480; | |
2692 a4.left = 0; | |
2693 a4.right = 640; | |
2694 PresentRect(&Rect, &a4); | |
2695 } | |
2696 else | |
2697 { | |
2698 RestoreFrontBuffer(); | |
2699 a4.top = 0; | |
2700 a4.bottom = 480; | |
2701 a4.left = 0; | |
2702 a4.right = 640; | |
2703 BltBackToFontFast(0, 0, &a4); | |
2704 } | |
1802 | 2705 }*/ |
0 | 2706 } |
2707 } | |
2708 | |
2709 //----- (0049FD3A) -------------------------------------------------------- | |
2154 | 2710 void Render::_49FD3A_fullscreen() |
0 | 2711 { |
2712 Render *v2; // esi@1 | |
2713 IDirectDrawSurface4 *v3; // eax@6 | |
2714 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
2715 RECT v5; // [sp+8h] [bp-10h]@6 | |
2716 | |
1980 | 2717 Render* a1 = this; |
0 | 2718 v2 = a1; |
2719 if ( a1->pRenderD3D ) | |
2720 { | |
2721 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
2722 pFrontBuffer4->Restore(); | |
2723 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
2724 pBackBuffer4->Restore(); | |
2725 v3 = v2->pBackBuffer4; | |
2726 v4 = v2->pFrontBuffer4; | |
2727 v5.top = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2728 v5.bottom = window->GetHeight(); |
0 | 2729 v5.left = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2730 v5.right = window->GetWidth(); |
0 | 2731 v3->BltFast(0, 0, v4, &v5, 16u); |
2732 } | |
2733 } | |
2734 | |
2735 //----- (0049FDBF) -------------------------------------------------------- | |
2736 void Render::CreateZBuffer() | |
2737 { | |
2738 if (!pDefaultZBuffer) | |
2739 { | |
2740 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
1583 | 2741 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); |
871 | 2742 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 2743 } |
2744 } | |
2745 | |
2746 //----- (0049FE05) -------------------------------------------------------- | |
2747 void Render::Release() | |
2748 { | |
2749 Render *v1; // esi@1 | |
1802 | 2750 //RenderD3D *v2; // ecx@1 |
2751 //char v3; // zf@4 | |
2752 //void *v4; // ebx@6 | |
0 | 2753 IDirectDraw *v5; // eax@10 |
2754 IDirectDrawSurface2 *v6; // eax@11 | |
2755 IDirectDrawSurface2 *v7; // eax@13 | |
2756 IDirectDrawSurface2 *v8; // eax@15 | |
2757 IDirectDraw2 *v9; // eax@17 | |
2758 IDirectDraw4 *v10; // eax@19 | |
2759 IDirectDrawSurface4 *v11; // eax@20 | |
2760 IDirectDrawSurface4 *v12; // eax@22 | |
2761 IDirectDrawSurface4 *v13; // eax@24 | |
2762 IDirectDraw4 *v14; // eax@26 | |
2763 unsigned __int16 **v15; // ebx@28 | |
2764 void **v16; // esi@29 | |
2765 | |
2766 v1 = this; | |
1802 | 2767 if (pRenderD3D) |
0 | 2768 { |
2069 | 2769 if ( v1->using_software_screen_buffer ) |
0 | 2770 { |
1802 | 2771 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2772 pRenderD3D->Present(0); |
1802 | 2773 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2774 } |
2154 | 2775 //v1->pColorKeySurface4 = 0; |
0 | 2776 v1->pBackBuffer4 = 0; |
2777 v1->pFrontBuffer4 = 0; | |
2778 v1->pDirectDraw4 = 0; | |
1802 | 2779 if (v1->pTargetSurface) |
0 | 2780 { |
2069 | 2781 delete [] v1->pTargetSurface_unaligned; |
0 | 2782 v1->pTargetSurface = 0; |
2069 | 2783 v1->pTargetSurface_unaligned = 0; |
0 | 2784 } |
1802 | 2785 if (pRenderD3D) |
0 | 2786 { |
2787 pRenderD3D->Release(); | |
1802 | 2788 delete pRenderD3D; |
2789 } | |
2790 pRenderD3D = 0; | |
0 | 2791 } |
2792 else | |
1802 | 2793 ;//__debugbreak(); // no sr |
2794 /*{ | |
0 | 2795 if ( bWinNT4_0 == 1 ) |
2796 { | |
2797 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
2798 if ( !v5 ) | |
2799 return; | |
2800 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
2801 v1->pDirectDraw2->FlipToGDISurface(); | |
2802 v6 = v1->pSomeSurface2; | |
2803 if ( v6 ) | |
2804 { | |
2805 v6->Release(); | |
2806 v1->pSomeSurface2 = 0; | |
2807 } | |
2808 v7 = v1->pBackBuffer2; | |
2809 if ( v7 ) | |
2810 { | |
2811 v7->Release(); | |
2812 v1->pBackBuffer2 = 0; | |
2813 } | |
2814 v8 = v1->pFrontBuffer2; | |
2815 if ( v8 ) | |
2816 { | |
2817 v8->Release(); | |
2818 v1->pFrontBuffer2 = 0; | |
2819 } | |
2820 v9 = v1->pDirectDraw2; | |
2821 if ( v9 ) | |
2822 { | |
2823 v9->Release(); | |
2824 v1->pDirectDraw2 = 0; | |
2825 } | |
2826 } | |
2827 else | |
2828 { | |
2829 v10 = v1->pDirectDraw4; | |
2830 if ( !v10 ) | |
2831 return; | |
2832 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
2833 v1->pDirectDraw4->FlipToGDISurface(); | |
2834 v11 = v1->pColorKeySurface4; | |
2835 if ( v11 ) | |
2836 { | |
2837 v11->Release(); | |
2838 v1->pColorKeySurface4 = 0; | |
2839 } | |
2840 v12 = v1->pBackBuffer4; | |
2841 if ( v12 ) | |
2842 { | |
2843 v12->Release(); | |
2844 v1->pBackBuffer4 = 0; | |
2845 } | |
2846 v13 = v1->pFrontBuffer4; | |
2847 if ( v13 ) | |
2848 { | |
2849 v13->Release(); | |
2850 v1->pFrontBuffer4 = 0; | |
2851 } | |
2852 v14 = v1->pDirectDraw4; | |
2853 if ( v14 ) | |
2854 { | |
2855 v14->Release(); | |
2856 v1->pDirectDraw4 = 0; | |
2857 } | |
2858 } | |
2859 v15 = &v1->pTargetSurface; | |
2860 if ( v1->pTargetSurface ) | |
2861 { | |
2862 v16 = (void **)&v1->ptr_400E8; | |
2863 free(*v16); | |
2864 *v15 = 0; | |
2865 *v16 = 0; | |
2866 } | |
1802 | 2867 }*/ |
0 | 2868 } |
2869 | |
2152 | 2870 |
2871 | |
2872 | |
2873 void Present32(unsigned __int32 *src, unsigned int src_pitch, | |
2874 unsigned __int32 *dst, unsigned int dst_pitch) | |
2875 { | |
2876 for (uint y = 0; y < 8; ++y) | |
2877 memcpy(dst + y * dst_pitch, | |
2878 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2879 | |
2880 for (uint y = 8; y < 352; ++y) | |
2881 { | |
2882 memcpy(dst + y * dst_pitch, | |
2883 src + y * src_pitch, 8 * sizeof(__int32)); | |
2884 memcpy(dst + 8 + game_viewport_width + y * dst_pitch, | |
2885 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32)); | |
2886 } | |
2887 | |
2888 for (uint y = 352; y < 480; ++y) | |
2889 memcpy(dst + y * dst_pitch, | |
2890 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2891 | |
2892 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
2893 { | |
2894 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
2895 { | |
2896 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) | |
2155 | 2897 if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) |
2152 | 2898 dst[x + y * dst_pitch] = src[x + y * src_pitch]; |
2899 } | |
2900 } | |
2901 } | |
2902 | |
2903 //----- (004A597D) -------------------------------------------------------- | |
2904 void Present_NoColorKey() | |
2905 { | |
2906 //unsigned __int16 *v0; // eax@4 | |
2907 unsigned __int16 *v1; // esi@4 | |
2908 void *v2; // edi@4 | |
2909 //signed int v4; // ebx@4 | |
2910 //signed int v5; // ebx@6 | |
2911 //void *v6; // edi@7 | |
2912 //const void *v7; // esi@7 | |
2913 signed int v8; // ebx@8 | |
2914 int v9; // eax@10 | |
2915 unsigned int v10; // esi@10 | |
2916 unsigned __int32 v11; // edi@10 | |
2917 //int v12; // ecx@10 | |
2918 unsigned int v13; // ebx@10 | |
2919 int v14; // eax@11 | |
2920 int v15; // eax@13 | |
2921 int v16; // eax@14 | |
2922 int v17; // eax@16 | |
2923 HRESULT v18; // eax@22 | |
2924 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 | |
2925 //int v20; // [sp+88h] [bp-1Ch]@10 | |
2926 int v21; // [sp+8Ch] [bp-18h]@10 | |
2927 __int32 v22; // [sp+90h] [bp-14h]@10 | |
2928 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10 | |
2929 unsigned int v24; // [sp+98h] [bp-Ch]@4 | |
2930 //unsigned int _this; // [sp+9Ch] [bp-8h]@10 | |
2931 //LPVOID v26; // [sp+A0h] [bp-4h]@4 | |
2932 | |
2933 int r_mask = 0xF800; | |
2934 int g_mask = 0x7E0; | |
2935 int b_mask = 0x1F; | |
2936 | |
2937 if ( !pRenderer->uNumSceneBegins ) | |
2938 { | |
2154 | 2939 //if ( pRenderer->using_software_screen_buffer ) |
2940 //{ | |
2152 | 2941 memset(&Dst, 0, 0x7Cu); |
2942 Dst.dwSize = 124; | |
2943 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
2944 { | |
2945 //v26 = Dst.lpSurface; | |
2946 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; | |
2947 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16); | |
2948 //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; | |
2949 //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; | |
2950 //v1 = pRenderer->pTargetSurface; | |
2951 v2 = Dst.lpSurface; | |
2952 | |
2953 | |
2954 /*for (uint y = 0; y < 480; ++y) | |
2955 { | |
2956 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch); | |
2957 for (uint x = 0; x < 640; ++x) | |
2958 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; | |
2959 }*/ | |
2960 | |
2961 if (!FORCE_16_BITS) | |
2962 Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4); | |
2963 else | |
2964 { | |
2965 ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface; | |
2966 short* pDst = (__int16 *)Dst.lpSurface; | |
2967 | |
2968 for (uint y = 0; y < 8; ++y) | |
2969 memcpy(pDst + y * Dst.lPitch / 2, | |
2970 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2971 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
2152 | 2972 |
2973 for (uint y = 8; y < 352; ++y) | |
2974 { | |
2975 memcpy(pDst + y * Dst.lPitch / 2, | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2976 pSrc + y * window->GetWidth(), 8 * sizeof(__int16)); |
2152 | 2977 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
|
2978 pSrc + 8 + game_viewport_width/*462*/ + y * window->GetWidth(), 174/*172*/ * sizeof(__int16)); |
2152 | 2979 } |
2980 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2981 for (uint y = 352; y < window->GetHeight(); ++y) |
2152 | 2982 memcpy(pDst + y * Dst.lPitch / 2, |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2983 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2984 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2985 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2986 ushort* pSrc_x1y1 = pSrc + window->GetWidth() * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; |
2152 | 2987 //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)]; |
2988 short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; | |
2989 //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY)); | |
2990 v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1); | |
2991 //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1); | |
2992 v22 = 4 * ((Dst.lPitch / 4) + v9); | |
2993 v21 = 4 * v9 + 1280; | |
2994 | |
2995 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1; | |
2996 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1); | |
2997 v10 = (int)pSrc_x1y1; | |
2998 v11 = (int)pDst_x1y1; | |
2999 int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; | |
3000 v13 = v24; | |
3001 | |
3002 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
3003 { | |
3004 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, | |
3005 // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); | |
3006 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
3007 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3008 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
|
3009 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * window->GetWidth() + x]; |
2152 | 3010 } |
3011 } | |
3012 } | |
3013 | |
3014 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3015 | |
3016 /* while ( 1 ) | |
3017 { | |
3018 while ( 1 ) | |
3019 { | |
3020 v14 = *(int *)v10; | |
3021 v10 += 4; | |
3022 if ( v14 == v13 ) | |
3023 break; | |
3024 if ( (short)v14 == (short)v13 ) | |
3025 { | |
3026 *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000; | |
3027 v11 += 4; | |
3028 --uHalfWidth; | |
3029 if ( !uHalfWidth ) | |
3030 goto LABEL_21; | |
3031 } | |
3032 else | |
3033 { | |
3034 v15 = __ROL__(v14, 16); | |
3035 if ( (short)v15 == (short)v13 ) | |
3036 { | |
3037 v17 = __ROR__(v15, 16); | |
3038 *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17; | |
3039 v11 += 4; | |
3040 --uHalfWidth; | |
3041 if ( !uHalfWidth ) | |
3042 goto LABEL_21; | |
3043 } | |
3044 else | |
3045 { | |
3046 v16 = __ROR__(v15, 16); | |
3047 *(int *)v11 = v16; | |
3048 v11 += 4; | |
3049 --uHalfWidth; | |
3050 if ( !uHalfWidth ) | |
3051 goto LABEL_21; | |
3052 } | |
3053 } | |
3054 } | |
3055 v11 += 4; | |
3056 --uHalfWidth; | |
3057 if ( !uHalfWidth ) | |
3058 { | |
3059 LABEL_21: | |
3060 v10 += v21; | |
3061 v11 += v22; | |
3062 uHalfWidth = v20; | |
3063 if ( !--uNumLines ) | |
3064 { | |
3065 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3066 return; | |
3067 } | |
3068 } | |
3069 }*/ | |
3070 } | |
2154 | 3071 //} |
3072 } | |
3073 } | |
3074 | |
0 | 3075 |
3076 //----- (0049FFFB) -------------------------------------------------------- | |
1802 | 3077 bool Render::InitializeFullscreen() |
0 | 3078 { |
3079 //Render *v2; // esi@1 | |
3080 //HWND v3; // ebx@1 | |
3081 //void *v4; // eax@2 | |
3082 //RenderD3D *v5; // eax@3 | |
3083 unsigned int v6; // edx@5 | |
3084 RenderD3D__DevInfo *v7; // ecx@5 | |
3085 bool v8; // eax@6 | |
3086 RenderD3D *v9; // ecx@13 | |
3087 unsigned int v10; // eax@13 | |
3088 RenderD3D *v11; // eax@25 | |
3089 HRESULT v12; // eax@25 | |
3090 int v13; // ecx@25 | |
3091 int v14; // eax@27 | |
3092 signed int v15; // ebx@31 | |
2069 | 3093 //bool v16; // eax@35 |
3094 //char v17; // zf@35 | |
0 | 3095 IDirectDraw4 *v18; // eax@38 |
3096 HRESULT v19; // eax@38 | |
2069 | 3097 //int *v20; // eax@39 |
0 | 3098 int *v22; // eax@42 |
3099 int v23; // ecx@42 | |
3100 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3101 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3102 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
3103 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
3104 void *v28; // [sp+2FCh] [bp-10h]@2 | |
3105 int v29; // [sp+308h] [bp-4h]@2 | |
3106 | |
2069 | 3107 __debugbreak(); // Nomad |
3108 | |
0 | 3109 //v2 = this; |
2069 | 3110 this->using_software_screen_buffer = 0; |
2154 | 3111 //this->pColorKeySurface4 = 0; |
0 | 3112 this->pBackBuffer4 = 0; |
3113 this->pFrontBuffer4 = 0; | |
3114 this->pDirectDraw4 = 0; | |
2069 | 3115 //this->bColorKeySupported = 0; |
0 | 3116 Release(); |
3117 //v3 = hWnd; | |
1802 | 3118 this->window = window; |
0 | 3119 CreateZBuffer(); |
1802 | 3120 |
3121 /*if (!bUserDirect3D) | |
3122 { | |
3123 CreateDirectDraw(); | |
3124 SetDirectDrawCooperationMode(hWnd, 1); | |
3125 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3126 CreateDirectDrawPrimarySurface(); | |
3127 v15 = 1; | |
3128 } | |
3129 else | |
3130 {*/ | |
0 | 3131 pRenderD3D = new RenderD3D; |
3132 v28 = pRenderD3D; | |
3133 v6 = uDesiredDirect3DDevice; | |
3134 v29 = -1; | |
3135 v7 = pRenderD3D->pAvailableDevices; | |
3136 if ( v7[v6].bIsDeviceCompatible ) | |
3137 { | |
2069 | 3138 v8 = pRenderD3D->CreateDevice(v6, /*0*/true, window); |
0 | 3139 } |
3140 else | |
3141 { | |
3142 if ( v7[1].bIsDeviceCompatible ) | |
3143 { | |
2069 | 3144 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window); |
0 | 3145 } |
3146 else | |
3147 { | |
3148 if ( !v7->bIsDeviceCompatible ) | |
1545 | 3149 Error("There aren't any D3D devices to create."); |
3150 | |
2069 | 3151 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window); |
0 | 3152 } |
3153 } | |
3154 if ( !v8 ) | |
1545 | 3155 Error("D3Drend->Init failed."); |
3156 | |
0 | 3157 v9 = pRenderD3D; |
3158 pBackBuffer4 = v9->pBackBuffer; | |
3159 pFrontBuffer4 = v9->pFrontBuffer; | |
3160 pDirectDraw4 = v9->pHost; | |
3161 v10 = pRenderD3D->GetDeviceCaps(); | |
3162 if ( v10 & 1 ) | |
3163 { | |
3164 if ( pRenderD3D ) | |
3165 { | |
3166 pRenderD3D->Release(); | |
3167 delete pRenderD3D; | |
3168 } | |
3169 pRenderD3D = 0; | |
3170 pBackBuffer4 = 0; | |
3171 pFrontBuffer4 = 0; | |
3172 pDirectDraw4 = 0; | |
1545 | 3173 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3174 } |
3175 if ( v10 & 0x3E ) | |
3176 { | |
3177 if ( pRenderD3D ) | |
3178 { | |
3179 pRenderD3D->Release(); | |
3180 delete pRenderD3D; | |
3181 } | |
2154 | 3182 //pColorKeySurface4 = 0; |
0 | 3183 pRenderD3D = 0; |
3184 pBackBuffer4 = 0; | |
3185 pFrontBuffer4 = 0; | |
3186 pDirectDraw4 = 0; | |
1545 | 3187 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3188 } |
3189 if ( (v10 & 0x80u) != 0 ) | |
3190 { | |
3191 if ( pRenderD3D ) | |
3192 { | |
3193 pRenderD3D->Release(); | |
3194 delete pRenderD3D; | |
3195 } | |
3196 pRenderD3D = 0; | |
3197 pBackBuffer4 = 0; | |
3198 pFrontBuffer4 = 0; | |
3199 pDirectDraw4 = 0; | |
1545 | 3200 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3201 } |
2154 | 3202 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; |
0 | 3203 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3204 memset(&halCaps, 0, 0xFCu); | |
3205 halCaps.dwSize = 252; | |
3206 memset(&refCaps, 0, 0xFCu); | |
3207 v11 = pRenderD3D; | |
3208 refCaps.dwSize = 252; | |
3209 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
3210 v13 = halCaps.dwMinTextureWidth; | |
3211 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3212 v13 = halCaps.dwMinTextureHeight; | |
3213 v14 = halCaps.dwMaxTextureWidth; | |
3214 uMinDeviceTextureDim = v13; | |
3215 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
3216 v14 = halCaps.dwMaxTextureHeight; | |
3217 uMaxDeviceTextureDim = v14; | |
3218 if ( (unsigned int)v13 < 4 ) | |
3219 uMinDeviceTextureDim = 4; | |
3220 v15 = 1; | |
3221 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3222 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
2154 | 3223 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2)); |
0 | 3224 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); |
3225 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3226 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
2154 | 3227 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); |
3228 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
3229 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
3230 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3)); | |
3231 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2)); | |
0 | 3232 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); |
2154 | 3233 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2)); |
3234 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
0 | 3235 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); |
2154 | 3236 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4)); |
1802 | 3237 //} |
2069 | 3238 ddpfPrimarySuface.dwSize = 32; |
3239 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3240 ParseTargetPixelFormat(); |
2069 | 3241 |
3242 if (!pRenderD3D) | |
3243 { | |
3244 __debugbreak(); | |
3245 pBeforePresentFunction = 0;//nullsub_1; | |
3246 } | |
3247 //else | |
3248 //{ | |
3249 /*v16 = IsColorKeySupported(pDirectDraw4); | |
0 | 3250 v17 = uAcquiredDirect3DDevice == v15; |
3251 bColorKeySupported = v16; | |
3252 if ( !v17 ) | |
3253 bColorKeySupported = 0; | |
3254 if ( bColorKeySupported ) | |
3255 { | |
3256 memset(&ddsd2, 0, 0x7Cu); | |
3257 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3258 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3259 v18 = pDirectDraw4; | |
3260 ddsd2.dwSize = 124; | |
3261 ddsd2.dwFlags = 65543; | |
3262 ddsd2.ddsCaps.dwCaps = 2112; | |
3263 ddsd2.dwWidth = 640; | |
3264 ddsd2.dwHeight = 480; | |
3265 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3266 pBeforePresentFunction = Present_ColorKey; | |
3267 } | |
2069 | 3268 else*/ |
0 | 3269 { |
3270 pTargetSurface = 0; | |
2069 | 3271 pTargetSurface_unaligned = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3272 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32); |
2069 | 3273 if ( !pTargetSurface_unaligned |
0 | 3274 || (memset(&pDesc, 0, 0x7Cu), |
3275 pDesc.dwSize = 124, | |
3276 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
3277 return 0; | |
3278 pBackBuffer4->Unlock(0); | |
2069 | 3279 v22 = (int *)pTargetSurface_unaligned + 4; |
0 | 3280 v23 = (unsigned int)pDesc.lpSurface & 7; |
3281 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3282 uTargetSurfacePitch = window->GetWidth(); |
0 | 3283 pBeforePresentFunction = Present_NoColorKey; |
3284 v15 = 1; | |
2069 | 3285 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23); |
3286 } | |
3287 using_software_screen_buffer = v15; | |
3288 //} | |
0 | 3289 bWindowMode = 0; |
3290 pParty->uFlags |= 2u; | |
2151 | 3291 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
3292 return v15 != 0; |
0 | 3293 } |
3294 | |
3295 //----- (004A05F3) -------------------------------------------------------- | |
1802 | 3296 bool Render::SwitchToWindow() |
0 | 3297 { |
3298 //Render *v2; // esi@1 | |
3299 //void *v3; // eax@2 | |
3300 //RenderD3D *v4; // eax@3 | |
3301 //unsigned int v5; // edx@5 | |
3302 //RenderD3D__DevInfo *v6; // ecx@5 | |
3303 bool v7; // eax@7 | |
3304 //RenderD3D *v8; // ecx@12 | |
3305 unsigned int v9; // eax@12 | |
3306 RenderD3D *v10; // eax@24 | |
3307 HRESULT v11; // eax@24 | |
3308 int v12; // eax@24 | |
3309 int v13; // eax@26 | |
2069 | 3310 //bool v14; // eax@32 |
3311 //char v15; // zf@32 | |
0 | 3312 IDirectDraw4 *v16; // eax@35 |
3313 HRESULT v17; // eax@35 | |
2069 | 3314 //int *v18; // eax@36 |
0 | 3315 int *v19; // edx@38 |
3316 int v20; // eax@38 | |
3317 unsigned int v21; // ecx@38 | |
3318 int v22; // eax@41 | |
3319 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
3320 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3321 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
3322 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
3323 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
3324 int v29; // [sp+308h] [bp-4h]@2 | |
3325 | |
2069 | 3326 pParty->uFlags |= PARTY_FLAGS_1_0002; |
2151 | 3327 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
2069 | 3328 using_software_screen_buffer = 0; |
0 | 3329 Release(); |
2154 | 3330 //pColorKeySurface4 = 0; |
0 | 3331 pBackBuffer4 = 0; |
3332 pFrontBuffer4 = 0; | |
3333 pDirectDraw4 = 0; | |
2069 | 3334 //bColorKeySupported = 0; |
0 | 3335 CreateZBuffer(); |
1802 | 3336 /*if (!bUserDirect3D) |
3337 { | |
3338 CreateDirectDraw(); | |
3339 SetDirectDrawCooperationMode(hWnd, 0); | |
3340 field_4004C = 1; | |
3341 CreateFrontBuffer(); | |
3342 CreateClipper(hWnd); | |
3343 CreateBackBuffer(); | |
3344 field_40030 = 0; | |
3345 field_18_locked_pitch = 0; | |
3346 } | |
3347 else | |
3348 {*/ | |
1631 | 3349 /*v3 = malloc(0x148u); |
0 | 3350 thisa = (RenderD3D *)v3; |
3351 v29 = 0; | |
3352 if ( v3 ) | |
3353 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3354 else | |
3355 v4 = 0;*/ | |
3356 pRenderD3D = new RenderD3D; | |
3357 //v4 = pRenderD3D; | |
3358 //v5 = uDesiredDirect3DDevice; | |
3359 v29 = -1; | |
3360 //v6 = pRenderD3D->pAvailableDevices; | |
3361 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
3362 uDesiredDirect3DDevice != 1 ) | |
3363 { | |
2069 | 3364 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window); |
0 | 3365 } |
3366 else | |
3367 { | |
3368 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
1545 | 3369 Error("There aren't any D3D devices to init."); |
3370 | |
2069 | 3371 v7 = pRenderD3D->CreateDevice(0, true, window); |
0 | 3372 } |
3373 if ( !v7 ) | |
1545 | 3374 Error("D3Drend->Init failed."); |
0 | 3375 |
3376 //v8 = pRenderD3D; | |
2154 | 3377 //pColorKeySurface4 = 0; |
0 | 3378 pBackBuffer4 = pRenderD3D->pBackBuffer; |
3379 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3380 pDirectDraw4 = pRenderD3D->pHost; | |
3381 v9 = pRenderD3D->GetDeviceCaps(); | |
3382 if ( v9 & 1 ) | |
3383 { | |
3384 if (pRenderD3D) | |
3385 { | |
3386 pRenderD3D->Release(); | |
3387 delete pRenderD3D; | |
3388 } | |
3389 pRenderD3D = 0; | |
3390 pBackBuffer4 = 0; | |
3391 pFrontBuffer4 = 0; | |
3392 pDirectDraw4 = 0; | |
1545 | 3393 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3394 } |
3395 if ( v9 & 0x3E ) | |
3396 { | |
3397 if (pRenderD3D) | |
3398 { | |
3399 pRenderD3D->Release(); | |
3400 delete pRenderD3D; | |
3401 } | |
2154 | 3402 //pColorKeySurface4 = 0; |
0 | 3403 pRenderD3D = 0; |
3404 pBackBuffer4 = 0; | |
3405 pFrontBuffer4 = 0; | |
3406 pDirectDraw4 = 0; | |
1545 | 3407 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3408 } |
2154 | 3409 if (v9 & 0x80) |
0 | 3410 { |
3411 if (pRenderD3D) | |
3412 { | |
3413 pRenderD3D->Release(); | |
3414 delete pRenderD3D; | |
3415 } | |
3416 pRenderD3D = 0; | |
3417 pBackBuffer4 = 0; | |
3418 pFrontBuffer4 = 0; | |
3419 pDirectDraw4 = 0; | |
1545 | 3420 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3421 } |
2154 | 3422 //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; |
0 | 3423 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3424 memset(&halCaps, 0, 0xFCu); | |
3425 halCaps.dwSize = 252; | |
3426 memset(&refCaps, 0, 0xFCu); | |
3427 //v10 = v2->pRenderD3D; | |
3428 refCaps.dwSize = 252; | |
3429 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3430 v12 = halCaps.dwMinTextureWidth; | |
2069 | 3431 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight ) |
0 | 3432 v12 = halCaps.dwMinTextureHeight; |
3433 uMinDeviceTextureDim = v12; | |
3434 v13 = halCaps.dwMaxTextureWidth; | |
3435 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3436 v13 = halCaps.dwMaxTextureHeight; | |
3437 uMaxDeviceTextureDim = v13; | |
3438 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
3439 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
3440 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3441 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
3442 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
3443 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3444 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3445 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3446 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3447 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3448 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3449 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3450 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3451 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3452 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
1802 | 3453 //} |
3454 | |
2069 | 3455 ddpfPrimarySuface.dwSize = 32; |
3456 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3457 ParseTargetPixelFormat(); |
2069 | 3458 |
0 | 3459 if ( !pRenderD3D ) |
3460 { | |
2069 | 3461 __debugbreak(); |
3462 //pBeforePresentFunction = 0;//nullsub_1; | |
3463 //goto LABEL_47; | |
3464 } | |
3465 /*v14 = IsColorKeySupported(pDirectDraw4); | |
0 | 3466 v15 = uAcquiredDirect3DDevice == 1; |
3467 bColorKeySupported = v14; | |
3468 if ( !v15 ) | |
2069 | 3469 bColorKeySupported = 0;*/ |
3470 //if ( bColorKeySupported ) | |
3471 if (false) | |
3472 { | |
3473 /*memset(&ddsd2, 0, 0x7Cu); | |
0 | 3474 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; |
3475 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3476 v16 = pDirectDraw4; | |
3477 ddsd2.dwSize = 124; | |
3478 ddsd2.dwFlags = 65543; | |
3479 ddsd2.ddsCaps.dwCaps = 2112; | |
3480 ddsd2.dwWidth = 640; | |
3481 ddsd2.dwHeight = 480; | |
3482 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
2069 | 3483 pBeforePresentFunction = Present_ColorKey;*/ |
0 | 3484 LABEL_45: |
2069 | 3485 using_software_screen_buffer = 1; |
3486 //LABEL_47: | |
0 | 3487 bWindowMode = 1; |
1802 | 3488 //hWnd = hWnd; |
0 | 3489 return 0; |
3490 } | |
3491 pTargetSurface = 0; | |
2069 | 3492 pTargetSurface_unaligned = 0; |
3493 | |
3494 uint num_pixels = window->GetWidth() * window->GetHeight(); | |
3495 pTargetSurface_unaligned = new unsigned int[num_pixels]; | |
3496 | |
3497 if (!pTargetSurface_unaligned) | |
3498 return false; | |
3499 | |
3500 memset(&pDesc, 0, 0x7Cu); | |
3501 pDesc.dwSize = 124; | |
3502 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT)) | |
3503 { | |
3504 delete [] pTargetSurface_unaligned; | |
3505 return false; | |
3506 } | |
3507 | |
3508 memset32(pTargetSurface_unaligned, -1, num_pixels); | |
3509 | |
3510 | |
0 | 3511 pRenderer->pBackBuffer4->Unlock(0); |
2069 | 3512 /*v19 = pTargetSurface_unaligned; |
0 | 3513 v20 = (unsigned int)pDesc.lpSurface & 7; |
3514 v21 = (unsigned int)ptr_400E8 & 7; | |
3515 if ( v21 == v20 ) | |
3516 { | |
3517 pTargetSurface = (unsigned __int16 *)v19; | |
3518 } | |
3519 else | |
3520 { | |
3521 if ( (signed int)v21 >= v20 ) | |
3522 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
3523 else | |
3524 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
3525 pTargetSurface = (unsigned __int16 *)v22; | |
2069 | 3526 }*/ |
3527 pTargetSurface = pTargetSurface_unaligned; | |
3528 uTargetSurfacePitch = window->GetWidth(); | |
0 | 3529 pBeforePresentFunction = Present_NoColorKey; |
3530 goto LABEL_45; | |
3531 } | |
3532 | |
2154 | 3533 |
3534 //----- (0044F2B2) -------------------------------------------------------- | |
3535 bool Render::IsGammaSupported() | |
3536 { | |
3537 bool result; // eax@3 | |
3538 HRESULT v1; // eax@4 | |
3539 | |
3540 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
3541 { | |
3542 DDCAPS halCaps; // [sp+0h] [bp-180h]@4 | |
3543 memset(&halCaps, 0, sizeof(DDCAPS)); | |
3544 halCaps.dwSize = sizeof(DDCAPS); | |
3545 | |
3546 ErrD3D(pDirectDraw4->GetCaps(&halCaps, 0)); | |
3547 return (halCaps.dwCaps2 >> 17) & 1; | |
3548 } | |
3549 /*else | |
3550 return false;*/ | |
3551 } | |
3552 | |
0 | 3553 //----- (004A0BEE) -------------------------------------------------------- |
2102 | 3554 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) |
3555 { | |
2198 | 3556 signed int lower_bound; // eax@17 |
3557 signed int left_bound; | |
0 | 3558 unsigned int v21; // edi@46 |
3559 int v22; // esi@47 | |
3560 int v23; // ebx@47 | |
3561 signed int v24; // edx@50 | |
3562 signed int v25; // esi@52 | |
3563 unsigned __int16 *v26; // ecx@52 | |
3564 int v27; // ebx@54 | |
3565 int v28; // edi@55 | |
3566 int v29; // edx@55 | |
3567 int v30; // ebx@60 | |
3568 int v31; // edx@61 | |
3569 int v32; // edi@61 | |
3570 __int64 v36; // [sp+14h] [bp-8h]@1 | |
2198 | 3571 signed int upper_bound; // [sp+18h] [bp-4h]@28 |
0 | 3572 unsigned int uXa; // [sp+24h] [bp+8h]@49 |
3573 int uYb; // [sp+28h] [bp+Ch]@47 | |
3574 | |
3575 v36 = 0i64; | |
2101 | 3576 if ( uX < this->raster_clip_x )// x âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2102 | 3577 HIDWORD(v36) = 8; //left_border = true; |
2101 | 3578 if ( uX > this->raster_clip_z )// x âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
2102 | 3579 HIDWORD(v36) |= 4;//right_border = true; |
2097 | 3580 |
2101 | 3581 if ( uZ < this->raster_clip_x )// z âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2102 | 3582 LODWORD(v36) = 8;// |
2101 | 3583 if ( uZ > this->raster_clip_z )// z âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
3584 LODWORD(v36) |= 4; | |
3585 | |
3586 if ( uY < this->raster_clip_y )// y âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
2102 | 3587 HIDWORD(v36) |= 2;//upper_border = true; |
2101 | 3588 if ( uY > this->raster_clip_w )// y âûõîäèò çà ðàìêè íèæíåé ãðàíèöû |
2102 | 3589 HIDWORD(v36) |= 1;//bottom_border = true; |
2101 | 3590 |
3591 if ( uW < this->raster_clip_y )// w âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
3592 LODWORD(v36) |= 2; | |
3593 if ( uW > this->raster_clip_w )// w âûõîäèò çà ðàìêè íèæíåé ãðàíèöû | |
3594 LODWORD(v36) |= 1; | |
3595 | |
2102 | 3596 //LOBYTE(v12) = v36; |
0 | 3597 if ( (unsigned int)v36 & HIDWORD(v36) ) |
2102 | 3598 return; |
3599 | |
2199 | 3600 if ( v36 ) //íå ïîëíîñòüþ â ðàìêàõ |
3601 { | |
3602 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left and right(ëåâàÿ è ïðàâàÿ) | |
3603 { | |
3604 if ( BYTE4(v36) & 8 )//left_border = true; | |
3605 { | |
3606 uY += ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX); | |
3607 uX = this->raster_clip_x; | |
3608 } | |
3609 else | |
3610 { | |
3611 uZ = this->raster_clip_x; | |
3612 uW += ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ); | |
3613 } | |
3614 } | |
3615 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
3616 { | |
3617 if ( BYTE4(v36) & 4 ) //right_border = true | |
3618 { | |
3619 uY += ((uW - uY) * (this->raster_clip_z - uX)) / (uZ - uX); | |
3620 uX = this->raster_clip_z; | |
0 | 3621 } |
3622 else | |
3623 { | |
2199 | 3624 uW += ((uY - uW) * (this->raster_clip_z - uZ)) / (uX - uZ); |
3625 uZ = this->raster_clip_z; | |
3626 } | |
3627 } | |
3628 upper_bound = 0; | |
3629 if ( uY < this->raster_clip_y ) | |
3630 upper_bound = 2; | |
3631 if ( uY > this->raster_clip_w ) | |
3632 upper_bound |= 1; | |
3633 | |
3634 lower_bound = 0; | |
3635 if ( uW < this->raster_clip_y ) | |
3636 lower_bound = 2; | |
3637 if ( uW > this->raster_clip_w ) | |
3638 lower_bound |= 1; | |
3639 | |
3640 if ( !(lower_bound & upper_bound) )//for up and down(äëÿ âåðõà è íèçà) | |
3641 { | |
3642 lower_bound ^= upper_bound; | |
3643 if ( lower_bound & 2 ) | |
3644 { | |
3645 if ( upper_bound & 2 ) | |
3646 { | |
3647 uX += ((uZ - uX) * (this->raster_clip_y - uY)) / (uW - uY); | |
3648 uY = this->raster_clip_y; | |
3649 } | |
3650 else | |
3651 { | |
3652 uZ += (uX - uZ) * (this->raster_clip_y - uW) / (uY - uW); | |
3653 uW = this->raster_clip_y; | |
3654 } | |
3655 } | |
3656 if ( lower_bound & 1 ) | |
3657 { | |
3658 if ( upper_bound & 1 ) | |
3659 { | |
3660 uX += ((uZ - uX) * (this->raster_clip_w - uY)) / (uW - uY); | |
3661 uY = this->raster_clip_w; | |
3662 } | |
3663 else | |
0 | 3664 { |
2199 | 3665 uZ += ((uX - uZ) * (this->raster_clip_w - uW)) / (uY - uW); |
3666 uW = this->raster_clip_w; | |
3667 } | |
3668 } | |
3669 } | |
3670 } | |
3671 v21 = pRenderer->uTargetSurfacePitch; | |
3672 if ( pRenderer->uTargetSurfacePitch ) | |
3673 { | |
3674 //v12 = uX + uY * pRenderer->uTargetSurfacePitch; | |
3675 v22 = uW - uY; | |
3676 v23 = v22; | |
3677 uYb = v22; | |
3678 if ( v22 < 0 ) | |
3679 { | |
3680 v23 = -v22; | |
3681 uYb = -v22; | |
3682 v21 = -pRenderer->uTargetSurfacePitch; | |
3683 } | |
3684 uXa = uZ - uX; | |
3685 if ((signed)(uZ - uX) >= 0) | |
3686 v24 = 1; | |
3687 else | |
3688 { | |
3689 uXa = -uXa; | |
3690 v24 = -1; | |
3691 } | |
3692 v25 = 0; | |
3693 | |
3694 v26 = (unsigned __int16 *)this->pTargetSurface; | |
3695 if ( v26 ) | |
3696 { | |
3697 if ( (signed int)uXa <= v23 )//ðèñóåì âåðòèêàëüíóþ ëèíèþ | |
3698 { | |
3699 v30 = v23 + 1; | |
3700 if ( v30 > 0 ) | |
3701 { | |
3702 v31 = 2 * v24; | |
3703 v32 = 2 * v21; | |
3704 //v12 = (int)&v26[v12]; | |
3705 int y = 0; | |
3706 int x = 0; | |
3707 for ( v30; v30; --v30 ) | |
0 | 3708 { |
2199 | 3709 v25 += uXa; |
3710 //*(short *)v12 = uColor; | |
3711 //v12 += v32; | |
3712 WritePixel16(uX + x, uY + y, uColor); | |
3713 if ( v32 >= 0 ) | |
3714 y += 1; | |
3715 else | |
3716 y -= 1; | |
3717 if ( v25 > 0 ) | |
0 | 3718 { |
2199 | 3719 v25 -= uYb; |
3720 //v12 += v31; | |
3721 if ( v31 >= 0 ) | |
2096 | 3722 x += 1; |
3723 else | |
3724 x -= 1; | |
0 | 3725 } |
3726 } | |
3727 } | |
3728 } | |
2199 | 3729 else//ðèñóåì ãîðèçîíòàëüíóþ ëèíèþ |
3730 { | |
3731 v27 = uXa + 1; | |
3732 if ( (signed int)(uXa + 1) > 0 ) | |
3733 { | |
3734 v28 = 2 * v21; | |
3735 v29 = 2 * v24; | |
3736 int y = 0; | |
3737 int x = 0; | |
3738 //v12 = (int)&v26[v12]; | |
3739 for ( v27; v27; --v27 ) | |
3740 { | |
3741 v25 += uYb; | |
3742 //*(short *)v12 = uColor; | |
3743 //v12 += v29; | |
3744 WritePixel16(uX + x, uY + y, uColor); | |
3745 if ( v29 >= 0 ) | |
3746 x += 1; | |
3747 else | |
3748 x -= 1; | |
3749 if ( v25 > (signed int)uXa ) | |
3750 { | |
3751 v25 -= uXa; | |
3752 //v12 += v28; | |
3753 if ( v28 >= 0 ) | |
3754 y += 1; | |
3755 else | |
3756 y -= 1; | |
3757 } | |
3758 } | |
3759 } | |
3760 } | |
3761 } | |
0 | 3762 } |
2102 | 3763 return; |
0 | 3764 } |
3765 | |
3766 //----- (004A0E80) -------------------------------------------------------- | |
3767 void Render::ClearZBuffer(int a2, int a3) | |
3768 { | |
3769 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
3770 } | |
3771 | |
3772 //----- (004A0E97) -------------------------------------------------------- | |
709 | 3773 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
3774 { | |
3775 this->raster_clip_x = uX; | |
3776 this->raster_clip_y = uY; | |
3777 this->raster_clip_z = uZ; | |
3778 this->raster_clip_w = uW; | |
0 | 3779 } |
3780 | |
3781 //----- (004A0EB6) -------------------------------------------------------- | |
3782 void Render::ParseTargetPixelFormat() | |
3783 { | |
3784 signed int v2; // ecx@1 | |
3785 DWORD uRedMask; // edx@1 | |
3786 unsigned int uGreenMask; // esi@5 | |
3787 signed int v5; // ecx@5 | |
3788 unsigned int uBlueMask; // edx@9 | |
3789 signed int v7; // ecx@9 | |
2069 | 3790 //unsigned int v8; // ecx@13 |
0 | 3791 |
3792 v2 = 0; | |
2132 | 3793 uRedMask = this->ddpfPrimarySuface.dwRBitMask; |
3794 this->uTargetBBits = 0; | |
3795 this->uTargetGBits = 0; | |
3796 this->uTargetRBits = 0; | |
0 | 3797 do |
3798 { | |
3799 if ( (1 << v2) & uRedMask ) | |
2132 | 3800 ++this->uTargetRBits; |
0 | 3801 ++v2; |
3802 } | |
2069 | 3803 while ( v2 < 32 ); |
2132 | 3804 uGreenMask = this->ddpfPrimarySuface.dwGBitMask; |
0 | 3805 v5 = 0; |
3806 do | |
3807 { | |
3808 if ( (1 << v5) & uGreenMask ) | |
2132 | 3809 ++this->uTargetGBits; |
0 | 3810 ++v5; |
3811 } | |
2069 | 3812 while ( v5 < 32 ); |
2132 | 3813 uBlueMask = this->ddpfPrimarySuface.dwBBitMask; |
0 | 3814 v7 = 0; |
3815 do | |
3816 { | |
3817 if ( (1 << v7) & uBlueMask ) | |
2132 | 3818 ++this->uTargetBBits; |
0 | 3819 ++v7; |
3820 } | |
2069 | 3821 while ( v7 < 32 ); |
2132 | 3822 this->uTargetGMask = uGreenMask; |
3823 this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask; | |
3824 this->uTargetBMask = uBlueMask; | |
0 | 3825 } |
3826 | |
3827 //----- (004A0F40) -------------------------------------------------------- | |
3828 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
3829 { | |
2132 | 3830 //IDirectDrawSurface4 *v4; // esi@1 |
168 | 3831 HRESULT result; // eax@1 |
0 | 3832 HRESULT v6; // eax@4 |
3833 int v7; // [sp-8h] [bp-14h]@10 | |
3834 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
3835 char v9; // [sp+Bh] [bp-1h]@1 | |
3836 | |
2132 | 3837 //v4 = pSurface; |
0 | 3838 v9 = 1; |
3839 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
3840 if ( result == DDERR_SURFACELOST ) | |
3841 { | |
2132 | 3842 v6 = pSurface->Restore(); |
0 | 3843 if ( v6 ) |
3844 { | |
3845 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
3846 { | |
3847 LABEL_20: | |
3848 v9 = 0; | |
3849 result = (bool)memset(pDesc, 0, 4u); | |
3850 goto LABEL_21; | |
3851 } | |
3852 pRenderer->pFrontBuffer4->Restore(); | |
2132 | 3853 pSurface->Restore(); |
3854 } | |
3855 result = pSurface->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
0 | 3856 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) |
3857 goto LABEL_20; | |
3858 ErrD3D(result); | |
3859 if ( result ) | |
3860 { | |
3861 //v8 = 0; | |
3862 //v7 = 2161; | |
3863 LABEL_19: | |
3864 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
3865 goto LABEL_20; | |
3866 } | |
3867 if ( pRenderer->pRenderD3D ) | |
3868 pRenderD3D->HandleLostResources(); | |
3869 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
3870 } | |
3871 else | |
3872 { | |
3873 if ( result ) | |
3874 { | |
3875 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3876 goto LABEL_20; | |
3877 ErrD3D(result); | |
3878 //v8 = 0; | |
3879 //v7 = 2199; | |
3880 //goto LABEL_19; | |
3881 } | |
3882 } | |
3883 LABEL_21: | |
3884 LOBYTE(result) = v9; | |
3885 return result; | |
3886 } | |
3887 | |
3888 | |
3889 //----- (004A10E4) -------------------------------------------------------- | |
3890 void Render::CreateDirectDraw() | |
3891 { | |
3892 Render *v1; // edi@1 | |
3893 HRESULT v2; // eax@1 | |
3894 HRESULT v3; // eax@5 | |
3895 int v6; // [sp-Ch] [bp-20h]@3 | |
3896 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
3897 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
3898 | |
3899 v1 = this; | |
3900 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
3901 | |
3902 pDirectDraw4 = nullptr; | |
3903 | |
2152 | 3904 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); |
0 | 3905 |
3906 lpDD->Release(); | |
3907 lpDD = nullptr; | |
3908 } | |
3909 | |
3910 //----- (004A1169) -------------------------------------------------------- | |
3911 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
3912 { | |
3913 DWORD flags; // eax@1 | |
3914 IDirectDraw *v4; // ecx@3 | |
3915 HRESULT v5; // eax@5 | |
3916 int v6; // [sp-8h] [bp-8h]@3 | |
3917 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
3918 | |
3919 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
3920 DDSCL_NORMAL; | |
3921 | |
2152 | 3922 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); |
0 | 3923 } |
3924 | |
3925 //----- (004A11C6) -------------------------------------------------------- | |
3926 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
3927 { | |
2152 | 3928 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); |
0 | 3929 } |
3930 | |
3931 //----- (004A121C) -------------------------------------------------------- | |
3932 void Render::CreateFrontBuffer() | |
3933 { | |
3934 Render *v1; // esi@1 | |
3935 IDirectDraw *pDD; // eax@3 | |
3936 IDirectDrawSurface **pOutSurf; // esi@3 | |
3937 struct _DDSURFACEDESC *v4; // edx@3 | |
3938 HRESULT v5; // eax@5 | |
3939 int v6; // [sp-8h] [bp-8Ch]@3 | |
3940 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
3941 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
3942 | |
3943 v1 = this; | |
2152 | 3944 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
3945 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 3946 { |
3947 memset(&a2, 0, 0x7Cu); | |
3948 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
3949 a2.dwSize = 124; | |
3950 a2.dwFlags = 1; | |
3951 v7 = 0; | |
3952 a2.ddsCaps.dwCaps = 512; | |
3953 v6 = 2357; | |
3954 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
3955 v4 = (struct _DDSURFACEDESC *)&a2; | |
3956 } | |
2152 | 3957 /*else |
0 | 3958 { |
3959 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
3960 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
3961 a2.lPitch = 108; | |
3962 a2.dwBackBufferCount = 1; | |
3963 v7 = 0; | |
3964 a2.dwTextureStage = 512; | |
3965 v6 = 2346; | |
3966 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
3967 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
2152 | 3968 }*/ |
0 | 3969 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); |
3970 } | |
3971 | |
3972 //----- (004A12CD) -------------------------------------------------------- | |
3973 void Render::CreateBackBuffer() | |
3974 { | |
3975 Render *v1; // esi@1 | |
3976 IDirectDraw *v2; // eax@3 | |
3977 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
3978 struct _DDSURFACEDESC *v4; // edx@3 | |
3979 HRESULT v5; // eax@5 | |
3980 int v6; // [sp-8h] [bp-8Ch]@3 | |
3981 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
3982 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
3983 | |
3984 v1 = this; | |
2152 | 3985 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
3986 // pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 3987 { |
3988 memset(&a2, 0, 0x7Cu); | |
3989 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
3990 a2.dwSize = 124; | |
3991 a2.dwFlags = 7; | |
3992 v7 = 0; | |
3993 a2.ddsCaps.dwCaps = 2112; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3994 a2.dwWidth = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3995 a2.dwHeight = window->GetHeight(); |
0 | 3996 v6 = 2387; |
3997 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
3998 v4 = (struct _DDSURFACEDESC *)&a2; | |
3999 } | |
2152 | 4000 /*else |
0 | 4001 { |
4002 memset(&a2.lPitch, 0, 0x6Cu); | |
4003 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4004 a2.lPitch = 108; | |
4005 a2.dwBackBufferCount = 7; | |
4006 v7 = 0; | |
4007 a2.dwTextureStage = 2112; | |
4008 a2.dwAlphaBitDepth = 640; | |
4009 a2.dwMipMapCount = 480; | |
4010 v6 = 2374; | |
4011 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4012 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
2152 | 4013 }*/ |
0 | 4014 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); |
4015 } | |
4016 | |
4017 //----- (004A139A) -------------------------------------------------------- | |
4018 void Render::CreateDirectDrawPrimarySurface() | |
4019 { | |
4020 Render *v1; // esi@1 | |
2154 | 4021 //int v2; // ebx@3 |
0 | 4022 IDirectDraw2 *v3; // eax@3 |
4023 HRESULT v4; // eax@3 | |
4024 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
4025 DDSCAPS2 *v6; // edx@3 | |
4026 IDirectDraw4 *v7; // eax@4 | |
4027 HRESULT v8; // eax@4 | |
4028 int v9; // ST14_4@5 | |
4029 IDirectDrawSurface *v10; // ST10_4@5 | |
4030 HRESULT v11; // eax@5 | |
4031 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
4032 const char *v13; // [sp+0h] [bp-A0h]@0 | |
4033 int v14; // [sp+4h] [bp-9Ch]@0 | |
4034 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
4035 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
4036 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
4037 int a4; // [sp+98h] [bp-8h]@3 | |
4038 | |
4039 v1 = this; | |
2152 | 4040 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4041 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4042 { |
2154 | 4043 //v2 = 0; |
4044 //this->field_4004C = 1; | |
0 | 4045 memset(&ddsd2, 0, 0x7Cu); |
4046 v7 = v1->pDirectDraw4; | |
4047 ddsd2.dwBackBufferCount = 1; | |
4048 ddsd2.dwSize = 0x7Cu; | |
4049 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4050 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4051 ErrD3D(v7->CreateSurface( | |
4052 &ddsd2, | |
4053 &pFrontBuffer4, | |
4054 0)); | |
4055 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
4056 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4057 } | |
2152 | 4058 /*else |
0 | 4059 { |
4060 v2 = 0; | |
4061 this->field_4004C = 1; | |
4062 | |
4063 DDSURFACEDESC ddsd; | |
4064 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4065 | |
4066 ddsd.lpSurface = (LPVOID)1; | |
4067 ddsd.lPitch = 108; | |
4068 ddsd.dwBackBufferCount = 33; | |
4069 ddsd.ddsCaps.dwCaps = 8728; | |
4070 ErrD3D(pDirectDraw2->CreateSurface( | |
4071 &ddsd, | |
4072 (IDirectDrawSurface **)&pFrontBuffer2, | |
4073 0)); | |
4074 | |
4075 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4076 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
2152 | 4077 }*/ |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4078 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used |
0 | 4079 v9 = (int)v6; |
4080 v10 = pFrontBuffer; // BUG | |
4081 | |
4082 v17.dwCaps = 4; | |
4083 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4084 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
2154 | 4085 //v1->field_40030 = v2; |
4086 //v1->field_18_locked_pitch = v2; | |
0 | 4087 } |
4088 | |
4089 //----- (004A14F4) -------------------------------------------------------- | |
4090 void Render::CreateClipper(HWND a2) | |
4091 { | |
2152 | 4092 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); |
4093 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4094 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
0 | 4095 } |
4096 | |
4097 //----- (004A15D8) -------------------------------------------------------- | |
4098 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4099 { | |
2152 | 4100 pFrontBuffer4->GetPixelFormat(pOut); |
0 | 4101 } |
4102 | |
4103 //----- (004A1605) -------------------------------------------------------- | |
4104 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4105 { | |
4106 signed int v4; // eax@3 | |
4107 | |
2152 | 4108 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4109 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4110 { |
4111 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4112 memset(&pDesc, 0, 0x7Cu); | |
4113 pDesc.dwSize = 124; | |
2132 | 4114 LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4115 *pOutSurfacePtr = pDesc.lpSurface; |
4116 v4 = pDesc.lPitch; | |
4117 } | |
2152 | 4118 /*else |
0 | 4119 { |
4120 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4121 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4122 pDesc.lPitch = 108; | |
2132 | 4123 LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1); |
0 | 4124 *pOutSurfacePtr = (void *)pDesc.lpSurface; |
4125 v4 = pDesc.dwReserved; | |
2152 | 4126 }*/ |
0 | 4127 *pOutPixelsPerRow = v4 >> 1; |
4128 } | |
4129 | |
4130 //----- (004A16E1) -------------------------------------------------------- | |
4131 void Render::UnlockBackBuffer() | |
4132 { | |
2152 | 4133 ErrD3D(pBackBuffer4->Unlock(0)); |
0 | 4134 } |
4135 | |
4136 //----- (004A172E) -------------------------------------------------------- | |
4137 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4138 { | |
4139 signed int v4; // eax@3 | |
4140 | |
2152 | 4141 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4142 { |
4143 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4144 memset(&pDesc, 0, 0x7Cu); | |
4145 pDesc.dwSize = 124; | |
2132 | 4146 LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4147 *pOutSurface = pDesc.lpSurface; |
4148 v4 = pDesc.lPitch; | |
4149 } | |
2152 | 4150 /*else |
0 | 4151 { |
4152 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4153 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4154 pDesc.lPitch = 108; | |
2132 | 4155 LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1); |
0 | 4156 *pOutSurface = (void *)pDesc.lpSurface; |
4157 v4 = pDesc.dwReserved; | |
2152 | 4158 }*/ |
0 | 4159 *pOutPixelsPerRow = v4 >> 1; |
4160 } | |
4161 | |
4162 //----- (004A17C7) -------------------------------------------------------- | |
4163 void Render::UnlockFrontBuffer() | |
4164 { | |
2152 | 4165 ErrD3D(pFrontBuffer4->Unlock(0)); |
0 | 4166 } |
4167 | |
4168 //----- (004A1814) -------------------------------------------------------- | |
4169 void Render::RestoreFrontBuffer() | |
4170 { | |
2152 | 4171 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST ) |
4172 pFrontBuffer4->Restore(); | |
0 | 4173 } |
4174 | |
4175 //----- (004A184C) -------------------------------------------------------- | |
2152 | 4176 void Render::RestoreBackBuffer() |
4177 { | |
4178 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST ) | |
4179 pBackBuffer4->Restore(); | |
0 | 4180 } |
4181 | |
4182 //----- (004A18F5) -------------------------------------------------------- | |
4183 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4184 { | |
2152 | 4185 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); |
0 | 4186 } |
4187 | |
4188 //----- (004A194A) -------------------------------------------------------- | |
4189 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
4190 { | |
4191 IDirectDrawSurface *pFront; // eax@3 | |
4192 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
4193 | |
2152 | 4194 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4195 { |
4196 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4197 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4198 } | |
2152 | 4199 /*else |
0 | 4200 { |
4201 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4202 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
2152 | 4203 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4204 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 4205 } |
4206 | |
4207 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4208 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4209 { |
0 | 4210 unsigned int v7; // edx@6 |
2166 | 4211 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4212 if (uNumBillboardsToDraw >= 999 ) |
0 | 4213 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4214 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4215 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4216 uNumBillboardsToDraw = 1; |
0 | 4217 return 0; |
4218 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4219 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4220 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4221 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4222 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4223 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4224 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4225 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4226 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4227 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4228 |
2166 | 4229 if (z > pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4230 { |
4231 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
4232 v7 = pRenderer->uNumBillboardsToDraw; | |
4233 else | |
4234 { | |
4235 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4236 { | |
2166 | 4237 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
0 | 4238 { |
2166 | 4239 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], |
4240 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - (i + 1)], | |
4241 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
0 | 4242 } |
4243 } | |
4244 ++v7; | |
4245 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4246 uNumBillboardsToDraw++; |
0 | 4247 return v7; |
4248 } | |
2166 | 4249 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4250 { |
4251 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4252 { | |
2166 | 4253 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
4254 { | |
4255 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], | |
4256 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw -(i + 1)], | |
4257 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
4258 } | |
4259 } | |
717 | 4260 uNumBillboardsToDraw++; |
4261 return v7; | |
0 | 4262 } |
4263 return v7; | |
4264 } | |
4265 | |
4266 //----- (004A1E9D) -------------------------------------------------------- | |
4267 unsigned int Render::GetBillboardDrawListSize() | |
4268 { | |
4269 return pRenderer->uNumBillboardsToDraw; | |
4270 } | |
4271 | |
4272 //----- (004A1EA3) -------------------------------------------------------- | |
4273 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
4274 { | |
2002 | 4275 return pRenderer->pBillboardRenderListD3D[uBillboardID].sParentBillboardID; |
0 | 4276 } |
4277 | |
4278 //----- (004A1EB6) -------------------------------------------------------- | |
4279 void Render::BeginSceneD3D() | |
4280 { | |
4281 if (!uNumD3DSceneBegins++) | |
4282 { | |
2154 | 4283 //if (pRenderD3D) |
0 | 4284 { |
4285 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
4286 pRenderer->uNumBillboardsToDraw = 0; | |
4287 pRenderD3D->pDevice->BeginScene(); | |
1390 | 4288 |
0 | 4289 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
4290 uFogColor = GetLevelFogColor(); | |
4291 else | |
4292 uFogColor = 0; | |
4293 | |
4294 if ( uFogColor & 0xFF000000 ) | |
4295 { | |
4296 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
4297 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
4298 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4299 bUsingSpecular = true; | |
4300 } | |
4301 else | |
4302 { | |
4303 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
4304 bUsingSpecular = 0; | |
4305 } | |
4306 } | |
2154 | 4307 /*else |
0 | 4308 { |
4309 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
4310 if (pTargetSurface) | |
4311 field_18_locked_pitch = uTargetSurfacePitch; | |
4312 else | |
4313 --uNumD3DSceneBegins; | |
2154 | 4314 }*/ |
0 | 4315 } |
4316 } | |
4317 | |
4318 //----- (004A1FE1) -------------------------------------------------------- | |
4319 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
4320 { | |
4321 --uNumD3DSceneBegins; | |
4322 if (uNumD3DSceneBegins) | |
4323 return; | |
4324 | |
4325 if (pRenderD3D) | |
4326 { | |
4327 pGame->draw_debug_outlines(); | |
161 | 4328 DoRenderBillboards_D3D(); |
0 | 4329 pGame->pStru6Instance->RenderSpecialEffects(); |
4330 pRenderD3D->pDevice->EndScene(); | |
4331 } | |
4332 else | |
4333 pGame->pStru6Instance->RenderSpecialEffects(); | |
4334 } | |
4335 | |
4336 //----- (004A2031) -------------------------------------------------------- | |
349 | 4337 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
4338 { | |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4339 // __debugbreak(); // should not fire outside decal builder |
349 | 4340 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 4341 } |
4342 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4343 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 4344 { |
4345 int v5; // ebx@1 | |
4346 int v6; // edi@1 | |
4347 int v8; // eax@7 | |
4348 float v9; // eax@12 | |
4349 float *v10; // esi@12 | |
4350 float v11; // ecx@14 | |
4351 double v12; // st7@14 | |
4352 double v13; // st7@14 | |
4353 double v14; // st7@14 | |
4354 signed int v15; // eax@14 | |
4355 int v16; // eax@15 | |
4356 float v17; // ST48_4@15 | |
4357 char v18; // zf@17 | |
4358 int v19; // eax@18 | |
4359 int v20; // eax@18 | |
4360 int v21; // edx@20 | |
4361 signed int v22; // ecx@20 | |
4362 int v23; // eax@20 | |
4363 const char *v24; // ST4C_4@20 | |
4364 unsigned int v25; // ST50_4@20 | |
4365 int v26; // ST54_4@20 | |
4366 int v27; // eax@20 | |
4367 _UNKNOWN *v28; // eax@21 | |
4368 int v29; // ecx@23 | |
4369 int v30; // eax@23 | |
4370 int v31; // eax@23 | |
4371 int v32; // eax@24 | |
4372 int v33; // eax@25 | |
4373 int v34; // eax@25 | |
4374 int v35; // eax@25 | |
4375 int v36; // eax@25 | |
4376 signed int v37; // ecx@26 | |
4377 int v38; // eax@26 | |
4378 _UNKNOWN *v39; // eax@27 | |
4379 int v40; // edx@28 | |
4380 int v41; // eax@29 | |
4381 int v42; // eax@29 | |
4382 int v43; // eax@29 | |
4383 int v44; // eax@29 | |
4384 unsigned int v46; // eax@29 | |
4385 int v47; // eax@30 | |
4386 int v48; // eax@30 | |
4387 int v49; // eax@30 | |
4388 double v52; // st6@35 | |
4389 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
4390 int v57; // [sp+5Ch] [bp-Ch]@3 | |
4391 signed int v59; // [sp+60h] [bp-8h]@12 | |
4392 int v61; // [sp+64h] [bp-4h]@4 | |
4393 int i; | |
4394 | |
4395 v6 = (int)this; | |
4396 v5 = 0; | |
4397 if (!this->uNumD3DSceneBegins) | |
4398 return; | |
4399 | |
4400 | |
4401 | |
4402 | |
186 | 4403 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 4404 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
4405 if (this->bUsingSpecular) | |
4406 { | |
186 | 4407 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4408 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4409 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 4410 } |
4411 | |
4412 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
4413 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
1637 | 4414 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4415 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); |
4416 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
4417 pVertices[0].specular = 0; | |
4418 pVertices[0].texcoord.x = array_50AC10[0].u; | |
4419 pVertices[0].texcoord.y = array_50AC10[0].v; | |
4420 | |
4421 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
4422 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
1637 | 4423 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4424 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); |
4425 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
4426 pVertices[1].specular = 0; | |
4427 pVertices[1].texcoord.x = array_50AC10[3].u; | |
4428 pVertices[1].texcoord.y = array_50AC10[3].v; | |
4429 | |
4430 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
4431 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
1637 | 4432 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4433 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); |
4434 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
4435 pVertices[2].specular = 0; | |
4436 pVertices[2].texcoord.x = array_50AC10[1].u; | |
4437 pVertices[2].texcoord.y = array_50AC10[1].v; | |
4438 | |
4439 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
4440 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
4441 | |
4442 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
4443 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
1637 | 4444 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4445 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); |
4446 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
4447 pVertices[5].specular = 0; | |
4448 pVertices[5].texcoord.x = array_50AC10[2].u; | |
4449 pVertices[5].texcoord.y = array_50AC10[2].v; | |
4450 | |
4451 | |
4452 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4453 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
4454 | |
186 | 4455 }*/ |
4456 | |
0 | 4457 //----- (004A26BC) -------------------------------------------------------- |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4458 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
186 | 4459 { |
4460 //RenderVertexSoft *pVertices; // esi@0 | |
4461 //int v7; // edi@1 | |
0 | 4462 unsigned int v8; // ebx@1 |
4463 LightmapBuilder *v9; // esi@3 | |
4464 unsigned int v10; // edx@3 | |
4465 int v11; // eax@5 | |
4466 int v12; // eax@11 | |
4467 char *v13; // esi@11 | |
4468 double v14; // st7@13 | |
4469 double v15; // st7@13 | |
4470 signed int v16; // eax@13 | |
4471 int v17; // ecx@13 | |
4472 double v18; // st7@13 | |
4473 float v19; // ST78_4@14 | |
4474 int v20; // eax@14 | |
4475 char v21; // zf@16 | |
4476 HRESULT v22; // eax@17 | |
4477 HRESULT v23; // eax@17 | |
4478 HRESULT v24; // eax@19 | |
4479 HRESULT v25; // eax@19 | |
4480 unsigned int v26; // ecx@19 | |
4481 char *v27; // eax@20 | |
4482 HRESULT v28; // eax@22 | |
4483 HRESULT v29; // eax@22 | |
4484 HRESULT v30; // eax@23 | |
4485 HRESULT v31; // eax@24 | |
4486 HRESULT v32; // eax@24 | |
4487 HRESULT v33; // eax@24 | |
4488 HRESULT v34; // eax@24 | |
4489 HRESULT v35; // eax@25 | |
4490 HRESULT v36; // eax@25 | |
4491 unsigned int v37; // ecx@25 | |
4492 char *v38; // eax@26 | |
4493 int v39; // edx@27 | |
4494 HRESULT v40; // eax@28 | |
4495 HRESULT v41; // eax@28 | |
4496 HRESULT v42; // eax@28 | |
4497 HRESULT v43; // eax@28 | |
4498 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
4499 unsigned int v45; // eax@28 | |
4500 HRESULT v46; // eax@29 | |
4501 HRESULT v47; // eax@29 | |
4502 HRESULT v48; // eax@29 | |
186 | 4503 //IDirect3DDevice3 *v49; // eax@35 |
0 | 4504 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
4505 int v51; // eax@40 | |
4506 char *v52; // esi@40 | |
4507 double v53; // st7@42 | |
4508 double v54; // st7@42 | |
4509 signed int v55; // eax@42 | |
4510 int v56; // ecx@42 | |
4511 double v57; // st7@42 | |
4512 float v58; // ST7C_4@43 | |
4513 int v59; // eax@43 | |
186 | 4514 //signed int v60; // [sp+78h] [bp-14h]@31 |
4515 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 4516 const char *v62; // [sp+80h] [bp-Ch]@0 |
4517 const char *v63; // [sp+80h] [bp-Ch]@19 | |
4518 int v64; // [sp+84h] [bp-8h]@0 | |
4519 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
4520 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
4521 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 4522 int a7; |
4523 | |
4524 //v7 = (int)this; | |
0 | 4525 v8 = 0; |
186 | 4526 if (!this->uNumD3DSceneBegins) |
75 | 4527 return; |
4528 if ( uNumVertices < 3) | |
4529 return; | |
4530 | |
186 | 4531 //v61 = pVertices; |
4532 | |
75 | 4533 /* v9 = pGame->pLightmapBuilder; |
0 | 4534 v65 = v9; |
75 | 4535 v10 = v9->std__vector_000004_size;*/ |
2155 | 4536 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 4537 { |
638 | 4538 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 4539 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); |
0 | 4540 } |
4541 else | |
4542 { | |
186 | 4543 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 4544 byte_4D864C && pGame->uFlags & 2 ) |
4545 { | |
186 | 4546 if (clampAtTextureBorders) |
4547 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 4548 else |
186 | 4549 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
4550 | |
4551 if (transparent || this->bUsingSpecular) | |
4552 { | |
4553 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4554 if (transparent) | |
0 | 4555 { |
186 | 4556 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
4557 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
4558 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
4559 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 4560 } |
4561 else | |
4562 { | |
186 | 4563 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
4564 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 4565 } |
186 | 4566 } |
1073 | 4567 |
4568 for (uint i = 0; i < uNumVertices; ++i) | |
4569 { | |
4570 | |
4571 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4572 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4573 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4574 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4575 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4576 if ( this->bUsingSpecular ) | |
0 | 4577 { |
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
|
4578 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4579 } |
1073 | 4580 else |
4581 { | |
4582 d3d_vertex_buffer[i].specular = 0; | |
4583 } | |
4584 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4585 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4586 } | |
4587 | |
4588 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4589 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
186 | 4590 if (transparent) |
4591 { | |
4592 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
4593 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4594 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4595 } |
4596 } | |
4597 else | |
4598 { | |
1073 | 4599 for (uint i = 0; i < uNumVertices; ++i) |
4600 { | |
4601 | |
4602 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4603 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4604 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4605 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4606 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4607 if ( this->bUsingSpecular ) | |
0 | 4608 { |
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
|
4609 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4610 } |
1073 | 4611 else |
4612 { | |
4613 d3d_vertex_buffer[i].specular = 0; | |
4614 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4615 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
1073 | 4616 d3d_vertex_buffer[i].specular = v20; |
4617 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4618 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4619 } | |
186 | 4620 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4621 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4622 if (pRenderer->bUsingSpecular) | |
4623 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 4624 |
4625 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 4626 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 4627 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4628 d3d_vertex_buffer, |
0 | 4629 uNumVertices, |
4630 16)); | |
4631 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 4632 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 4633 //(*(void (**)(void))(*(int *)v63 + 88))(); |
1394 | 4634 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
1073 | 4635 for (uint i = 0; i < uNumVertices; ++i) |
4636 { | |
4637 d3d_vertex_buffer[i].diffuse = -1; | |
4638 } | |
0 | 4639 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 4640 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4641 if ( !pRenderer->bUsingSpecular ) |
4642 { | |
186 | 4643 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4644 } | |
4645 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4646 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4647 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
4648 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4649 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4650 d3d_vertex_buffer, |
0 | 4651 uNumVertices, |
4652 16)); | |
4653 if ( pRenderer->bUsingSpecular ) | |
4654 { | |
186 | 4655 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4656 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 4657 for (uint i = 0; i < uNumVertices; ++i) |
4658 { | |
4659 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4660 d3d_vertex_buffer[i].specular = 0; | |
4661 } | |
4662 | |
75 | 4663 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 4664 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4665 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
4666 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4667 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4668 d3d_vertex_buffer, |
0 | 4669 uNumVertices, |
4670 16)); | |
186 | 4671 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4672 //v44 = pRenderer->pRenderD3D->pDevice; |
4673 v45 = GetLevelFogColor(); | |
4674 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
4675 v8 = 0; | |
4676 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
4677 } | |
186 | 4678 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4679 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4680 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
4681 } | |
4682 } | |
186 | 4683 |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
4684 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
1642 | 4685 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
|
4686 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 4687 } |
4688 // 4A26BC: could not find valid save-restore pair for esi | |
4689 // 4D864C: using guessed type char byte_4D864C; | |
4690 | |
4691 //----- (004A2DA3) -------------------------------------------------------- | |
1923 | 4692 void Render::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
852 | 4693 { |
67 | 4694 int v7; // eax@7 |
4695 | |
4696 if ( !this->uNumD3DSceneBegins ) | |
4697 return; | |
4698 if ( uNumVertices >= 3 ) | |
4699 { | |
186 | 4700 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 4701 if ( this->bUsingSpecular ) |
4702 { | |
186 | 4703 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4704 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4705 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 4706 } |
1427 | 4707 for ( uint i = 0; i < uNumVertices; ++i ) |
67 | 4708 { |
4709 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4710 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4711 pVertices[i].pos.z = 0.99989998; | |
168 | 4712 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 4713 |
840 | 4714 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 4715 v7 = 0; |
4716 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
|
4717 v7 = sub_47C3D7_get_fog_specular(0, 1, array_50AC10[i].vWorldViewPosition.x); |
67 | 4718 pVertices[i].specular = v7; |
4719 pVertices[i].texcoord.x = array_50AC10[i].u; | |
4720 pVertices[i].texcoord.y = array_50AC10[i].v; | |
4721 } | |
4722 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4723 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 4724 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 4725 } |
4726 } | |
4727 | |
4728 //----- (004A2ED5) -------------------------------------------------------- | |
1923 | 4729 void Render::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
0 | 4730 { |
4731 int v5; // eax@3 | |
4732 | |
4733 if ( this->uNumD3DSceneBegins ) | |
4734 { | |
1923 | 4735 if ( uNumVertices >= 3 ) |
0 | 4736 { |
186 | 4737 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1923 | 4738 v5 = 31 - (pSkyPolygon->dimming_level & 0x1F); |
638 | 4739 if ( v5 < pOutdoor->max_terrain_dimming_level ) |
4740 v5 = pOutdoor->max_terrain_dimming_level; | |
1937 | 4741 for (uint i = 0; i < uNumVertices; ++i) |
4742 { | |
4743 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
4744 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
1999 | 4745 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); |
1937 | 4746 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; |
4747 d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); | |
4748 d3d_vertex_buffer[i].specular = 0; | |
4749 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
4750 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
4751 } | |
1923 | 4752 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
1936 | 4753 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
4754 d3d_vertex_buffer, uNumVertices, 28)); | |
0 | 4755 } |
4756 } | |
4757 } | |
4758 | |
1390 | 4759 //----- (00479A53) -------------------------------------------------------- |
1923 | 4760 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID) |
1390 | 4761 { |
4762 BLVFace *pFace; // esi@1 | |
4763 double v5; // st7@3 | |
4764 signed __int64 v6; // qax@3 | |
4765 int v12; // edx@7 | |
4766 int v13; // eax@7 | |
4767 void *v15; // ecx@9 | |
4768 int v17; // edi@9 | |
4769 double v18; // st7@9 | |
4770 signed int v19; // ebx@9 | |
4771 void *v20; // ecx@9 | |
4772 int v21; // ebx@11 | |
4773 int v22; // eax@14 | |
4774 signed __int64 v23; // qtt@16 | |
4775 double v24; // st7@16 | |
4776 unsigned __int8 v25; // sf@16 | |
4777 unsigned __int8 v26; // of@16 | |
4778 double v28; // st7@20 | |
4779 char *v29; // ebx@20 | |
4780 char *v30; // edx@20 | |
4781 unsigned __int8 v31; // c0@21 | |
4782 unsigned __int8 v32; // c3@21 | |
4783 double v33; // st6@23 | |
4784 char *v34; // esi@30 | |
4785 const void *v35; // ecx@31 | |
4786 int v36; // eax@31 | |
4787 const void *v37; // edi@31 | |
4788 signed __int64 v38; // qax@31 | |
4789 int v39; // ecx@31 | |
4790 int v40; // ebx@33 | |
4791 int v41; // eax@36 | |
4792 signed __int64 v42; // qtt@39 | |
4793 int v43; // eax@39 | |
4794 char v44; // zf@39 | |
4795 double v45; // st7@39 | |
4796 double v46; // st7@39 | |
4797 unsigned int v47; // edx@40 | |
4798 double v48; // st7@41 | |
4799 RenderVertexSoft *v49; // ebx@41 | |
4800 void *v50; // edi@43 | |
4801 double v51; // st7@46 | |
4802 RenderVertexSoft *v52; // edx@46 | |
4803 void *v53; // edi@48 | |
4804 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
|
4805 struct Polygon *v60; // [sp+0h] [bp-174h]@17 |
1390 | 4806 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 |
1981 | 4807 struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6 |
1390 | 4808 unsigned int v63; // [sp+120h] [bp-54h]@7 |
4809 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
4810 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4811 //float v67; // [sp+130h] [bp-44h]@7 |
1390 | 4812 __int64 v69; // [sp+13Ch] [bp-38h]@3 |
4813 int v70; // [sp+144h] [bp-30h]@3 | |
4814 int X; // [sp+148h] [bp-2Ch]@9 | |
4815 int v72; // [sp+14Ch] [bp-28h]@7 | |
4816 float v73; // [sp+150h] [bp-24h]@16 | |
4817 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
1999 | 4818 unsigned int v74_; // [sp+154h] [bp-20h]@3 |
1390 | 4819 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 |
4820 float v76; // [sp+15Ch] [bp-18h]@9 | |
4821 int v77; // [sp+160h] [bp-14h]@9 | |
4822 int v78; // [sp+164h] [bp-10h]@7 | |
4823 void *v79; // [sp+168h] [bp-Ch]@9 | |
4824 float v80; // [sp+16Ch] [bp-8h]@3 | |
4825 const void *v81; // [sp+170h] [bp-4h]@7 | |
4826 | |
4827 pFace = &pIndoor->pFaces[uFaceID]; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4828 //for floor and wall(for example Selesta)------------------- |
1644 | 4829 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor) |
4830 { | |
4831 int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x; | |
4832 int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y; | |
4833 for (uint i = 0; i < uNumVertices; ++i) | |
4834 { | |
4835 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f; | |
4836 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f; | |
4837 } | |
4838 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0); | |
1390 | 4839 return; |
4840 } | |
1981 | 4841 //--------------------------------------- |
4842 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179 | |
1641 | 4843 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) |
1390 | 4844 * 65536.0) |
1922 | 4845 + (double)pBLVRenderParams->uViewportCenterY); |
1981 | 4846 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0 |
4847 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183 | |
1641 | 4848 - (double)pBLVRenderParams->fov_rad_fixpoint |
1644 | 4849 / ((cos(v5) * 16192.0 + 0.0000001) |
1390 | 4850 * 65535.0) |
1922 | 4851 * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); |
1644 | 4852 |
1999 | 4853 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); |
1981 | 4854 pSkyPolygon.Create_48607B(&stru_8019C8); |
4855 pSkyPolygon.uTileBitmapID = pFace->uBitmapID; | |
4856 | |
4857 pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID); | |
4858 if ( !pSkyPolygon.pTexture ) | |
1390 | 4859 return; |
1644 | 4860 |
1981 | 4861 pSkyPolygon.dimming_level = 0; |
4862 pSkyPolygon.uNumVertices = uNumVertices; | |
4863 | |
4864 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4865 pSkyPolygon.v_18.y = 0; | |
4866 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4867 | |
1644 | 4868 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices])); |
1981 | 4869 pSkyPolygon.field_24 = 0x2000000; |
1644 | 4870 |
4871 extern float _calc_fov(int viewport_width, int angle_degree); | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4872 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4873 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); |
1644 | 4874 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74); |
1981 | 4875 v12 = pSkyPolygon.pTexture->uWidthMinus1; |
4876 v13 = pSkyPolygon.pTexture->uHeightMinus1; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4877 //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth; |
1390 | 4878 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; |
4879 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
4880 v78 = 0; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4881 //v81 = 0; |
1981 | 4882 float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight; |
4883 if ( (signed int)pSkyPolygon.uNumVertices <= 0 ) | |
4884 return; | |
1644 | 4885 |
4886 int _507D30_idx = 0; | |
1999 | 4887 for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ ) |
1390 | 4888 { |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4889 //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)); |
2207 | 4890 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1981 | 4891 v74 = v77 + pSkyPolygon.ptr_38->angle_from_north; |
4892 | |
2207 | 4893 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1999 | 4894 v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east; |
1981 | 4895 |
2207 | 4896 v79 = (void *)(fixpoint_mul(pSkyPolygon.v_18.z, v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))); |
1644 | 4897 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX); |
4898 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0; | |
1981 | 4899 v19 = -pSkyPolygon.field_24; |
4900 v77 = -pSkyPolygon.field_24; | |
4901 X = (int)((char *)v79 + pSkyPolygon.v_18.x); | |
1390 | 4902 LODWORD(v76) = (signed __int64)v18; |
4903 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
4904 while ( 1 ) | |
4905 { | |
4906 v79 = v20; | |
4907 if ( !X ) | |
4908 goto LABEL_14; | |
4909 v21 = abs(v19 >> 14); | |
1999 | 4910 if ( v21 <= abs(X) )//0x800 <= 0x28652 |
1390 | 4911 break; |
4912 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
4913 break; | |
4914 v19 = v77; | |
4915 v20 = v79; | |
4916 LABEL_14: | |
2207 | 4917 v79 = (void *)fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); |
4918 v22 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); | |
1390 | 4919 --LODWORD(v76); |
4920 v20 = (char *)v20 + v72; | |
1981 | 4921 X = v22 + pSkyPolygon.v_18.x; |
1390 | 4922 v78 = 1; |
4923 } | |
4924 if ( !v78 ) | |
4925 { | |
4926 LODWORD(v23) = v77 << 16; | |
1981 | 4927 HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000 |
1997 | 4928 v79 = (void *)(v23 / X);//X = FFFF9014(-28652) |
1390 | 4929 v77 = v17; |
2207 | 4930 signed __int64 s = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v17);// s = 0xFFFFFFFF FFFF3EE6 |
4931 LODWORD(v80) = v66 + ((signed int)fixpoint_mul(SLODWORD(s), v23 / X) >> 4); | |
1981 | 4932 array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); |
4933 | |
2207 | 4934 signed __int64 s2 = v74_ + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v17); |
4935 LODWORD(v80) = v63 + ((signed int)fixpoint_mul(SLODWORD(s2), v23 / X) >> 4); | |
1981 | 4936 array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68; |
4937 | |
2207 | 4938 v77 = fixpoint_mul(SLODWORD(s), v23 / X); |
4939 LODWORD(v73) = fixpoint_mul(SLODWORD(s2), v23 / X); | |
1644 | 4940 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4941 |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4942 //if ( (int)v81 >= pSkyPolygon.uNumVertices ) |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4943 //{ |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4944 // pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4945 // pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4946 // return; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4947 //} |
1390 | 4948 continue; |
4949 } | |
4950 break; | |
4951 } | |
1999 | 4952 if ( _507D30_idx >= pSkyPolygon.uNumVertices ) |
4953 { | |
4954 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, | |
4955 pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
4956 return; | |
4957 } | |
1390 | 4958 LODWORD(v73) = 0; |
4959 v80 = v76; | |
1981 | 4960 if ( (signed int)pSkyPolygon.uNumVertices > 0 ) |
1390 | 4961 { |
4962 v28 = (double)SLODWORD(v76); | |
4963 LODWORD(v76) = (int)(char *)array_50AC10 + 28; | |
1997 | 4964 uint i = 0; |
4965 for ( v78 = pSkyPolygon.uNumVertices; v78; --v78 ) | |
4966 { | |
1390 | 4967 ++LODWORD(v73); |
1997 | 4968 memcpy(&array_50AC10[i], &array_507D30[i], 0x30u); |
1390 | 4969 LODWORD(v76) += 48; |
1997 | 4970 if ( v28 < array_507D30[i].vWorldViewProjY | v28 == array_507D30[i].vWorldViewProjY |
4971 || v28 >= array_507D30[i + 1].vWorldViewProjY ) | |
4972 { | |
4973 if ( v28 >= array_507D30[i].vWorldViewProjY || v28 <= array_507D30[i + 1].vWorldViewProjY ) | |
4974 { | |
4975 i++; | |
4976 continue; | |
4977 } | |
4978 v33 = (array_507D30[i + 1].vWorldViewProjX - array_507D30[i].vWorldViewProjX) * v28 / (array_507D30[i + 1].vWorldViewProjY - array_507D30[i].vWorldViewProjY) | |
4979 + array_507D30[i + 1].vWorldViewProjX; | |
1390 | 4980 } |
4981 else | |
4982 { | |
1997 | 4983 v33 = (array_507D30[i].vWorldViewProjX - array_507D30[i + 1].vWorldViewProjX) * v28 / (array_507D30[i].vWorldViewProjY - array_507D30[i + 1].vWorldViewProjY) |
4984 + array_507D30[i].vWorldViewProjX; | |
4985 } | |
4986 array_50AC10[i + 1].vWorldViewProjX = v33; | |
1390 | 4987 ++LODWORD(v73); |
4988 *(unsigned int *)LODWORD(v76) = v28; | |
4989 LODWORD(v76) += 48; | |
1997 | 4990 i++; |
4991 } | |
1390 | 4992 } |
4993 if ( SLODWORD(v73) <= 0 ) | |
4994 goto LABEL_40; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4995 //v34 = (char *)&array_50AC10[0].vWorldViewProjY; |
1997 | 4996 uint j = 0; |
1390 | 4997 v65 = v77 >> 14; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4998 //HIDWORD(v69) = LODWORD(v73); |
1997 | 4999 for ( int t = (int)LODWORD(v73); t > 1; t-- ) |
5000 { | |
5001 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjY)); | |
5002 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5003 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east; |
2207 | 5004 //v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v35); |
5005 v36 = (int)(fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, (int)v35) + pSkyPolygon.ptr_38->angle_from_north); | |
1997 | 5006 |
1390 | 5007 v81 = v35; |
5008 v74 = v36; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5009 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south; |
2207 | 5010 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, (int)v35); |
1390 | 5011 v78 = (int)v35; |
1981 | 5012 v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east); |
2207 | 5013 //v81 = (const void *)pSkyPolygon.v_18.z; |
5014 v78 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v35); | |
5015 v37 = (const void *)(v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX)); | |
1997 | 5016 v38 = (signed __int64)(array_50AC10[j].vWorldViewProjY - 1.0); |
1390 | 5017 v81 = 0; |
5018 LODWORD(v76) = v38; | |
5019 v39 = v72 * (v70 - v38); | |
5020 while ( 1 ) | |
5021 { | |
5022 v78 = v39; | |
5023 if ( !X ) | |
5024 goto LABEL_36; | |
5025 v40 = abs(X); | |
5026 if ( abs((signed __int64)v65) <= v40 ) | |
5027 break; | |
5028 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5029 break; | |
5030 v39 = v78; | |
5031 LABEL_36: | |
1981 | 5032 v78 = pSkyPolygon.v_18.z; |
2207 | 5033 v41 = fixpoint_mul(pSkyPolygon.v_18.z, v39); |
1390 | 5034 --LODWORD(v76); |
5035 v39 += v72; | |
1981 | 5036 X = v41 + pSkyPolygon.v_18.x; |
1390 | 5037 v81 = (const void *)1; |
5038 } | |
5039 if ( v81 ) | |
5040 { | |
1981 | 5041 v79 = (void *)pSkyPolygon.v_18.z; |
1390 | 5042 v78 = 2 * LODWORD(v76); |
2207 | 5043 v81 = (const void *)fixpoint_mul(pSkyPolygon.v_18.z, (((double)v70 - ((double)(2 * LODWORD(v76)) - array_50AC10[j].vWorldViewProjY)) |
5044 * (double)v72)); | |
1981 | 5045 X = (int)((char *)v81 + pSkyPolygon.v_18.x); |
1390 | 5046 } |
5047 LODWORD(v42) = v77 << 16; | |
5048 HIDWORD(v42) = v77 >> 16; | |
5049 v79 = (void *)(v42 / X); | |
5050 v81 = v37; | |
1997 | 5051 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5052 //v78 = pSkyPolygon.ptr_38->angle_from_west; |
2207 | 5053 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); |
5054 v43 = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); | |
1390 | 5055 v74 = (unsigned int)v37; |
5056 LODWORD(v76) = v43; | |
1997 | 5057 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5058 //v78 = pSkyPolygon.ptr_38->angle_from_south; |
2207 | 5059 v75 = (RenderVertexSoft *)((char *)v75 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, (int)v37)); |
5060 //v74 = fixpoint_mul(v43, v42 / X); | |
5061 v81 = (const void *)fixpoint_mul((int)v75, v42 / X); | |
1997 | 5062 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5063 //v34 += 48; |
2207 | 5064 //v78 = v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4); |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5065 //v44 = HIDWORD(v69)-- == 1; |
2207 | 5066 //v45 = (double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022; |
5067 //v78 = v63 + ((signed int)fixpoint_mul((int)v75, v42 / X) >> 4); | |
5068 array_50AC10[j].u = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); | |
5069 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
|
5070 //v46 = (double)(signed int)v79; |
1997 | 5071 array_50AC10[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79; |
5072 array_50AC10[j]._rhw = 65536.0 / (double)(signed int)v79; | |
5073 ++j; | |
5074 } | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5075 //while ( !v44 ); |
1390 | 5076 LABEL_40: |
1997 | 5077 uint i = 0; |
1390 | 5078 if ( SLODWORD(v73) > 0 ) |
5079 { | |
5080 v48 = (double)SLODWORD(v80); | |
1997 | 5081 for ( HIDWORD(v69) = LODWORD(v73); HIDWORD(v69); --HIDWORD(v69) ) |
5082 { | |
5083 if ( v48 >= array_50AC10[i].vWorldViewProjY ) | |
5084 { | |
5085 ++i; | |
5086 memcpy(&array_507D30[i], &array_50AC10[i], 0x30u); | |
5087 } | |
5088 } | |
5089 } | |
5090 pSkyPolygon.uNumVertices = i; | |
5091 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5092 int pNumVertices = 0; | |
1390 | 5093 if ( SLODWORD(v73) > 0 ) |
5094 { | |
5095 v51 = (double)SLODWORD(v80); | |
1997 | 5096 for ( v80 = v73; v80 != 0.0; --LODWORD(v80) ) |
5097 { | |
5098 if ( v51 <= array_50AC10[pNumVertices].vWorldViewProjY ) | |
5099 { | |
5100 ++pNumVertices; | |
5101 memcpy(&array_507D30[pNumVertices], &array_50AC10[pNumVertices], 0x30u); | |
5102 } | |
5103 } | |
5104 } | |
5105 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
1390 | 5106 } |
5107 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5108 |
0 | 5109 //----- (004A2FC0) -------------------------------------------------------- |
5110 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
5111 { | |
5112 //Render *v8; // edi@1 | |
5113 //unsigned int v9; // esi@3 | |
1072 | 5114 RenderVertexSoft *v12; // ecx@9 |
5115 RenderVertexD3D3 *v13; // eax@9 | |
0 | 5116 double v14; // st6@10 |
5117 int v15; // edx@10 | |
5118 Texture *v16; // edx@10 | |
5119 double v17; // st6@10 | |
5120 //char v18; // zf@10 | |
5121 Texture *v19; // edx@10 | |
595 | 5122 //Texture *v23; // edx@16 |
5123 //char *v24; // ecx@16 | |
5124 //char *v25; // eax@16 | |
5125 //double v26; // st6@17 | |
5126 //int v27; // esi@17 | |
5127 //double v28; // st6@17 | |
5128 //unsigned int v33; // ecx@18 | |
5129 //char *v34; // eax@19 | |
0 | 5130 //Texture *v45; // edx@23 |
5131 //char *v46; // ecx@23 | |
5132 //char *v47; // eax@23 | |
5133 //double v48; // st6@24 | |
5134 //int v49; // esi@24 | |
5135 //double v50; // st6@24 | |
5136 const char *v53; // [sp-Ch] [bp-20h]@21 | |
5137 //int v54; // [sp-8h] [bp-1Ch]@21 | |
5138 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
5139 const char *v56; // [sp+0h] [bp-14h]@0 | |
5140 int v57; // [sp+4h] [bp-10h]@0 | |
5141 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
5142 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
5143 //int a3a; // [sp+10h] [bp-4h]@4 | |
5144 | |
5145 //v8 = this; | |
5146 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
5147 return; | |
5148 | |
5149 //auto a3 = pFace; | |
5150 //auto a6 = uPackedID; | |
5151 //v59 = pGame->pLightmapBuilder; | |
5152 //v9 = v59->std__vector_000004_size; | |
5153 | |
2006 | 5154 int sCorrectedColor = uColor; |
0 | 5155 if (pGame->pLightmapBuilder->std__vector_000004_size) |
2006 | 5156 sCorrectedColor = -1; |
5157 pGame->AlterGamma_BLV(pFace, &sCorrectedColor); | |
0 | 5158 |
792 | 5159 |
5160 if (pFace->uAttributes & FACE_OUTLINED) | |
5161 { | |
5162 int color; | |
5163 if (GetTickCount() % 300 >= 150) | |
2006 | 5164 uColor = sCorrectedColor = 0xFF20FF20; |
5165 else uColor = sCorrectedColor = 0xFF109010; | |
792 | 5166 } |
5167 | |
2155 | 5168 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 5169 { |
5170 __debugbreak(); | |
5171 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 5172 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 5173 for (uint i = 0; i < uNumVertices; ++i) |
5174 { | |
5175 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5176 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5177 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5178 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5179 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
1072 | 5180 d3d_vertex_buffer[i].specular = 0; |
5181 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5182 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5183 } | |
5184 | |
186 | 5185 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5186 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
5187 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
5188 D3DPT_TRIANGLEFAN, | |
5189 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5190 d3d_vertex_buffer, |
0 | 5191 uNumVertices, |
5192 28)); | |
1394 | 5193 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
0 | 5194 } |
5195 else | |
5196 { | |
5197 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
5198 byte_4D864C && pGame->uFlags & 2) | |
5199 { | |
5200 for (uint i = 0; i < uNumVertices; ++i) | |
5201 { | |
186 | 5202 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
5203 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5204 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5205 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5206 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
186 | 5207 d3d_vertex_buffer[i].specular = 0; |
5208 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5209 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5210 } | |
5211 | |
5212 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 5213 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
5214 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5215 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5216 d3d_vertex_buffer, |
0 | 5217 uNumVertices, |
5218 28)); | |
5219 } | |
5220 else | |
5221 { | |
595 | 5222 for (uint i = 0; i < uNumVertices; ++i) |
5223 { | |
5224 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5225 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5226 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5227 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5228 d3d_vertex_buffer[i].diffuse = uColor; | |
5229 d3d_vertex_buffer[i].specular = 0; | |
5230 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5231 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5232 } | |
5233 //__debugbreak(); | |
5234 //if ( (signed int)uNumVertices > 0 ) | |
5235 //{ | |
5236 //v23 = pTex; | |
5237 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
5238 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
5239 //pTex = (Texture *)uNumVertices; | |
5240 //uint v18; | |
5241 //do | |
5242 //{ | |
5243 //v26 = *(float *)v24 * 0.061758894; | |
5244 //v27 = *((int *)v24 + 3); | |
5245 //*((int *)v25 + 4) = 0; | |
5246 //*((int *)v25 - 1) = v27; | |
5247 //*(int *)v25 = *((int *)v24 + 4); | |
5248 //*((int *)v25 + 3) = uColor; | |
5249 //v25 += 32; | |
5250 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
5251 //v28 = 1.0 / *(float *)v24; | |
5252 //v24 += 48; | |
5253 //v18 = pTex == (Texture *)1; | |
5254 //pTex = (Texture *)((char *)pTex - 1); | |
5255 //*((float *)v25 - 6) = v28; | |
0 | 5256 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 5257 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 5258 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 5259 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
5260 //} | |
5261 //while ( !v18 ); | |
5262 //} | |
0 | 5263 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 5264 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5265 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 5266 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5267 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5268 d3d_vertex_buffer, |
0 | 5269 uNumVertices, |
5270 28)); | |
595 | 5271 |
5272 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1394 | 5273 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
595 | 5274 |
5275 for (uint i = 0; i < uNumVertices; ++i) | |
2006 | 5276 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
595 | 5277 /*v33 = uNumVertices; |
0 | 5278 if ( (signed int)uNumVertices > 0 ) |
5279 { | |
186 | 5280 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 5281 do |
5282 { | |
5283 *(int *)v34 = uCorrectedColor; | |
5284 v34 += 32; | |
5285 --v33; | |
5286 } | |
5287 while ( v33 ); | |
595 | 5288 }*/ |
0 | 5289 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5290 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
5291 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5292 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5293 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5294 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
5295 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 5296 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5297 d3d_vertex_buffer, |
0 | 5298 uNumVertices, |
5299 28)); | |
186 | 5300 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
5301 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5302 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 5303 } |
5304 } | |
5305 } | |
5306 // 4D864C: using guessed type char byte_4D864C; | |
5307 | |
5308 //----- (004A43B1) -------------------------------------------------------- | |
717 | 5309 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
5310 { | |
5311 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
5312 //double v5; // st7@2 | |
5313 //float v6; // ST08_4@2 | |
0 | 5314 unsigned int v7; // eax@2 |
717 | 5315 //int v8; // ecx@2 |
5316 //unsigned int v9; // esi@2 | |
5317 //Sprite *v10; // edi@5 | |
0 | 5318 signed int v11; // eax@9 |
5319 signed int v12; // eax@9 | |
717 | 5320 //double v13; // st7@12 |
5321 //double v14; // st6@12 | |
0 | 5322 double v15; // st5@12 |
5323 double v16; // st4@12 | |
5324 double v17; // st3@12 | |
5325 double v18; // st2@12 | |
5326 int v19; // ecx@14 | |
5327 double v20; // st3@14 | |
5328 int v21; // ecx@16 | |
5329 double v22; // st3@16 | |
717 | 5330 //IDirect3DTexture2 *v23; // eax@18 |
5331 //signed int v24; // [sp+18h] [bp-18h]@5 | |
5332 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
5333 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 5334 float v27; // [sp+24h] [bp-Ch]@5 |
5335 int v28; // [sp+28h] [bp-8h]@2 | |
5336 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 5337 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 5338 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 5339 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 5340 float a1; // [sp+40h] [bp+10h]@5 |
5341 | |
717 | 5342 //v26 = this; |
0 | 5343 if ( this->uNumD3DSceneBegins ) |
5344 { | |
717 | 5345 //v4 = pSoftBillboard; |
5346 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
5347 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
5348 //v6 = pSoftBillboard->zbuffer_depth; | |
5349 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
5350 //v8 = dimming_level; | |
5351 //v9 = v7; | |
657 | 5352 v28 = dimming_level & 0xFF000000; |
5353 if ( dimming_level & 0xFF000000 ) | |
2155 | 5354 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3; |
0 | 5355 else |
2155 | 5356 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent; |
717 | 5357 //v10 = a3; |
5358 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
5359 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
2002 | 5360 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID; |
717 | 5361 //v25 = pSoftBillboard->uScreenSpaceX; |
5362 //v24 = pSoftBillboard->uScreenSpaceY; | |
5363 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
5364 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
5365 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5366 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
5367 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5368 v31 = v31 * -1.0; |
2006 | 5369 if ( pSoftBillboard->sTintColor && this->bTinting ) |
717 | 5370 { |
5371 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
2006 | 5372 v12 = BlendColors(pSoftBillboard->sTintColor, v11); |
0 | 5373 if ( v28 ) |
5374 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
5375 } | |
5376 else | |
5377 { | |
717 | 5378 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
5379 } | |
5380 //v13 = (double)v25; | |
1390 | 5381 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; |
5382 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
5383 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
717 | 5384 //v14 = (double)v24; |
5385 //v32 = v14; | |
1390 | 5386 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; |
717 | 5387 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); |
1390 | 5388 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; |
717 | 5389 v16 = 1.0 / pSoftBillboard->zbuffer_depth; |
1390 | 5390 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; |
5391 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
5392 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
717 | 5393 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); |
5394 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
5395 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5396 v17 = v17 * -1.0; |
1390 | 5397 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; |
5398 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
5399 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
5400 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
5401 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
5402 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
5403 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
5404 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
717 | 5405 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; |
5406 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5407 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5408 v20 = v20 * -1.0; |
1390 | 5409 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; |
5410 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
5411 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
5412 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
5413 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
5414 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
5415 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
5416 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
717 | 5417 v21 = pSprite->uBufferHeight - pSprite->uAreaY; |
5418 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5419 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5420 v22 = v22 * -1.0; |
1390 | 5421 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; |
5422 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
5423 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
5424 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
5425 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
5426 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
5427 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
5428 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
717 | 5429 //v23 = pSprite->pTexture; |
5430 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
5431 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
5432 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 5433 } |
5434 } | |
5435 | |
5436 //----- (004A354F) -------------------------------------------------------- | |
5437 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5438 { | |
743 | 5439 //double v5; // st7@3 |
5440 //float v6; // ST20_4@3 | |
5441 //float v7; // ST00_4@3 | |
0 | 5442 unsigned int v8; // esi@3 |
743 | 5443 //int v9; // eax@3 |
5444 //int v10; // ebx@3 | |
0 | 5445 float v11; // ST28_4@3 |
743 | 5446 //double v12; // st7@3 |
5447 //float v13; // ST24_4@3 | |
5448 //double v14; // st6@3 | |
5449 //float v15; // ST1C_4@3 | |
0 | 5450 float v16; // ST2C_4@3 |
5451 float v17; // ST30_4@3 | |
5452 signed int v18; // ST18_4@3 | |
5453 signed int v19; // ST14_4@3 | |
5454 signed int v20; // ST10_4@3 | |
5455 signed int v21; // eax@3 | |
5456 double v22; // st6@3 | |
5457 float v23; // ST2C_4@3 | |
5458 float v24; // ST30_4@3 | |
5459 signed int v25; // ST10_4@3 | |
5460 signed int v26; // ST14_4@3 | |
5461 signed int v27; // ST18_4@3 | |
5462 signed int v28; // eax@3 | |
5463 double v29; // st6@3 | |
5464 float v30; // ecx@3 | |
5465 float v31; // ST2C_4@3 | |
5466 float v32; // ST30_4@3 | |
5467 signed int v33; // ST10_4@3 | |
5468 signed int v34; // ST14_4@3 | |
5469 signed int v35; // ST18_4@3 | |
5470 signed int v36; // eax@3 | |
5471 float v37; // ecx@3 | |
5472 double v38; // st6@3 | |
5473 float v39; // ST2C_4@3 | |
5474 float v40; // ST30_4@3 | |
5475 signed int v41; // ST10_4@3 | |
5476 signed int v42; // ST14_4@3 | |
5477 signed int v43; // ST18_4@3 | |
5478 signed int v44; // eax@3 | |
5479 double v45; // st6@3 | |
5480 float v46; // eax@3 | |
5481 | |
5482 if ( this->uNumD3DSceneBegins ) | |
5483 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5484 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5485 { |
743 | 5486 //v5 = (double)a2->zbuffer_depth; |
5487 //v6 = v5; | |
5488 //v7 = v5; | |
5489 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
2155 | 5490 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5491 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5492 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5493 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
743 | 5494 //v9 = a2->uScreenSpaceX; |
5495 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5496 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 5497 //v12 = (double) a2->uScreenSpaceX; |
5498 //v13 = v12; | |
5499 //v14 = (double)(a2->uScreenSpaceY - 12); | |
5500 //v15 = v14; | |
5501 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5502 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5503 v18 = stru_5C6E00->Cos(angle); |
5504 v19 = stru_5C6E00->Sin(angle); | |
5505 v20 = stru_5C6E00->Sin(angle); | |
5506 v21 = stru_5C6E00->Cos(angle); | |
1390 | 5507 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5508 + (double)(v18 >> 16)) |
5509 * v16 | |
5510 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
5511 + (double)(v19 >> 16)) | |
5512 * v17) | |
743 | 5513 * v11 + (double) a2->uScreenSpaceX; |
0 | 5514 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
5515 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
5516 - 12.0) | |
5517 * v11 | |
5518 + (double)a2->uScreenSpaceY; | |
1390 | 5519 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5520 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5521 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
5522 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
5523 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5524 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5525 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
743 | 5526 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5527 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5528 v25 = stru_5C6E00->Cos(angle); |
5529 v26 = stru_5C6E00->Sin(angle); | |
5530 v27 = stru_5C6E00->Sin(angle); | |
5531 v28 = stru_5C6E00->Cos(angle); | |
1390 | 5532 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
0 | 5533 + (double)(v25 >> 16)) |
740 | 5534 * v31 |
0 | 5535 - ((double)(unsigned __int16)v26 * 0.000015259022 |
5536 + (double)(v26 >> 16)) | |
740 | 5537 * v32) |
743 | 5538 * v11 + (double) a2->uScreenSpaceX; |
740 | 5539 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
5540 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 5541 - 12.0) |
5542 * v11 | |
5543 + (double)a2->uScreenSpaceY; | |
1390 | 5544 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5545 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5546 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
5547 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5548 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
5549 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5550 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5551 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
743 | 5552 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
5553 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5554 v33 = stru_5C6E00->Cos(angle); |
5555 v34 = stru_5C6E00->Sin(angle); | |
5556 v35 = stru_5C6E00->Sin(angle); | |
5557 v36 = stru_5C6E00->Cos(angle); | |
1390 | 5558 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
0 | 5559 + (double)(v33 >> 16)) |
740 | 5560 * v23 |
0 | 5561 - ((double)(unsigned __int16)v34 * 0.000015259022 |
5562 + (double)(v34 >> 16)) | |
740 | 5563 * v24) |
743 | 5564 * v11 + (double) a2->uScreenSpaceX; |
1390 | 5565 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
740 | 5566 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
5567 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 5568 - 12.0) |
5569 * v11 | |
5570 + (double)a2->uScreenSpaceY; | |
1390 | 5571 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5572 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
5573 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5574 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5575 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
5576 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5577 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
743 | 5578 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5579 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5580 v41 = stru_5C6E00->Cos(angle); |
5581 v42 = stru_5C6E00->Sin(angle); | |
5582 v43 = stru_5C6E00->Sin(angle); | |
5583 v44 = stru_5C6E00->Cos(angle); | |
1390 | 5584 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
0 | 5585 + (double)(v41 >> 16)) |
5586 * v39 | |
5587 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
5588 + (double)(v42 >> 16)) | |
5589 * v40) | |
743 | 5590 * v11 + (double) a2->uScreenSpaceX; |
0 | 5591 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
5592 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
5593 - 12.0) | |
5594 * v11 | |
5595 + (double)a2->uScreenSpaceY; | |
1390 | 5596 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5597 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5598 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
5599 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5600 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5601 pBillboardRenderListD3D[v8].pTexture = a3; |
743 | 5602 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 5603 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5604 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; |
5605 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5606 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5607 } |
5608 } | |
5609 } | |
5610 | |
5611 //----- (004A3AD9) -------------------------------------------------------- | |
5612 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5613 { | |
5614 double v5; // st7@2 | |
5615 float v6; // ST28_4@2 | |
5616 float v7; // ST00_4@2 | |
5617 unsigned int v8; // esi@2 | |
5618 int v9; // eax@2 | |
5619 int v10; // ebx@2 | |
5620 float v11; // ST34_4@2 | |
5621 double v12; // st7@2 | |
5622 float v13; // ST2C_4@2 | |
5623 double v14; // st6@2 | |
5624 float v15; // ST24_4@2 | |
5625 float v16; // ST38_4@2 | |
5626 float v17; // ST3C_4@2 | |
5627 signed int v18; // ST1C_4@2 | |
5628 int v19; // ST30_4@2 | |
5629 signed int v20; // ST20_4@2 | |
5630 signed int v21; // ST18_4@2 | |
5631 signed int v22; // eax@2 | |
5632 double v23; // st6@2 | |
5633 float v24; // ST20_4@2 | |
5634 float v25; // ST1C_4@2 | |
5635 float v26; // ST38_4@2 | |
5636 float v27; // ST3C_4@2 | |
5637 signed int v28; // ST18_4@2 | |
5638 signed int v29; // ST14_4@2 | |
5639 signed int v30; // ST10_4@2 | |
5640 signed int v31; // eax@2 | |
5641 double v32; // st6@2 | |
5642 float v33; // ST38_4@2 | |
5643 float v34; // ST3C_4@2 | |
5644 signed int v35; // ST10_4@2 | |
5645 signed int v36; // ST14_4@2 | |
5646 signed int v37; // ST18_4@2 | |
5647 signed int v38; // eax@2 | |
5648 double v39; // st6@2 | |
5649 float v40; // ST38_4@2 | |
5650 float v41; // ST3C_4@2 | |
5651 signed int v42; // ST10_4@2 | |
5652 signed int v43; // ST14_4@2 | |
5653 signed int v44; // ST18_4@2 | |
5654 signed int v45; // eax@2 | |
5655 double v46; // st6@2 | |
5656 | |
5657 if ( this->uNumD3DSceneBegins ) | |
5658 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5659 v5 = (double)a2->zbuffer_depth; |
0 | 5660 v6 = v5; |
5661 v7 = v5; | |
5662 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
2155 | 5663 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5664 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5665 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5666 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
0 | 5667 v9 = a2->uScreenSpaceX; |
5668 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5669 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 5670 v12 = (double)v9; |
5671 v13 = v12; | |
5672 v14 = (double)(v10 - 12); | |
5673 v15 = v14; | |
5674 v16 = (double)(v9 - 12) - v12; | |
5675 v17 = (double)(v10 - 25) - v14; | |
323 | 5676 v18 = stru_5C6E00->Cos(angle); |
0 | 5677 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 5678 v20 = stru_5C6E00->Sin(angle); |
5679 v21 = stru_5C6E00->Sin(angle); | |
5680 v22 = stru_5C6E00->Cos(angle); | |
1390 | 5681 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5682 + (double)(v18 >> 16)) |
5683 * v16 | |
5684 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
5685 + (double)(v20 >> 16)) | |
5686 * v17) | |
5687 * v11 + v13; | |
5688 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
5689 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
5690 - 12.0) | |
5691 * v11 | |
5692 + (double)a2->uScreenSpaceY; | |
1390 | 5693 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5694 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5695 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
1637 | 5696 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5697 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; |
0 | 5698 v25 = 1.0 / v6; |
1390 | 5699 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; |
5700 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5701 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
0 | 5702 v26 = (double)(a2->uScreenSpaceX - 12) - v13; |
5703 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 5704 v28 = stru_5C6E00->Cos(angle); |
5705 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5706 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5707 v31 = stru_5C6E00->Cos(angle); | |
1390 | 5708 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
0 | 5709 + (double)(v28 >> 16)) |
5710 * v26 | |
5711 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
5712 + (double)(v29 >> 16)) | |
5713 * v27) | |
5714 * v11 + v13; | |
5715 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
5716 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
5717 - 12.0) | |
5718 * v11 | |
5719 + (double)a2->uScreenSpaceY; | |
1390 | 5720 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; |
5721 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
5722 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5723 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
5724 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5725 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5726 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
0 | 5727 v33 = (double)(a2->uScreenSpaceX + 12) - v13; |
5728 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 5729 v35 = stru_5C6E00->Cos(angle); |
5730 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5731 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5732 v38 = stru_5C6E00->Cos(angle); | |
1390 | 5733 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
0 | 5734 + (double)(v35 >> 16)) |
5735 * v33 | |
5736 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
5737 + (double)(v36 >> 16)) | |
5738 * v34) | |
5739 * v11 + v13; | |
5740 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
5741 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
5742 - 12.0) | |
5743 * v11 | |
5744 + (double)a2->uScreenSpaceY; | |
1390 | 5745 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5746 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
5747 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
5748 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5749 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
5750 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5751 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
0 | 5752 v40 = (double)(a2->uScreenSpaceX + 12) - v13; |
5753 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 5754 v42 = stru_5C6E00->Cos(angle); |
5755 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5756 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5757 v45 = stru_5C6E00->Cos(angle); | |
1390 | 5758 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
0 | 5759 + (double)(v42 >> 16)) |
5760 * v40 | |
5761 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
5762 + (double)(v43 >> 16)) | |
5763 * v41) | |
5764 * v11 + v13; | |
5765 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
5766 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
5767 - 12.0) | |
5768 * v11 | |
5769 + (double)a2->uScreenSpaceY; | |
1390 | 5770 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; |
5771 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
5772 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
5773 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5774 pBillboardRenderListD3D[v8].pTexture = a3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5775 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 5776 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5777 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; |
5778 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5779 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5780 } |
5781 } | |
5782 | |
5783 //----- (004A4023) -------------------------------------------------------- | |
657 | 5784 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
|
5785 { |
0 | 5786 unsigned int v8; // esi@2 |
5787 double v14; // st6@14 | |
5788 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5789 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5790 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5791 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5792 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5793 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5794 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5795 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5796 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5797 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5798 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 5799 float v29; // [sp+28h] [bp-8h]@5 |
5800 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5801 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5802 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5803 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5804 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5805 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5806 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5807 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5808 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
|
5809 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
|
5810 |
657 | 5811 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); |
2006 | 5812 if (a2->sTintColor & 0x00FFFFFF && bTinting) |
5813 { | |
5814 diffuse = BlendColors(a2->sTintColor, diffuse); | |
5815 if (a2->sTintColor & 0xFF000000) | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5816 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5817 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5818 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5819 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5820 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
|
5821 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
|
5822 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5823 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5824 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5825 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5826 v14 *= -1.0; |
1390 | 5827 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; |
5828 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5829 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5830 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5831 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; |
5832 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
5833 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5834 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5835 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5836 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5837 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5838 if ( a2->uFlags & 4 ) |
0 | 5839 v14 = v14 * -1.0; |
1390 | 5840 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; |
5841 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
5842 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5843 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5844 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5845 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; |
5846 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5847 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5848 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5849 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
|
5850 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5851 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5852 v14 *= -1.0; |
1390 | 5853 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; |
5854 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
5855 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5856 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5857 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5858 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; |
5859 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5860 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5861 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5862 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
|
5863 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5864 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5865 v14 *= -1.0; |
1390 | 5866 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; |
5867 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
5868 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5869 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5870 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5871 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; |
5872 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5873 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5874 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5875 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5876 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5877 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5878 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5879 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
2002 | 5880 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5881 |
2006 | 5882 if (a2->sTintColor & 0xFF000000) |
2155 | 5883 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5884 else |
2155 | 5885 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent; |
0 | 5886 } |
5887 | |
5888 | |
5889 //----- (004A49D0) -------------------------------------------------------- | |
5890 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
5891 { | |
1159 | 5892 int absXDifference; // eax@1 |
5893 int absYDifference; // eax@1 | |
5894 unsigned int smallerabsdiff; // ebx@1 | |
5895 unsigned int largerabsdiff; | |
0 | 5896 double v16; // st7@7 |
5897 double v17; // st7@7 | |
5898 double v18; // st6@7 | |
5899 double v20; // st4@8 | |
5900 double v21; // st4@10 | |
5901 double v22; // st4@10 | |
5902 double v23; // st4@10 | |
5903 double v25; // st4@11 | |
5904 double v26; // st4@13 | |
5905 double v28; // st4@13 | |
5906 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
1159 | 5907 int xDifference; // [sp+88h] [bp-Ch]@1 |
0 | 5908 signed int v32; // [sp+8Ch] [bp-8h]@1 |
1159 | 5909 int yDifference; // [sp+90h] [bp-4h]@1 |
5910 | |
5911 xDifference = bankersRounding(dstX - srcX); | |
5912 yDifference = bankersRounding(dstY - srcY); | |
5913 absYDifference = abs(yDifference); | |
5914 absXDifference = abs(xDifference); | |
5915 smallerabsdiff = min(absXDifference, absYDifference); | |
5916 largerabsdiff = max(absXDifference, absYDifference); | |
5917 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
0 | 5918 v16 = 1.0 / (double)v32; |
1159 | 5919 v17 = (double)yDifference * v16 * a4; |
5920 v18 = (double)xDifference * v16 * a4; | |
5921 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
5922 { | |
1637 | 5923 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
5924 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
1159 | 5925 } |
5926 else | |
5927 { | |
5928 v20 = a3 * 0.061758894; | |
5929 v25 = a7 * 0.061758894; | |
5930 } | |
5931 v21 = 1.0 / a3; | |
5932 v22 = (double)yDifference * v16 * a8; | |
5933 v23 = (double)xDifference * v16 * a8; | |
5934 v26 = 1.0 - 1.0 / v25; | |
5935 v28 = 1.0 / a7; | |
0 | 5936 v29[0].pos.x = srcX + v17; |
5937 v29[0].pos.y = srcY - v18; | |
1159 | 5938 v29[0].pos.z = 1.0 - 1.0 / v20; |
5939 v29[0].rhw = v21; | |
0 | 5940 v29[0].diffuse = -1; |
5941 v29[0].specular = 0; | |
5942 v29[0].texcoord.x = 1.0; | |
5943 v29[0].texcoord.y = 0.0; | |
1159 | 5944 |
0 | 5945 v29[1].pos.x = v22 + dstX; |
5946 v29[1].pos.y = dstY - v23; | |
1159 | 5947 v29[1].pos.z = v26; |
5948 v29[1].rhw = v28; | |
0 | 5949 v29[1].diffuse = -16711936; |
5950 v29[1].specular = 0; | |
5951 v29[1].texcoord.x = 1.0; | |
5952 v29[1].texcoord.y = 1.0; | |
1159 | 5953 |
5954 v29[2].pos.x = dstX - v22; | |
5955 v29[2].pos.y = v23 + dstY; | |
5956 v29[2].pos.z = v26; | |
0 | 5957 v29[2].rhw = v28; |
1159 | 5958 v29[2].diffuse = -1; |
5959 v29[2].specular = 0; | |
0 | 5960 v29[2].texcoord.x = 0.0; |
5961 v29[2].texcoord.y = 1.0; | |
1159 | 5962 |
0 | 5963 v29[3].pos.x = srcX - v17; |
5964 v29[3].pos.y = v18 + srcY; | |
1159 | 5965 v29[3].pos.z = v29[0].pos.z; |
5966 v29[3].rhw = v21; | |
5967 v29[3].diffuse = -1; | |
5968 v29[3].specular = 0; | |
0 | 5969 v29[3].texcoord.x = 0.0; |
5970 v29[3].texcoord.y = 0.0; | |
186 | 5971 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
5972 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
5973 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
5974 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
5975 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
5976 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 5977 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
5978 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
5979 D3DPT_TRIANGLEFAN, | |
5980 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
5981 v29, | |
5982 4, | |
5983 24)); | |
186 | 5984 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
5985 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
5986 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5987 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
5988 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5989 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 5990 } |
5991 | |
5992 //----- (004A4CC9) -------------------------------------------------------- | |
1390 | 5993 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) |
5994 { | |
0 | 5995 unsigned int v5; // eax@7 |
5996 char *v7; // edx@8 | |
5997 double v10; // st6@9 | |
5998 double v11; // st6@10 | |
5999 int v12; // ebx@13 | |
1390 | 6000 |
6001 if (a1->uNumVertices < 3) | |
6002 return; | |
6003 | |
6004 float depth = 1000000.0; | |
6005 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6006 { | |
6007 if (a1->field_104[i].z < depth) | |
6008 depth = a1->field_104[i * 4].z; | |
6009 } | |
6010 | |
6011 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
6012 pBillboardRenderListD3D[v5].field_90 = 0; | |
2002 | 6013 pBillboardRenderListD3D[v5].sParentBillboardID = -1; |
2155 | 6014 pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2; |
1390 | 6015 pBillboardRenderListD3D[v5].pTexture = 0; |
6016 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
6017 pBillboardRenderListD3D[v5].z_order = depth; | |
6018 | |
6019 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6020 { | |
6021 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
6022 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
6023 | |
6024 v10 = a1->field_104[i].z; | |
6025 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
6026 v11 = v10 * 0.061758894; | |
6027 else | |
1637 | 6028 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
1390 | 6029 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; |
6030 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
6031 | |
6032 if (diffuse & 0xFF000000) | |
6033 v12 = a1->field_104[i].diffuse; | |
6034 else | |
6035 v12 = diffuse; | |
6036 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
6037 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
6038 | |
6039 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
6040 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
0 | 6041 } |
6042 } | |
6043 | |
6044 //----- (004A4DE1) -------------------------------------------------------- | |
6045 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
6046 { | |
6047 HRESULT v12; // eax@14 | |
6048 unsigned __int16 *v13; // ecx@19 | |
6049 unsigned __int16 *v14; // eax@19 | |
6050 DWORD v15; // edx@20 | |
6051 HRESULT v16; // eax@23 | |
6052 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
6053 | |
1980 | 6054 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); |
0 | 6055 if ( pHWLTexture ) |
6056 { | |
6057 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
6058 if ( !pRenderD3D->CreateTexture( | |
6059 pHWLTexture->uWidth, | |
6060 pHWLTexture->uHeight, | |
6061 pOutSurface, | |
6062 pOutTexture, | |
6063 true, | |
6064 bMipMaps, | |
6065 uMinDeviceTextureDim) ) | |
1545 | 6066 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6067 //v10 = *pOutSurface; |
6068 //v11 = 0; | |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1574
diff
changeset
|
6069 if (bMipMaps) |
0 | 6070 { |
6071 Dst._450DDE(); | |
6072 //v20 = 0; | |
6073 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
6074 | |
6075 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
6076 while ( 1 ) | |
6077 { | |
6078 DDSCAPS2 v19; | |
6079 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6080 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6081 | |
6082 DDSURFACEDESC2 desc; | |
6083 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6084 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6085 | |
168 | 6086 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6087 { |
1831 | 6088 Dst.sub_451007_scale_image_bicubic( |
0 | 6089 pHWLTexture->pPixels, |
6090 pHWLTexture->uWidth, | |
6091 pHWLTexture->uHeight, | |
6092 pHWLTexture->uWidth, | |
6093 (unsigned short *)desc.lpSurface, | |
6094 desc.dwWidth, | |
6095 desc.dwHeight, | |
6096 desc.lPitch >> 1, | |
6097 0, | |
1831 | 6098 0); |
0 | 6099 ErrD3D(pNextSurf->Unlock(0)); |
6100 //bMipMaps = 0x4D86ACu; | |
6101 } | |
6102 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
6103 break; | |
6104 //v10 = (IDirectDrawSurface4 *)pName; | |
6105 //v11 = 0; | |
6106 } | |
6107 //v20 = -1; | |
6108 //nullsub_1(); | |
6109 } | |
6110 else | |
6111 { | |
6112 DDSCAPS2 v19; | |
6113 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6114 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6115 | |
6116 DDSURFACEDESC2 desc; | |
6117 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6118 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6119 | |
168 | 6120 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6121 { |
6122 bMipMaps = 0; | |
6123 v13 = pHWLTexture->pPixels; | |
6124 v14 = (unsigned __int16 *)desc.lpSurface; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6125 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
|
6126 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6127 for (v15 = 0; v15 < desc.dwWidth; v15++) |
0 | 6128 { |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6129 *v14 = *v13; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6130 ++v14; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6131 ++v13; |
0 | 6132 } |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6133 v14 += (desc.lPitch >> 1) - desc.dwWidth; |
0 | 6134 } |
6135 ErrD3D((*pOutSurface)->Unlock(0)); | |
6136 } | |
6137 } | |
6138 delete [] pHWLTexture->pPixels; | |
6139 delete pHWLTexture; | |
6140 return true; | |
6141 } | |
6142 return false; | |
6143 } | |
6144 | |
6145 //----- (004A5048) -------------------------------------------------------- | |
670 | 6146 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
6147 { | |
6148 | |
6149 HWLTexture *sprite_texture; // eax@1 | |
0 | 6150 unsigned __int16 *v9; // edx@5 |
6151 LPVOID v10; // eax@5 | |
6152 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6153 | |
670 | 6154 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
6155 if ( sprite_texture ) | |
6156 { | |
6157 pSprite->uAreaX = sprite_texture->uAreaX; | |
6158 pSprite->uAreaY = sprite_texture->uAreaY; | |
6159 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
6160 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
6161 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
6162 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6163 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6164 //v7 = v3->pRenderD3D; |
670 | 6165 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
1545 | 6166 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6167 //pSprite = v2->pTextureSurface; |
6168 //pSprite = (Sprite *)pSprite->pName; | |
6169 //v8 = pSprite; | |
670 | 6170 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 6171 Dst.dwSize = 124; |
670 | 6172 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
6173 { | |
6174 v9 = sprite_texture->pPixels; | |
6175 v10 = Dst.lpSurface; | |
6176 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 6177 { |
670 | 6178 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
6179 { | |
0 | 6180 *(int *)v10 = *(int *)v9; |
6181 v9 += 2; | |
6182 v10 = (char *)v10 + 4; | |
670 | 6183 } |
6184 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 6185 } |
670 | 6186 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
6187 } | |
6188 free(sprite_texture->pPixels); | |
6189 free(sprite_texture); | |
6190 return true; | |
6191 } | |
6192 return false; | |
0 | 6193 } |
6194 | |
6195 //----- (004A51CB) -------------------------------------------------------- | |
6196 void Render::BeginScene() | |
6197 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6198 //Render *v1; // esi@1 |
0 | 6199 unsigned int v2; // eax@1 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6200 /*int v3; // eax@5 |
0 | 6201 unsigned __int16 **v4; // edi@6 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6202 char *v5; // ebx@7*/ |
0 | 6203 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 |
6204 | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6205 //v1 = this; |
0 | 6206 v2 = this->uNumSceneBegins; |
6207 this->uNumSceneBegins = v2 + 1; | |
6208 if ( !v2 ) | |
6209 { | |
6210 if ( this->pRenderD3D ) | |
6211 { | |
2069 | 6212 /*if ( this->bColorKeySupported ) |
0 | 6213 { |
6214 memset(&Dst, 0, 0x7Cu); | |
6215 Dst.dwSize = 124; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6216 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
|
6217 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6218 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6219 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6220 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
|
6221 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6222 --this->uNumSceneBegins; |
2069 | 6223 }*/ |
0 | 6224 } |
6225 else | |
6226 { | |
6227 if ( !this->pTargetSurface ) | |
6228 { | |
6229 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
2154 | 6230 /*if ( this->pTargetSurface ) |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6231 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6232 this->field_18_locked_pitch = this->uTargetSurfacePitch; |
2154 | 6233 }*/ |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6234 --this->uNumSceneBegins; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6235 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6236 } |
0 | 6237 RestoreFrontBuffer(); |
6238 } | |
6239 } | |
6240 | |
6241 //----- (004A527D) -------------------------------------------------------- | |
6242 void Render::EndScene() | |
6243 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6244 if ( this->uNumSceneBegins ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6245 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6246 this->uNumSceneBegins--; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6247 if ( !this->uNumSceneBegins ) |
0 | 6248 { |
6249 if ( this->pRenderD3D ) | |
6250 { | |
2069 | 6251 /*if ( this->bColorKeySupported ) |
0 | 6252 { |
6253 this->pTargetSurface = 0; | |
6254 this->uTargetSurfacePitch = 0; | |
6255 this->field_18_locked_pitch = 0; | |
6256 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
2069 | 6257 }*/ |
0 | 6258 } |
6259 else | |
6260 { | |
6261 this->pTargetSurface = 0; | |
6262 this->uTargetSurfacePitch = 0; | |
2154 | 6263 //this->field_18_locked_pitch = 0; |
0 | 6264 UnlockBackBuffer(); |
6265 } | |
6266 } | |
6267 } | |
6268 } | |
6269 | |
2155 | 6270 //----- (004A52F1) -------------------------------------------------------- |
6271 void Render::ScreenFade(unsigned int color, float t) | |
0 | 6272 { |
6273 unsigned int v3; // esi@1 | |
2155 | 6274 //double v4; // st7@2 |
6275 //double v5; // st7@6 | |
0 | 6276 double v6; // st6@6 |
6277 unsigned int v7; // eax@6 | |
6278 double v8; // st5@6 | |
6279 double v9; // st4@6 | |
6280 HRESULT v10; // eax@6 | |
6281 HRESULT v11; // eax@6 | |
6282 unsigned int result; // eax@6 | |
6283 unsigned int v13; // eax@7 | |
6284 unsigned __int16 *v14; // ecx@7 | |
6285 int *v15; // eax@7 | |
6286 unsigned int v16; // ecx@8 | |
6287 __int16 v17; // ax@10 | |
6288 int v18; // esi@10 | |
6289 float v19; // edi@10 | |
6290 void *v20; // esi@10 | |
6291 int v21; // edx@10 | |
6292 int v22; // ecx@11 | |
6293 int v23; // edx@12 | |
6294 __int16 v24; // ax@15 | |
6295 int v25; // esi@15 | |
6296 float v26; // edi@15 | |
6297 char *v27; // esi@15 | |
6298 int v28; // edx@15 | |
6299 int v29; // ecx@16 | |
6300 int v30; // edx@17 | |
6301 int v31; // [sp-Ch] [bp-ACh]@11 | |
6302 int v32; // [sp-Ch] [bp-ACh]@16 | |
6303 const char *v33; // [sp+0h] [bp-A0h]@0 | |
6304 int v34; // [sp+4h] [bp-9Ch]@0 | |
6305 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
6306 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
6307 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
6308 int v38; // [sp+90h] [bp-10h]@7 | |
6309 double v39; // [sp+94h] [bp-Ch]@6 | |
2155 | 6310 int v40; // [sp+9Ch] [bp-4h]@6 |
6311 | |
0 | 6312 v3 = 0; |
1574 | 6313 |
6314 //{ | |
2155 | 6315 if (t > 1.0f) |
6316 t = 1.0f; | |
6317 else if (t < 0.0f) | |
6318 t = 0.0f; | |
6319 | |
6320 v40 = (char)floorf(t * 255.0f + 0.5f); | |
6321 //v5 = (double)(signed int)pViewport->uViewportTL_X; | |
6322 v36[0].pos.x = pViewport->uViewportTL_X; | |
693 | 6323 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
2155 | 6324 v7 = color | (v40 << 24); |
6325 //this_ = pViewport->uViewportBR_Y + 1; | |
0 | 6326 v36[0].specular = 0; |
6327 v36[0].pos.y = v6; | |
6328 v36[0].diffuse = v7; | |
6329 v36[1].diffuse = v7; | |
6330 v36[0].pos.z = 0.0; | |
6331 v36[2].diffuse = v7; | |
6332 v36[3].diffuse = v7; | |
6333 v36[0].rhw = 1.0; | |
6334 v36[1].specular = 0; | |
6335 v36[0].texcoord.x = 0.0; | |
6336 v36[2].specular = 0; | |
6337 v36[3].specular = 0; | |
6338 v36[0].texcoord.y = 0.0; | |
2155 | 6339 v36[1].pos.x = pViewport->uViewportTL_X; |
693 | 6340 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 6341 v36[1].pos.y = v8; |
6342 v36[1].pos.z = 0.0; | |
6343 v36[1].rhw = 1.0; | |
6344 v36[1].texcoord.x = 0.0; | |
6345 v36[1].texcoord.y = 0.0; | |
693 | 6346 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 6347 v36[2].pos.x = v9; |
6348 v36[2].pos.y = v8; | |
6349 v36[2].pos.z = 0.0; | |
6350 v36[2].rhw = 1.0; | |
6351 v36[2].texcoord.x = 0.0; | |
6352 v36[2].texcoord.y = 0.0; | |
6353 v36[3].pos.x = v9; | |
6354 v36[3].pos.y = v6; | |
6355 v36[3].pos.z = 0.0; | |
6356 v36[3].rhw = 1.0; | |
6357 v36[3].texcoord.x = 0.0; | |
6358 v36[3].texcoord.y = 0.0; | |
6359 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 6360 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
6361 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6362 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6363 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
6364 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
6365 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6366 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 6367 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
6368 D3DPT_TRIANGLEFAN, | |
6369 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6370 v36, | |
6371 4, | |
6372 28)); | |
186 | 6373 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
6374 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6375 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
6376 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6377 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6378 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
1574 | 6379 /*} |
0 | 6380 else |
6381 { | |
6382 v40 = (1.0 - a3) * 65536.0; | |
6383 v39 = v40 + 6.7553994e15; | |
6384 LODWORD(a3) = LODWORD(v39); | |
693 | 6385 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
6386 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
6387 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
6388 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 6389 v37 = 2 * v13; |
6390 LODWORD(v40) = (int)v14; | |
6391 | |
6392 int __i = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
6393 v15 = dword_F1B430.data(); |
0 | 6394 do |
6395 { | |
6396 v16 = v3; | |
6397 v3 += LODWORD(a3); | |
6398 dword_F1B430[__i++] = v16 >> 16; | |
6399 } | |
6400 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
6401 while (__i < 32); | |
6402 | |
6403 if ( pRenderer->uTargetGBits == 6 ) | |
6404 { | |
1574 | 6405 v17 = sr_42690D_colors_cvt(this_); |
0 | 6406 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); |
6407 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); | |
6408 v19 = v40; | |
6409 v20 = off_4EFDB0; | |
6410 v21 = HIDWORD(v39); | |
6411 do | |
6412 { | |
6413 v22 = v38; | |
6414 v31 = v21; | |
6415 do | |
6416 { | |
6417 v23 = (*(int *)((char *)v20 | |
6418 + ((((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; | |
6419 result = this_ | |
6420 + (*((int *)v20 | |
6421 + (((unsigned __int8)(*((char *)v20 | |
6422 + ((((unsigned __int16)(*(short *)((char *)v20 | |
6423 + ((*(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); | |
6424 *(unsigned int *)LODWORD(v19) = result; | |
6425 LODWORD(v19) += 4; | |
6426 --v22; | |
6427 } | |
6428 while ( v22 ); | |
6429 LODWORD(v19) += v37; | |
6430 v21 = v31 - 1; | |
6431 } | |
6432 while ( v31 != 1 ); | |
6433 } | |
6434 else | |
6435 { | |
1574 | 6436 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_); |
0 | 6437 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); |
6438 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
6439 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
6440 v26 = v40; | |
6441 v27 = (char *)off_4EFDB0; | |
6442 v28 = HIDWORD(v39); | |
6443 do | |
6444 { | |
6445 v29 = v38; | |
6446 v32 = v28; | |
6447 do | |
6448 { | |
6449 v30 = 32 | |
6450 * *(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; | |
6451 result = this_ | |
6452 + (*(int *)&v27[4 | |
6453 * (((unsigned __int8)(32 | |
6454 * 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); | |
6455 *(unsigned int *)LODWORD(v26) = result; | |
6456 LODWORD(v26) += 4; | |
6457 --v29; | |
6458 } | |
6459 while ( v29 ); | |
6460 LODWORD(v26) += v37; | |
6461 v28 = v32 - 1; | |
6462 } | |
6463 while ( v32 != 1 ); | |
6464 } | |
1574 | 6465 }*/ |
0 | 6466 } |
6467 | |
6468 //----- (004A5B81) -------------------------------------------------------- | |
727 | 6469 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 6470 { |
6471 this->bClip = 1; | |
6472 this->uClipY = uY; | |
6473 this->uClipX = uX; | |
6474 this->uClipW = uW; | |
6475 this->uClipZ = uZ; | |
6476 } | |
6477 | |
6478 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 6479 void Render::ResetTextureClipRect() |
0 | 6480 { |
6481 this->uClipY = 0; | |
6482 this->uClipX = 0; | |
6483 this->bClip = 1; | |
6484 this->uClipW = 480; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
6485 this->uClipZ = window->GetWidth(); |
0 | 6486 } |
6487 | |
2069 | 6488 unsigned __int32 Color32(unsigned __int16 color16) |
6489 { | |
6490 unsigned __int32 c = color16; | |
6491 unsigned int b = (c & 31) * 8; | |
6492 unsigned int g = ((c >> 5) & 63) * 4; | |
6493 unsigned int r = ((c >> 11) & 31) * 8; | |
6494 | |
2078 | 6495 return (r << 16) | (g << 8) | b;// |
2069 | 6496 } |
6497 | |
6498 //----- (0040DEF3) -------------------------------------------------------- | |
6499 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b) | |
6500 { | |
6501 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + | |
6502 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + | |
6503 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
6504 return (b >> (8 - 5)) | | |
6505 0x7E0 & (g << (6 + 5 - 8)) | | |
6506 0xF800 & (r << (6 + 5 + 5 - 8)); | |
6507 } | |
6508 | |
6509 | |
0 | 6510 //----- (004A5BE3) -------------------------------------------------------- |
6511 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
6512 { | |
6513 int v4; // edi@3 | |
2069 | 6514 //unsigned __int16 *v5; // edx@3 |
0 | 6515 unsigned __int16 *v6; // esi@3 |
6516 unsigned int v8; // eax@5 | |
6517 unsigned int v9; // ebx@5 | |
6518 unsigned int v11; // eax@7 | |
6519 unsigned int v12; // ebx@8 | |
6520 unsigned int v15; // eax@14 | |
6521 int v19; // [sp+10h] [bp-8h]@3 | |
6522 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
6523 int v23; // [sp+28h] [bp+10h]@3 | |
6524 | |
6525 if ( this->uNumSceneBegins && a4 ) | |
6526 { | |
6527 v4 = a4->uWidth; | |
2069 | 6528 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6529 v6 = a4->pPixels; |
6530 v23 = a4->uHeight; | |
6531 v19 = v4; | |
6532 if ( this->bClip ) | |
6533 { | |
1152 | 6534 if ( (signed int)uOutX < (signed int)this->uClipX ) |
6535 { | |
6536 v8 = this->uClipX - uOutX; | |
6537 v9 = uOutX - this->uClipX; | |
0 | 6538 v8 *= 2; |
6539 v4 += v9; | |
6540 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
2069 | 6541 //v5 = (unsigned __int16 *)((char *)v5 + v8); |
0 | 6542 } |
1152 | 6543 if ( (signed int)uOutY < (signed int)this->uClipY ) |
6544 { | |
6545 v11 = this->uClipY - uOutY; | |
0 | 6546 v6 += v19 * v11; |
6547 v23 += uOutY - this->uClipY; | |
2069 | 6548 //v5 += this->uTargetSurfacePitch * v11; |
0 | 6549 } |
1152 | 6550 v12 = max(this->uClipX, uOutX); |
6551 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | |
6552 { | |
6553 v4 = this->uClipZ - max(this->uClipX, uOutX); | |
6554 } | |
6555 v15 = max(this->uClipY, uOutY); | |
6556 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) | |
6557 { | |
6558 v23 = this->uClipW - max(this->uClipY, uOutY); | |
6559 } | |
6560 } | |
6561 | |
2069 | 6562 for (int y = 0; y < v23; y++) |
6563 { | |
6564 for (int x = 0; x < v4; x++) | |
6565 { | |
6566 WritePixel16(uOutX + x, uOutY + y, *v6); | |
6567 //*v5 = *v6; | |
6568 //++v5; | |
1152 | 6569 ++v6; |
6570 } | |
6571 v6 += v19 - v4; | |
2069 | 6572 //v5 += this->uTargetSurfacePitch - v4; |
0 | 6573 } |
6574 } | |
6575 } | |
6576 | |
6577 //----- (004A5D33) -------------------------------------------------------- | |
1675 | 6578 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) |
0 | 6579 { |
2069 | 6580 //unsigned __int16 *v7; // ebx@3 |
1675 | 6581 int full_width; // ecx@3 |
6582 int full_height; // edi@3 | |
2069 | 6583 //int v23; // edi@23 |
0 | 6584 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 |
6585 | |
6586 if ( this->uNumSceneBegins && pTexture ) | |
6587 { | |
2069 | 6588 /*auto v7 = this->pTargetSurface; |
6589 if (FORCE_16_BITS) | |
6590 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2); | |
6591 else | |
6592 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/ | |
1675 | 6593 full_width = pTexture->uWidth - move_X; |
6594 full_height = pTexture->uHeight - move_Y; | |
6595 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth]; | |
6596 if ( this->bClip ) | |
6597 { | |
6598 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó | |
6599 { | |
6600 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX))); | |
6601 full_width += pX - this->uClipX; | |
2069 | 6602 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX))); |
1675 | 6603 } |
6604 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó | |
6605 { | |
6606 pTexturea += pTexture->uWidth * (this->uClipY - pY); | |
6607 full_height += pY - this->uClipY; | |
2069 | 6608 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY)); |
1675 | 6609 } |
6610 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà | |
6611 this->uClipX = pX; | |
6612 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà | |
6613 this->uClipY = pY; | |
6614 if ( (full_width + this->uClipX) > this->uClipZ )//åñëè øèðèíà êàäðà âûõîäèò çà ïðàâóþ ãðàíèöó | |
6615 { | |
6616 if ( this->uClipX < pX ) | |
6617 this->uClipX = pX; | |
6618 full_width = this->uClipZ - this->uClipX; | |
6619 } | |
6620 if ( (full_height + this->uClipY) > this->uClipW )//åñëè âûñîòà êàäðà âûõîäèò çà íèæíþþ ãðàíèöó | |
6621 { | |
6622 if ( this->uClipY < pY ) | |
6623 this->uClipY = pY; | |
6624 full_height = this->uClipW - this->uClipY; | |
6625 } | |
6626 } | |
2069 | 6627 |
6628 for (int y = 0; y < full_height; ++y) | |
6629 { | |
6630 for (int x = 0; x < full_width; ++x) | |
6631 { | |
6632 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) ) | |
6633 { | |
6634 WritePixel16(pX + x, pY + y, *pTexturea); | |
6635 /*if (FORCE_16_BITS) | |
6636 *(unsigned __int16 *)v7 = *pTexturea; | |
6637 else | |
6638 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/ | |
6639 } | |
0 | 6640 ++pTexturea; |
2069 | 6641 //++v7; |
0 | 6642 } |
2069 | 6643 //v7 += this->uTargetSurfacePitch - full_width; |
1675 | 6644 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width)); |
2069 | 6645 } |
0 | 6646 } |
6647 } | |
6648 | |
6649 //----- (004A6E7E) -------------------------------------------------------- | |
2155 | 6650 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 6651 { |
2069 | 6652 //unsigned __int16 *v4; // eax@4 |
0 | 6653 int v5; // edx@4 |
6654 unsigned int v6; // edi@4 | |
6655 unsigned int v7; // edx@5 | |
6656 unsigned int v8; // edx@6 | |
6657 unsigned int v9; // edx@7 | |
6658 unsigned int v10; // edx@8 | |
6659 unsigned int v11; // ebx@9 | |
6660 unsigned int v12; // esi@11 | |
6661 unsigned int v13; // edx@12 | |
6662 unsigned int v14; // ebx@15 | |
6663 unsigned int v15; // esi@17 | |
6664 unsigned int v16; // edi@18 | |
6665 char v17; // zf@29 | |
6666 int v18; // [sp+14h] [bp-Ch]@4 | |
6667 int v19; // [sp+18h] [bp-8h]@4 | |
6668 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
6669 int v21; // [sp+28h] [bp+8h]@25 | |
6670 int v22; // [sp+28h] [bp+8h]@34 | |
6671 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
6672 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
6673 | |
6674 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
6675 { | |
2069 | 6676 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
710 | 6677 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 6678 v5 = a4->uTextureWidth; |
6679 v6 = a4->uTextureHeight; | |
6680 v19 = a4->uTextureWidth; | |
6681 v18 = a4->uTextureWidth; | |
2069 | 6682 int clipped_out_x = a2; |
6683 int clipped_out_y = a3; | |
0 | 6684 if ( this->bClip ) |
6685 { | |
6686 v7 = this->uClipX; | |
6687 if ( (signed int)a2 < (signed int)v7 ) | |
6688 { | |
6689 v8 = v7 - a2; | |
6690 v20 += v8; | |
6691 v19 += a2 - this->uClipX; | |
2069 | 6692 //v4 += v8; |
6693 clipped_out_x = uClipX; | |
0 | 6694 } |
6695 v9 = this->uClipY; | |
6696 if ( (signed int)a3 < (signed int)v9 ) | |
6697 { | |
6698 v10 = v9 - a3; | |
6699 v20 += v18 * v10; | |
6700 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
2069 | 6701 //v4 += this->uTargetSurfacePitch * v10; |
6702 clipped_out_y = uClipY; | |
0 | 6703 } |
6704 v11 = this->uClipX; | |
6705 v5 = v19; | |
6706 if ( (signed int)v11 < (signed int)a2 ) | |
6707 v11 = a2; | |
6708 v12 = this->uClipZ; | |
6709 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
6710 { | |
6711 v13 = this->uClipX; | |
6712 if ( (signed int)v13 < (signed int)a2 ) | |
6713 v13 = a2; | |
6714 v5 = v12 - v13; | |
6715 } | |
6716 v14 = this->uClipY; | |
6717 if ( (signed int)v14 < (signed int)a3 ) | |
6718 v14 = a3; | |
6719 v15 = this->uClipW; | |
6720 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
6721 { | |
6722 v16 = this->uClipY; | |
6723 if ( (signed int)v16 < (signed int)a3 ) | |
6724 v16 = a3; | |
6725 v6 = v15 - v16; | |
6726 } | |
6727 } | |
2069 | 6728 |
6729 for (int y = 0; y < v6; ++y) | |
6730 { | |
6731 for (int x = 0; x < v5; ++x) | |
6732 { | |
6733 if ( *v20 ) | |
6734 WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF); | |
6735 ++v20; | |
6736 } | |
6737 v20 += v18 - v5; | |
6738 } | |
6739 | |
6740 /*if ( pRenderer->uTargetGBits == 5 ) | |
0 | 6741 { |
6742 if ( (signed int)v6 > 0 ) | |
6743 { | |
6744 v23 = v6; | |
6745 do | |
6746 { | |
6747 if ( v5 > 0 ) | |
6748 { | |
6749 v21 = v5; | |
6750 do | |
6751 { | |
6752 if ( *v20 ) | |
6753 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
6754 ++v4; | |
6755 ++v20; | |
6756 --v21; | |
6757 } | |
6758 while ( v21 ); | |
6759 } | |
6760 v20 += v18 - v5; | |
6761 v17 = v23-- == 1; | |
6762 v4 += this->uTargetSurfacePitch - v5; | |
6763 } | |
6764 while ( !v17 ); | |
6765 } | |
6766 } | |
6767 else | |
6768 { | |
6769 if ( (signed int)v6 > 0 ) | |
6770 { | |
6771 v24 = v6; | |
6772 do | |
6773 { | |
6774 if ( v5 > 0 ) | |
6775 { | |
6776 v22 = v5; | |
6777 do | |
6778 { | |
6779 if ( *v20 ) | |
6780 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
6781 ++v4; | |
6782 ++v20; | |
6783 --v22; | |
6784 } | |
6785 while ( v22 ); | |
6786 } | |
6787 v20 += v18 - v5; | |
6788 v17 = v24-- == 1; | |
6789 v4 += this->uTargetSurfacePitch - v5; | |
6790 } | |
6791 while ( !v17 ); | |
6792 } | |
2069 | 6793 }*/ |
0 | 6794 } |
6795 } | |
6796 | |
6797 //----- (004A6DF5) -------------------------------------------------------- | |
2069 | 6798 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) |
0 | 6799 { |
2219 | 6800 int width; // ecx@3 |
6801 unsigned __int16 *pixels; // ebx@4 | |
6802 int height; // esi@4 | |
0 | 6803 |
2069 | 6804 if ( !pBitmap || !pTarget) |
6805 return; | |
6806 | |
2219 | 6807 width = a7->z - a7->x; |
6808 height = a7->w - a7->y; | |
6809 pixels = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; | |
6810 for ( int y = 0; y < height; ++y ) | |
6811 { | |
6812 for ( int x = 0; x < width; ++x ) | |
6813 { | |
6814 WritePixel16(a7->x + x, a7->y + y, *pixels); | |
6815 ++pixels; | |
6816 } | |
6817 pixels += uTargetPitch - width; | |
2093 | 6818 } |
0 | 6819 } |
6820 | |
6821 //----- (004A6D87) -------------------------------------------------------- | |
6822 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
6823 { | |
6824 if (!uNumSceneBegins) | |
6825 return; | |
6826 | |
6827 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
6828 for (uint y = 0; y < uHeight; ++y) | |
6829 { | |
2069 | 6830 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch); |
6831 | |
6832 memset32(pDst, | |
2098 | 6833 FORCE_16_BITS ? twoColors : 0xFF000000 | Color32(uColor16), // two colors per int (16bit) or 1 (32bit) |
2069 | 6834 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit) |
6835 | |
6836 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit | |
6837 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16; | |
0 | 6838 } |
6839 } | |
6840 | |
6841 //----- (004A6C4F) -------------------------------------------------------- | |
2073 | 6842 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, |
6843 unsigned int uCharHeight, unsigned __int16 *pFontPalette, | |
6844 unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
0 | 6845 { |
6846 unsigned int v9; // edi@2 | |
6847 unsigned int v10; // esi@2 | |
2069 | 6848 //unsigned __int16 *v11; // eax@2 |
0 | 6849 unsigned int v12; // ebx@3 |
6850 signed int v13; // edx@5 | |
6851 int v14; // edx@6 | |
6852 signed int v15; // ebx@7 | |
6853 unsigned int v16; // edx@9 | |
6854 signed int v17; // edi@10 | |
6855 signed int v18; // ebx@13 | |
6856 unsigned int v19; // edx@15 | |
6857 signed int v20; // esi@16 | |
2069 | 6858 //unsigned int v21; // esi@22 |
0 | 6859 unsigned __int16 v22; // dx@24 |
2069 | 6860 //char v23; // zf@28 |
0 | 6861 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 |
2069 | 6862 //unsigned int uOutXa; // [sp+18h] [bp+8h]@20 |
6863 | |
6864 if (!this->uNumSceneBegins) | |
6865 return; | |
6866 | |
0 | 6867 v9 = uCharWidth; |
6868 v10 = uCharHeight; | |
2069 | 6869 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6870 v24 = pFontPixels; |
2069 | 6871 |
6872 int clipped_out_x = uOutX, clipped_out_y = uOutY; | |
0 | 6873 if ( this->bClip ) |
6874 { | |
6875 v12 = this->uClipX; | |
6876 if ( uOutX < (signed int)v12 ) | |
6877 { | |
6878 v24 = &pFontPixels[v12 - uOutX]; | |
2069 | 6879 //v11 += v12 - uOutX; |
6880 clipped_out_x = uClipX; | |
0 | 6881 v9 = uCharWidth + uOutX - v12; |
6882 } | |
6883 v13 = this->uClipY; | |
6884 if ( uOutY < v13 ) | |
6885 { | |
6886 v14 = v13 - uOutY; | |
6887 v24 += uCharWidth * v14; | |
6888 v10 = uCharHeight + uOutY - this->uClipY; | |
2069 | 6889 //v11 += this->uTargetSurfacePitch * v14; |
6890 clipped_out_y = uClipY; | |
0 | 6891 } |
6892 v15 = this->uClipX; | |
6893 if ( v15 < uOutX ) | |
6894 v15 = uOutX; | |
6895 v16 = this->uClipZ; | |
6896 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
6897 { | |
6898 v17 = this->uClipX; | |
6899 if ( v17 < uOutX ) | |
6900 v17 = uOutX; | |
6901 v9 = v16 - v17; | |
6902 } | |
6903 v18 = this->uClipY; | |
6904 if ( v18 < uOutY ) | |
6905 v18 = uOutY; | |
6906 v19 = this->uClipW; | |
6907 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
6908 { | |
6909 v20 = this->uClipY; | |
6910 if ( v20 < uOutY ) | |
6911 v20 = uOutY; | |
6912 v10 = v19 - v20; | |
6913 } | |
6914 } | |
2069 | 6915 |
6916 for (int y = 0; y < v10; ++y) | |
6917 { | |
6918 for (int x = 0; x < v9; ++x) | |
6919 { | |
6920 if (*v24) | |
0 | 6921 { |
2069 | 6922 v22 = uShadowColor; |
6923 if ( *v24 != 1 ) | |
6924 v22 = uFaceColor; | |
2073 | 6925 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22); |
0 | 6926 } |
2073 | 6927 ++v24; |
6928 } | |
6929 v24 += uCharWidth - v9; | |
2069 | 6930 //v23 = uOutXa-- == 1; |
6931 //v11 += this->uTargetSurfacePitch - v9; | |
6932 } | |
0 | 6933 } |
6934 | |
6935 //----- (004A6A68) -------------------------------------------------------- | |
1496 | 6936 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) |
6937 { | |
0 | 6938 Texture tex; // [sp+Ch] [bp-48h]@1 |
1496 | 6939 |
0 | 6940 memcpy(&tex, a4, sizeof(tex)); |
1496 | 6941 tex.uTextureHeight = a4->uTextureHeight - height; |
6942 if ( (signed __int16)tex.uTextureHeight > 0 ) | |
0 | 6943 DrawTextureIndexed(a2, a3, &tex); |
6944 } | |
6945 | |
6946 //----- (004A6AB1) -------------------------------------------------------- | |
1268 | 6947 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
6948 { | |
0 | 6949 int v8; // edi@2 |
6950 unsigned int v9; // esi@2 | |
2069 | 6951 //unsigned __int16 *v10; // eax@2 |
0 | 6952 unsigned char *v11; // edx@2 |
6953 unsigned int v12; // ebx@3 | |
6954 signed int v13; // edx@5 | |
6955 int v14; // edx@6 | |
6956 signed int v15; // ebx@7 | |
6957 unsigned int v16; // edx@9 | |
6958 signed int v17; // edi@10 | |
6959 signed int v18; // ebx@13 | |
6960 unsigned int v19; // edx@15 | |
6961 signed int v20; // esi@16 | |
6962 int v21; // ebx@22 | |
6963 char v22; // zf@28 | |
6964 int v23; // ebx@31 | |
6965 unsigned __int16 v24; // si@35 | |
6966 int v25; // [sp+Ch] [bp-4h]@2 | |
6967 int v26; // [sp+1Ch] [bp+Ch]@24 | |
6968 int v27; // [sp+1Ch] [bp+Ch]@33 | |
6969 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
6970 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
6971 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
6972 | |
1980 | 6973 int a2 = x; |
6974 int a3 = y; | |
6975 uint a6 = uFontHeight; | |
2069 | 6976 if (!this->uNumSceneBegins) |
6977 return; | |
6978 | |
0 | 6979 v8 = a5; |
6980 v9 = a6; | |
2069 | 6981 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; |
1268 | 6982 v11 = (unsigned char *)font_pixels; |
6983 v25 = (int)font_pixels; | |
2069 | 6984 int clipped_out_x = x; |
6985 int clipped_out_y = y; | |
0 | 6986 if ( this->bClip ) |
6987 { | |
6988 v12 = this->uClipX; | |
6989 if ( a2 < (signed int)v12 ) | |
6990 { | |
1268 | 6991 v25 = v12 - a2 + (int)font_pixels; |
2069 | 6992 //v10 += v12 - a2; |
0 | 6993 v8 = a5 + a2 - v12; |
2069 | 6994 clipped_out_x = uClipX; |
0 | 6995 } |
6996 v13 = this->uClipY; | |
6997 if ( a3 < v13 ) | |
6998 { | |
6999 v14 = v13 - a3; | |
7000 v25 += a5 * v14; | |
7001 v9 = a6 + a3 - this->uClipY; | |
2069 | 7002 //v10 += this->uTargetSurfacePitch * v14; |
7003 clipped_out_y = uClipY; | |
0 | 7004 } |
7005 v15 = this->uClipX; | |
7006 if ( v15 < a2 ) | |
7007 v15 = a2; | |
7008 v16 = this->uClipZ; | |
7009 if ( v8 + v15 > (signed int)v16 ) | |
7010 { | |
7011 v17 = this->uClipX; | |
7012 if ( v17 < a2 ) | |
7013 v17 = a2; | |
7014 v8 = v16 - v17; | |
7015 } | |
7016 v18 = this->uClipY; | |
7017 if ( v18 < a3 ) | |
7018 v18 = a3; | |
7019 v19 = this->uClipW; | |
7020 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
7021 { | |
7022 v20 = this->uClipY; | |
7023 if ( v20 < a3 ) | |
7024 v20 = a3; | |
7025 v9 = v19 - v20; | |
7026 } | |
7027 v11 = (unsigned char *)v25; | |
7028 } | |
2069 | 7029 |
0 | 7030 if ( a8 ) |
7031 { | |
2069 | 7032 v28 = 0x7FF; // 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask; |
7033 for (int dy = 0; dy < v9; ++dy) | |
7034 { | |
7035 for (int dx = 0; dx < v8; ++dx) | |
7036 { | |
7037 if ( *v11 ) | |
7038 v24 = pPalette[*v11]; | |
7039 else | |
7040 v24 = v28; | |
7041 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24); | |
7042 //*v10 = v24; | |
7043 //++v10; | |
2074 | 7044 ++v11; |
2069 | 7045 //--v27; |
2074 | 7046 |
2069 | 7047 } |
7048 v11 += a5 - v8; | |
7049 } | |
7050 /*if ( (signed int)v9 > 0 ) | |
0 | 7051 { |
7052 v23 = a5; | |
7053 v30 = v9; | |
7054 do | |
7055 { | |
7056 if ( v8 > 0 ) | |
7057 { | |
7058 v27 = v8; | |
7059 do | |
7060 { | |
7061 if ( *v11 ) | |
7062 v24 = pPalette[*v11]; | |
7063 else | |
7064 v24 = v28; | |
7065 *v10 = v24; | |
7066 ++v10; | |
7067 ++v11; | |
7068 --v27; | |
7069 } | |
7070 while ( v27 ); | |
7071 } | |
7072 v11 += v23 - v8; | |
7073 v22 = v30-- == 1; | |
7074 v10 += this->uTargetSurfacePitch - v8; | |
7075 } | |
7076 while ( !v22 ); | |
2069 | 7077 }*/ |
0 | 7078 } |
7079 else | |
7080 { | |
2069 | 7081 for (int dy = 0; dy < v9; ++dy) |
7082 { | |
7083 for (int dx = 0; dx < v8; ++dx) | |
7084 { | |
2074 | 7085 if ( *v11 ) |
2069 | 7086 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]); |
7087 //*v10 = v24; | |
7088 //++v10; | |
2074 | 7089 ++v11; |
2069 | 7090 //--v27; |
7091 } | |
7092 v11 += a5 - v8; | |
7093 } | |
7094 | |
7095 /*if ( (signed int)v9 > 0 ) | |
0 | 7096 { |
7097 v21 = a5; | |
7098 v29 = v9; | |
7099 do | |
7100 { | |
7101 if ( v8 > 0 ) | |
7102 { | |
7103 v26 = v8; | |
7104 do | |
7105 { | |
7106 if ( *v11 ) | |
7107 *v10 = pPalette[*v11]; | |
7108 ++v10; | |
7109 ++v11; | |
7110 --v26; | |
7111 } | |
7112 while ( v26 ); | |
7113 } | |
7114 v11 += v21 - v8; | |
7115 v22 = v29-- == 1; | |
7116 v10 += this->uTargetSurfacePitch - v8; | |
7117 } | |
7118 while ( !v22 ); | |
2069 | 7119 }*/ |
7120 } | |
0 | 7121 } |
7122 | |
7123 //----- (004A68EF) -------------------------------------------------------- | |
7124 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
7125 { | |
2069 | 7126 DrawMasked(a2, a3, pTexture, 0x07E0); |
7127 } | |
7128 | |
0 | 7129 |
7130 //----- (004A6776) -------------------------------------------------------- | |
315 | 7131 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 7132 { |
2069 | 7133 DrawMasked(a2, a3, a4, 0xF800); |
7134 /*Texture *v4; // edi@2 | |
0 | 7135 unsigned int v5; // ebx@4 |
7136 unsigned __int16 *v6; // eax@4 | |
7137 unsigned int v7; // edx@5 | |
7138 unsigned int v8; // edx@6 | |
7139 unsigned int v9; // edx@7 | |
7140 unsigned int v10; // edx@8 | |
7141 unsigned int v11; // edx@9 | |
7142 unsigned int v12; // esi@12 | |
7143 unsigned int v13; // esi@15 | |
7144 unsigned int v14; // edx@17 | |
7145 unsigned int v15; // esi@18 | |
7146 unsigned __int8 *v16; // ebx@22 | |
7147 char v17; // zf@28 | |
7148 int v18; // [sp+10h] [bp-10h]@4 | |
7149 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7150 int v20; // [sp+1Ch] [bp-4h]@4 | |
7151 int a2a; // [sp+28h] [bp+8h]@24 | |
7152 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
7153 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
7154 | |
7155 if ( this->uNumSceneBegins ) | |
7156 { | |
7157 v4 = a4; | |
7158 if ( a4 ) | |
7159 { | |
7160 if ( a4->pPalette16 ) | |
7161 { | |
7162 v5 = a4->uTextureHeight; | |
7163 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7164 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7165 v20 = a4->uTextureWidth; |
7166 v18 = a4->uTextureWidth; | |
7167 if ( this->bClip ) | |
7168 { | |
7169 v7 = this->uClipX; | |
7170 if ( (signed int)a2 < (signed int)v7 ) | |
7171 { | |
7172 v8 = v7 - a2; | |
7173 v19 += v8; | |
7174 v20 += a2 - this->uClipX; | |
7175 v6 += v8; | |
7176 } | |
7177 v9 = this->uClipY; | |
7178 v5 = a4->uTextureHeight; | |
7179 if ( (signed int)a3 < (signed int)v9 ) | |
7180 { | |
7181 v10 = v9 - a3; | |
7182 v19 += v18 * v10; | |
7183 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
7184 v4 = a4; | |
7185 v6 += this->uTargetSurfacePitch * v10; | |
7186 } | |
7187 v11 = this->uClipX; | |
7188 if ( (signed int)v11 < (signed int)a2 ) | |
7189 v11 = a2; | |
7190 a4a = this->uClipZ; | |
7191 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
7192 { | |
7193 v12 = this->uClipX; | |
7194 if ( (signed int)v12 < (signed int)a2 ) | |
7195 v12 = a2; | |
7196 v20 = a4a - v12; | |
7197 } | |
7198 v13 = this->uClipY; | |
7199 if ( (signed int)v13 < (signed int)a3 ) | |
7200 v13 = a3; | |
7201 v14 = this->uClipW; | |
7202 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7203 { | |
7204 v15 = this->uClipY; | |
7205 if ( (signed int)v15 < (signed int)a3 ) | |
7206 v15 = a3; | |
7207 v5 = v14 - v15; | |
7208 } | |
7209 } | |
7210 if ( (signed int)v5 > 0 ) | |
7211 { | |
7212 a3a = v5; | |
7213 v16 = v19; | |
7214 do | |
7215 { | |
7216 if ( v20 > 0 ) | |
7217 { | |
7218 a2a = v20; | |
7219 do | |
7220 { | |
7221 if ( *v16 ) | |
7222 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
7223 ++v6; | |
7224 ++v16; | |
7225 --a2a; | |
7226 } | |
7227 while ( a2a ); | |
7228 } | |
7229 v16 += v18 - v20; | |
7230 v17 = a3a-- == 1; | |
7231 v6 += this->uTargetSurfacePitch - v20; | |
7232 } | |
7233 while ( !v17 ); | |
7234 } | |
7235 } | |
7236 } | |
2069 | 7237 }*/ |
7238 } | |
7239 | |
7240 //----- (004A68EF) -------------------------------------------------------- | |
7241 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask) | |
7242 { | |
7243 Texture *v4; // edi@2 | |
7244 unsigned int v5; // ebx@4 | |
7245 //unsigned __int16 *v6; // eax@4 | |
7246 signed int v7; // edx@5 | |
7247 int v8; // edx@6 | |
7248 signed int v9; // edx@7 | |
7249 int v10; // edx@8 | |
7250 signed int v11; // edx@9 | |
7251 signed int v12; // esi@12 | |
7252 signed int v13; // esi@15 | |
7253 unsigned int v14; // edx@17 | |
7254 signed int v15; // esi@18 | |
7255 unsigned __int8 *v16; // ebx@22 | |
7256 char v17; // zf@28 | |
7257 int v18; // [sp+10h] [bp-10h]@4 | |
7258 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7259 int v20; // [sp+1Ch] [bp-4h]@4 | |
7260 int v21; // [sp+28h] [bp+8h]@24 | |
7261 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
7262 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7263 | |
7264 if (!uNumSceneBegins || !pTexture) | |
7265 return; | |
7266 | |
7267 v4 = pTexture; | |
7268 | |
7269 if ( pTexture->pPalette16 ) | |
7270 { | |
7271 v5 = pTexture->uTextureHeight; | |
7272 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
7273 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; | |
7274 v20 = pTexture->uTextureWidth; | |
7275 v18 = pTexture->uTextureWidth; | |
7276 int clipped_out_x = a2; | |
7277 int clipped_out_y = a3; | |
7278 if ( this->bClip ) | |
7279 { | |
7280 v7 = this->uClipX; | |
7281 if ( a2 < v7 ) | |
7282 { | |
7283 v8 = v7 - a2; | |
7284 v19 += v8; | |
7285 v20 += a2 - this->uClipX; | |
7286 //v6 += v8; | |
7287 clipped_out_x = uClipX; | |
7288 } | |
7289 v9 = this->uClipY; | |
7290 v5 = pTexture->uTextureHeight; | |
7291 if ( a3 < v9 ) | |
7292 { | |
7293 v10 = v9 - a3; | |
7294 v19 += v18 * v10; | |
7295 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7296 v4 = pTexture; | |
7297 //v6 += this->uTargetSurfacePitch * v10; | |
7298 clipped_out_y = uClipY; | |
7299 } | |
7300 v11 = this->uClipX; | |
7301 if ( v11 < a2 ) | |
7302 v11 = a2; | |
7303 pTexturea = this->uClipZ; | |
7304 if ( v11 + v20 > (signed int)pTexturea ) | |
7305 { | |
7306 v12 = this->uClipX; | |
7307 if ( v12 < a2 ) | |
7308 v12 = a2; | |
7309 v20 = pTexturea - v12; | |
7310 } | |
7311 v13 = this->uClipY; | |
7312 if ( v13 < a3 ) | |
7313 v13 = a3; | |
7314 v14 = this->uClipW; | |
7315 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7316 { | |
7317 v15 = this->uClipY; | |
7318 if ( v15 < a3 ) | |
7319 v15 = a3; | |
7320 v5 = v14 - v15; | |
7321 } | |
7322 } | |
7323 | |
7324 v16 = v19; | |
7325 for (int y = 0; y < v5; ++y) | |
7326 { | |
7327 for (int x = 0; x < v20; ++x) | |
7328 { | |
7329 if ( *v16 ) | |
7330 WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16] & mask); | |
7331 ++v16; | |
7332 } | |
7333 v16 += v18 - v20; | |
7334 } | |
7335 | |
7336 /*if ( (signed int)v5 > 0 ) | |
7337 { | |
7338 v22 = v5; | |
7339 v16 = v19; | |
7340 do | |
7341 { | |
7342 if ( v20 > 0 ) | |
7343 { | |
7344 v21 = v20; | |
7345 do | |
7346 { | |
7347 if ( *v16 ) | |
7348 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7349 ++v6; | |
7350 ++v16; | |
7351 --v21; | |
7352 } | |
7353 while ( v21 ); | |
7354 } | |
7355 v16 += v18 - v20; | |
7356 v17 = v22-- == 1; | |
7357 v6 += this->uTargetSurfacePitch - v20; | |
7358 } | |
7359 while ( !v17 ); | |
7360 }*/ | |
7361 } | |
7362 } | |
7363 | |
0 | 7364 |
7365 //----- (004A65CC) -------------------------------------------------------- | |
7366 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
7367 { | |
2198 | 7368 unsigned int uHeight; // edi@6 |
0 | 7369 unsigned int v14; // edx@11 |
7370 unsigned int v16; // edx@14 | |
7371 unsigned int v17; // edx@17 | |
7372 unsigned int v19; // edx@20 | |
7373 int v20; // eax@27 | |
7374 int v21; // edx@29 | |
7375 int v23; // [sp+Ch] [bp-Ch]@24 | |
7376 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
7377 int xa; // [sp+20h] [bp+8h]@26 | |
7378 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
2198 | 7379 int Width; // [sp+2Ch] [bp+14h]@6 |
0 | 7380 |
7381 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
7382 { | |
710 | 7383 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7384 Width = a4->uTextureWidth; |
7385 uHeight = a4->uTextureHeight; | |
2069 | 7386 int clipped_out_x = x; |
7387 int clipped_out_y = y; | |
0 | 7388 if ( this->bClip ) |
7389 { | |
2198 | 7390 if ( (signed int)x < (signed int)this->uClipX ) |
7391 { | |
7392 v24 += this->uClipX - x; | |
7393 Width += x - this->uClipX; | |
2069 | 7394 clipped_out_x = uClipX; |
0 | 7395 } |
2198 | 7396 if ( (signed int)y < (signed int)this->uClipY ) |
7397 { | |
7398 v24 += a4->uTextureWidth * (this->uClipY - y); | |
7399 uHeight = y - this->uClipY + a4->uTextureHeight; | |
2069 | 7400 clipped_out_y = uClipY; |
0 | 7401 } |
7402 v14 = this->uClipX; | |
2198 | 7403 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7404 v14 = x; |
2198 | 7405 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7406 { |
7407 v16 = this->uClipX; | |
2198 | 7408 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7409 v16 = x; |
2198 | 7410 Width = this->uClipZ - v16; |
0 | 7411 } |
7412 v17 = this->uClipY; | |
2198 | 7413 if ( (signed int)this->uClipY < (signed int)y ) |
0 | 7414 v17 = y; |
2198 | 7415 if ( (signed int)(uHeight + v17) > (signed int)this->uClipW ) |
0 | 7416 { |
7417 v19 = this->uClipY; | |
7418 if ( (signed int)v19 < (signed int)y ) | |
7419 v19 = y; | |
2198 | 7420 uHeight = this->uClipW - v19; |
7421 } | |
7422 } | |
7423 | |
7424 for (int dy = 0; dy < uHeight; ++dy) | |
7425 { | |
7426 for (int dx = 0; dx < Width; ++dx) | |
7427 { | |
7428 v20 = *v24; | |
7429 if ( v20 >= a7 && v20 <= a8 ) | |
7430 { | |
7431 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7432 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7433 v21 = 2 * a8 - v21 - a7; | |
7434 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]); | |
7435 } | |
7436 ++v24; | |
7437 } | |
7438 v24 += a4->uTextureWidth - Width; | |
2069 | 7439 } |
7440 /*if ( (signed int)v9 > 0 ) | |
0 | 7441 { |
7442 ya = v9; | |
7443 v23 = v22 - v27; | |
7444 do | |
7445 { | |
7446 if ( v27 > 0 ) | |
7447 { | |
7448 xa = v27; | |
7449 do | |
7450 { | |
7451 v20 = *v24; | |
7452 if ( v20 >= a7 && v20 <= a8 ) | |
7453 { | |
7454 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7455 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7456 v21 = 2 * a8 - v21 - a7; | |
7457 *v8 = a4->pPalette16[v21]; | |
7458 } | |
7459 ++v8; | |
7460 ++v24; | |
7461 --xa; | |
7462 } | |
7463 while ( xa ); | |
7464 } | |
7465 v8 += this->uTargetSurfacePitch - v27; | |
7466 v24 += v23; | |
7467 --ya; | |
7468 } | |
7469 while ( ya ); | |
2069 | 7470 }*/ |
0 | 7471 } |
7472 } | |
7473 | |
7474 //----- (004A63E6) -------------------------------------------------------- | |
1455 | 7475 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) |
0 | 7476 { |
7477 unsigned int v14; // edx@11 | |
7478 unsigned int v16; // edx@14 | |
7479 unsigned int v17; // edx@17 | |
7480 unsigned int v19; // edx@20 | |
7481 int v20; // eax@27 | |
7482 int v21; // edx@29 | |
7483 int v23; // [sp+Ch] [bp-Ch]@24 | |
2198 | 7484 int Height; // [sp+10h] [bp-8h]@6 |
7485 int Width; // [sp+14h] [bp-4h]@6 | |
0 | 7486 int v27; // [sp+24h] [bp+Ch]@23 |
7487 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
7488 | |
7489 if ( this->uNumSceneBegins ) | |
7490 { | |
7491 if ( a4 ) | |
7492 { | |
7493 if ( a4->pPalette16 ) | |
7494 { | |
7495 if ( a5 ) | |
7496 { | |
7497 if ( a5->pPalette16 ) | |
7498 { | |
710 | 7499 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7500 Width = a4->uTextureWidth; |
7501 Height = a4->uTextureHeight; | |
2069 | 7502 int clipped_out_x = a2; |
7503 int clipped_out_y = a3; | |
0 | 7504 if ( this->bClip ) |
7505 { | |
2198 | 7506 if ( (signed int)a2 < (signed int)this->uClipX ) |
0 | 7507 { |
2198 | 7508 v28 += this->uClipX - a2; |
7509 Width += a2 - this->uClipX; | |
2069 | 7510 clipped_out_x = uClipX; |
0 | 7511 } |
2198 | 7512 |
7513 if ( (signed int)a3 < (signed int)this->uClipY ) | |
0 | 7514 { |
2198 | 7515 v28 += a4->uTextureWidth * (this->uClipY - a3); |
7516 Height += a3 - this->uClipY; | |
2069 | 7517 clipped_out_y = uClipY; |
0 | 7518 } |
2198 | 7519 |
0 | 7520 v14 = this->uClipX; |
2198 | 7521 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7522 v14 = a2; |
2198 | 7523 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7524 { |
7525 v16 = this->uClipX; | |
2198 | 7526 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7527 v16 = a2; |
2198 | 7528 Width = this->uClipZ - v16; |
0 | 7529 } |
2198 | 7530 |
0 | 7531 v17 = this->uClipY; |
2198 | 7532 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7533 v17 = a3; |
2198 | 7534 if ( (signed int)(Height + v17) > (signed int)this->uClipW ) |
0 | 7535 { |
7536 v19 = this->uClipY; | |
2198 | 7537 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7538 v19 = a3; |
2198 | 7539 Height = this->uClipW - v19; |
0 | 7540 } |
7541 } | |
2069 | 7542 |
0 | 7543 v27 = 0; |
2198 | 7544 for (int y = 0; y < Height; ++y) |
2069 | 7545 { |
2198 | 7546 for (int x = 0; x < Width; ++x) |
2069 | 7547 { |
7548 if ( *v28 ) | |
7549 { | |
2101 | 7550 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); |
2069 | 7551 if ( v20 >= a7 ) |
7552 { | |
7553 if ( v20 <= a8 ) | |
7554 { | |
7555 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7556 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7557 v21 = 2 * a8 - v21 - a7; | |
7558 //v9 = a5; | |
7559 //*v10 = a5->pPalette16[v21]; | |
7560 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]); | |
7561 } | |
7562 } | |
7563 } | |
7564 v28++; | |
7565 } | |
2198 | 7566 v28 += a4->uTextureWidth - Width; |
2069 | 7567 } |
7568 | |
7569 /*if ( v24 > 0 ) | |
0 | 7570 { |
7571 v23 = v22 - v25; | |
7572 do | |
7573 { | |
7574 for ( i = 0; i < v25; ++v28 ) | |
7575 { | |
7576 if ( *v28 ) | |
7577 { | |
710 | 7578 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 7579 if ( v20 >= a7 ) |
7580 { | |
7581 if ( v20 <= a8 ) | |
7582 { | |
7583 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7584 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7585 v21 = 2 * a8 - v21 - a7; | |
7586 v9 = a5; | |
7587 *v10 = a5->pPalette16[v21]; | |
7588 } | |
7589 } | |
7590 } | |
7591 ++i; | |
7592 ++v10; | |
7593 } | |
7594 ++v27; | |
7595 v10 += this->uTargetSurfacePitch - v25; | |
7596 v28 += v23; | |
7597 } | |
7598 while ( v27 < v24 ); | |
2069 | 7599 }*/ |
7600 | |
0 | 7601 } |
7602 } | |
7603 } | |
7604 } | |
7605 } | |
7606 } | |
7607 | |
7608 //----- (004A6274) -------------------------------------------------------- | |
7609 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
7610 { | |
7611 int uHeight; // ebx@4 | |
7612 unsigned int v11; // edx@9 | |
7613 unsigned int v12; // esi@12 | |
7614 unsigned int v13; // esi@15 | |
7615 unsigned int v15; // esi@18 | |
7616 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7617 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
7618 | |
7619 if ( this->uNumSceneBegins ) | |
7620 { | |
7621 if ( pTexture ) | |
7622 { | |
7623 if ( pTexture->pPalette16 ) | |
7624 { | |
7625 uHeight = pTexture->uTextureHeight; | |
710 | 7626 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7627 uWidth = pTexture->uTextureWidth; |
2069 | 7628 |
7629 int clipped_out_x = uX; | |
7630 int clipped_out_y = uY; | |
0 | 7631 if ( this->bClip ) |
7632 { | |
2198 | 7633 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 7634 { |
2198 | 7635 v19 += this->uClipX - uX; |
0 | 7636 uWidth += uX - this->uClipX; |
2069 | 7637 clipped_out_x = uClipX; |
0 | 7638 } |
2198 | 7639 |
0 | 7640 uHeight = pTexture->uTextureHeight; |
2198 | 7641 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 7642 { |
2198 | 7643 v19 += pTexture->uTextureWidth * (this->uClipY - uY); |
0 | 7644 uHeight = uY - this->uClipY + pTexture->uTextureHeight; |
2069 | 7645 clipped_out_y = uClipY; |
0 | 7646 } |
7647 v11 = this->uClipX; | |
2198 | 7648 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7649 v11 = uX; |
2198 | 7650 |
7651 if ( (signed int)(v11 + uWidth) > (signed int)this->uClipZ ) | |
0 | 7652 { |
7653 v12 = this->uClipX; | |
2198 | 7654 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7655 v12 = uX; |
2198 | 7656 uWidth = this->uClipZ - v12; |
0 | 7657 } |
7658 v13 = this->uClipY; | |
2198 | 7659 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7660 v13 = uY; |
2198 | 7661 |
7662 if ( (signed int)(uHeight + v13) > (signed int)this->uClipW ) | |
0 | 7663 { |
7664 v15 = this->uClipY; | |
2198 | 7665 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7666 v15 = uY; |
2198 | 7667 uHeight = this->uClipW - v15; |
0 | 7668 } |
7669 } | |
2198 | 7670 |
2069 | 7671 for (int y = 0; y < uHeight; ++y) |
7672 { | |
7673 for (int x = 0; x < uWidth; ++x) | |
7674 { | |
2198 | 7675 if ( *v19 ) |
7676 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); | |
7677 ++v19; | |
2069 | 7678 } |
2198 | 7679 v19 += pTexture->uTextureWidth - uWidth; |
2069 | 7680 } |
7681 /*if ( (signed int)uHeight > 0 ) | |
0 | 7682 { |
7683 uYa = uHeight; | |
7684 v16 = v19; | |
7685 do | |
7686 { | |
7687 if ( uWidth > 0 ) | |
7688 { | |
7689 uXa = uWidth; | |
7690 do | |
7691 { | |
7692 if ( *v16 ) | |
7693 *v6 = pCurrentTexture->pPalette16[*v16]; | |
7694 ++v6; | |
7695 ++v16; | |
7696 } | |
7697 while ( uXa-- !=1 ); | |
7698 } | |
7699 v16 += v18 - uWidth; | |
7700 uFlag = uYa-- == 1; | |
7701 v6 += this->uTargetSurfacePitch - uWidth; | |
7702 } | |
7703 while ( !uFlag ); | |
2069 | 7704 }*/ |
0 | 7705 } |
7706 } | |
7707 } | |
7708 } | |
7709 | |
7710 //----- (004A612A) -------------------------------------------------------- | |
710 | 7711 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 7712 { |
7713 Texture *v5; // eax@2 | |
7714 unsigned int v6; // edx@3 | |
7715 int v7; // ebx@3 | |
7716 int v8; // edi@3 | |
7717 signed int v9; // eax@4 | |
7718 int v10; // eax@5 | |
7719 unsigned int v11; // esi@6 | |
7720 signed int v12; // esi@8 | |
7721 unsigned int v13; // eax@10 | |
7722 signed int v14; // esi@11 | |
7723 unsigned int v15; // esi@14 | |
7724 unsigned int v16; // eax@16 | |
7725 unsigned int v17; // ecx@17 | |
7726 int v18; // edx@23 | |
7727 int v19; // [sp+Ch] [bp-Ch]@3 | |
7728 int v20; // [sp+10h] [bp-8h]@3 | |
7729 int uOutXa; // [sp+20h] [bp+8h]@21 | |
7730 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
7731 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
7732 | |
7733 if ( this->uNumSceneBegins ) | |
7734 { | |
7735 v5 = pTexture; | |
7736 if ( pTexture ) | |
7737 { | |
7738 v6 = uOutY; | |
7739 v7 = pTexture->uTextureHeight; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7740 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; |
710 | 7741 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7742 v8 = v5->uTextureWidth; |
7743 v20 = v5->uTextureWidth; | |
7744 v19 = v5->uTextureWidth; | |
7745 if ( this->bClip ) | |
7746 { | |
7747 v9 = this->uClipX; | |
7748 if ( uOutX < v9 ) | |
7749 { | |
7750 v10 = v9 - uOutX; | |
7751 uOutYa += v10; | |
7752 v8 += uOutX - this->uClipX; | |
7753 v20 = v8; | |
7754 pZBuffer += v10; | |
7755 } | |
7756 v11 = this->uClipY; | |
7757 if ( (signed int)v6 < (signed int)v11 ) | |
7758 { | |
7759 uOutYa += v19 * (v11 - v6); | |
7760 v7 += v6 - v11; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7761 pZBuffer += window->GetWidth() * (v11 - v6); |
0 | 7762 v8 = v20; |
7763 } | |
7764 v12 = this->uClipX; | |
7765 if ( v12 < uOutX ) | |
7766 v12 = uOutX; | |
7767 v13 = this->uClipZ; | |
7768 if ( v8 + v12 > (signed int)v13 ) | |
7769 { | |
7770 v14 = this->uClipX; | |
7771 if ( v14 < uOutX ) | |
7772 v14 = uOutX; | |
7773 v8 = v13 - v14; | |
7774 } | |
7775 v15 = this->uClipY; | |
7776 if ( (signed int)v15 < (signed int)v6 ) | |
7777 v15 = v6; | |
7778 v16 = this->uClipW; | |
7779 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
7780 { | |
7781 v17 = this->uClipY; | |
7782 if ( (signed int)v17 >= (signed int)v6 ) | |
7783 v6 = v17; | |
7784 v7 = v16 - v6; | |
7785 } | |
7786 } | |
7787 if ( v7 > 0 ) | |
7788 { | |
7789 uOutXa = v7; | |
7790 do | |
7791 { | |
7792 if ( v8 > 0 ) | |
7793 { | |
7794 v18 = v8; | |
7795 do | |
7796 { | |
7797 if ( *uOutYa ) | |
7798 *pZBuffer = zVal; | |
7799 ++pZBuffer; | |
7800 ++uOutYa; | |
7801 --v18; | |
7802 } | |
7803 while ( v18 ); | |
7804 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7805 pZBuffer += window->GetWidth() - v8; |
0 | 7806 uOutYa += v19 - v8; |
7807 --uOutXa; | |
7808 } | |
7809 while ( uOutXa ); | |
7810 } | |
7811 } | |
7812 } | |
7813 } | |
7814 | |
7815 //----- (004A601E) -------------------------------------------------------- | |
991 | 7816 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 7817 { |
7818 signed int v5; // edx@3 | |
7819 int v6; // ebx@3 | |
7820 int v7; // esi@3 | |
7821 void *v8; // esi@3 | |
7822 unsigned int v9; // eax@4 | |
7823 unsigned int v10; // eax@6 | |
7824 signed int v11; // edi@8 | |
7825 unsigned int v12; // eax@10 | |
7826 signed int v13; // edi@11 | |
7827 unsigned int v14; // edi@14 | |
7828 unsigned int v15; // eax@16 | |
7829 unsigned int v16; // ecx@17 | |
7830 int v17; // [sp+18h] [bp+Ch]@3 | |
7831 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
7832 | |
7833 if ( this->uNumSceneBegins && pTexture ) | |
7834 { | |
7835 v5 = a3; | |
7836 v6 = pTexture->uTextureHeight; | |
7837 v7 = 5 * a3; | |
7838 v17 = pTexture->uTextureHeight; | |
7839 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
7840 pTexturea = pTexture->uTextureWidth; | |
7841 if ( this->bClip ) | |
7842 { | |
7843 v9 = this->uClipX; | |
7844 if ( a2 < (signed int)v9 ) | |
7845 { | |
7846 pTexturea += a2 - v9; | |
7847 v8 = (char *)v8 + 4 * (v9 - a2); | |
7848 } | |
7849 v10 = this->uClipY; | |
7850 if ( v5 < (signed int)v10 ) | |
7851 { | |
7852 v17 += v5 - v10; | |
7853 v8 = (char *)v8 + 2560 * (v10 - v5); | |
7854 } | |
7855 v11 = this->uClipX; | |
7856 if ( v11 < a2 ) | |
7857 v11 = a2; | |
7858 v12 = this->uClipZ; | |
7859 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
7860 { | |
7861 v13 = this->uClipX; | |
7862 if ( v13 < a2 ) | |
7863 v13 = a2; | |
7864 pTexturea = v12 - v13; | |
7865 } | |
7866 v14 = this->uClipY; | |
7867 if ( (signed int)v14 < v5 ) | |
7868 v14 = v5; | |
7869 v6 = v17; | |
7870 v15 = this->uClipW; | |
7871 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
7872 { | |
7873 v16 = this->uClipY; | |
7874 if ( (signed int)v16 < v5 ) | |
7875 v16 = v5; | |
7876 v6 = v15 - v16; | |
7877 } | |
7878 } | |
7879 if ( v6 > 0 ) | |
7880 { | |
7881 do | |
7882 { | |
7883 if ( (signed int)pTexturea > 0 ) | |
7884 { | |
7885 memset32(v8, a5, pTexturea); | |
7886 v8 = (char *)v8 + 4 * pTexturea; | |
7887 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7888 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea); |
0 | 7889 --v6; |
7890 } | |
7891 while ( v6 ); | |
7892 } | |
7893 } | |
7894 } | |
7895 | |
7896 //----- (004A5EB2) -------------------------------------------------------- | |
7897 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
7898 { | |
2069 | 7899 int v5; // ebx@4 |
0 | 7900 unsigned int v8; // edx@6 |
7901 unsigned int v10; // edx@8 | |
7902 unsigned int v11; // edx@9 | |
7903 unsigned int v12; // esi@12 | |
7904 unsigned int v13; // esi@15 | |
7905 unsigned int v15; // esi@18 | |
7906 char v17; // zf@26 | |
7907 int v18; // [sp+10h] [bp-10h]@4 | |
7908 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7909 int v20; // [sp+1Ch] [bp-4h]@4 | |
7910 int uXa; // [sp+28h] [bp+8h]@24 | |
7911 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
7912 | |
7913 if ( this->uNumSceneBegins ) | |
7914 { | |
7915 if ( a4 ) | |
7916 { | |
7917 if ( a4->pPalette16 ) | |
7918 { | |
7919 v5 = a4->uTextureHeight; | |
2069 | 7920 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
710 | 7921 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7922 v20 = a4->uTextureWidth; |
7923 v18 = a4->uTextureWidth; | |
2069 | 7924 |
7925 int clipped_out_x = uX; | |
7926 int clipped_out_y = uY; | |
0 | 7927 if ( this->bClip ) |
7928 { | |
2198 | 7929 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 7930 { |
2198 | 7931 v8 = this->uClipX - uX; |
0 | 7932 v19 += v8; |
7933 v20 += uX - this->uClipX; | |
2069 | 7934 clipped_out_x = uClipX; |
0 | 7935 } |
2198 | 7936 |
0 | 7937 v5 = a4->uTextureHeight; |
2198 | 7938 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 7939 { |
2198 | 7940 v10 = this->uClipY - uY; |
0 | 7941 v19 += v18 * v10; |
7942 v5 = uY - this->uClipY + a4->uTextureHeight; | |
2198 | 7943 //v4 = a4; |
2069 | 7944 clipped_out_y = uClipY; |
0 | 7945 } |
2198 | 7946 |
0 | 7947 v11 = this->uClipX; |
7948 if ( (signed int)v11 < (signed int)uX ) | |
7949 v11 = uX; | |
2198 | 7950 |
7951 if ( (signed int)(v11 + v20) > (signed int)this->uClipZ ) | |
0 | 7952 { |
7953 v12 = this->uClipX; | |
7954 if ( (signed int)v12 < (signed int)uX ) | |
7955 v12 = uX; | |
2198 | 7956 v20 = this->uClipZ - v12; |
0 | 7957 } |
2198 | 7958 |
0 | 7959 v13 = this->uClipY; |
7960 if ( (signed int)v13 < (signed int)uY ) | |
7961 v13 = uY; | |
2069 | 7962 |
7963 if ( (signed int)(v5 + v13) > (signed int)uClipW ) | |
0 | 7964 { |
7965 v15 = this->uClipY; | |
7966 if ( (signed int)v15 < (signed int)uY ) | |
7967 v15 = uY; | |
2069 | 7968 v5 = uClipW - v15; |
0 | 7969 } |
7970 } | |
2198 | 7971 |
2069 | 7972 for (int y = 0; y < v5; ++y) |
7973 { | |
7974 for (int x = 0; x < v20; ++x) | |
7975 { | |
2198 | 7976 if ( a4->pPalette16[*v19] != 0x7FF )// 2047 |
7977 WritePixel16(clipped_out_x + x, clipped_out_y + y, a4->pPalette16[*v19]); | |
7978 ++v19; | |
2069 | 7979 } |
2198 | 7980 v19 += v18 - v20; |
2069 | 7981 } |
7982 /*if ( (signed int)v5 > 0 ) | |
0 | 7983 { |
7984 uYa = v5; | |
7985 v16 = v19; | |
7986 do | |
7987 { | |
7988 if ( v20 > 0 ) | |
7989 { | |
7990 uXa = v20; | |
7991 do | |
7992 { | |
7993 *pTarget = v4->pPalette16[*v16]; | |
7994 ++pTarget; | |
7995 ++v16; | |
7996 --uXa; | |
7997 } | |
7998 while ( uXa ); | |
7999 } | |
8000 v16 += v18 - v20; | |
8001 v17 = uYa-- == 1; | |
8002 pTarget += this->uTargetSurfacePitch - v20; | |
8003 } | |
8004 while ( !v17 ); | |
2069 | 8005 }*/ |
0 | 8006 } |
8007 } | |
8008 } | |
8009 } | |
8010 | |
8011 //----- (004667E9) -------------------------------------------------------- | |
8012 void Render::ChangeBetweenWinFullscreenModes() | |
8013 { | |
8014 float v0; // ST14_4@17 | |
8015 int v4; // edx@26 | |
8016 ObjectDesc *v5; // eax@26 | |
8017 RGBTexture *v6; // esi@33 | |
8018 const char *v8; // [sp-4h] [bp-28h]@33 | |
8019 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
8020 | |
2061 | 8021 /*if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) |
0 | 8022 { |
1458 | 8023 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 | 8024 return; |
2061 | 8025 }*/ |
2154 | 8026 if ( pRenderer->bWindowMode || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8027 { |
0 | 8028 if ( pEventTimer->bPaused ) |
2061 | 8029 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0800; |
0 | 8030 else |
8031 pEventTimer->Pause(); | |
8032 if ( pMiscTimer->bPaused ) | |
2061 | 8033 dword_6BE364_game_settings_1 |= GAME_SETTINGS_1000; |
0 | 8034 else |
8035 pMiscTimer->Pause(); | |
8036 pMouse->bActive = 0; | |
8037 if ( pRenderer->pRenderD3D ) | |
8038 { | |
8039 pBitmaps_LOD->ReleaseHardwareTextures(); | |
8040 pSprites_LOD->ReleaseAll(); | |
8041 } | |
8042 if ( pRenderer->bWindowMode ) | |
8043 { | |
1802 | 8044 //SetMenu(hWnd, 0); |
8045 //SetWindowLongA(hWnd, -20, 0); | |
8046 //SetWindowLongA(hWnd, -16, 0x10000000u); | |
8047 window->SetFullscreenMode(); | |
8048 pRenderer->InitializeFullscreen(); | |
0 | 8049 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; |
8050 pGame->pGammaController->Initialize(v0); | |
8051 } | |
8052 else | |
8053 { | |
1802 | 8054 //ClipCursor(0); |
8055 window->SetWindowedMode(window->GetWidth(), window->GetHeight()); | |
8056 pRenderer->SwitchToWindow(); | |
0 | 8057 } |
8058 if ( pRenderer->pRenderD3D ) | |
8059 { | |
8060 pBitmaps_LOD->_410423_move_textures_to_device(); | |
8061 pSprites_LOD->MoveSpritesToVideoMemory(); | |
8062 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8063 if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits |
0 | 8064 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8065 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8066 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8067 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8068 pPaletteManager->RecalculateAll(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8069 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8070 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8071 for (int i = 0; i < pObjectList->uNumObjects; i++) |
0 | 8072 { |
8073 BYTE3(v4) = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8074 v5 = &pObjectList->pObjects[i]; |
0 | 8075 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; |
8076 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
8077 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8078 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8079 SetUserInterface(pParty->alignment, true); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8080 if ( pVideoPlayer->pVideoFrame.pPixels ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8081 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); |
2006 | 8082 if ( sCurrentMenuID != MENU_CREATEPARTY ) |
8083 { | |
8084 if ( sCurrentMenuID == MENU_CREDITSPROC ) | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8085 dword_A74C88 = 1; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8086 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8087 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8088 { |
2006 | 8089 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8090 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8091 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8092 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8093 v8 = "makeme.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8094 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8095 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8096 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8097 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8098 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8099 v8 = "title.pcx"; |
2006 | 8100 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8101 v8 = "lsave640.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8102 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8103 v6->Load(v8, 0); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8104 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8105 } |
0 | 8106 viewparams->bRedrawGameUI = 1; |
688 | 8107 viewparams->InitGrayPalette(); |
0 | 8108 pMouse->SetCurrentCursorBitmap(); |
1802 | 8109 /*if ( pRenderer->bWindowMode ) |
0 | 8110 { |
1655 | 8111 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); |
8112 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); | |
1586 | 8113 ShowWindow(hWnd, SW_SHOWNORMAL); |
1802 | 8114 }*/ |
8115 pMouse->bActive = true; | |
0 | 8116 if ( pVideoPlayer->AnyMovieLoaded() ) |
898 | 8117 pVideoPlayer->SelectMovieType(); |
2061 | 8118 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0800) |
8119 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0800; | |
0 | 8120 else |
8121 pEventTimer->Resume(); | |
2061 | 8122 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_1000) |
8123 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_1000; | |
0 | 8124 else |
8125 pMiscTimer->Resume(); | |
8126 } | |
8127 } | |
8128 | |
8129 | |
8130 //----- (004524D8) -------------------------------------------------------- | |
8131 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
8132 { | |
1583 | 8133 //int v11; // eax@13 |
8134 //int v12; // ecx@13 | |
0 | 8135 void *v13; // eax@13 |
1583 | 8136 //unsigned __int8 v14; // zf@13 |
8137 //unsigned __int8 v15; // sf@13 | |
0 | 8138 int v16; // esi@14 |
8139 int v17; // ecx@16 | |
8140 int v18; // esi@16 | |
8141 unsigned __int16 *v19; // eax@16 | |
8142 int v20; // edx@16 | |
8143 int v21; // ecx@16 | |
8144 int v22; // eax@16 | |
8145 int v23; // esi@16 | |
8146 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
8147 int v27; // [sp+28h] [bp-Ch]@14 | |
8148 int v28; // [sp+2Ch] [bp-8h]@13 | |
8149 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
8150 | |
8151 //v3 = this; | |
8152 //sprintf(Str1, "%s", pName); | |
8153 //v4 = uNumItems; | |
8154 if (!uNumItems) | |
8155 return nullptr; | |
8156 | |
8157 //{ | |
8158 //v5 = 0, pDesta = uNumItems; | |
8159 uint idx1 = 0, | |
8160 idx2 = uNumItems; | |
8161 while (true) | |
8162 { | |
1980 | 8163 uint i = idx1 + (idx2 - idx1) / 2; |
8164 | |
8165 int res = _stricmp(pName, pSpriteNames[i]); | |
0 | 8166 if (!res) |
8167 { | |
8168 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
8169 break; | |
8170 } | |
8171 else if (res < 0) | |
8172 idx2 = idx1 + (idx2 - idx1) / 2; | |
8173 else | |
8174 idx1 = i + 1; | |
8175 | |
8176 if ( idx1 >= idx2 ) | |
8177 return false; | |
8178 } | |
8179 | |
8180 | |
8181 uint uCompressedSize = 0; | |
8182 fread(&uCompressedSize, 4, 1, pFile); | |
8183 | |
1980 | 8184 HWLTexture* pTex = new HWLTexture; |
670 | 8185 fread(&pTex->uBufferWidth, 4, 1, pFile); |
8186 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
8187 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
8188 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 8189 fread(&pTex->uWidth, 4, 1, pFile); |
8190 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 8191 fread(&pTex->uAreaX, 4, 1, pFile); |
8192 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 8193 |
8194 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
8195 if (uCompressedSize) | |
8196 { | |
1980 | 8197 char* pCompressedData = new char[uCompressedSize]; |
0 | 8198 { |
8199 fread(pCompressedData, 1, uCompressedSize, pFile); | |
1980 | 8200 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); |
0 | 8201 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); |
8202 } | |
8203 delete [] pCompressedData; | |
8204 } | |
8205 else | |
8206 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
8207 | |
1583 | 8208 if ( scale_hwls_to_half ) |
8209 { | |
8210 pTex->uHeight /= 2; | |
8211 pTex->uWidth /= 2; | |
8212 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
0 | 8213 v28 = 0; |
8214 v26 = (unsigned __int16 *)v13; | |
1583 | 8215 if ( pTex->uHeight > 0 ) |
0 | 8216 { |
8217 v16 = pTex->uWidth; | |
8218 v27 = 1; | |
8219 do | |
8220 { | |
8221 pDestb = 0; | |
8222 if ( v16 > 0 ) | |
8223 { | |
8224 do | |
8225 { | |
8226 v17 = v16 * v27; | |
8227 v18 = v28 * v16; | |
8228 v19 = pTex->pPixels; | |
8229 v20 = pDestb + 2 * v18; | |
8230 v21 = (int)&v19[2 * (pDestb + v17)]; | |
8231 v22 = (int)&v19[2 * v20]; | |
8232 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
8233 LOWORD(v21) = *(unsigned short *)v21; | |
8234 v23 = pDestb++ + v18; | |
1583 | 8235 extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); |
8236 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
0 | 8237 v16 = pTex->uWidth; |
8238 } | |
8239 while (pDestb < pTex->uWidth); | |
8240 } | |
8241 ++v28; | |
8242 v27 += 2; | |
8243 } | |
8244 while ( v28 < (signed int)pTex->uHeight ); | |
8245 } | |
8246 delete [] pTex->pPixels; | |
8247 pTex->pPixels = v26; | |
8248 } | |
8249 return pTex; | |
8250 } | |
8251 | |
8252 //----- (0045271F) -------------------------------------------------------- | |
8253 bool RenderHWLContainer::Release() | |
8254 { | |
8255 __int32 v4; // eax@6 | |
8256 FILE *v5; // ST24_4@6 | |
8257 FILE *File; // [sp+4h] [bp-4h]@6 | |
8258 | |
1162 | 8259 if ( this->bDumpDebug) |
0 | 8260 { |
8261 File = fopen("logd3d.txt", "w"); | |
1162 | 8262 v4 = ftell(this->pFile); |
8263 v5 = this->pFile; | |
8264 this->uDataOffset = v4; | |
8265 fwrite(&this->uNumItems, 4u, 1u, v5); | |
8266 for (int i = 0; i < this->uNumItems; i++) | |
8267 { | |
8268 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
8269 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
8270 } | |
8271 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
8272 fseek(this->pFile, 4, 0); | |
8273 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
8274 fclose(this->pFile); | |
0 | 8275 fclose(File); |
8276 } | |
8277 else | |
8278 { | |
8279 fclose(this->pFile); | |
1162 | 8280 for (int i = 0; i < this->uNumItems; i++) |
8281 { | |
8282 free(this->pSpriteNames[i]); | |
0 | 8283 } |
8284 } | |
1093 | 8285 return true; |
0 | 8286 } |
8287 | |
8288 //----- (00452347) -------------------------------------------------------- | |
8289 RenderHWLContainer::RenderHWLContainer(): | |
8290 bDumpDebug(false) | |
8291 { | |
8292 this->pFile = 0; | |
8293 uSignature = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8294 this->uDataOffset = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8295 memset(&this->uNumItems, 0, 0x61A84u); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8296 this->uNumItems = 0; |
1583 | 8297 this->scale_hwls_to_half = false; |
0 | 8298 } |
8299 | |
8300 //----- (0045237F) -------------------------------------------------------- | |
8301 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
8302 { | |
8303 pFile = _wfopen(pFilename, L"rb"); | |
8304 if (!pFile) | |
8305 { | |
8306 Log::Warning(L"Failed to open file: %s", pFilename); | |
8307 return false; | |
8308 } | |
8309 | |
8310 fread(&uSignature, 1, 4, pFile); | |
8311 if (uSignature != 'TD3D') | |
8312 { | |
8313 Log::Warning(L"Invalid format: %s", pFilename); | |
8314 return false; | |
8315 } | |
8316 | |
8317 fread(&uDataOffset, 4, 1, pFile); | |
8318 fseek(pFile, uDataOffset, SEEK_SET); | |
8319 fread(&uNumItems, 4, 1, pFile); | |
8320 | |
8321 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
8322 for (uint i = 0; i < uNumItems; ++i) | |
8323 { | |
8324 pSpriteNames[i] = new char[20]; | |
8325 fread(pSpriteNames[i], 1, 20, pFile); | |
8326 } | |
8327 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
8328 | |
8329 return true; | |
8330 } | |
8331 | |
8332 //----- (004A1C1E) -------------------------------------------------------- | |
2153 | 8333 void Render::DoRenderBillboards_D3D() |
8334 { | |
8335 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
8336 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8337 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8338 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8339 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8340 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8341 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8342 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8343 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8344 { |
1390 | 8345 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; |
8346 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
8347 } | |
8348 p->pQuads[0].pos.x = 10; | |
8349 p->pQuads[0].pos.y = 10; | |
8350 | |
8351 p->pQuads[1].pos.x = 10; | |
8352 p->pQuads[1].pos.y = 200; | |
8353 | |
8354 p->pQuads[2].pos.x = 100; | |
8355 p->pQuads[2].pos.y = 200; | |
8356 | |
8357 p->pQuads[3].pos.x = 100; | |
8358 p->pQuads[3].pos.y = 10; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8359 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8360 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8361 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8362 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8363 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8364 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8365 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8366 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8367 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8368 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8369 }*/ |
0 | 8370 |
2153 | 8371 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) |
8372 { | |
2155 | 8373 if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend) |
8374 SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity); | |
2114 | 8375 |
2153 | 8376 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture); |
8377 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
8378 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8379 pBillboardRenderListD3D[i].pQuads, pBillboardRenderListD3D[i].uNumVertices, | |
8380 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); | |
8381 } | |
8382 | |
8383 if (bFogEnabled) | |
8384 { | |
8385 bFogEnabled = false; | |
8386 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8387 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8388 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8389 } | |
8390 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
8391 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8392 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8393 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8394 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8395 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8396 } |
8397 | |
8398 //----- (004A1DA8) -------------------------------------------------------- | |
2153 | 8399 void Render::SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) |
0 | 8400 { |
8401 switch (a1) | |
8402 { | |
8403 case RenderBillboardD3D::Transparent: | |
8404 { | |
2153 | 8405 if (bFogEnabled) |
8406 { | |
8407 bFogEnabled = false; | |
8408 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8409 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8410 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8411 } | |
8412 | |
8413 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
8414 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
8415 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8416 } |
8417 break; | |
8418 | |
8419 case RenderBillboardD3D::Opaque_1: | |
8420 case RenderBillboardD3D::Opaque_2: | |
8421 case RenderBillboardD3D::Opaque_3: | |
8422 { | |
2153 | 8423 if (bUsingSpecular) |
8424 { | |
8425 if (!bFogEnabled) | |
0 | 8426 { |
2153 | 8427 bFogEnabled = true; |
8428 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
186 | 8429 } |
8430 } | |
8431 | |
2153 | 8432 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
8433 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8434 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 8435 } |
8436 break; | |
8437 | |
8438 default: | |
8439 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8440 assert(false); |
0 | 8441 break; |
8442 } | |
1787 | 8443 } |
1903 | 8444 //----- (00424CD7) -------------------------------------------------------- |
8445 int ODM_NearClip(unsigned int num_vertices) | |
8446 { | |
8447 bool current_vertices_flag; // edi@1 | |
8448 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 | |
8449 double t; // st6@10 | |
8450 int pNextVertices; | |
8451 | |
8452 if (!num_vertices) | |
8453 return 0; | |
8454 | |
8455 memcpy(&array_50AC10[num_vertices], array_50AC10, sizeof(array_50AC10[0])); | |
8456 current_vertices_flag = 0; | |
8457 if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 ) | |
8458 current_vertices_flag = 1; | |
8459 | |
8460 int out_num_vertices = 0; | |
8461 for (int i = 0; i < num_vertices; ++i) | |
8462 { | |
8463 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= 8.0; | |
8464 if ( current_vertices_flag != next_vertices_flag ) | |
8465 { | |
8466 if ( next_vertices_flag ) | |
8467 { | |
2191 | 8468 //t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) |
1903 | 8469 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
8470 array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; | |
8471 array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; | |
8472 array_507D30[out_num_vertices].u = (array_50AC10[i + 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; | |
8473 array_507D30[out_num_vertices].v = (array_50AC10[i + 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; | |
8474 } | |
8475 else | |
8476 { | |
8477 t = (8.0 - array_50AC10[i + 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); | |
8478 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; | |
8479 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; | |
8480 array_507D30[out_num_vertices].u = (array_50AC10[i].u - array_50AC10[i + 1].u) * t + array_50AC10[i + 1].u; | |
8481 array_507D30[out_num_vertices].v = (array_50AC10[i].v - array_50AC10[i + 1].v) * t + array_50AC10[i + 1].v; | |
8482 } | |
8483 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; | |
8484 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
1904 | 8485 //array_507D30[out_num_vertices]._rhw = 0x3E000000u; |
1903 | 8486 ++out_num_vertices; |
8487 } | |
8488 if ( next_vertices_flag ) | |
8489 { | |
8490 pNextVertices = out_num_vertices++; | |
8491 memcpy(&array_507D30[pNextVertices], &array_50AC10[i + 1], 0x30); | |
8492 } | |
8493 current_vertices_flag = next_vertices_flag; | |
8494 } | |
8495 return out_num_vertices >= 3 ? out_num_vertices : 0; | |
8496 } | |
1787 | 8497 //----- (00424EE0) -------------------------------------------------------- |
1903 | 8498 int ODM_FarClip(unsigned int uNumVertices) |
1787 | 8499 { |
8500 signed int previous_vertices_flag; // edi@1 | |
8501 double t; // st6@10 | |
8502 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 | |
8503 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 | |
8504 int pNextVertices; | |
8505 //Äîï èíôî "Ïðîãðàììèðîâàíèå òð¸õìåðíûõ èãð äëÿ windows" Ëàìîò ñòð 910 | |
8506 | |
8507 memcpy(&array_50AC10[uNumVertices], array_50AC10, sizeof(array_50AC10[uNumVertices])); | |
8508 depth_num_vertices = 0; | |
8509 previous_vertices_flag = 0; | |
8510 if ( array_50AC10[0].vWorldViewPosition.x <= pODMRenderParams->shading_dist_mist ) | |
8511 previous_vertices_flag = 1;//ïðåäûäóùàÿ ãðàíü ìåíüøå ãðàíèöû âèäèìîñòè | |
8512 if ( (signed int)uNumVertices <= 0 ) | |
8513 return 0; | |
8514 for ( uint i = 1; i <= uNumVertices; ++i ) | |
8515 { | |
8516 current_vertices_flag = pODMRenderParams->shading_dist_mist >= array_50AC10[i].vWorldViewPosition.x; | |
8517 if ( previous_vertices_flag != current_vertices_flag )//îäíà èç ãðàíåé çà ãðàíèöåé âèäèìîñòè | |
8518 { | |
8519 if ( current_vertices_flag )//òåêóùàÿ ãðàíü ìåíüøå ãðàíèöû âèäèìîñòè(ïðåäûäóùàÿ ãðàíü çà ïðåäåëàìè âèäèìîñòè) | |
8520 { | |
8521 //t = far_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
8522 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i - 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i - 1].vWorldViewPosition.x); | |
8523 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; | |
8524 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; | |
8525 array_507D30[depth_num_vertices].u = (array_50AC10[i].u - array_50AC10[i - 1].u) * t + array_50AC10[i - 1].u; | |
8526 array_507D30[depth_num_vertices].v = (array_50AC10[i].v - array_50AC10[i - 1].v) * t + array_50AC10[i - 1].v; | |
8527 } | |
8528 else//ïðåäûäóùàÿ ãðàíü ìåíüøå ãðàíèöû âèäèìîñòè(òåêóùàÿ ãðàíü âûøëà çà ïðåäåëû âèäèìîñòè) | |
8529 { | |
8530 //t = far_clip - v1.x / v0.x - v1.x | |
8531 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i - 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); | |
8532 array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i - 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; | |
8533 array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i - 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; | |
8534 array_507D30[depth_num_vertices].u = (array_50AC10[i - 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; | |
8535 array_507D30[depth_num_vertices].v = (array_50AC10[i - 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; | |
8536 } | |
8537 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; | |
8538 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; | |
8539 ++depth_num_vertices; | |
8540 } | |
8541 if ( current_vertices_flag )//îáà â ãðàíèöå âèäèìîñòè | |
8542 { | |
8543 pNextVertices = depth_num_vertices++; | |
8544 memcpy(&array_507D30[pNextVertices], &array_50AC10[i], 0x30); | |
1799 | 8545 //array_507D30[pNextVertices]._rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
8546 //array_507D30[pNextVertices].flt_2C = array_50AC10[i].flt_2C; | |
1787 | 8547 } |
8548 previous_vertices_flag = current_vertices_flag; | |
8549 } | |
8550 if ( depth_num_vertices < 3 ) | |
8551 return 0; | |
8552 return depth_num_vertices; | |
8553 } | |
8554 | |
8555 //----- (0047840D) -------------------------------------------------------- | |
8556 void Render::DrawBuildingsD3D() | |
8557 { | |
8558 int v9; // ecx@8 | |
8559 Texture *pFaceTexture; // eax@10 | |
8560 unsigned int v16; // edi@22 | |
8561 int v27; // eax@57 | |
8562 int vertex_id; // eax@58 | |
8563 unsigned int v34; // eax@80 | |
8564 int v40; // [sp-4h] [bp-5Ch]@2 | |
8565 int v49; // [sp+2Ch] [bp-2Ch]@10 | |
8566 int v50; // [sp+30h] [bp-28h]@34 | |
8567 int v51; // [sp+34h] [bp-24h]@35 | |
8568 int v52; // [sp+38h] [bp-20h]@36 | |
8569 int v53; // [sp+3Ch] [bp-1Ch]@8 | |
8570 int uNumVertices; // [sp+4Ch] [bp-Ch]@34 | |
8571 int unused; // [sp+50h] [bp-8h]@3 | |
8572 | |
8573 if ( !pRenderer->pRenderD3D ) | |
8574 { | |
8575 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); | |
8576 } | |
8577 | |
8578 unused = 0; | |
8579 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
8580 { | |
8581 for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++ ) | |
8582 { | |
8583 if ( IsBModelVisible(model_id, &unused) ) | |
8584 { | |
8585 pOutdoor->pBModels[model_id].field_40 |= 1; | |
8586 if ( pOutdoor->pBModels[model_id].uNumFaces > 0 ) | |
8587 { | |
8588 for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ ) | |
8589 { | |
8590 if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible()) | |
8591 { | |
8592 v53 = 0; | |
8593 array_77EC08[pODMRenderParams->uNumPolygons].flags = 0; | |
8594 array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0; | |
8595 v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID; | |
8596 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME) | |
8597 v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); | |
8598 pFaceTexture = pBitmaps_LOD->GetTexture(v9); | |
8599 array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture; | |
8600 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID) | |
8601 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2; | |
1922 | 8602 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_INDOOR_SKY ) |
1787 | 8603 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
2166 | 8604 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW8 ) |
1787 | 8605 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
8606 else | |
8607 { | |
2166 | 8608 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW9 ) |
1787 | 8609 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8; |
8610 } | |
2166 | 8611 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW10) |
1787 | 8612 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000; |
8613 else | |
8614 { | |
8615 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE) | |
8616 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10u; | |
8617 } | |
8618 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU; | |
8619 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV; | |
8620 v16 = GetTickCount() >> 4; | |
8621 if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 ) | |
8622 { | |
8623 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8624 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8625 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8626 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8627 } | |
8628 else | |
8629 { | |
8630 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8631 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8632 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8633 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8634 } | |
8635 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 ) | |
8636 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8637 else | |
8638 { | |
8639 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 ) | |
8640 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8641 } | |
8642 v50 = 0; | |
8643 v49 = 0; | |
8644 uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8645 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 ) | |
8646 { | |
8647 for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ ) | |
8648 { | |
8649 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; | |
8650 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; | |
8651 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; | |
8652 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); | |
8653 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); | |
8654 } | |
8655 for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ ) | |
8656 { | |
8657 if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z ) | |
8658 ++v53; | |
8659 pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); | |
8660 if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) | |
8661 { | |
8662 if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 ) | |
8663 v49 = 1; | |
8664 else | |
8665 v50 = 1; | |
8666 } | |
8667 else | |
8668 pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); | |
8669 } | |
8670 } | |
8671 if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices ) | |
8672 LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1; | |
8673 array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8674 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8675 array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5; | |
2207 | 8676 v51 = fixpoint_mul(-pOutdoor->vSunlight.x, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x); |
8677 v53 = fixpoint_mul(-pOutdoor->vSunlight.y, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y); | |
8678 v52 = fixpoint_mul(-pOutdoor->vSunlight.z, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z); | |
8679 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - fixpoint_mul(20, v51 + v53 + v52); | |
1787 | 8680 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 ) |
8681 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0; | |
8682 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 ) | |
8683 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31; | |
8684 if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) | |
8685 return; | |
2169 | 8686 if ( ODMFace::IsBackfaceCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) |
1787 | 8687 { |
8688 pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1; | |
8689 array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id; | |
8690 array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id; | |
8691 v27 = 8 * (face_id | (model_id << 6)); | |
8692 LOBYTE(v27) = v27 | 6; | |
8693 array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27; | |
8694 for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id) | |
8695 { | |
8696 memcpy(&array_50AC10[vertex_id], &array_73D150[vertex_id], sizeof(array_50AC10[vertex_id])); | |
8697 array_50AC10[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001); | |
8698 } | |
8699 static stru154 static_RenderBuildingsD3D_stru_73C834; | |
8700 /*static bool __init_flag = false; | |
8701 if (!__init_flag) | |
8702 { | |
8703 __init_flag = true; | |
8704 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; | |
8705 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); | |
8706 atexit(loc_4789D4); | |
8707 }*/ | |
8708 | |
8709 v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8710 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8711 pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8712 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
8713 int v31 = 0; | |
8714 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
8715 { | |
8716 v31 = v50 ? 3 : v49 != 0 ? 5 : 0; | |
8717 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices); | |
8718 if ( pDecalBuilder->uNumDecals > 0 ) | |
8719 { | |
8720 v40 = -1; | |
8721 pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834, | |
8722 pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, array_50AC10, 0, (char)v31, -1); | |
8723 } | |
8724 } | |
8725 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
8726 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); | |
8727 if ( v50 ) | |
8728 { | |
1903 | 8729 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8730 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8731 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8732 } | |
8733 if ( v49 ) | |
8734 { | |
1903 | 8735 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8736 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8737 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8738 } | |
8739 if ( uNumVertices ) | |
8740 { | |
8741 if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 ) | |
8742 { | |
8743 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C ) | |
8744 v34 = pRenderer->pHDWaterBitmapIDs[0]; | |
8745 else | |
8746 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
8747 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; | |
8748 } | |
8749 else | |
8750 v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; | |
8751 pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40); | |
8752 } | |
8753 } | |
8754 } | |
8755 } | |
8756 } | |
8757 } | |
8758 } | |
8759 } | |
8760 return; | |
1911 | 8761 } |
8762 //----- (00479543) -------------------------------------------------------- | |
1923 | 8763 void Render::DrawOutdoorSkyD3D() |
1911 | 8764 { |
8765 int v9; // eax@4 | |
8766 int v10; // ebx@4 | |
8767 int v13; // edi@6 | |
8768 int v14; // ecx@6 | |
8769 int v15; // eax@8 | |
8770 int v16; // eax@12 | |
8771 signed __int64 v17; // qtt@13 | |
8772 signed int v18; // ecx@13 | |
8773 struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1 | |
8774 int v30; // [sp+134h] [bp-30h]@1 | |
8775 int v32; // [sp+13Ch] [bp-28h]@6 | |
8776 int v33; // [sp+140h] [bp-24h]@2 | |
8777 signed __int64 v34; // [sp+144h] [bp-20h]@1 | |
8778 int v35; // [sp+148h] [bp-1Ch]@4 | |
8779 int v36; // [sp+14Ch] [bp-18h]@2 | |
8780 int v37; // [sp+154h] [bp-10h]@8 | |
8781 int v38; // [sp+158h] [bp-Ch]@1 | |
8782 int v39; // [sp+15Ch] [bp-8h]@4 | |
2120 | 8783 |
8784 v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z) | |
1911 | 8785 / ((double)pODMRenderParams->int_fov_rad + 8192.0) |
2119 | 8786 + (double)(pViewport->uScreenCenterY)); |
8787 v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192 | |
2120 | 8788 v38 = (signed __int64)((double)(pViewport->uScreenCenterY) |
1911 | 8789 - (double)pODMRenderParams->int_fov_rad |
8790 / (v34 + 0.0000001) | |
8791 * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) | |
8792 * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist | |
8793 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); | |
8794 pSkyPolygon.Create_48607B(&stru_8019C8);//çàïîëíÿåòñÿ ptr_38 | |
8795 pSkyPolygon.ptr_38->_48694B_frustum_sky(); | |
2006 | 8796 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166) |
8797 pSkyPolygon.pTexture = (Texture *)(SLOWORD(pOutdoor->sSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->sSky_TextureID)] : 0); | |
1911 | 8798 if ( pSkyPolygon.pTexture ) |
8799 { | |
8800 pSkyPolygon.dimming_level = 0; | |
8801 pSkyPolygon.uNumVertices = 4; | |
2119 | 8802 //centering(öåíòðóåì)----------------------------------------------------------------- |
2120 | 8803 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8804 pSkyPolygon.v_18.y = 0; |
2120 | 8805 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8806 |
8807 //sky wiew position(ïîëîæåíèå íåáà íà ýêðàíå)------------------------------------------ | |
8808 // X | |
8809 // 0._____________________________.3 | |
8810 // |8,8 468,8 | | |
8811 // | | | |
8812 // | | | |
8813 // Y| | | |
8814 // | | | |
8815 // |8,351 468,351 | | |
8816 // 1._____________________________.2 | |
8817 // | |
2119 | 8818 array_50AC10[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 |
8819 array_50AC10[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8820 | |
8821 array_50AC10[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 | |
8822 array_50AC10[1].vWorldViewProjY = (double)v38;//247 | |
8823 | |
8824 array_50AC10[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8825 array_50AC10[2].vWorldViewProjY = (double)v38;//247 | |
8826 | |
8827 array_50AC10[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8828 array_50AC10[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8829 | |
8830 pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8831 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8832 | |
8833 pSkyPolygon.field_24 = 0x2000000u;//maybe attributes | |
2120 | 8834 v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2) / tan(0.6457717418670654) + 0.5); |
1911 | 8835 for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i ) |
8836 { | |
8837 //rotate skydome(âðàùåíèå êóïîëà íåáà)-------------------------------------- | |
8838 //  èãðå ïðèíÿòà ñâîÿ ñèñòåìà èçìåðåíèÿ óãëîâ. Ïîëíûé óãîë (180). Çíà÷åíèþ óãëà 0 ñîîòâåòñòâóåò | |
8839 // íàïðàâëåíèå íà ñåâåð è/èëè þã (ëèáî íà âîñòîê è/èëè çàïàä), çíà÷åíèþ 65536 åäåíèöàì(0õ10000) ñîîòâåòñòâóåò óãîë 90. | |
2119 | 8840 // äâå ïåðåìåííûå õðàíÿò äàííûå ïî óãëó îáçîðà. field_14 ïî çàïàäó è âîñòîêó. field_20 ïî þãó è ñåâåðó |
1911 | 8841 // îò -25080 äî 25080 |
2207 | 8842 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8843 v35 = v39 + pSkyPolygon.ptr_38->angle_from_north; |
8844 | |
2207 | 8845 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f))); |
2120 | 8846 v36 = v39 + pSkyPolygon.ptr_38->angle_from_east; |
8847 | |
2207 | 8848 v9 = fixpoint_mul(pSkyPolygon.v_18.z, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8849 v10 = pSkyPolygon.v_18.x + v9; |
2119 | 8850 if ( v10 > 0 ) |
1911 | 8851 v10 = 0; |
2120 | 8852 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX); |
8853 v34 = -pSkyPolygon.field_24; | |
8854 v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0; | |
8855 v14 = v33 * (v30 - v32); | |
1911 | 8856 while ( 1 ) |
8857 { | |
2120 | 8858 if ( v10 ) |
1911 | 8859 { |
2120 | 8860 v37 = abs((int)v34 >> 14); |
8861 v15 = abs(v10); | |
8862 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportTL_Y ) | |
8863 { | |
8864 if ( v10 <= 0 ) | |
8865 break; | |
8866 } | |
1911 | 8867 } |
2207 | 8868 v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14); |
1911 | 8869 --v32; |
8870 v14 += v33; | |
8871 v10 = pSkyPolygon.v_18.x + v16; | |
8872 } | |
8873 LODWORD(v17) = LODWORD(v34) << 16; | |
2120 | 8874 HIDWORD(v17) = v34 >> 16; |
8875 v18 = v17 / v10; | |
1911 | 8876 if ( v18 < 0 ) |
8877 v18 = pODMRenderParams->shading_dist_mist; | |
2207 | 8878 v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v13); |
8879 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v37, v18) >> 3); | |
2120 | 8880 array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0); |
8881 | |
2207 | 8882 v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v13); |
8883 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v36, v18) >> 3); | |
2120 | 8884 array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0); |
2119 | 8885 |
8886 array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192 | |
2120 | 8887 array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16); |
1911 | 8888 } |
1923 | 8889 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
2120 | 8890 array_50AC10[0].vWorldViewProjY = (double)v10; |
1911 | 8891 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; |
8892 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; | |
2120 | 8893 array_50AC10[3].vWorldViewProjY = (double)v10; |
1923 | 8894 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
1911 | 8895 return; |
8896 } | |
1913 | 8897 } |
8898 //----- (004226C2) -------------------------------------------------------- | |
8899 bool PauseGameDrawing() | |
8900 { | |
8901 if ( pCurrentScreen != SCREEN_GAME | |
8902 && pCurrentScreen != SCREEN_NPC_DIALOGUE | |
8903 && pCurrentScreen != SCREEN_CHANGE_LOCATION ) | |
8904 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2135
diff
changeset
|
8905 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
|
8906 return pVideoPlayer->pMovie;//pSmackerMovie != 0; |
1913 | 8907 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) |
8908 return true; | |
8909 } | |
8910 return false; | |
2154 | 8911 } |
8912 | |
8913 | |
8914 //----- (0045E03A) -------------------------------------------------------- | |
8915 unsigned short *Render::MakeScreenshot(signed int width, signed int height) | |
8916 { | |
8917 unsigned __int16 *v3; // ebx@1 | |
8918 int v4; // edx@7 | |
8919 unsigned __int8 v5; // cf@9 | |
8920 unsigned int v6; // ecx@9 | |
8921 unsigned __int16 *v7; // edi@9 | |
8922 int j; // ecx@9 | |
8923 unsigned int screen_x; // qax@18 | |
8924 HRESULT v14; // eax@21 | |
8925 int v15; // edi@29 | |
8926 signed __int64 v16; // qax@30 | |
8927 signed int v17; // edx@34 | |
8928 unsigned __int16 *v18; // edi@36 | |
8929 int k; // ecx@36 | |
8930 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 | |
8931 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 | |
8932 float interval_x; // [sp+84h] [bp-20h]@1 | |
8933 unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 | |
8934 float interval_y; // [sp+8Ch] [bp-18h]@1 | |
8935 unsigned int screen_y; // [sp+90h] [bp-14h]@17 | |
8936 int v28; // [sp+98h] [bp-Ch]@16 | |
8937 int v29; // [sp+9Ch] [bp-8h]@15 | |
8938 | |
8939 interval_x = game_viewport_width / (double)width; | |
8940 interval_y = game_viewport_height / (double)height; | |
8941 | |
8942 pPixels = (unsigned __int16 *)malloc(2 * height * width); | |
8943 memset(pPixels, 0 , 2 * height * width); | |
8944 | |
8945 v3 = pPixels; | |
8946 | |
2182 | 8947 BeginSceneD3D(); |
8948 | |
8949 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
8950 pIndoor->Draw(); | |
8951 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
8952 pOutdoor->Draw(); | |
8953 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
8954 memset(&Dst, 0, 0x7C); | |
8955 Dst.dwSize = sizeof(Dst); | |
8956 | |
8957 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
8958 { | |
8959 for (uint y = 0; y < height; ++y) | |
8960 { | |
8961 for (uint x = 0; x < width; ++x) | |
8962 { | |
8963 //*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 | 8964 /* |
8965 if (ddpfPrimarySuface.dwRGBBitCount == 32) | |
8966 { | |
8967 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
8968 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
8969 } | |
8970 else if (ddpfPrimarySuface.dwRGBBitCount == 16) | |
8971 { | |
8972 auto p = (unsigned __int16 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
8973 *v3 = *p; | |
8974 } | |
8975 */ | |
8976 pRenderer->pTargetSurface; | |
2182 | 8977 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) |
2154 | 8978 { |
2182 | 8979 auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch; |
8980 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
8981 } | |
8982 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) | |
8983 { | |
8984 auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; | |
8985 *v3 = *p; | |
2154 | 8986 } |
2182 | 8987 else __debugbreak(); |
8988 ++v3; | |
8989 } | |
8990 } | |
8991 ErrD3D(pBackBuffer4->Unlock(0)); | |
8992 } | |
8993 else | |
8994 { | |
8995 __debugbreak(); // unrefactored - black screenshot | |
8996 v4 = height; | |
8997 if ( height > 0 ) | |
8998 { | |
8999 do | |
9000 { | |
9001 if ( width > 0 ) | |
2154 | 9002 { |
2182 | 9003 v5 = width & 1; |
9004 v6 = (unsigned int)width / 2; | |
9005 memset(v3, 0, 4 * ((unsigned int)width / 2)); | |
9006 v7 = &v3[2 * v6]; | |
9007 for ( j = v5; j; --j ) | |
2154 | 9008 { |
2182 | 9009 *v7 = 0; |
9010 ++v7; | |
2154 | 9011 } |
2182 | 9012 v3 += width; |
2154 | 9013 } |
2182 | 9014 --v4; |
9015 } | |
9016 while ( v4 ); | |
9017 } | |
9018 } | |
9019 | |
2154 | 9020 /*if (!pRenderer->pRenderD3D) |
9021 { | |
9022 pRenderer->BeginScene(); | |
9023 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
9024 { | |
9025 pIndoor->Draw(); | |
9026 } | |
9027 else | |
9028 { | |
9029 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
9030 pOutdoor->Draw(); | |
9031 } | |
9032 _this = pRenderer->pTargetSurface; | |
9033 v26 = pRenderer->uTargetSurfacePitch; | |
9034 if ( pRenderer->pTargetSurface ) | |
9035 { | |
9036 if ( height > 0 ) | |
9037 { | |
9038 for ( v29 = 0; v29 < height; ++v29 ) | |
9039 { | |
9040 if ( width > 0 ) | |
9041 { | |
9042 v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); | |
9043 for ( v28 = 0; v28 < width; v28++ ) | |
9044 { | |
9045 *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)]; | |
9046 ++v3; | |
9047 } | |
9048 } | |
9049 } | |
9050 } | |
9051 } | |
9052 else | |
9053 { | |
9054 if ( height > 0 ) | |
9055 { | |
9056 for ( v17 = height; v17; --v17 ) | |
9057 { | |
9058 if ( width > 0 ) | |
9059 { | |
9060 memset(v3, 0, 4 * ((unsigned int)width >> 1)); | |
9061 v18 = &v3[2 * ((unsigned int)width >> 1)]; | |
9062 for ( k = width & 1; k; --k ) | |
9063 { | |
9064 *v18 = 0; | |
9065 ++v18; | |
9066 } | |
9067 v3 += width; | |
9068 } | |
9069 } | |
9070 } | |
9071 } | |
9072 pRenderer->EndScene(); | |
9073 }*/ | |
9074 return pPixels; | |
9075 } | |
9076 //----- (0045E26C) -------------------------------------------------------- | |
9077 void Render::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height) | |
9078 { | |
9079 auto pixels = pRenderer->MakeScreenshot(width, height); | |
9080 pRenderer->SavePCXImage(pFilename, pixels, width, height); | |
9081 free(pixels); | |
9082 } | |
9083 | |
9084 void Render::PackScreenshot(unsigned int width, unsigned int height, void *data, unsigned int data_size, unsigned int *out_screenshot_size) | |
9085 { | |
9086 auto pixels = pRenderer->MakeScreenshot(150, 112); | |
9087 pRenderer->PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size); | |
9088 free(pixels); | |
9089 } | |
2155 | 9090 |
9091 | |
9092 //----- (0046A7C8) -------------------------------------------------------- | |
2182 | 9093 int Render::_46À6ÀÑ_GetActorsInViewport(int pDepth) |
9094 { | |
9095 unsigned int v3; // eax@2 ïðèìåíÿåòñÿ â çàêëå Æàð ïå÷è äëÿ ïîäñ÷¸òà êîë-âà ìîíñòðîâ âèäèìûõ ãðóïïå è çàïîëíåíèÿ ìàññèâà id âèäèìûõ ìîíñòðîâ | |
2155 | 9096 unsigned int v5; // eax@2 |
9097 unsigned int v6; // eax@4 | |
9098 unsigned int v12; // [sp+10h] [bp-14h]@1 | |
2182 | 9099 int mon_num; // [sp+1Ch] [bp-8h]@1 |
2155 | 9100 unsigned int a1a; // [sp+20h] [bp-4h]@1 |
9101 | |
2182 | 9102 mon_num = 0; |
2155 | 9103 v12 = GetBillboardDrawListSize(); |
9104 if ( (signed int)GetBillboardDrawListSize() > 0 ) | |
9105 { | |
9106 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) | |
9107 { | |
9108 v3 = GetParentBillboardID(a1a); | |
9109 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; | |
9110 if ( PID_TYPE(v5) == OBJECT_Actor) | |
9111 { | |
2182 | 9112 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) ) |
2155 | 9113 { |
9114 v6 = PID_ID(v5); | |
9115 if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed | |
9116 && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) | |
9117 { | |
2182 | 9118 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) ) |
2155 | 9119 { |
2182 | 9120 if ( mon_num < 100 ) |
2155 | 9121 { |
2182 | 9122 _50BF30_actors_in_viewport_ids[mon_num] = v6; |
9123 mon_num++; | |
2155 | 9124 } |
9125 } | |
9126 } | |
9127 } | |
9128 } | |
9129 } | |
9130 } | |
2182 | 9131 return mon_num; |
2155 | 9132 } |
9133 | |
9134 | |
9135 | |
9136 | |
9137 void Render::BeginLightmaps() | |
9138 { | |
9139 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9140 | |
9141 if (bUsingSpecular) | |
9142 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); | |
9143 | |
9144 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9145 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9146 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9147 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9148 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9149 } | |
9150 | |
9151 void Render::EndLightmaps() | |
9152 { | |
9153 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9154 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9155 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9156 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9157 | |
9158 if (bUsingSpecular) | |
9159 { | |
9160 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9161 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor)); | |
9162 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
9163 } | |
9164 } | |
9165 | |
9166 | |
9167 void Render::BeginLightmaps2() | |
9168 { | |
9169 if (bUsingSpecular) | |
9170 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9171 | |
9172 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9173 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9174 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9175 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9176 | |
9177 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9178 | |
9179 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9180 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9181 } | |
9182 | |
9183 | |
9184 void Render::EndLightmaps2() | |
9185 { | |
9186 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9187 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9188 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9189 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9190 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9191 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9192 | |
9193 if (bUsingSpecular) | |
9194 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9195 } | |
9196 | |
9197 | |
9198 | |
9199 //----- (00437C96) -------------------------------------------------------- | |
9200 void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) | |
9201 { | |
9202 double v6; // st7@2 | |
9203 //IDirect3DDevice3 *v7; // eax@2 | |
9204 HRESULT v8; // eax@2 | |
9205 std::string v9; // [sp-18h] [bp-60h]@3 | |
9206 const char *v10; // [sp-Ch] [bp-54h]@2 | |
9207 const char *v11; // [sp-8h] [bp-50h]@2 | |
9208 int v12; // [sp-4h] [bp-4Ch]@2 | |
9209 RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2 | |
9210 | |
9211 //if ( pRenderer->pRenderD3D ) | |
9212 { | |
9213 v6 = 0.001 - z_stuff; | |
9214 memcpy(v13, pLineBegin, 0x20u); | |
9215 memcpy(&v13[1], pLineEnd, sizeof(v13[1])); | |
9216 v13[0].pos.z = v6; | |
9217 v13[1].pos.z = v6; | |
9218 v13[0].diffuse = sDiffuseBegin; | |
9219 v13[1].diffuse = sDiffuseEnd; | |
9220 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9221 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
9222 D3DPT_LINELIST, | |
9223 452, | |
9224 v13, | |
9225 2, | |
9226 16)); | |
9227 } | |
9228 } | |
9229 | |
9230 | |
9231 void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9232 { | |
9233 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9234 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, | |
9235 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9236 (void *)vertices, | |
9237 num_vertices, | |
9238 D3DDP_DONOTLIGHT)); | |
9239 } | |
9240 | |
9241 | |
9242 void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9243 { | |
9244 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
9245 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); | |
9246 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9247 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9248 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9249 | |
9250 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9251 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9252 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9253 (void *)vertices, | |
9254 num_vertices, | |
9255 28)); | |
9256 | |
9257 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9258 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9259 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9260 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); | |
9261 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9262 } | |
9263 | |
9264 | |
9265 void Render::BeginDecals() | |
9266 { | |
9267 // code chunk from 0049C304 | |
9268 if (bUsingSpecular) | |
9269 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9270 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9271 | |
9272 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9273 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9274 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9275 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9276 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9277 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9278 | |
9279 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); | |
9280 } | |
9281 | |
9282 | |
9283 void Render::EndDecals() | |
9284 { | |
9285 // code chunk from 0049C304 | |
9286 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9287 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9288 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9289 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9290 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9291 | |
9292 if (bUsingSpecular) | |
9293 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9294 } | |
9295 | |
9296 | |
9297 | |
9298 //----- (0049C095) -------------------------------------------------------- | |
9299 void Render::DrawDecal(Decal *pDecal, float z_bias) | |
9300 { | |
9301 signed int v21; // [sp+Ch] [bp-864h]@15 | |
9302 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6 | |
9303 | |
9304 if (pDecal->uNumVertices < 3) | |
9305 { | |
9306 Log::Warning(L"Decal has < 3 vertices"); | |
9307 return; | |
9308 } | |
9309 | |
9310 float color_mult; | |
9311 if ( pDecal->field_C1C & 1 ) | |
9312 color_mult = 1.0; | |
9313 else | |
9314 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time(); | |
9315 | |
9316 for (uint i = 0; i < pDecal->uNumVertices; ++i) | |
9317 { | |
9318 uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr); | |
9319 | |
9320 uint uTintR = (uTint >> 16) & 0xFF, | |
9321 uTintG = (uTint >> 8) & 0xFF, | |
9322 uTintB = uTint & 0xFF; | |
9323 | |
9324 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF, | |
9325 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF, | |
9326 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF; | |
9327 | |
9328 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f), | |
9329 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f), | |
9330 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f); | |
9331 | |
9332 | |
9333 float v15; | |
9334 if (fabs(z_bias) < 1e-5) | |
9335 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); | |
9336 else | |
9337 { | |
9338 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; | |
9339 if (v15 < 0.000099999997) | |
9340 v15 = 0.000099999997; | |
9341 } | |
9342 | |
9343 pVerticesD3D[i].pos.z = v15; | |
9344 | |
9345 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX; | |
9346 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY; | |
9347 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u; | |
9348 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v; | |
9349 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB; | |
9350 pVerticesD3D[i].specular = 0; | |
9351 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x; | |
9352 } | |
9353 | |
9354 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9355 v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; | |
9356 else | |
9357 v21 = D3DDP_DONOTLIGHT; | |
9358 | |
9359 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9360 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9361 pVerticesD3D, | |
9362 pDecal->uNumVertices, | |
9363 v21)); | |
9364 } | |
9365 | |
9366 | |
9367 void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) | |
9368 { | |
9369 ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture)); | |
9370 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9371 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9372 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9373 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9374 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9375 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9376 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
9377 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9378 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9379 (void *)vertices, 4, 28)); | |
9380 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9381 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9382 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9383 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9384 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9385 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
9386 } |