Mercurial > mm7
annotate Render.cpp @ 2356:08c4f1799ca1
Elements of VideoPlayer structure moved
author | Ritor1 |
---|---|
date | Thu, 10 Apr 2014 17:34:50 +0600 |
parents | d6407efaa4ea |
children | 23192f5b41d4 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2245
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
2336 | 2 #include "mm7_unsorted_subs.h" |
3 #include "ErrorHandling.h" | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2245
diff
changeset
|
4 |
2153 | 5 #include "Render.h" |
1277 | 6 #include "Outdoor_stuff.h" |
1016 | 7 #include "VideoPlayer.h" |
8 #include "Sprites.h" | |
9 #include "Mouse.h" | |
10 #include "GammaControl.h" | |
11 #include "stru6.h" | |
1183 | 12 #include "GUIWindow.h" |
1016 | 13 #include "DecalBuilder.h" |
14 #include "ParticleEngine.h" | |
0 | 15 #include "Outdoor.h" |
16 #include "Party.h" | |
17 #include "LOD.h" | |
18 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2016
diff
changeset
|
19 #include "OurMath.h" |
0 | 20 #include "PaletteManager.h" |
2044 | 21 #include "Timer.h" |
0 | 22 #include "Game.h" |
23 #include "LightmapBuilder.h" | |
24 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
25 #include "SpriteObject.h" |
0 | 26 #include "DecorationList.h" |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
27 #include "Actor.h" |
0 | 28 #include "Log.h" |
179 | 29 #include "TileFrameTable.h" |
189 | 30 #include "texts.h" |
0 | 31 #include "mm7_data.h" |
860 | 32 #include "MM7.h" |
1262 | 33 #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
|
34 #include "Level/Decoration.h" |
2155 | 35 #include "Vis.h" |
2341 | 36 #include "Registry.h" |
0 | 37 |
1924
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
38 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") |
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
39 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") |
0 | 40 |
41 struct IDirectDrawClipper *pDDrawClipper; | |
42 struct Render *pRenderer; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
43 struct RenderVertexD3D3 pVertices[50]; |
0 | 44 int uNumDecorationsDrawnThisFrame; // weak |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
45 RenderBillboard pBillboardRenderList[500]; |
0 | 46 unsigned int uNumBillboardsToDraw; |
47 int uNumSpritesDrawnThisFrame; // weak | |
48 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
49 RenderVertexSoft array_507D30[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
50 RenderVertexSoft array_50AC10[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
51 RenderVertexSoft array_73D150[20]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
52 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
53 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 54 |
55 /* 384 */ | |
56 #pragma pack(push, 1) | |
57 struct PCXHeader_1 | |
58 { | |
59 char manufacturer; | |
60 char version; | |
61 char encoding; | |
62 char bpp; | |
63 __int16 left; | |
64 __int16 up; | |
65 __int16 right; | |
66 __int16 bottom; | |
67 __int16 hdpi; | |
68 __int16 vdpi; | |
69 }; | |
70 #pragma pack(pop) | |
71 | |
72 /* 385 */ | |
73 #pragma pack(push, 1) | |
74 struct PCXHeader_2 | |
75 { | |
76 char reserved; | |
77 char planes; | |
78 __int16 pitch; | |
79 __int16 palette_info; | |
80 }; | |
81 #pragma pack(pop) | |
82 | |
83 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
84 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
85 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
86 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
87 | |
88 //----- (0049E79F) -------------------------------------------------------- | |
2154 | 89 bool Render::CheckTextureStages() |
0 | 90 { |
91 bool v0; // edi@1 | |
92 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
93 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
94 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
95 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
96 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
97 | |
98 v0 = false; | |
2154 | 99 pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); |
100 pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
101 | |
102 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
103 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
104 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2)); | |
105 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
106 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
107 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
108 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1)); | |
109 | |
110 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
111 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
112 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1)); | |
113 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7)); | |
114 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2)); | |
115 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1)); | |
116 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2)); | |
117 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2)); | |
118 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1)); | |
119 | |
120 if ( !pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
0 | 121 v0 = true; |
2154 | 122 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); |
0 | 123 pTexture1->Release(); |
124 pTexture2->Release(); | |
125 pSurface1->Release(); | |
126 pSurface2->Release(); | |
127 return v0; | |
128 } | |
129 | |
2002 | 130 |
0 | 131 //----- (00440CB8) -------------------------------------------------------- |
132 void Render::DrawBillboardList_BLV() | |
133 { | |
134 __int16 v2; // ax@3 | |
135 int v5; // eax@11 | |
136 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
137 | |
2002 | 138 soft_billboard.sParentBillboardID = -1; |
0 | 139 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; |
140 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
141 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
142 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
143 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
144 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
145 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
146 | |
1637 | 147 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw; |
617 | 148 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 149 { |
1980 | 150 RenderBillboard* p = &pBillboardRenderList[i]; |
0 | 151 |
152 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
2002 | 153 soft_billboard.sParentBillboardID = i; |
0 | 154 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
155 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
|
156 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 157 soft_billboard.sZValue = p->sZValue; |
158 soft_billboard.uFlags = p->field_1E; | |
2006 | 159 soft_billboard.sTintColor = p->sTintColor; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
160 v2 = p->HwSpriteID; |
0 | 161 if ( v2 != -1 ) |
162 { | |
163 if ( pRenderer->pRenderD3D ) | |
657 | 164 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 165 else |
166 { | |
657 | 167 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 168 if (p->field_1E & 0x0100) |
169 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
170 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
171 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
|
172 v5 = p->HwSpriteID; |
0 | 173 if ( v5 >= 0 ) |
733 | 174 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 175 } |
176 } | |
177 } | |
178 } | |
179 | |
180 //----- (004A16A5) -------------------------------------------------------- | |
2154 | 181 bool Render::AreRenderSurfacesOk() |
182 { | |
183 return pFrontBuffer4 && pBackBuffer4; | |
0 | 184 } |
185 | |
2152 | 186 |
187 //----- (004A19D8) -------------------------------------------------------- | |
188 unsigned int BlendColors(unsigned int a1, unsigned int a2) | |
189 { | |
190 /*signed __int64 v2; // ST10_8@1 | |
191 double v3; // st7@1 | |
192 float v4; // ST24_4@1 | |
193 double v5; // ST10_8@1 | |
194 int v6; // ST1C_4@1 | |
195 float v7; // ST24_4@1 | |
196 double v8; // ST10_8@1 | |
197 unsigned __int8 v9; // ST20_1@1 | |
198 float v10; // ST24_4@1 | |
199 double v11; // ST10_8@1 | |
200 float v12; // ST24_4@1 | |
201 double v13; // ST08_8@1*/ | |
202 | |
203 uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f * | |
204 (a2 >> 24) / 255.0f * 255.0f), | |
205 red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f * | |
206 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f), | |
207 green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f * | |
208 ((a2 >> 8) & 0xFF) / 255.0f * 255.0f), | |
209 blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f * | |
210 ((a2 >> 0) & 0xFF) / 255.0f * 255.0f); | |
211 return (alpha << 24) | (red << 16) | (green << 8) | blue; | |
212 /*v2 = a1 >> 24; | |
213 v3 = (double)v2 / 255.0f; | |
214 HIDWORD(v2) = 0; | |
215 LODWORD(v2) = a2 >> 24; | |
216 v4 = v3 * (double)v2 / 255.0f * 255.0; | |
217 v5 = v4 + 6.7553994e15; | |
218 v6 = LODWORD(v5); | |
219 v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0; | |
220 v8 = v7 + 6.7553994e15; | |
221 v9 = LOBYTE(v8); | |
222 v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0; | |
223 v11 = v10 + 6.7553994e15; | |
224 v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0; | |
225 v13 = v12 + 6.7553994e15; | |
226 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ | |
227 } | |
228 | |
229 | |
1338 | 230 void Render::RenderTerrainD3D() // New function |
86 | 231 { |
232 int v6; // ecx@8 | |
1427 | 233 struct Polygon *pTilePolygon; // ebx@8 |
2334 | 234 // float Light_tile_dist; |
186 | 235 |
236 //warning: the game uses CW culling by default, ccw is incosistent | |
237 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
238 | |
1338 | 239 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ |
240 | |
241 //Ãåíåðàöèÿ ìåñòîïîëîæåíèÿ âåðøèí------------------------------------------------------------------------- | |
242 //ðåø¸òêà âåðøèí äåëèòñÿ íà äâå ÷àñòè îò -64 äî 0 è îò 0 äî 64 | |
243 // | |
244 // -64 X 0 64 | |
245 // --------------- 64 | |
246 // | | | | |
247 // | | | | |
248 // | | | | |
249 // 0|------+------| Z | |
250 // | | | | |
251 // | | | | |
252 // | | | | |
253 // --------------- | |
254 // -64 | |
255 | |
256 int blockScale = 512; | |
257 int heightScale = 32; | |
258 for (unsigned int z = 0; z < 128; ++z) | |
259 { | |
260 for (unsigned int x = 0; x < 128; ++x) | |
261 { | |
262 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
263 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
264 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 265 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
266 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 267 } |
268 } | |
2318 | 269 //-------(Îòñå÷åíèå íåâèäèìîé ÷àñòè êàðòû)------------------------------------------------------------------------------------------ |
270 float direction = pGame->pIndoorCameraD3D->sRotationY / 256;//direction of the camera(íàïðâëåíèå êàìåðû) | |
2316 | 271 //0-East(B) |
272 //1-NorthEast(CB) | |
273 //2-North(C) | |
274 //3-WestNorth(CÇ) | |
275 //4-West(Ç) | |
276 //5-SouthWest(ÞÇ) | |
277 //6-South(Þ) | |
278 //7-SouthEast(ÞÂ) | |
279 int Start_X, End_X, Start_Z, End_Z; | |
2318 | 280 if ( direction >= 0 && direction < 1.0 )//East(B) - NorthEast(CB) |
281 { | |
2321 | 282 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127; |
2318 | 283 Start_Z = 0, End_Z = 127; |
284 } | |
285 else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CÇ) | |
286 { | |
2316 | 287 Start_X = 0, End_X = 127; |
2321 | 288 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ + 1; |
2318 | 289 } |
290 else if (direction >= 3.0 && direction < 5.0)//WestNorth(CÇ) - SouthWest(ÞÇ) | |
291 { | |
2322 | 292 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 2; |
2318 | 293 Start_Z = 0, End_Z = 127; |
294 } | |
295 else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ÞÇ) - //SouthEast(ÞÂ) | |
296 { | |
297 Start_X = 0, End_X = 127; | |
2321 | 298 Start_Z = pODMRenderParams->uMapGridCellZ - 2, End_Z = 127; |
2318 | 299 } |
300 else//SouthEast(ÞÂ) - East(B) | |
301 { | |
2321 | 302 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127; |
2318 | 303 Start_Z = 0, End_Z = 127; |
2316 | 304 } |
305 for (unsigned int z = Start_Z; z < End_Z; ++z) | |
306 { | |
307 for (unsigned int x = Start_X; x < End_X; ++x) | |
1338 | 308 { |
1637 | 309 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; |
1427 | 310 pTilePolygon->flags = 0; |
311 pTilePolygon->field_32 = 0; | |
312 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
313 pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; | |
314 if (pTilePolygon->uTileBitmapID == 0xFFFF) | |
106 | 315 continue; |
186 | 316 |
1338 | 317 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1427 | 318 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); |
319 pTilePolygon->field_32 = 0; | |
320 pTilePolygon->field_59 = 1; | |
321 pTilePolygon->sTextureDeltaU = 0; | |
322 pTilePolygon->sTextureDeltaV = 0; | |
1338 | 323 // x,z x+1,z |
324 // .____________. | |
325 // | | | |
326 // | | | |
327 // | | | |
328 // | | | |
329 // | | | |
330 // .____________. | |
331 // x,z+1 x+1,z+1 | |
332 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
106 | 333 array_73D150[0].u = 0; |
334 array_73D150[0].v = 0; | |
1338 | 335 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z |
106 | 336 array_73D150[1].u = 1; |
337 array_73D150[1].v = 0; | |
1338 | 338 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 |
106 | 339 array_73D150[2].u = 1; |
340 array_73D150[2].v = 1; | |
1338 | 341 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 |
106 | 342 array_73D150[3].u = 0; |
343 array_73D150[3].v = 1; | |
1338 | 344 //v58 = 0; |
345 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
346 //pTile->field_32 |= 0x0001; | |
1427 | 347 pTilePolygon->pODMFace = nullptr; |
348 pTilePolygon->uNumVertices = 4; | |
349 pTilePolygon->field_59 = 5; | |
1338 | 350 |
351 //shading (çàòåíåíèå)---------------------------------------------------------------------------- | |
352 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
1424 | 353 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; |
638 | 354 assert(norm_idx < uNumTerrainNormals); |
355 | |
1980 | 356 Vec3_float_* norm = &pTerrainNormals[norm_idx]; |
1338 | 357 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
358 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
359 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
1427 | 360 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); |
2274 | 361 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 ) |
362 norm = 0; | |
363 else | |
364 norm = &pTerrainNormals[norm_idx]; | |
2322 | 365 //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows |
366 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1); | |
367 //unsigned int a5 = 4; | |
368 //---------------------------------------------------------------------------- | |
638 | 369 |
1637 | 370 ++pODMRenderParams->uNumPolygons; |
371 ++pODMRenderParams->field_44; | |
372 assert(pODMRenderParams->uNumPolygons < 20000); | |
265 | 373 |
1427 | 374 pTilePolygon->uBModelID = 0; |
375 pTilePolygon->uBModelFaceID = 0; | |
376 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
377 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
106 | 378 { |
379 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 380 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 381 } |
2318 | 382 //---------Draw distance(Äàëüíîñòü îòðèñîâêè)------------------------------- |
2320 | 383 int temp = pODMRenderParams->shading_dist_mist; |
384 if ( draw_terrain_dist_mist ) | |
385 pODMRenderParams->shading_dist_mist = 0x5000; | |
2318 | 386 bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0 |
387 || array_73D150[1].vWorldViewPosition.x < 8.0 | |
388 || array_73D150[2].vWorldViewPosition.x < 8.0 | |
389 || array_73D150[3].vWorldViewPosition.x < 8.0; | |
390 bool far_clip = (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x | |
391 || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x | |
392 || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x | |
393 || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x; | |
2322 | 394 |
395 /* int v33 = 0; | |
396 static stru154 static_sub_0048034E_stru_154; | |
397 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
398 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
399 { | |
400 if ( neer_clip ) | |
401 v33 = 3; | |
402 else | |
403 v33 = far_clip != 0 ? 5 : 0; | |
404 static_sub_0048034E_stru_154.ClassifyPolygon(norm, Light_tile_dist); | |
405 if ( pDecalBuilder->uNumDecals > 0 ) | |
406 pDecalBuilder->ApplyDecals(31 - pTilePolygon->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); | |
407 } | |
408 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
409 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);*/ | |
410 | |
2318 | 411 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) |
412 { | |
2321 | 413 //if ( neer_clip ) //Ritor1: Äà¸ò èñêàæåíèÿ íà ïîäú¸ìå, âîçìîæíî òðåáóåòñÿ ô-öèÿ Áåçüå |
414 //{ | |
415 // pTilePolygon->uNumVertices = ODM_NearClip(pTilePolygon->uNumVertices); | |
416 // ODM_Project(pTilePolygon->uNumVertices); | |
417 //} | |
2318 | 418 if ( far_clip ) |
419 { | |
420 pTilePolygon->uNumVertices = ODM_FarClip(pTilePolygon->uNumVertices); | |
2320 | 421 ODM_Project(pTilePolygon->uNumVertices); |
2318 | 422 } |
423 } | |
2320 | 424 pODMRenderParams->shading_dist_mist = temp; |
140 | 425 |
1338 | 426 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))---------------------- |
186 | 427 bool transparent = false; |
1427 | 428 if ( !( pTilePolygon->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable |
429 { | |
430 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id) | |
1338 | 431 { |
432 //transparent = false; | |
433 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
434 } | |
435 else | |
436 { | |
1427 | 437 v6 = pTilePolygon->uTileBitmapID; |
438 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) ) | |
1338 | 439 transparent = true; |
440 } | |
179 | 441 |
140 | 442 assert(v6 < 1000); // many random crashes here |
186 | 443 |
444 // for all shore tiles - draw a tile water under them since they're half-empty | |
1427 | 445 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX |
2153 | 446 DrawBorderTiles(pTilePolygon); |
1427 | 447 |
448 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1338 | 449 } |
450 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû | |
451 //pTile->DrawBorderTiles(); | |
452 //-------------------------------------------------------------------------------------------------------------------------------- | |
186 | 453 |
1637 | 454 --pODMRenderParams->uNumPolygons; |
455 --pODMRenderParams->field_44; | |
106 | 456 } |
457 } | |
458 } | |
0 | 459 |
2153 | 460 //----- (004811A3) -------------------------------------------------------- |
461 void Render::DrawBorderTiles(struct Polygon *poly) | |
462 { | |
463 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); | |
464 DrawTerrainPolygon(poly->uNumVertices, poly, | |
465 pBitmaps_LOD->pHardwareTextures[pHDWaterBitmapIDs[hd_water_current_frame]], false, true); | |
466 | |
467 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); | |
468 //DrawTerrainPolygon(poly->uNumVertices, poly, pBitmaps_LOD->pHardwareTextures[poly->uTileBitmapID], true, true); | |
469 } | |
470 | |
0 | 471 |
472 //----- (0047BACF) -------------------------------------------------------- | |
473 void Render::TransformBillboardsAndSetPalettesODM() | |
474 { | |
142 | 475 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
476 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
477 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
478 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
479 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
480 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
481 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
482 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
483 //int v8; // ebx@4 |
2334 | 484 // unsigned __int16 *v9; // eax@7 |
485 // char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
486 //DWORD v11; // eax@13 |
2334 | 487 // int v12; // eax@13 |
488 // int v13; // eax@14 | |
0 | 489 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 |
2334 | 490 // int v15; // [sp+54h] [bp-10h]@13 |
142 | 491 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
492 //int v17; // [sp+5Ch] [bp-8h]@2 |
2334 | 493 // int v18; // [sp+60h] [bp-4h]@13 |
0 | 494 |
2002 | 495 billboard.sParentBillboardID = -1; |
0 | 496 billboard.pTarget = pRenderer->pTargetSurface; |
497 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
498 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 499 billboard.uViewportX = pViewport->uViewportTL_X; |
500 billboard.uViewportY = pViewport->uViewportTL_Y; | |
501 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
502 billboard.uViewportW = pViewport->uViewportBR_Y; | |
1637 | 503 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw; |
142 | 504 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
505 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 506 { |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
507 billboard.uScreenSpaceX = pBillboardRenderList[i].uScreenSpaceX; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
508 billboard.uScreenSpaceY = pBillboardRenderList[i].uScreenSpaceY; |
2002 | 509 billboard.sParentBillboardID = i; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
510 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
|
511 billboard.sTintColor = pBillboardRenderList[i].sTintColor; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
512 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
|
513 billboard.sZValue = pBillboardRenderList[i].sZValue; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
514 billboard.uFlags = pBillboardRenderList[i].field_1E; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
515 if (pBillboardRenderList[i].HwSpriteID != -1) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
516 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
517 if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
518 //if (pRenderer->pRenderD3D) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
519 pRenderer->TransformBillboard(&billboard, |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
520 &pSprites_LOD->pHardwareSprites[pBillboardRenderList[i].HwSpriteID], |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
521 pBillboardRenderList[i].dimming_level, &pBillboardRenderList[i]); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
522 /*else |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
523 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
524 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
525 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
526 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 527 if ( *(v1 - 10) & 2 ) |
528 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
529 else | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
530 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 531 v10 = (*(v1 - 9) & 1) == 0; |
532 billboard.pPalette = v9; | |
533 if ( !v10 ) | |
534 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
535 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
536 { | |
323 | 537 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 538 v15 = abs(v12); |
539 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
540 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
541 } | |
542 v13 = *((short *)v1 - 8); | |
543 if ( v13 >= 0 ) | |
733 | 544 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
545 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
546 } |
0 | 547 } |
548 } | |
549 | |
550 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
551 void Render::DrawSpriteObjects_ODM() |
0 | 552 { |
2206 | 553 SpriteFrame *frame; // eax@10 |
0 | 554 unsigned int v6; // eax@10 |
555 int v9; // ecx@10 | |
556 int v17; // ecx@25 | |
557 int v18; // eax@25 | |
2334 | 558 // int v22; // ST3C_4@29 |
0 | 559 signed __int64 v23; // qtt@30 |
560 int v26; // eax@31 | |
2334 | 561 // char v27; // zf@31 |
0 | 562 int v30; // [sp+14h] [bp-2Ch]@23 |
563 int v37; // [sp+1Ch] [bp-24h]@23 | |
564 int a6; // [sp+20h] [bp-20h]@10 | |
565 int v42; // [sp+2Ch] [bp-14h]@23 | |
566 int y; // [sp+30h] [bp-10h]@10 | |
567 int x; // [sp+34h] [bp-Ch]@10 | |
568 int z; // [sp+38h] [bp-8h]@10 | |
569 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
570 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
571 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
572 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
|
573 { |
1980 | 574 SpriteObject* object = &pSpriteObjects[i]; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
575 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
576 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
577 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
578 //{ |
430 | 579 if (!object->uObjectDescID) // item probably pciked up |
580 continue; | |
581 | |
582 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
1980 | 583 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID]; |
430 | 584 if (object_desc->NoSprite()) |
585 continue; | |
586 | |
587 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
588 //if ( !(v1->uFlags & 1) ) | |
589 //{ | |
590 //v2 = *((short *)v0 - 14) | |
2206 | 591 //v2 = object->uType; |
592 if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600) | |
593 || pGame->pStru6Instance->_4A81CA(object) ) | |
430 | 594 { |
595 //a5 = *(short *)v0; | |
596 x = object->vPosition.x; | |
597 y = object->vPosition.y; | |
598 z = object->vPosition.z; | |
2206 | 599 frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); |
600 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
|
601 v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
430 | 602 //LOWORD(v7) = object->uFacing; |
603 //v8 = v36; | |
2206 | 604 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
|
605 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[v9]; |
2206 | 606 if ( frame->uFlags & 0x20 ) |
607 { | |
608 //v8 = v36; | |
609 z -= fixpoint_mul(frame->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)frame->pHwSpriteIDs[v9]].uHeight) / 2; | |
610 } | |
611 v46 = 0; | |
612 if ( frame->uFlags & 2 ) | |
613 v46 = 2; | |
614 //v11 = (int *)(256 << v9); | |
615 if ( (256 << v9) & frame->uFlags ) | |
616 v46 |= 4u; | |
617 if ( frame->uFlags & 0x40000 ) | |
618 v46 |= 0x40u; | |
619 if ( frame->uFlags & 0x20000 ) | |
620 LOBYTE(v46) = v46 | 0x80; | |
621 if ( a6 ) | |
622 { | |
623 //LOBYTE(v11) = _4E94D3_light_type; | |
624 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type); | |
625 } | |
626 if (pGame->pIndoorCameraD3D->sRotationX) | |
627 { | |
628 v30 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
629 + fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
630 v37 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
631 v42 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x) | |
632 + fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_cosine_x); | |
633 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
634 { | |
635 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - v37; | |
636 v18 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) | |
637 - fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_sine_x); | |
638 if ( abs(v42) >= abs(v17) ) | |
639 { | |
640 LODWORD(v23) = 0; | |
641 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
642 | |
643 object->uAttributes |= 1; | |
644 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
645 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
646 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
647 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
648 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
649 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
650 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
651 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
652 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
653 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
654 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
655 HIWORD(v26) = HIWORD(v42); | |
656 LOWORD(v26) = 0; | |
657 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
658 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
659 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
660 if ( !(object->uAttributes & 0x20) ) | |
0 | 661 { |
2206 | 662 if ( !pRenderer->pRenderD3D ) |
663 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
0 | 664 } |
2206 | 665 //if (::uNumBillboardsToDraw >= 500) |
666 // return; | |
667 assert(::uNumBillboardsToDraw < 500); | |
668 ++::uNumBillboardsToDraw; | |
669 ++uNumSpritesDrawnThisFrame; | |
0 | 670 } |
2206 | 671 } |
672 } | |
673 else | |
674 { | |
675 v42 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y) | |
676 + fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y); | |
677 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
678 { | |
679 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
680 - fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y); | |
681 v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; | |
682 if ( abs(v42) >= abs(v17) ) | |
683 { | |
684 LODWORD(v23) = 0; | |
685 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
686 | |
687 object->uAttributes |= 1; | |
688 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
689 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
690 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
691 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
692 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
693 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
694 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
695 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
696 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
697 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
698 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
699 HIWORD(v26) = HIWORD(v42); | |
700 LOWORD(v26) = 0; | |
701 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
702 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
703 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
704 if ( !(object->uAttributes & 0x20) ) | |
705 { | |
706 if ( !pRenderer->pRenderD3D ) | |
707 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
708 } | |
709 //if (::uNumBillboardsToDraw >= 500) | |
710 // return; | |
711 assert(::uNumBillboardsToDraw < 500); | |
712 ++::uNumBillboardsToDraw; | |
713 ++uNumSpritesDrawnThisFrame; | |
714 } | |
715 } | |
716 } | |
717 } | |
0 | 718 } |
719 } | |
720 | |
721 //----- (0049D9BC) -------------------------------------------------------- | |
722 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
723 { | |
724 size_t v4; // eax@1 | |
725 size_t v5; // eax@1 | |
726 IUnknown *v6; // eax@10 | |
727 size_t v7; // eax@13 | |
728 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
729 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
730 int v11; // [sp+430h] [bp-CCh]@16 | |
731 int v12; // [sp+434h] [bp-C8h]@16 | |
732 int v13; // [sp+438h] [bp-C4h]@16 | |
733 int v14; // [sp+474h] [bp-88h]@16*/ | |
734 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
735 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
736 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
737 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
738 int v19; // [sp+4C8h] [bp-34h]@16 | |
739 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
740 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
741 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
742 | |
743 v4 = strlen(lpDriverName); | |
744 v20.pDriverName = new char[v4 + 1]; | |
745 v5 = strlen(lpDevDesc); | |
746 v20.pDeviceDesc = new char[v5 + 1]; | |
747 strcpy(v20.pDriverName, lpDriverName); | |
748 strcpy(v20.pDeviceDesc, lpDevDesc); | |
749 if ( lpGUID ) | |
750 { | |
751 v20.pGUID = new GUID; | |
752 memcpy(v20.pGUID, lpGUID, 0x10u); | |
753 } | |
754 else | |
755 v20.pGUID = 0; | |
756 | |
757 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
758 { | |
759 delete [] v20.pDriverName; | |
760 delete [] v20.pDeviceDesc; | |
761 if ( v20.pGUID ) | |
762 delete v20.pGUID; | |
763 } | |
764 else | |
765 { | |
766 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
767 { | |
768 delete [] v20.pDriverName; | |
769 delete [] v20.pDeviceDesc; | |
770 if ( v20.pGUID ) | |
771 delete v20.pGUID; | |
772 v6 = (IUnknown *)pDirectDraw; | |
773 } | |
774 else | |
775 { | |
776 pDirectDraw->Release(); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
777 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1))) |
0 | 778 v20.pDDraw4DevDesc = 0; |
779 else | |
780 { | |
781 v7 = strlen(ddDevId.szDescription); | |
782 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
783 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
784 } | |
785 memset(&ddsCaps, 0, 0x10u); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
786 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem))) |
0 | 787 v20.uVideoMem = 0; |
788 memset(&v10, 0, 0x7Cu); | |
789 v10.dwSize = 124; | |
790 v10.dwFlags = 6; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
791 v10.dwHeight = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
792 v10.dwWidth = window->GetHeight(); |
0 | 793 v10.ddpfPixelFormat.dwSize = 32; |
794 | |
795 v19 = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
796 if ( FAILED(pDirectDraw4->EnumDisplayModes(0, 0, &v19, (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) |
0 | 797 || !v19 |
798 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
799 { | |
800 delete [] v20.pDriverName; | |
801 delete [] v20.pDeviceDesc; | |
802 if ( v20.pDDraw4DevDesc ) | |
803 free(v20.pDDraw4DevDesc); | |
804 if ( v20.pGUID ) | |
805 delete v20.pGUID; | |
806 v6 = (IUnknown *)pDirectDraw4; | |
807 } | |
808 else | |
809 { | |
810 aux.pInfo = pOut; | |
811 aux.ptr_4 = &v20; | |
812 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
813 delete [] v20.pDriverName; | |
814 delete [] v20.pDeviceDesc; | |
815 if ( v20.pDDraw4DevDesc ) | |
816 free(v20.pDDraw4DevDesc); | |
817 if ( v20.pGUID ) | |
818 delete v20.pGUID; | |
819 pDirectDraw4->Release(); | |
820 v6 = (IUnknown *)pDirect3D3; | |
821 pDirectDraw4 = 0; | |
822 } | |
823 } | |
824 v6->Release(); | |
825 } | |
826 return 1; | |
827 } | |
828 | |
829 //----- (0049D784) -------------------------------------------------------- | |
830 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
831 { | |
832 int v6; // eax@1 | |
833 signed int v7; // edi@1 | |
834 signed int v8; // edi@14 | |
835 size_t v9; // eax@30 | |
836 size_t v10; // eax@30 | |
837 size_t v11; // eax@30 | |
838 size_t v12; // eax@30 | |
839 size_t v13; // eax@30 | |
840 | |
841 v6 = pHWDesc->dwFlags; | |
842 v7 = -1; | |
843 if ( v6 ) | |
844 { | |
845 if ( !a6->ptr_4->pGUID ) | |
846 v7 = 0; | |
847 if ( v6 && a6->ptr_4->pGUID ) | |
848 v7 = 1; | |
849 } | |
850 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
851 v7 = 2; | |
852 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
853 v7 = 3; | |
854 if ( v7 != -1 ) | |
855 { | |
856 v8 = v7; | |
857 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
858 a6->pInfo[v8].uCaps = 0; | |
859 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
860 a6->pInfo[v8].uCaps |= 2u; | |
861 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
862 a6->pInfo[v8].uCaps |= 4u; | |
863 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
864 a6->pInfo[v8].uCaps |= 8u; | |
865 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
866 a6->pInfo[v8].uCaps |= 0x10u; | |
867 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
868 a6->pInfo[v8].uCaps |= 0x20u; | |
869 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
870 a6->pInfo[v8].uCaps |= 0x40u; | |
871 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
872 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
873 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
874 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
875 v9 = strlen(lpDeviceName); | |
876 a6->pInfo[v8].pName = new char[v9 + 1]; | |
877 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
878 v10 = strlen(lpDeviceDesc); | |
879 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
880 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
1631 | 881 a6->pInfo[v8].pGUID = new GUID; |
0 | 882 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); |
883 v11 = strlen(a6->ptr_4->pDriverName); | |
884 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
885 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
886 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
887 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
888 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
889 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
890 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
891 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
892 if ( a6->ptr_4->pGUID ) | |
893 { | |
894 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
895 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
896 } | |
897 else | |
898 { | |
899 a6->pInfo[v8].pDirectDrawGUID = 0; | |
900 } | |
901 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
902 } | |
903 return 1; | |
904 } | |
905 | |
906 //----- (0049D75C) -------------------------------------------------------- | |
907 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
908 { | |
909 HRESULT result; // eax@3 | |
910 | |
911 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
912 { | |
913 *a2 = 1; | |
914 result = 0; | |
915 } | |
916 else | |
917 result = 1; | |
918 return result; | |
919 } | |
920 | |
921 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
922 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
923 { |
0 | 924 unsigned int v6; // edi@9 |
925 int v7; // eax@9 | |
926 SpriteFrame *v8; // eax@9 | |
927 unsigned __int16 *v10; // eax@9 | |
928 int v13; // ecx@9 | |
929 int v14; // ecx@20 | |
930 char v15; // dl@20 | |
931 signed int v16; // eax@20 | |
932 int v17; // eax@23 | |
933 int v18; // ecx@24 | |
934 int v19; // eax@24 | |
935 int v20; // ecx@24 | |
936 int v21; // ebx@26 | |
937 int v22; // eax@26 | |
938 signed __int64 v24; // qtt@31 | |
939 int v25; // ebx@31 | |
940 __int16 v29; // cx@37 | |
941 int v30; // ecx@37 | |
942 int v31; // ebx@37 | |
619 | 943 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
0 | 944 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
945 int v38; // [sp+88h] [bp-1Ch]@9 | |
946 int v40; // [sp+90h] [bp-14h]@24 | |
947 int v41; // [sp+94h] [bp-10h]@24 | |
948 int v42; // [sp+98h] [bp-Ch]@9 | |
949 int b; // [sp+A0h] [bp-4h]@22 | |
950 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
951 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
952 { |
2274 | 953 //LevelDecoration* decor = &pLevelDecorations[i]; |
954 if ((!(pLevelDecorations[i].uFlags & LEVEL_DECORATION_OBELISK_CHEST) | |
955 || pLevelDecorations[i].IsObeliskChestActive()) && !(pLevelDecorations[i].uFlags & LEVEL_DECORATION_INVISIBLE)) | |
956 { | |
957 DecorationDesc* decor_desc = &pDecorationList->pDecorations[pLevelDecorations[i].uDecorationDescID]; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
958 if ( (char)decor_desc->uFlags >= 0 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
959 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
960 if ( !(decor_desc->uFlags & 0x22) ) |
0 | 961 { |
1490 | 962 v6 = pMiscTimer->uTotalGameTimeElapsed; |
2274 | 963 v7 = abs(pLevelDecorations[i].vPosition.x + pLevelDecorations[i].vPosition.y); |
1490 | 964 |
965 #pragma region "New: seasons change" | |
966 extern bool change_seasons; | |
967 if (change_seasons) | |
968 switch (pParty->uCurrentMonth) | |
969 { | |
970 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
971 case 11: case 0: case 1: // winter | |
972 switch (decor_desc->uSpriteID) | |
973 { | |
974 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
975 case 548: // flower10 | |
976 case 547: // flower09 | |
977 case 541: // flower03 | |
978 case 539: continue; // flower01 | |
979 | |
980 case 483: // tree01 | |
981 case 486: // tree04 | |
982 case 492: // tree10 | |
983 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); | |
984 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
985 break; | |
986 | |
987 default: | |
988 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
989 } | |
990 break; | |
991 | |
992 case 2: case 3: case 4: // spring | |
993 switch (decor_desc->uSpriteID) | |
994 { | |
995 } | |
996 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
997 break; | |
998 | |
999 case 8: case 9: case 10: // autumn | |
1000 switch (decor_desc->uSpriteID) | |
1001 { | |
1002 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
1003 case 548: // flower10 | |
1004 case 547: // flower09 | |
1005 case 541: // flower03 | |
1006 case 539: continue; // flower01 | |
1007 | |
1008 case 483: // tree01 | |
1009 case 486: // tree04 | |
1010 case 492: // tree10 | |
1011 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); | |
1012 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
1013 break; | |
1014 | |
1015 default: | |
1016 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1017 } | |
1018 break; | |
1019 | |
1020 case 5: case 6: case 7: // summer | |
1021 //all green by default | |
1022 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1023 break; | |
1024 | |
1025 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
1026 } | |
1027 else | |
1028 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1029 #pragma endregion | |
1030 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1031 | |
2274 | 1032 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, |
1033 pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); | |
1490 | 1034 v38 = 0; |
2274 | 1035 v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + pLevelDecorations[i].field_10_y_rot - (signed int)v10) >> 8) & 7; |
1490 | 1036 v37 = (unsigned __int16 *)v13; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1037 if ( v8->uFlags & 2 ) |
1490 | 1038 v38 = 2; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1039 if ( (256 << v13) & v8->uFlags ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1040 v38 |= 4; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1041 if ( v8->uFlags & 0x40000 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1042 v38 |= 0x40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1043 if ( v8->uFlags & 0x20000 ) |
1490 | 1044 LOBYTE(v38) = v38 | 0x80; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1045 if ( v8->uGlowRadius ) |
0 | 1046 { |
1490 | 1047 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) |
0 | 1048 { |
2322 | 1049 v14 = 255;//decor_desc->uColoredLightRed; |
1050 v15 = 255;//decor_desc->uColoredLightGreen; | |
1051 v16 = 255;//decor_desc->uColoredLightBlue; | |
0 | 1052 } |
1053 else | |
1054 { | |
1490 | 1055 v16 = 255; |
1056 v14 = 255; | |
1057 v15 = 255; | |
1058 } | |
2274 | 1059 pStationaryLightsStack->AddLight(pLevelDecorations[i].vPosition.x, pLevelDecorations[i].vPosition.y, pLevelDecorations[i].vPosition.z + decor_desc->uDecorationHeight / 2, |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1060 v8->uGlowRadius, v14, v15, v16, _4E94D0_light_type); |
1490 | 1061 } |
2274 | 1062 v17 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
1063 if (pGame->pIndoorCameraD3D->sRotationX) |
1490 | 1064 { |
2274 | 1065 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
2207 | 1066 v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1067 v41 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 1068 v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x); |
2274 | 1069 v20 = v19 + fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 1070 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1071 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1072 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1073 v22 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_sine_x); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1074 if ( 2 * abs(v20) >= abs(v21) ) |
0 | 1075 { |
1490 | 1076 LODWORD(v24) = 0; |
1637 | 1077 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1078 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
|
1079 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
|
1080 v41 = fixpoint_mul(v8->scale, v24 / v20); |
1490 | 1081 if ( pRenderer->pRenderD3D ) |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1082 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41); |
1490 | 1083 else |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1084 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41); |
1490 | 1085 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
1086 { | |
1087 if (::uNumBillboardsToDraw >= 500) | |
1088 return; | |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1089 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1090 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1091 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
1490 | 1092 v29 = v38; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1093 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1094 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1095 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1096 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
2274 | 1097 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; |
1098 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1099 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1100 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1101 HIWORD(v30) = HIWORD(v20); |
1490 | 1102 v31 = PID(OBJECT_Decoration,i); |
1103 LOWORD(v30) = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1104 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1105 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1106 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1107 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1108 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1109 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1110 ++uNumDecorationsDrawnThisFrame; |
1490 | 1111 } |
0 | 1112 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1113 continue; |
1490 | 1114 } |
1115 } | |
1116 else | |
1117 { | |
2274 | 1118 v42 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
1119 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1120 v20 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2207 | 1121 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1122 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1123 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1124 v22 = (pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1125 v42 = v22; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1126 if ( 2 * abs(v20) >= abs(v21) ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1127 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1128 LODWORD(v24) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1129 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1130 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
|
1131 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
|
1132 v41 = fixpoint_mul(v8->scale, v24 / v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1133 if ( pRenderer->pRenderD3D ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1134 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
|
1135 else |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1136 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
|
1137 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
|
1138 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1139 if (::uNumBillboardsToDraw >= 500) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1140 return; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1141 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1142 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1143 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1144 v29 = v38; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1145 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1146 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1147 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1148 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
2274 | 1149 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; |
1150 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1151 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1152 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1153 HIWORD(v30) = HIWORD(v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1154 v31 = PID(OBJECT_Decoration,i); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1155 LOWORD(v30) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1156 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1157 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1158 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1159 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1160 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1161 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1162 ++uNumDecorationsDrawnThisFrame; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1163 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1164 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1165 continue; |
0 | 1166 } |
1167 } | |
1168 } | |
1490 | 1169 } |
1170 else | |
1171 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1172 memset(&local_0, 0, 0x68); |
1490 | 1173 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
1174 local_0.uDiffuse = 0xFF3C1E; | |
2274 | 1175 local_0.x = (double)pLevelDecorations[i].vPosition.x; |
1176 local_0.y = (double)pLevelDecorations[i].vPosition.y; | |
1177 local_0.z = (double)pLevelDecorations[i].vPosition.z; | |
1490 | 1178 local_0.r = 0.0; |
1179 local_0.g = 0.0; | |
1180 local_0.b = 0.0; | |
1181 local_0.flt_28 = 1.0; | |
1182 local_0.timeToLive = (rand() & 0x80) + 128; | |
1183 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
1184 pGame->pParticleEngine->AddParticle(&local_0); | |
1185 } | |
1186 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1187 } |
0 | 1188 } |
1189 | |
1190 //----- (0049D717) -------------------------------------------------------- | |
1191 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1192 { | |
2069 | 1193 if ( Src->dwFlags & (0x400 | 0x2000)) |
0 | 1194 { |
1195 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1196 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1197 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1198 return 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1199 } |
0 | 1200 if ( !Dst->dwSize ) |
1201 { | |
2078 | 1202 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1203 return 1; |
0 | 1204 } |
1205 } | |
1206 return 1; | |
1207 } | |
1208 | |
1209 //----- (0049DC28) -------------------------------------------------------- | |
1210 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1211 { | |
1212 RenderD3D__DevInfo *v2; // eax@1 | |
1213 | |
1214 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1215 *pOutDevices = v2; | |
1216 memset(v2, 0, 0xA0u); | |
1985 | 1217 DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)RenderD3D__DeviceEnumerator, *pOutDevices, DDENUM_ATTACHEDSECONDARYDEVICES); |
0 | 1218 } |
1219 | |
1220 //----- (0049DC58) -------------------------------------------------------- | |
1221 RenderD3D::RenderD3D() | |
1222 { | |
1223 this->pHost = 0; | |
1224 this->pDirect3D = 0; | |
1225 this->pUnk = 0; | |
1226 this->pBackBuffer = 0; | |
1227 this->pFrontBuffer = 0; | |
1228 this->pZBuffer = 0; | |
1229 this->pDevice = 0; | |
1230 this->pViewport = 0; | |
1231 this->field_40 = 1; | |
1232 this->field_44 = 10; | |
1233 GetAvailableDevices(&this->pAvailableDevices); | |
1234 } | |
1235 | |
1236 //----- (0049DC90) -------------------------------------------------------- | |
1237 void RenderD3D::Release() | |
1238 { | |
1239 RenderD3D *v1; // esi@1 | |
1240 IDirectDraw4 *v2; // eax@2 | |
1241 signed int v3; // edi@4 | |
1242 IDirect3DViewport3 *v4; // eax@22 | |
1243 IUnknown *v5; // eax@24 | |
1244 IDirectDrawSurface4 *v6; // eax@26 | |
1245 IDirect3DDevice3 *v7; // eax@28 | |
1246 IDirect3D3 *v8; // eax@30 | |
1247 IDirectDrawSurface4 *v9; // eax@32 | |
1248 IDirectDrawSurface4 *v10; // eax@34 | |
1249 IDirectDraw4 *v11; // eax@36 | |
1250 | |
1251 v1 = this; | |
1252 if ( !this->bWindowed ) | |
1253 { | |
1254 v2 = this->pHost; | |
1255 if ( v2 ) | |
1256 { | |
1257 v2->RestoreDisplayMode(); | |
1258 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
1259 v1->pHost->FlipToGDISurface(); | |
1260 } | |
1261 } | |
1262 v3 = 0; | |
1263 do | |
1264 { | |
1265 if ( v1->pAvailableDevices[v3].pDriverName ) | |
1266 { | |
1267 free(v1->pAvailableDevices[v3].pDriverName); | |
1268 v1->pAvailableDevices[v3].pDriverName = 0; | |
1269 } | |
1270 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
1271 { | |
1272 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
1273 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
1274 } | |
1275 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
1276 { | |
1277 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
1278 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
1279 } | |
1280 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
1281 { | |
1282 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
1283 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
1284 } | |
1285 if ( v1->pAvailableDevices[v3].pName ) | |
1286 { | |
1287 free(v1->pAvailableDevices[v3].pName); | |
1288 v1->pAvailableDevices[v3].pName = 0; | |
1289 } | |
1290 if ( v1->pAvailableDevices[v3].pDescription ) | |
1291 { | |
1292 free(v1->pAvailableDevices[v3].pDescription); | |
1293 v1->pAvailableDevices[v3].pDescription = 0; | |
1294 } | |
1295 if ( v1->pAvailableDevices[v3].pGUID ) | |
1296 { | |
1297 free(v1->pAvailableDevices[v3].pGUID); | |
1298 v1->pAvailableDevices[v3].pGUID = 0; | |
1299 } | |
1300 ++v3; | |
1301 } | |
1302 while ( v3 < 4 ); | |
1303 if ( v1->pAvailableDevices ) | |
1304 { | |
1305 free(v1->pAvailableDevices); | |
1306 v1->pAvailableDevices = 0; | |
1307 } | |
1308 v4 = v1->pViewport; | |
1309 if ( v4 ) | |
1310 { | |
1311 v4->Release(); | |
1312 v1->pViewport = 0; | |
1313 } | |
1314 v5 = v1->pUnk; | |
1315 if ( v5 ) | |
1316 { | |
1317 v5->Release(); | |
1318 v1->pUnk = 0; | |
1319 } | |
1320 v6 = v1->pZBuffer; | |
1321 if ( v6 ) | |
1322 { | |
1323 v6->Release(); | |
1324 v1->pZBuffer = 0; | |
1325 } | |
1326 v7 = v1->pDevice; | |
1327 if ( v7 ) | |
1328 { | |
1329 v7->Release(); | |
1330 v1->pDevice = 0; | |
1331 } | |
1332 v8 = v1->pDirect3D; | |
1333 if ( v8 ) | |
1334 { | |
1335 v8->Release(); | |
1336 v1->pDirect3D = 0; | |
1337 } | |
1338 v9 = v1->pBackBuffer; | |
1339 if ( v9 ) | |
1340 { | |
1341 v9->Release(); | |
1342 v1->pBackBuffer = 0; | |
1343 } | |
1344 v10 = v1->pFrontBuffer; | |
1345 if ( v10 ) | |
1346 { | |
1347 v10->Release(); | |
1348 v1->pFrontBuffer = 0; | |
1349 } | |
1350 v11 = v1->pHost; | |
1351 if ( v11 ) | |
1352 { | |
1353 v11->Release(); | |
1354 v1->pHost = 0; | |
1355 } | |
1356 } | |
1357 | |
1358 //----- (0049DE14) -------------------------------------------------------- | |
2069 | 1359 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window) |
0 | 1360 { |
1361 //IDirectDraw4 *v8; // eax@12 | |
1362 //IDirectDraw4 *v9; // eax@16 | |
1363 //IDirectDraw4 *v10; // eax@20 | |
1364 //IDirectDraw4 *v13; // eax@35 | |
1365 const char *v23; // [sp-4h] [bp-DCh]@9 | |
1366 const char *v24; // [sp-4h] [bp-DCh]@13 | |
1367 const char *v25; // [sp-4h] [bp-DCh]@19 | |
1368 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1369 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1370 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1371 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1372 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
1373 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1374 | |
2069 | 1375 auto hWnd = window->GetApiHandle(); |
1376 int game_width = window->GetWidth(); | |
1377 int game_height = window->GetHeight(); | |
1378 | |
0 | 1379 this->bWindowed = bWindowed; |
1380 this->hWindow = hWnd; | |
1381 | |
1382 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
1383 { | |
1384 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1385 return 0; | |
1386 } | |
1387 | |
1388 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1389 { | |
1390 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1391 if (lpDD) | |
1392 lpDD->Release(); | |
1393 return 0; | |
1394 } | |
1395 lpDD->Release(); | |
1396 lpDD = 0; | |
1397 | |
1398 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1399 { | |
1400 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
1401 { | |
1402 v23 = "Init - Failed to set cooperative level.\n"; | |
1403 sprintf(pErrorMessage, v23); | |
1404 LABEL_65: | |
1405 if (pHost) | |
1406 { | |
1407 pHost->Release(); | |
1408 pHost = 0; | |
1409 } | |
1410 return 0; | |
1411 } | |
1412 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1413 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1414 ddsd2.dwFlags = DDSD_CAPS; | |
1415 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
1416 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1417 { | |
1418 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1419 pHost->GetDisplayMode(&ddsd2); | |
2069 | 1420 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) |
0 | 1421 { |
1422 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
1423 goto LABEL_14; | |
1424 } | |
1425 | |
1426 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
1427 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
2069 | 1428 ddsd2.dwWidth = game_width; |
1429 ddsd2.dwHeight = game_height; | |
0 | 1430 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) |
1431 { | |
1432 v24 = "Init - Failed to create back buffer.\n"; | |
1433 LABEL_14: | |
1434 sprintf(pErrorMessage, v24); | |
1435 if (pFrontBuffer) | |
1436 { | |
1437 pFrontBuffer->Release(); | |
1438 pFrontBuffer = 0; | |
1439 } | |
1440 goto LABEL_65; | |
1441 } | |
1442 if ( pHost->CreateClipper(0, &v30, 0) ) | |
1443 { | |
1444 v25 = "Init - Failed to create clipper.\n"; | |
1445 goto LABEL_45; | |
1446 } | |
1447 v30->SetHWnd(0, hWnd); | |
1448 pFrontBuffer->SetClipper(v30); | |
1449 | |
1450 v30->Release(); | |
1451 v30 = 0; | |
1452 | |
1453 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1454 | |
1455 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1456 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
2069 | 1457 ddsd2.dwWidth = game_width; |
1458 ddsd2.dwHeight = game_height; | |
0 | 1459 |
1460 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1461 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1462 &ddsd2.ddpfPixelFormat) ) | |
1463 goto LABEL_21; | |
1464 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1465 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
1466 | |
1467 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1468 { | |
1469 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
1470 { | |
1471 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1472 pBackBuffer, | |
1473 &pDevice, | |
1474 0) ) | |
1475 { | |
1476 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1477 d3dvp2.dvClipWidth = 2.0; | |
1478 d3dvp2.dvClipY = 1.0; | |
1479 d3dvp2.dvClipHeight = 2.0; | |
1480 d3dvp2.dvMaxZ = 1.0; | |
1481 d3dvp2.dvMinZ = 0.0; | |
1482 goto LABEL_54; | |
1483 } | |
1484 LABEL_51: | |
1485 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1486 if (pDirect3D) | |
1487 { | |
1488 pDirect3D->Release(); | |
1489 pDirect3D = 0; | |
1490 } | |
1491 goto LABEL_59; | |
1492 } | |
1493 LABEL_48: | |
1494 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1495 if (pZBuffer) | |
1496 { | |
1497 pZBuffer->Release(); | |
1498 pZBuffer = 0; | |
1499 } | |
1500 goto LABEL_61; | |
1501 } | |
1502 goto LABEL_44; | |
1503 } | |
1504 LABEL_36: | |
1505 v23 = "Init - Failed to create front buffer.\n"; | |
1506 sprintf(pErrorMessage, v23); | |
1507 goto LABEL_65; | |
1508 } | |
1509 if ( uDeviceID == 1 ) | |
1510 v26 = 1045; | |
1511 else | |
1512 v26 = 1041; | |
1513 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
1514 { | |
1515 v23 = "Init - Failed to set cooperative level.\n"; | |
1516 sprintf(pErrorMessage, v23); | |
1517 goto LABEL_65; | |
1518 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1519 if (pHost->SetDisplayMode(window->GetWidth(), window->GetHeight(), 16, 0, 0) ) |
0 | 1520 { |
1521 v23 = "Init - Failed to set display mode.\n"; | |
1522 sprintf(pErrorMessage, v23); | |
1523 goto LABEL_65; | |
1524 } | |
1525 | |
1526 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1527 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1528 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
1529 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
1530 ddsd2.dwBackBufferCount = 1; | |
1531 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1532 goto LABEL_36; | |
1533 //a3a = &pBackBuffer; | |
1534 //v14 = *v34; | |
1535 memset(&v27, 0, sizeof(DDSCAPS2)); | |
1536 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
1537 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
1538 //hWnda = &pDirect3D; | |
1539 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1540 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
1541 { | |
1542 v25 = "Init - Failed to get D3D interface.\n"; | |
1543 goto LABEL_45; | |
1544 } | |
1545 | |
1546 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1547 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1548 ddsd2.dwWidth = 640; | |
1549 ddsd2.dwHeight = 480; | |
1550 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1551 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1552 &ddsd2.ddpfPixelFormat) ) | |
1553 { | |
1554 LABEL_21: | |
1555 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
1556 goto LABEL_45; | |
1557 } | |
1558 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1559 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
1560 //uDeviceIDa = &pZBuffer; | |
1561 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1562 { | |
1563 LABEL_44: | |
1564 v25 = "Init - Failed to create z-buffer.\n"; | |
1565 LABEL_45: | |
1566 sprintf(pErrorMessage, v25); | |
1567 if (pBackBuffer) | |
1568 { | |
1569 pBackBuffer->Release(); | |
1570 pBackBuffer = 0; | |
1571 } | |
1572 LABEL_63: | |
1573 //v19 = &pFrontBuffer; | |
1574 if (pFrontBuffer) | |
1575 { | |
1576 pFrontBuffer->Release(); | |
1577 pFrontBuffer= 0; | |
1578 } | |
1579 goto LABEL_65; | |
1580 } | |
1581 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
1582 goto LABEL_48; | |
1583 //v33 = &pDevice; | |
1584 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1585 pBackBuffer, | |
1586 &pDevice, | |
1587 0) ) | |
1588 goto LABEL_51; | |
1589 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1590 d3dvp2.dvClipWidth = 2.0; | |
1591 d3dvp2.dvClipY = 1.0; | |
1592 d3dvp2.dvClipHeight = 2.0; | |
1593 d3dvp2.dvMaxZ = 1.0; | |
1594 | |
1595 LABEL_54: | |
1596 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
1597 //v17 = *hWnda; | |
2069 | 1598 d3dvp2.dwWidth = game_width; |
1599 d3dvp2.dwHeight = game_height; | |
0 | 1600 d3dvp2.dvClipX = -1.0; |
1601 //v18 = v17->lpVtbl; | |
1602 //v32 = &v4->pViewport; | |
1603 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
1604 { | |
1605 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
1606 if (pDevice) | |
1607 { | |
1608 pDevice->Release(); | |
1609 pDevice = 0; | |
1610 } | |
1611 if (pDirect3D) | |
1612 { | |
1613 pDirect3D->Release(); | |
1614 pDirect3D = 0; | |
1615 } | |
1616 LABEL_59: | |
1617 if (pZBuffer) | |
1618 { | |
1619 pZBuffer->Release(); | |
1620 pZBuffer = 0; | |
1621 } | |
1622 LABEL_61: | |
1623 if (pBackBuffer) | |
1624 { | |
1625 pBackBuffer->Release(); | |
1626 pBackBuffer = 0; | |
1627 } | |
1628 goto LABEL_63; | |
1629 } | |
1630 | |
1631 pDevice->AddViewport(pViewport); | |
1632 pViewport->SetViewport2(&d3dvp2); | |
1633 pDevice->SetCurrentViewport(pViewport); | |
1634 return 1; | |
1635 } | |
1636 | |
1637 //----- (0049E444) -------------------------------------------------------- | |
1638 unsigned int RenderD3D::GetDeviceCaps() | |
1639 { | |
1640 unsigned int v1; // ebx@1 | |
1641 RenderD3D *v2; // edi@1 | |
1642 IDirect3DDevice3 *v3; // eax@1 | |
1643 unsigned int result; // eax@2 | |
1644 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
1645 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
1646 | |
1647 v1 = 0; | |
1648 v2 = this; | |
1649 memset(&halCaps, 0, 0xFCu); | |
1650 halCaps.dwSize = 252; | |
1651 memset(&refCaps, 0, 0xFCu); | |
1652 v3 = v2->pDevice; | |
1653 refCaps.dwSize = 252; | |
1654 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
1655 { | |
1656 result = 1; | |
1657 } | |
1658 else | |
1659 { | |
2154 | 1660 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) ) |
0 | 1661 v1 = 2; |
2154 | 1662 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1663 v1 |= 4u; |
2154 | 1664 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) ) |
0 | 1665 v1 |= 8u; |
2154 | 1666 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) ) |
0 | 1667 v1 |= 0x10u; |
2154 | 1668 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1669 v1 |= 0x20u; |
2154 | 1670 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) ) |
0 | 1671 v1 |= 0x40u; |
2154 | 1672 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ) |
1673 v1 |= 0x80; | |
0 | 1674 result = v1; |
1675 } | |
1676 return result; | |
1677 } | |
1678 | |
1679 //----- (0049E4FC) -------------------------------------------------------- | |
1680 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
1681 { | |
1682 uint uClearFlags = 0; | |
1683 | |
1684 if (bClearColor) | |
1685 uClearFlags |= D3DCLEAR_TARGET; | |
1686 if (bClearDepth) | |
1687 uClearFlags |= D3DCLEAR_ZBUFFER; | |
1688 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1689 D3DRECT rects[] = {{0, 0, window->GetWidth(), window->GetHeight()}}; |
0 | 1690 if (uClearFlags) |
1691 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
1692 } | |
1693 | |
1694 //----- (0049E54D) -------------------------------------------------------- | |
1695 void RenderD3D::Present(bool bForceBlit) | |
1696 { | |
1697 RECT v5; // [sp+18h] [bp-18h]@1 | |
1698 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
1699 | |
1700 v5.left = 0; | |
1701 v5.top = 0; | |
2217 | 1702 v5.bottom = 480;//window->GetHeight(); //Ritor1: ïðîáëåìà ñ êíîïêîé "ðàçâåðíóòü" |
1703 v5.right = 640; //window->GetWidth(); | |
0 | 1704 |
1705 if (bWindowed || bForceBlit) | |
1706 { | |
1707 RECT rc; | |
1708 GetClientRect(hWindow, &rc); | |
1709 Point.y = 0; | |
1710 Point.x = 0; | |
1711 ClientToScreen(hWindow, &Point); | |
1712 OffsetRect(&rc, Point.x, Point.y); | |
1713 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
1714 } | |
1715 else | |
1716 pFrontBuffer->Flip(0, 1); | |
1717 } | |
1718 | |
1719 //----- (0049E5D4) -------------------------------------------------------- | |
1720 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
1721 { | |
1722 unsigned int v8; // edx@4 | |
1723 unsigned int v9; // ebx@5 | |
1724 unsigned int v10; // eax@5 | |
1725 DWORD v11; // edx@5 | |
1726 //int v12; // edx@7 | |
1727 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
1728 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
1729 | |
1730 //v15 = this; | |
1731 memset(&ddsd2, 0, 0x7Cu); | |
1732 ddsd2.dwSize = 0x7Cu; | |
1733 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1734 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
1735 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
1736 ddsd2.dwHeight = uTextureHeight; | |
1737 ddsd2.dwWidth = uTextureWidth; | |
1738 if ( bMipmaps ) | |
1739 { | |
1740 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
1741 { | |
1742 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
1743 LABEL_8: | |
1744 ddsd2.dwMipMapCount = v8; | |
1745 if ( !v8 ) | |
1746 goto LABEL_12; | |
1747 goto LABEL_11; | |
1748 } | |
1749 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
1750 { | |
1751 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
1752 goto LABEL_8; | |
1753 } | |
1754 v9 = GetMaxMipLevels(uTextureWidth); | |
1755 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
1756 ddsd2.dwMipMapCount = v9 - v10; | |
1757 if ( v9 == v10 ) | |
1758 { | |
1759 ddsd2.dwFlags = 0x1007u; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
1760 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used |
0 | 1761 ddsd2.ddsCaps.dwCaps = v11; |
1762 goto LABEL_12; | |
1763 } | |
1764 } | |
1765 else | |
1766 { | |
1767 ddsd2.dwMipMapCount = 1; | |
1768 } | |
1769 LABEL_11: | |
1770 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1771 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1772 LABEL_12: | |
1773 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
1774 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
1775 if (bAlphaChannel) | |
1776 { | |
1777 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
1778 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
1779 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
1780 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1781 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
1782 } | |
1783 else | |
1784 { | |
1785 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
1786 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
1787 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
1788 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1789 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
1790 } | |
1791 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
1792 return false; | |
1793 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
1794 { | |
1795 (*pOutSurface)->Release(); | |
1796 *pOutSurface = 0; | |
1797 return false; | |
1798 } | |
1799 return true; | |
1800 } | |
1801 | |
1802 //----- (004A5190) -------------------------------------------------------- | |
1803 void RenderD3D::HandleLostResources() | |
1804 { | |
1805 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
1806 pBitmaps_LOD->_410423_move_textures_to_device(); | |
1807 pSprites_LOD->ReleaseLostHardwareSprites(); | |
1808 } | |
1809 | |
1810 //----- (004A2050) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
1811 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) |
0 | 1812 { |
1813 Render *v5; // edi@1 | |
1814 unsigned int v6; // ebx@1 | |
1815 LightmapBuilder *v7; // esi@3 | |
1816 int v8; // eax@7 | |
2334 | 1817 // ODMFace *v9; // eax@12 |
1818 // char *v10; // esi@12 | |
1819 // double v11; // st7@14 | |
1820 // double v12; // st7@14 | |
1821 // int v13; // eax@14 | |
1822 // ODMFace *v14; // ecx@14 | |
1823 // double v15; // st7@14 | |
1824 // float v16; // ST48_4@15 | |
1825 // int v17; // eax@15 | |
1826 // char v18; // zf@17 | |
1827 // HRESULT v19; // eax@18 | |
1828 // HRESULT v20; // eax@18 | |
1829 // HRESULT v21; // eax@20 | |
1830 // HRESULT v22; // eax@20 | |
1831 // unsigned int v23; // ecx@20 | |
1832 // char *v24; // eax@21 | |
1833 // HRESULT v25; // eax@23 | |
1834 // HRESULT v26; // eax@23 | |
1835 // HRESULT v27; // eax@24 | |
1836 // HRESULT v28; // eax@25 | |
1837 // HRESULT v29; // eax@25 | |
1838 // HRESULT v30; // eax@25 | |
1839 // HRESULT v31; // eax@25 | |
1840 // HRESULT v32; // eax@26 | |
1841 // unsigned int v33; // ecx@26 | |
1842 // char *v34; // eax@27 | |
1843 // int v35; // edx@28 | |
1844 // HRESULT v36; // eax@29 | |
1845 // HRESULT v37; // eax@29 | |
1846 // HRESULT v38; // eax@29 | |
1847 // HRESULT v39; // eax@29 | |
0 | 1848 //IDirect3DDevice3Vtbl *v40; // ebx@29 |
1849 unsigned int v41; // eax@29 | |
2334 | 1850 // HRESULT v42; // eax@30 |
1851 // HRESULT v43; // eax@30 | |
1852 // HRESULT v44; // eax@30 | |
1853 // char *v45; // esi@34 | |
1854 // int v46; // ecx@35 | |
1855 // double v47; // st6@35 | |
1856 // int v48; // eax@36 | |
1857 // const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
1858 // const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
1859 // int v51; // [sp+50h] [bp-18h]@0 | |
1860 // unsigned int v52; // [sp+54h] [bp-14h]@0 | |
0 | 1861 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 |
1862 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
2334 | 1863 // unsigned int v55; // [sp+5Ch] [bp-Ch]@34 |
1864 // unsigned int v56; // [sp+60h] [bp-8h]@12 | |
1865 // int v57; // [sp+60h] [bp-8h]@34 | |
2006 | 1866 signed int a2; // [sp+64h] [bp-4h]@4 |
0 | 1867 |
1868 v5 = this; | |
1869 v6 = 0; | |
1870 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
1871 { | |
1872 v7 = pGame->pLightmapBuilder; | |
1873 v53 = v7; | |
1874 v54 = v7->std__vector_000004_size; | |
1875 if ( v7->std__vector_000004_size) | |
2006 | 1876 a2 = -1; |
638 | 1877 pGame->AlterGamma_ODM(a4, &a2); |
2155 | 1878 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 1879 { |
638 | 1880 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 1881 v7->DrawLightmaps(/*v8, 0*/); |
0 | 1882 } |
1883 else | |
1884 { | |
1885 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
1886 { | |
323 | 1887 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1888 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
1889 if (bUsingSpecular) | |
1890 { | |
186 | 1891 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
1892 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1893 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1894 } |
1073 | 1895 for (uint i = 0; i < uNumVertices; ++i) |
1896 { | |
1897 | |
1898 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1899 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1900 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1901 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1902 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1903 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
1904 | |
1905 if ( this->bUsingSpecular ) | |
0 | 1906 { |
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
|
1907 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1908 } |
1073 | 1909 else |
1910 { | |
1911 d3d_vertex_buffer[i].specular = 0; | |
1912 } | |
1913 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1914 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1915 | |
1916 } | |
323 | 1917 |
1918 if (a4->uAttributes & FACE_OUTLINED) | |
1919 { | |
1920 int color; | |
1921 if (GetTickCount() % 300 >= 150) | |
1922 color = 0xFFFF2020; | |
1923 else color = 0xFF901010; | |
1924 | |
1925 for (uint i = 0; i < uNumVertices; ++i) | |
1926 d3d_vertex_buffer[i].diffuse = color; | |
1927 } | |
1928 | |
0 | 1929 pRenderD3D->pDevice->SetTexture(0, pTexture); |
1930 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1931 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1932 d3d_vertex_buffer, |
0 | 1933 uNumVertices, |
1934 D3DDP_DONOTLIGHT); | |
1935 } | |
1936 else | |
1937 { | |
1073 | 1938 for (uint i = 0; i < uNumVertices; ++i) |
1939 { | |
1940 | |
1941 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1942 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1943 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1944 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1945 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1946 if ( this->bUsingSpecular ) | |
0 | 1947 { |
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
|
1948 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1949 } |
1073 | 1950 else |
1951 { | |
1952 d3d_vertex_buffer[i].specular = 0; | |
1953 } | |
1954 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1955 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1956 | |
1957 } | |
1958 | |
186 | 1959 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
1960 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 1961 if (bUsingSpecular) |
186 | 1962 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 1963 |
1964 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
1965 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1966 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1967 d3d_vertex_buffer, |
0 | 1968 uNumVertices, |
1969 D3DDP_DONOTLIGHT)); | |
1970 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
1971 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1972 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
1394 | 1973 v53->DrawLightmaps(/*-1, 0*/); |
1073 | 1974 for (uint i = 0; i < uNumVertices; ++i) |
1975 { | |
1976 d3d_vertex_buffer[i].diffuse = a2; | |
1977 } | |
0 | 1978 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 1979 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1980 if ( !pRenderer->bUsingSpecular ) |
186 | 1981 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
1982 | |
1983 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
1984 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
1985 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 1986 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1987 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1988 d3d_vertex_buffer, |
0 | 1989 uNumVertices, |
1990 D3DDP_DONOTLIGHT)); | |
1991 if (bUsingSpecular) | |
1992 { | |
186 | 1993 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 1994 |
1073 | 1995 for (uint i = 0; i < uNumVertices; ++i) |
1996 { | |
1997 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
1998 d3d_vertex_buffer[i].specular = 0; | |
1999 } | |
2000 | |
0 | 2001 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 2002 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
2003 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 2004 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
2005 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2006 d3d_vertex_buffer, |
0 | 2007 uNumVertices, |
2008 D3DDP_DONOTLIGHT)); | |
186 | 2009 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 2010 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
2011 v41 = GetLevelFogColor(); | |
2012 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
2013 v6 = 0; | |
2014 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
2015 } | |
186 | 2016 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
2017 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 2018 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
2019 } | |
2020 } | |
2021 } | |
2022 } | |
2023 // 4D864C: using guessed type char byte_4D864C; | |
2024 | |
2025 //----- (0049EB79) -------------------------------------------------------- | |
2026 Render::~Render() | |
2027 { | |
2028 Render *v1; // esi@1 | |
2029 | |
2030 v1 = this; | |
1583 | 2031 free(this->pDefaultZBuffer); |
0 | 2032 v1->pD3DBitmaps.Release(); |
2033 v1->pD3DSprites.Release(); | |
2034 Release(); | |
2035 v1->bWindowMode = 1; | |
2036 //nullsub_1(); | |
2037 //nullsub_1(); | |
2038 } | |
2039 | |
2040 | |
2041 //----- (0049E992) -------------------------------------------------------- | |
2042 Render::Render() | |
2043 { | |
2216 | 2044 //Render *v1; // esi@1 |
2334 | 2045 // int v2; // eax@1 |
2046 // char v3; // zf@1 | |
0 | 2047 |
2216 | 2048 //v1 = this; |
0 | 2049 this->pDirectDraw4 = 0; |
2050 this->pFrontBuffer4 = 0; | |
2051 this->pBackBuffer4 = 0; | |
2154 | 2052 //this->pColorKeySurface4 = 0; |
2152 | 2053 //this->pDirectDraw2 = 0; |
2054 //this->pFrontBuffer2 = 0; | |
2055 //this->pBackBuffer2 = 0; | |
2056 //this->pSomeSurface2 = 0; | |
0 | 2057 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); |
2058 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2216 | 2059 this->bWindowMode = 1; |
2060 //this->field_40054 = 0; | |
2061 //this->field_10 = 640; | |
2062 //this->field_14 = 480; | |
2063 //this->field_40030 = 0; | |
2064 //this->field_4002C = 0; | |
2065 this->pActiveZBuffer = 0; | |
2066 this->pDefaultZBuffer = 0; | |
2067 this->raster_clip_y = 0; | |
2068 this->raster_clip_x = 0; | |
2069 this->raster_clip_z = 639; | |
2070 this->raster_clip_w = 479; | |
2071 //this->field_4003C = 0x004EED80; | |
2072 //this->field_40040 = dword_4EED78; | |
2073 this->uClipZ = 640; | |
2074 //this->field_40044 = 2; | |
2075 //this->field_40048 = 6; | |
2076 this->pFrontBuffer4 = 0; | |
2077 this->pBackBuffer4 = 0; | |
2078 //this->pColorKeySurface4 = 0; | |
2079 this->pDirectDraw4 = 0; | |
2080 this->pRenderD3D = 0; | |
2081 this->uNumSceneBegins = 0; | |
2082 this->uNumD3DSceneBegins = 0; | |
2083 this->using_software_screen_buffer = 0; | |
2084 this->pTargetSurface = 0; | |
2085 this->uTargetSurfacePitch = 0; | |
2086 this->uClipY = 0; | |
2087 this->uClipX = 0; | |
2088 this->uClipW = 480; | |
2089 this->bClip = 1; | |
2090 //this->bColorKeySupported = 0; | |
2091 this->bRequiredTextureStagesAvailable = 0; | |
2092 this->bTinting = 1; | |
2093 //LOBYTE(this->field_103668) = 0; | |
0 | 2094 uNumBillboardsToDraw = 0; |
2095 bFogEnabled = false; | |
265 | 2096 |
2097 hd_water_tile_id = -1; | |
2098 hd_water_current_frame = 0; | |
0 | 2099 } |
2100 | |
2069 | 2101 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
0 | 2102 { |
1802 | 2103 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); |
2104 | |
2105 this->window = window; | |
2069 | 2106 //bStartInWindow = true; |
1802 | 2107 //windowed_mode_width = windowed_width; |
2108 //windowed_mode_height = windowed_height; | |
2109 | |
1985 | 2110 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0); |
0 | 2111 |
2112 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
2113 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
2114 | |
2115 this->bTinting = bTinting; | |
2116 | |
1980 | 2117 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); |
2118 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
0 | 2119 |
2120 return r1 && r2; | |
2121 } | |
2122 | |
2123 | |
2124 //----- (0049ECC4) -------------------------------------------------------- | |
2125 void Render::ClearBlack() | |
2126 { | |
2154 | 2127 //if (pRenderD3D) |
0 | 2128 { |
2069 | 2129 if (using_software_screen_buffer) |
0 | 2130 pRenderD3D->ClearTarget(true, 0, false, 0.0); |
2131 } | |
2154 | 2132 //else |
2133 //memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
0 | 2134 } |
2135 | |
2136 //----- (0049ED18) -------------------------------------------------------- | |
2137 void Render::PresentBlackScreen() | |
2138 { | |
2139 IDirectDrawSurface *v2; // eax@3 | |
2140 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
2141 RECT x; // [sp+68h] [bp-10h]@3 | |
2142 | |
2143 memset(&v3, 0, sizeof(DDBLTFX)); | |
1802 | 2144 GetWindowRect(window->GetApiHandle(), &x); |
2152 | 2145 |
0 | 2146 { |
2147 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
2148 } | |
2152 | 2149 |
0 | 2150 v3.dwFillColor = 0; |
2151 v3.dwSize = 100; | |
2152 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
2153 pRenderer->Present(); | |
2154 } | |
2155 | |
2156 //----- (0049EDB6) -------------------------------------------------------- | |
2157 void Render::SavePCXScreenshot() | |
2158 { | |
2159 int v5; // eax@8 | |
2132 | 2160 FILE *pOutFile; // edi@10 |
2133 | 2161 unsigned short *v8; // eax@11 |
2334 | 2162 // int v9; // eax@13 |
2163 // int v10; // ecx@15 | |
0 | 2164 signed int v12; // eax@18 |
2334 | 2165 // HRESULT v14; // eax@29 |
0 | 2166 char v15[56]; // [sp+Ch] [bp-158h]@10 |
2167 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2168 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2169 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2132 | 2170 char *lineB; // [sp+11Ch] [bp-48h]@14 |
2171 char *lineG; // [sp+120h] [bp-44h]@14 | |
2172 //int v24; // [sp+124h] [bp-40h]@11 | |
0 | 2173 FILE *File; // [sp+128h] [bp-3Ch]@3 |
2174 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2175 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2132 | 2176 char *lineRGB; // [sp+148h] [bp-1Ch]@10 |
2177 void *surface; // [sp+14Ch] [bp-18h]@8 | |
2178 int image_width; // [sp+150h] [bp-14h]@4 | |
2179 int pitch; // [sp+154h] [bp-10h]@4 | |
0 | 2180 char v31; // [sp+15Ah] [bp-Ah]@25 |
2132 | 2181 unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17 |
2182 unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10 | |
2183 byte test_byte; // [sp+163h] [bp-1h]@17 | |
2184 | |
2185 int num_r_bits = 5; | |
2186 int num_g_bits = 6; | |
2187 int num_b_bits = 5; | |
2188 | |
2189 int r_mask = 0xF800; | |
2190 int g_mask = 0x7E0; | |
2191 int b_mask = 0x1F; | |
2192 | |
2069 | 2193 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2194 { |
2132 | 2195 sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100); |
0 | 2196 File = fopen(Filename, "wb"); |
2197 if ( File ) | |
2198 { | |
2154 | 2199 pitch = this->GetRenderWidth(); |
2200 if ( pitch & 1 ) | |
2201 pitch = pitch + 1; | |
2132 | 2202 if ( this->pRenderD3D ) |
2203 { | |
2204 memset(&Dst, 0, 0x7C); | |
0 | 2205 Dst.dwSize = 124; |
168 | 2206 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 2207 return; |
2132 | 2208 surface = Dst.lpSurface; |
2209 v5 = Dst.lPitch / 2; | |
0 | 2210 } |
2211 else | |
2212 { | |
2213 pRenderer->BeginScene(); | |
2132 | 2214 surface = pRenderer->pTargetSurface; |
0 | 2215 v5 = pRenderer->uTargetSurfacePitch; |
2216 } | |
2154 | 2217 header1.right = GetRenderWidth() - 1; |
2132 | 2218 header1.left = 0; |
2154 | 2219 header1.bottom = this->GetRenderHeight() - 1; |
2132 | 2220 header1.up = 0; |
2221 header2.pitch = pitch; | |
0 | 2222 memset(color_map, 0, sizeof(color_map)); |
2223 memset(v15, 0, sizeof(v15)); | |
2224 header2.reserved = 0; | |
2225 header1.manufacturer = 10; | |
2132 | 2226 pOutFile = File; |
0 | 2227 header1.version = 5; |
2228 header1.encoding = 1; | |
2229 header1.bpp = 8; | |
2230 header1.hdpi = 75; | |
2231 header1.vdpi = 75; | |
2232 header2.planes = 3; | |
2233 header2.palette_info = 1; | |
2132 | 2234 fwrite(&header1, 1, 1, File); |
2235 fwrite(&header1.version, 1, 1, pOutFile); | |
2236 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2237 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2238 fwrite(&header1.left, 2, 1, pOutFile); | |
2239 fwrite(&header1.up, 2, 1, pOutFile); | |
2240 fwrite(&header1.right, 2, 1, pOutFile); | |
2241 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2242 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2243 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2244 fwrite(color_map, 0x30u, 1, pOutFile); | |
2245 fwrite(&header2, 1, 1, pOutFile); | |
2246 fwrite(&header2.planes, 1, 1, pOutFile); | |
2247 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2248 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2249 fwrite(v15, 0x3Au, 1, pOutFile); | |
2154 | 2250 lineRGB = (char *)malloc(3 * GetRenderWidth() + 6); |
2251 if ( this->GetRenderHeight() > 0 ) | |
2132 | 2252 { |
2253 image_width = 3 * pitch; | |
2254 //v24 = 2 * v5; | |
2255 v8 = (unsigned short *)surface; | |
2154 | 2256 for ( int y = 0; y < this->GetRenderHeight(); y++ ) |
0 | 2257 { |
2132 | 2258 line_picture_data = v8; |
2154 | 2259 if ( GetRenderWidth() > 0 ) |
0 | 2260 { |
2132 | 2261 lineG = (char *)lineRGB + pitch; |
2262 lineB = (char *)lineRGB + 2 * pitch; | |
2154 | 2263 for ( uint x = 0; x < this->GetRenderWidth(); x++ ) |
0 | 2264 { |
2221 | 2265 //int p = *line_picture_data; //0x2818 |
2266 //int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits );//16 = 8 + 8 | |
2267 //int value = (pRenderer->uTargetRMask & *line_picture_data);//0 = 0xFF0000 & 0x2818 | |
2268 //int result = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits ); | |
2133 | 2269 lineRGB[x] = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits );// + pRenderer->uTargetRBits - 8); |
2270 lineG[x] = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits);// + pRenderer->uTargetGBits - 8); | |
2221 | 2271 //int value2 = (pRenderer->uTargetGMask & *line_picture_data); //10240 = 0xFF00 & 0x2818 |
2272 //int result2 = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits); | |
2133 | 2273 lineB[x] = (pRenderer->uTargetBMask & *line_picture_data);// << (8 - pRenderer->uTargetBBits); |
2221 | 2274 //int value3 = (pRenderer->uTargetBMask & *line_picture_data);//24 = 0xFF & 0x2818 |
2132 | 2275 line_picture_data += 2; |
0 | 2276 } |
2277 } | |
2132 | 2278 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2279 { |
2132 | 2280 pict_byte = lineRGB[i]; |
2281 for ( test_byte = 1; test_byte < 0x3F; ++test_byte ) | |
0 | 2282 { |
2132 | 2283 v12 = i + test_byte; |
2284 if ( lineRGB[v12] != pict_byte ) | |
0 | 2285 break; |
2132 | 2286 if ( !(v12 % pitch) ) |
0 | 2287 break; |
2288 } | |
2132 | 2289 if ( i + test_byte > image_width ) |
2290 test_byte = 3 * pitch - i; | |
2291 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
2292 { | |
2293 v31 = test_byte | 0xC0; | |
2294 fwrite(&v31, 1, 1, pOutFile); | |
2295 } | |
2296 fwrite(&pict_byte, 1, 1, pOutFile); | |
0 | 2297 } |
2132 | 2298 v8 += v5; |
0 | 2299 } |
2300 } | |
2132 | 2301 if ( this->pRenderD3D ) |
0 | 2302 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2303 else | |
2304 pRenderer->EndScene(); | |
2132 | 2305 |
2306 free(lineRGB); | |
2307 fclose(pOutFile); | |
0 | 2308 } |
2309 } | |
2310 } | |
2311 | |
2312 //----- (0049F1BC) -------------------------------------------------------- | |
2069 | 2313 void Render::SaveWinnersCertificate(const char *a1) |
0 | 2314 { |
2315 unsigned int v6; // eax@8 | |
2133 | 2316 //FILE *v7; // edi@10 |
2334 | 2317 // int v8; // ecx@11 |
2133 | 2318 unsigned short *v9; // eax@11 |
0 | 2319 int v10; // eax@13 |
2320 signed int v13; // eax@18 | |
2334 | 2321 // char v14; // zf@27 |
2322 // HRESULT v15; // eax@29 | |
2133 | 2323 char v16[56]; // [sp+Ch] [bp-12Ch]@10 |
0 | 2324 __int16 v17; // [sp+44h] [bp-F4h]@10 |
2133 | 2325 DDSURFACEDESC2 Dst; // [sp+48h] [bp-F0h]@7 |
2334 | 2326 // int v19; // [sp+58h] [bp-E0h]@8 |
2327 // unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
2133 | 2328 char color_map[48]; // [sp+C4h] [bp-74h]@10 |
2334 | 2329 // unsigned int v22; // [sp+F4h] [bp-44h]@11 |
2133 | 2330 char *lineB; // [sp+F8h] [bp-40h]@14 |
2331 int image_width; // [sp+FCh] [bp-3Ch]@11 | |
0 | 2332 int v25; // [sp+100h] [bp-38h]@4 |
2333 FILE *File; // [sp+104h] [bp-34h]@3 | |
2334 char Str; // [sp+108h] [bp-30h]@10 | |
2335 char v28; // [sp+109h] [bp-2Fh]@10 | |
2336 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
2337 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
2338 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
2339 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
2340 __int16 v33; // [sp+110h] [bp-28h]@10 | |
2341 __int16 v34; // [sp+112h] [bp-26h]@10 | |
2342 __int16 v35; // [sp+114h] [bp-24h]@10 | |
2343 __int16 v36; // [sp+116h] [bp-22h]@10 | |
2344 char v37; // [sp+118h] [bp-20h]@10 | |
2345 char v38; // [sp+119h] [bp-1Fh]@10 | |
2346 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
2347 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
2133 | 2348 char *lineRGB; // [sp+120h] [bp-18h]@10 |
2349 void *surface; // [sp+124h] [bp-14h]@8 | |
2350 int pitch; // [sp+128h] [bp-10h]@4 | |
0 | 2351 char v44; // [sp+12Fh] [bp-9h]@25 |
2133 | 2352 char *lineG; // [sp+130h] [bp-8h]@10 |
2353 unsigned char pict_byte; // [sp+137h] [bp-1h]@17 | |
2354 byte test_byte; | |
2355 | |
2356 int num_r_bits = 5; | |
2357 int num_g_bits = 6; | |
2358 int num_b_bits = 5; | |
2359 | |
2360 int r_mask = 0xF800; | |
2361 int g_mask = 0x7E0; | |
2362 int b_mask = 0x1F; | |
2363 | |
2069 | 2364 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2365 { |
2154 | 2366 static int _4EFA84_num_winners_certificates = 0; |
2367 ++_4EFA84_num_winners_certificates; | |
2368 | |
0 | 2369 File = fopen(a1, "wb"); |
2370 if ( File ) | |
2371 { | |
2154 | 2372 v25 = this->GetRenderWidth(); |
2373 pitch = v25; | |
2374 if ( pitch & 1 ) | |
2375 pitch = pitch + 1; | |
2133 | 2376 if ( this->pRenderD3D ) |
2377 { | |
2378 memset(&Dst, 0, 0x7C); | |
2379 Dst.dwSize = 124; | |
168 | 2380 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 2381 return; |
2133 | 2382 surface = Dst.lpSurface; |
2383 v6 = Dst.lPitch / 2; | |
0 | 2384 } |
2385 else | |
2386 { | |
2387 pRenderer->BeginScene(); | |
2133 | 2388 surface = pRenderer->pTargetSurface; |
0 | 2389 v6 = pRenderer->uTargetSurfacePitch; |
2390 } | |
2154 | 2391 v33 = this->GetRenderWidth() - 1; |
2133 | 2392 v31 = 0; |
2154 | 2393 v34 = (short)this->GetRenderHeight() - 1; |
2133 | 2394 v32 = 0; |
2395 v39 = pitch; | |
2396 memset(&color_map, 0, sizeof(color_map)); | |
2397 memset(&v16, 0, sizeof(v16)); | |
0 | 2398 v37 = 0; |
2399 Str = 10; | |
2400 v17 = 0; | |
2401 v28 = 5; | |
2402 v29 = 1; | |
2403 v30 = 8; | |
2404 v35 = 75; | |
2405 v36 = 75; | |
2406 v38 = 3; | |
2407 v40 = 1; | |
2133 | 2408 fwrite(&Str, 1, 1, File); |
2409 fwrite(&v28, 1, 1, File); | |
2410 fwrite(&v29, 1, 1, File); | |
2411 fwrite(&v30, 1, 1, File); | |
2412 fwrite(&v31, 2, 1, File); | |
2413 fwrite(&v32, 2, 1, File); | |
2414 fwrite(&v33, 2, 1, File); | |
2415 fwrite(&v34, 2, 1, File); | |
2416 fwrite(&v35, 2, 1, File); | |
2417 fwrite(&v36, 2, 1, File); | |
2418 fwrite(&color_map, 0x30, 1, File); | |
2419 fwrite(&v37, 1, 1, File); | |
2420 fwrite(&v38, 1, 1, File); | |
2421 fwrite(&v39, 2, 1, File); | |
2422 fwrite(&v40, 2, 1, File); | |
2423 fwrite(&v16, 0x3A, 1, File); | |
2424 lineRGB = (char *)malloc(3 * (v25 + 2)); | |
2154 | 2425 if ( (signed int)this->GetRenderHeight() > 0 ) |
2133 | 2426 { |
2427 image_width = 3 * pitch; | |
2428 v9 = (unsigned short *)surface; | |
2154 | 2429 for ( uint j = 0; j < this->GetRenderHeight(); j++) |
0 | 2430 { |
2431 a1 = (const char *)v9; | |
2432 if ( v25 > 0 ) | |
2433 { | |
2133 | 2434 lineG = (char *)lineRGB + pitch; |
2435 lineB = (char *)lineRGB + 2 * pitch; | |
2436 for ( v10 = 0; v10 < v25; v10++ ) | |
0 | 2437 { |
2133 | 2438 lineRGB[v10] = (signed int)(r_mask & *(short *)a1) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2439 lineG[v10] = (signed int)(g_mask & *(short *)a1) >> (num_b_bits + num_g_bits - 8); | |
2440 lineB[v10] = (b_mask & *(short *)a1) << (8 - num_b_bits); | |
0 | 2441 a1 += 2; |
2442 } | |
2443 } | |
2133 | 2444 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2445 { |
2133 | 2446 pict_byte = lineRGB[i]; |
2447 for ( test_byte = 1; test_byte < 0x3F; test_byte ) | |
0 | 2448 { |
2133 | 2449 v13 = i + test_byte; |
2450 if ( lineRGB[v13] != pict_byte ) | |
0 | 2451 break; |
2133 | 2452 if ( !(v13 % pitch) ) |
0 | 2453 break; |
2454 } | |
2133 | 2455 if ( i + test_byte > image_width ) |
2456 test_byte = 3 * pitch - i; | |
2457 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
0 | 2458 { |
2133 | 2459 v44 = test_byte | 0xC0; |
2460 fwrite(&v44, 1, 1, File); | |
0 | 2461 } |
2133 | 2462 fwrite(&pict_byte, 1, 1, File); |
0 | 2463 } |
2133 | 2464 v9 += pitch; |
0 | 2465 } |
2466 } | |
2133 | 2467 if ( this->pRenderD3D ) |
0 | 2468 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2469 else | |
2470 pRenderer->EndScene(); | |
2133 | 2471 free(lineRGB); |
2472 fclose(File); | |
0 | 2473 } |
2474 } | |
2475 } | |
2476 | |
2477 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 2478 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
2127 | 2479 { |
0 | 2480 void *v8; // esi@3 |
2481 void *v9; // esi@3 | |
810 | 2482 unsigned short* v11; // eax@4 |
2334 | 2483 // int v13; // eax@8 |
2484 // int v14; // ecx@8 | |
0 | 2485 signed int v15; // eax@11 |
2334 | 2486 // char v16; // zf@20 |
2487 // int result; // eax@21 | |
0 | 2488 char v18[58]; // [sp+Ch] [bp-ACh]@3 |
2489 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 2490 char *lineG; // [sp+78h] [bp-40h]@7 |
2491 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 2492 int v23; // [sp+80h] [bp-38h]@4 |
2493 int v24; // [sp+84h] [bp-34h]@4 | |
2494 int v25; // [sp+88h] [bp-30h]@4 | |
2495 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 2496 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
2497 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
2498 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
2499 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 2500 char v43; // [sp+B3h] [bp-5h]@18 |
2501 int i; // [sp+B4h] [bp-4h]@6 | |
2132 | 2502 unsigned short* line_picture_data; |
810 | 2503 byte test_byte; |
2504 unsigned char pict_byte; | |
0 | 2505 |
2131 | 2506 int num_r_bits = 5; |
2507 int num_g_bits = 6; | |
2508 int num_b_bits = 5; | |
2509 | |
2510 int r_mask = 0xF800; | |
2511 int g_mask = 0x7E0; | |
2512 int b_mask = 0x1F; | |
2513 | |
810 | 2514 pitch = wight; |
2515 if ( wight & 1 ) | |
2516 pitch = wight + 1; | |
2517 Src.left = 0; | |
2518 Src.up = 0; | |
2519 Src.right = wight - 1; | |
2520 Src.bottom = heidth - 1; | |
2521 v27.pitch = pitch; | |
0 | 2522 memset(&v20, 0, 0x30u); |
2523 memset(&v18, 0, 0x38u); | |
810 | 2524 v8 = data_buff; |
2525 v27.reserved = 0; | |
0 | 2526 *(_WORD *)&v18[56] = 0; |
810 | 2527 Src.manufacturer = 10; |
2528 Src.version = 5; | |
2529 Src.encoding = 1; | |
2530 Src.bpp = 8; | |
2531 Src.hdpi = 75; | |
2532 Src.vdpi = 75; | |
2533 v27.planes = 3; | |
2534 v27.palette_info = 1; | |
2128 | 2535 memcpy(data_buff, &Src, 1); |
0 | 2536 v8 = (char *)v8 + 1; |
2128 | 2537 memcpy(v8, &Src.version, 1); |
0 | 2538 v8 = (char *)v8 + 1; |
2128 | 2539 memcpy(v8, &Src.encoding, 1); |
0 | 2540 v8 = (char *)v8 + 1; |
2128 | 2541 memcpy(v8, &Src.bpp, 1); |
0 | 2542 v8 = (char *)v8 + 1; |
2128 | 2543 memcpy(v8, &Src.left, 2); |
0 | 2544 v8 = (char *)v8 + 2; |
2128 | 2545 memcpy(v8, &Src.up, 2); |
0 | 2546 v8 = (char *)v8 + 2; |
2128 | 2547 memcpy(v8, &Src.right, 2); |
0 | 2548 v8 = (char *)v8 + 2; |
2128 | 2549 memcpy(v8, &Src.bottom, 2); |
0 | 2550 v8 = (char *)v8 + 2; |
2127 | 2551 memcpy(v8, &Src.hdpi, 2); |
0 | 2552 v8 = (char *)v8 + 2; |
2127 | 2553 memcpy(v8, &Src.vdpi, 2); |
0 | 2554 v8 = (char *)v8 + 2; |
2555 memcpy(v8, &v20, 0x30u); | |
2556 v8 = (char *)v8 + 48; | |
810 | 2557 memcpy(v8, &v27, 1u); |
0 | 2558 v8 = (char *)v8 + 1; |
2127 | 2559 memcpy(v8, &v27.planes, 1); |
0 | 2560 v8 = (char *)v8 + 1; |
2127 | 2561 memcpy(v8, &v27.pitch, 2); |
0 | 2562 v8 = (char *)v8 + 2; |
2127 | 2563 memcpy(v8, &v27.palette_info, 2); |
0 | 2564 v8 = (char *)v8 + 2; |
2565 memcpy(v8, &v18, 0x3Au); | |
2566 v9 = (char *)v8 + 58; | |
810 | 2567 |
1583 | 2568 lineRGB = (char*)malloc(3 * (wight + 2)); |
810 | 2569 if ( heidth > 0 ) |
2570 { | |
2571 v26 = 3 * pitch; | |
2572 v23 = 2 * wight; | |
2573 v11 = picture_data; | |
2574 v24 = (int)picture_data; | |
2127 | 2575 for ( v25 = heidth; v25; v25-- ) |
0 | 2576 { |
2132 | 2577 line_picture_data = v11; |
810 | 2578 if ( wight > 0 ) |
2579 { | |
2580 lineG = (char *)lineRGB + pitch; | |
2581 lineB = (char *)lineRGB + 2 * pitch; | |
2127 | 2582 for ( uint i = 0; i < wight; i++ ) |
0 | 2583 { |
2132 | 2584 lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2585 lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8); | |
2586 lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits); | |
2587 line_picture_data += 1; | |
810 | 2588 } |
0 | 2589 } |
2590 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
2591 { | |
2128 | 2592 pict_byte = lineRGB[i]; |
2127 | 2593 for ( test_byte = 1; test_byte < 63; ++test_byte ) |
0 | 2594 { |
810 | 2595 v15 = i + test_byte; |
2128 | 2596 if ( lineRGB[v15] != pict_byte ) |
0 | 2597 break; |
810 | 2598 if ( !(v15 % pitch) ) |
0 | 2599 break; |
810 | 2600 } |
2601 if ( i + test_byte > v26 ) | |
2602 test_byte = 3 * pitch - i; | |
2127 | 2603 if ( test_byte > 1 || pict_byte >= 192 ) |
810 | 2604 { |
2605 v43 = test_byte | 0xC0; | |
2127 | 2606 memcpy(v9, &v43, 1); |
0 | 2607 v9 = (char *)v9 + 1; |
2608 } | |
2127 | 2609 memcpy(v9, &pict_byte, 1); |
810 | 2610 i += test_byte; |
2611 } | |
2128 | 2612 v11 += wight; |
810 | 2613 } |
2614 } | |
1583 | 2615 free(lineRGB); |
810 | 2616 *(int *)packed_size = (char *)v9 - data_buff; |
0 | 2617 } |
2618 | |
2619 //----- (0049F8B5) -------------------------------------------------------- | |
2155 | 2620 void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) |
0 | 2621 { |
2622 FILE *result; // eax@1 | |
2127 | 2623 FILE *pOutFile; // edi@4 |
2128 | 2624 unsigned short* v9; // eax@5 |
2334 | 2625 // int v10; // eax@7 |
0 | 2626 signed int v12; // eax@12 |
2334 | 2627 // char v13; // zf@21 |
0 | 2628 char v14[56]; // [sp+4h] [bp-A0h]@4 |
2629 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
2630 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
2631 int v18; // [sp+74h] [bp-30h]@5 | |
2334 | 2632 // char *v19; // [sp+78h] [bp-2Ch]@5 |
2127 | 2633 int image_width; // [sp+7Ch] [bp-28h]@5 |
0 | 2634 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 |
2635 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
2128 | 2636 char *lineRGB; // [sp+98h] [bp-Ch]@4 |
2637 int pitch; // [sp+9Ch] [bp-8h]@2 | |
2638 char *lineB; // [sp+A0h] [bp-4h]@8 | |
2639 char *lineG; | |
2640 unsigned short* line_pictute_data; | |
2641 byte test_byte; | |
2642 char v43; | |
2127 | 2643 |
2644 int num_r_bits = 5; | |
2645 int num_g_bits = 6; | |
2646 int num_b_bits = 5; | |
2647 | |
2648 int r_mask = 0xF800; | |
2649 int g_mask = 0x7E0; | |
2650 int b_mask = 0x1F; | |
0 | 2651 |
2652 result = fopen(Filename, "wb"); | |
2653 Filename = (const char *)result; | |
2654 if ( result ) | |
2655 { | |
2128 | 2656 pitch = width; |
2127 | 2657 if ( width & 1 ) |
2128 | 2658 pitch = width + 1; |
0 | 2659 header1.left = 0; |
2660 header1.up = 0; | |
2127 | 2661 header1.right = width - 1; |
2662 header1.bottom = height - 1; | |
2128 | 2663 header2.pitch = pitch; |
0 | 2664 memset(color_map, 0, sizeof(color_map)); |
2665 header2.reserved = 0; | |
2666 memset(v14, 0, sizeof(v14)); | |
2667 v15 = 0; | |
2668 header1.manufacturer = 10; | |
2669 header1.version = 5; | |
2670 header1.encoding = 1; | |
2671 header1.bpp = 8; | |
2672 header1.hdpi = 75; | |
2673 header1.vdpi = 75; | |
2674 header2.planes = 3; | |
2675 header2.palette_info = 1; | |
2127 | 2676 fwrite(&header1, 1, 1, (FILE *)Filename); |
2677 pOutFile = (FILE *)Filename; | |
2678 fwrite(&header1.version, 1, 1, (FILE *)Filename); | |
2679 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2680 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2681 fwrite(&header1.left, 2, 1, pOutFile); | |
2682 fwrite(&header1.up, 2, 1, pOutFile); | |
2683 fwrite(&header1.right, 2, 1, pOutFile); | |
2684 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2685 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2686 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2687 fwrite(color_map, 0x30u, 1, pOutFile); | |
2688 fwrite(&header2, 1, 1, pOutFile); | |
2689 fwrite(&header2.planes, 1, 1, pOutFile); | |
2690 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2691 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2692 fwrite(v14, 0x3Au, 1, pOutFile); | |
2128 | 2693 |
2694 lineRGB = (char *)malloc(3 * (width + 2)); | |
2131 | 2695 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ |
2696 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî. | |
2128 | 2697 image_width = 3 * pitch; |
2698 v9 = picture_data; | |
2127 | 2699 for ( v18 = 0; v18 < height; v18++ )//ñòîëáåö |
2700 { | |
2128 | 2701 line_pictute_data = v9; |
2702 lineG = (char *)lineRGB + pitch; | |
2703 lineB = (char *)lineRGB + 2 * pitch; | |
2704 | |
2705 for ( int i = 0; i < width; i++ )//ñòðîêà | |
2706 { | |
2707 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); | |
2708 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); | |
2709 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); | |
2131 | 2710 line_pictute_data += 1; |
2128 | 2711 } |
2712 test_byte = 1; | |
2131 | 2713 for ( int i = 0; (signed int)i < image_width; i += test_byte ) |
2128 | 2714 { |
2715 unsigned char pic_byte = lineRGB[i]; | |
2716 for ( test_byte; test_byte < 63; ++test_byte )// ðàñ÷¸ò êîëè÷åñòâà îäèíàêîâûõ öâåòîâ | |
0 | 2717 { |
2128 | 2718 v12 = i + test_byte; |
2719 if ( lineRGB[v12] != pic_byte ) | |
2127 | 2720 break; |
2128 | 2721 if ( !(v12 % pitch) ) |
2127 | 2722 break; |
0 | 2723 } |
2128 | 2724 if ( i + test_byte > image_width ) |
2725 test_byte = 3 * pitch - i; | |
2726 if ( test_byte > 1 || pic_byte >= 0xC0 ) | |
0 | 2727 { |
2128 | 2728 v43 = test_byte | 0xC0;//òåñò-áàéò îáúåäèíåíèÿ |
2729 fwrite(&v43, 1, 1, pOutFile); | |
0 | 2730 } |
2128 | 2731 fwrite(&pic_byte, 1, 1, pOutFile); |
2732 } | |
2733 v9 += width; | |
2131 | 2734 } |
2128 | 2735 free(lineRGB); |
2155 | 2736 fclose(pOutFile); |
2737 } | |
0 | 2738 } |
2739 | |
2740 //----- (0049FBCD) -------------------------------------------------------- | |
2741 void Render::ClearTarget(unsigned int uColor) | |
2742 { | |
2154 | 2743 //if (pRenderD3D) |
0 | 2744 { |
2069 | 2745 if (using_software_screen_buffer) |
0 | 2746 pRenderD3D->ClearTarget(true, uColor, false, 0.0); |
2747 } | |
2154 | 2748 //else |
2749 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
0 | 2750 } |
2751 | |
2752 | |
2753 //----- (0049FC37) -------------------------------------------------------- | |
2754 void Render::Present() | |
2755 { | |
2217 | 2756 //struct tagRECT Rect; // [sp+8h] [bp-28h]@11 |
2757 //RECT a4; // [sp+18h] [bp-18h]@11 | |
2758 //struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
2759 | |
2069 | 2760 if ( !pRenderer->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2761 { |
2762 this->pBeforePresentFunction(); | |
2217 | 2763 if ( this->pRenderD3D ) |
2764 { | |
2765 if ( this->using_software_screen_buffer ) | |
0 | 2766 pRenderD3D->Present(false); |
2217 | 2767 } |
2768 else | |
2769 __debugbreak(); // no sr | |
1802 | 2770 /*{ |
2217 | 2771 if ( this->bWindowMode ) |
0 | 2772 { |
2773 RestoreFrontBuffer(); | |
2217 | 2774 GetClientRect(this->hWnd, &Rect); |
0 | 2775 Point.y = 0; |
2776 Point.x = 0; | |
2217 | 2777 ClientToScreen(this->hWnd, &Point); |
0 | 2778 OffsetRect(&Rect, Point.x, Point.y); |
2779 a4.top = 0; | |
2780 a4.bottom = 480; | |
2781 a4.left = 0; | |
2782 a4.right = 640; | |
2783 PresentRect(&Rect, &a4); | |
2784 } | |
2785 else | |
2786 { | |
2787 RestoreFrontBuffer(); | |
2788 a4.top = 0; | |
2789 a4.bottom = 480; | |
2790 a4.left = 0; | |
2791 a4.right = 640; | |
2792 BltBackToFontFast(0, 0, &a4); | |
2793 } | |
1802 | 2794 }*/ |
0 | 2795 } |
2796 } | |
2797 | |
2798 //----- (0049FD3A) -------------------------------------------------------- | |
2154 | 2799 void Render::_49FD3A_fullscreen() |
0 | 2800 { |
2801 Render *v2; // esi@1 | |
2802 IDirectDrawSurface4 *v3; // eax@6 | |
2803 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
2804 RECT v5; // [sp+8h] [bp-10h]@6 | |
2805 | |
1980 | 2806 Render* a1 = this; |
0 | 2807 v2 = a1; |
2808 if ( a1->pRenderD3D ) | |
2809 { | |
2810 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
2811 pFrontBuffer4->Restore(); | |
2812 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
2813 pBackBuffer4->Restore(); | |
2814 v3 = v2->pBackBuffer4; | |
2815 v4 = v2->pFrontBuffer4; | |
2816 v5.top = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2817 v5.bottom = window->GetHeight(); |
0 | 2818 v5.left = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2819 v5.right = window->GetWidth(); |
0 | 2820 v3->BltFast(0, 0, v4, &v5, 16u); |
2821 } | |
2822 } | |
2823 | |
2824 //----- (0049FDBF) -------------------------------------------------------- | |
2825 void Render::CreateZBuffer() | |
2826 { | |
2827 if (!pDefaultZBuffer) | |
2828 { | |
2829 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
1583 | 2830 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); |
871 | 2831 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 2832 } |
2833 } | |
2834 | |
2835 //----- (0049FE05) -------------------------------------------------------- | |
2836 void Render::Release() | |
2837 { | |
2838 Render *v1; // esi@1 | |
1802 | 2839 //RenderD3D *v2; // ecx@1 |
2840 //char v3; // zf@4 | |
2841 //void *v4; // ebx@6 | |
2334 | 2842 // IDirectDraw *v5; // eax@10 |
2843 // IDirectDrawSurface2 *v6; // eax@11 | |
2844 // IDirectDrawSurface2 *v7; // eax@13 | |
2845 // IDirectDrawSurface2 *v8; // eax@15 | |
2846 // IDirectDraw2 *v9; // eax@17 | |
2847 // IDirectDraw4 *v10; // eax@19 | |
2848 // IDirectDrawSurface4 *v11; // eax@20 | |
2849 // IDirectDrawSurface4 *v12; // eax@22 | |
2850 // IDirectDrawSurface4 *v13; // eax@24 | |
2851 // IDirectDraw4 *v14; // eax@26 | |
2852 // unsigned __int16 **v15; // ebx@28 | |
2853 // void **v16; // esi@29 | |
0 | 2854 |
2855 v1 = this; | |
1802 | 2856 if (pRenderD3D) |
0 | 2857 { |
2069 | 2858 if ( v1->using_software_screen_buffer ) |
0 | 2859 { |
1802 | 2860 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2861 pRenderD3D->Present(0); |
1802 | 2862 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2863 } |
2154 | 2864 //v1->pColorKeySurface4 = 0; |
0 | 2865 v1->pBackBuffer4 = 0; |
2866 v1->pFrontBuffer4 = 0; | |
2867 v1->pDirectDraw4 = 0; | |
1802 | 2868 if (v1->pTargetSurface) |
0 | 2869 { |
2069 | 2870 delete [] v1->pTargetSurface_unaligned; |
0 | 2871 v1->pTargetSurface = 0; |
2069 | 2872 v1->pTargetSurface_unaligned = 0; |
0 | 2873 } |
1802 | 2874 if (pRenderD3D) |
0 | 2875 { |
2876 pRenderD3D->Release(); | |
1802 | 2877 delete pRenderD3D; |
2878 } | |
2879 pRenderD3D = 0; | |
0 | 2880 } |
2881 else | |
1802 | 2882 ;//__debugbreak(); // no sr |
2883 /*{ | |
0 | 2884 if ( bWinNT4_0 == 1 ) |
2885 { | |
2886 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
2887 if ( !v5 ) | |
2888 return; | |
2889 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
2890 v1->pDirectDraw2->FlipToGDISurface(); | |
2891 v6 = v1->pSomeSurface2; | |
2892 if ( v6 ) | |
2893 { | |
2894 v6->Release(); | |
2895 v1->pSomeSurface2 = 0; | |
2896 } | |
2897 v7 = v1->pBackBuffer2; | |
2898 if ( v7 ) | |
2899 { | |
2900 v7->Release(); | |
2901 v1->pBackBuffer2 = 0; | |
2902 } | |
2903 v8 = v1->pFrontBuffer2; | |
2904 if ( v8 ) | |
2905 { | |
2906 v8->Release(); | |
2907 v1->pFrontBuffer2 = 0; | |
2908 } | |
2909 v9 = v1->pDirectDraw2; | |
2910 if ( v9 ) | |
2911 { | |
2912 v9->Release(); | |
2913 v1->pDirectDraw2 = 0; | |
2914 } | |
2915 } | |
2916 else | |
2917 { | |
2918 v10 = v1->pDirectDraw4; | |
2919 if ( !v10 ) | |
2920 return; | |
2921 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
2922 v1->pDirectDraw4->FlipToGDISurface(); | |
2923 v11 = v1->pColorKeySurface4; | |
2924 if ( v11 ) | |
2925 { | |
2926 v11->Release(); | |
2927 v1->pColorKeySurface4 = 0; | |
2928 } | |
2929 v12 = v1->pBackBuffer4; | |
2930 if ( v12 ) | |
2931 { | |
2932 v12->Release(); | |
2933 v1->pBackBuffer4 = 0; | |
2934 } | |
2935 v13 = v1->pFrontBuffer4; | |
2936 if ( v13 ) | |
2937 { | |
2938 v13->Release(); | |
2939 v1->pFrontBuffer4 = 0; | |
2940 } | |
2941 v14 = v1->pDirectDraw4; | |
2942 if ( v14 ) | |
2943 { | |
2944 v14->Release(); | |
2945 v1->pDirectDraw4 = 0; | |
2946 } | |
2947 } | |
2948 v15 = &v1->pTargetSurface; | |
2949 if ( v1->pTargetSurface ) | |
2950 { | |
2951 v16 = (void **)&v1->ptr_400E8; | |
2952 free(*v16); | |
2953 *v15 = 0; | |
2954 *v16 = 0; | |
2955 } | |
1802 | 2956 }*/ |
0 | 2957 } |
2958 | |
2152 | 2959 |
2960 | |
2961 | |
2962 void Present32(unsigned __int32 *src, unsigned int src_pitch, | |
2963 unsigned __int32 *dst, unsigned int dst_pitch) | |
2964 { | |
2965 for (uint y = 0; y < 8; ++y) | |
2966 memcpy(dst + y * dst_pitch, | |
2967 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2968 | |
2969 for (uint y = 8; y < 352; ++y) | |
2970 { | |
2971 memcpy(dst + y * dst_pitch, | |
2972 src + y * src_pitch, 8 * sizeof(__int32)); | |
2973 memcpy(dst + 8 + game_viewport_width + y * dst_pitch, | |
2974 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32)); | |
2975 } | |
2976 | |
2977 for (uint y = 352; y < 480; ++y) | |
2978 memcpy(dst + y * dst_pitch, | |
2979 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2980 | |
2981 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
2982 { | |
2983 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
2984 { | |
2985 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) | |
2155 | 2986 if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) |
2152 | 2987 dst[x + y * dst_pitch] = src[x + y * src_pitch]; |
2988 } | |
2989 } | |
2990 } | |
2991 | |
2992 //----- (004A597D) -------------------------------------------------------- | |
2993 void Present_NoColorKey() | |
2994 { | |
2995 //unsigned __int16 *v0; // eax@4 | |
2334 | 2996 // unsigned __int16 *v1; // esi@4 |
2152 | 2997 void *v2; // edi@4 |
2998 //signed int v4; // ebx@4 | |
2999 //signed int v5; // ebx@6 | |
3000 //void *v6; // edi@7 | |
3001 //const void *v7; // esi@7 | |
2334 | 3002 // signed int v8; // ebx@8 |
2152 | 3003 int v9; // eax@10 |
3004 unsigned int v10; // esi@10 | |
3005 unsigned __int32 v11; // edi@10 | |
3006 //int v12; // ecx@10 | |
3007 unsigned int v13; // ebx@10 | |
2334 | 3008 // int v14; // eax@11 |
3009 // int v15; // eax@13 | |
3010 // int v16; // eax@14 | |
3011 // int v17; // eax@16 | |
3012 // HRESULT v18; // eax@22 | |
2152 | 3013 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 |
3014 //int v20; // [sp+88h] [bp-1Ch]@10 | |
3015 int v21; // [sp+8Ch] [bp-18h]@10 | |
3016 __int32 v22; // [sp+90h] [bp-14h]@10 | |
3017 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10 | |
3018 unsigned int v24; // [sp+98h] [bp-Ch]@4 | |
3019 //unsigned int _this; // [sp+9Ch] [bp-8h]@10 | |
3020 //LPVOID v26; // [sp+A0h] [bp-4h]@4 | |
3021 | |
3022 int r_mask = 0xF800; | |
3023 int g_mask = 0x7E0; | |
3024 int b_mask = 0x1F; | |
3025 | |
3026 if ( !pRenderer->uNumSceneBegins ) | |
3027 { | |
2154 | 3028 //if ( pRenderer->using_software_screen_buffer ) |
3029 //{ | |
2152 | 3030 memset(&Dst, 0, 0x7Cu); |
3031 Dst.dwSize = 124; | |
3032 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
3033 { | |
3034 //v26 = Dst.lpSurface; | |
3035 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; | |
3036 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16); | |
3037 //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; | |
3038 //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; | |
3039 //v1 = pRenderer->pTargetSurface; | |
3040 v2 = Dst.lpSurface; | |
3041 | |
3042 | |
3043 /*for (uint y = 0; y < 480; ++y) | |
3044 { | |
3045 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch); | |
3046 for (uint x = 0; x < 640; ++x) | |
3047 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; | |
3048 }*/ | |
3049 | |
3050 if (!FORCE_16_BITS) | |
3051 Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4); | |
3052 else | |
3053 { | |
3054 ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface; | |
3055 short* pDst = (__int16 *)Dst.lpSurface; | |
3056 | |
3057 for (uint y = 0; y < 8; ++y) | |
3058 memcpy(pDst + y * Dst.lPitch / 2, | |
3059 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3060 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
2152 | 3061 |
3062 for (uint y = 8; y < 352; ++y) | |
3063 { | |
3064 memcpy(pDst + y * Dst.lPitch / 2, | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3065 pSrc + y * window->GetWidth(), 8 * sizeof(__int16)); |
2152 | 3066 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
|
3067 pSrc + 8 + game_viewport_width/*462*/ + y * window->GetWidth(), 174/*172*/ * sizeof(__int16)); |
2152 | 3068 } |
3069 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3070 for (uint y = 352; y < window->GetHeight(); ++y) |
2152 | 3071 memcpy(pDst + y * Dst.lPitch / 2, |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3072 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3073 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3074 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3075 ushort* pSrc_x1y1 = pSrc + window->GetWidth() * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; |
2152 | 3076 //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)]; |
3077 short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; | |
3078 //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY)); | |
3079 v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1); | |
3080 //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1); | |
3081 v22 = 4 * ((Dst.lPitch / 4) + v9); | |
3082 v21 = 4 * v9 + 1280; | |
3083 | |
3084 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1; | |
3085 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1); | |
3086 v10 = (int)pSrc_x1y1; | |
3087 v11 = (int)pDst_x1y1; | |
3088 int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; | |
3089 v13 = v24; | |
3090 | |
3091 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
3092 { | |
3093 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, | |
3094 // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); | |
3095 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
3096 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3097 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
|
3098 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * window->GetWidth() + x]; |
2152 | 3099 } |
3100 } | |
3101 } | |
3102 | |
3103 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3104 | |
3105 /* while ( 1 ) | |
3106 { | |
3107 while ( 1 ) | |
3108 { | |
3109 v14 = *(int *)v10; | |
3110 v10 += 4; | |
3111 if ( v14 == v13 ) | |
3112 break; | |
3113 if ( (short)v14 == (short)v13 ) | |
3114 { | |
3115 *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000; | |
3116 v11 += 4; | |
3117 --uHalfWidth; | |
3118 if ( !uHalfWidth ) | |
3119 goto LABEL_21; | |
3120 } | |
3121 else | |
3122 { | |
3123 v15 = __ROL__(v14, 16); | |
3124 if ( (short)v15 == (short)v13 ) | |
3125 { | |
3126 v17 = __ROR__(v15, 16); | |
3127 *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17; | |
3128 v11 += 4; | |
3129 --uHalfWidth; | |
3130 if ( !uHalfWidth ) | |
3131 goto LABEL_21; | |
3132 } | |
3133 else | |
3134 { | |
3135 v16 = __ROR__(v15, 16); | |
3136 *(int *)v11 = v16; | |
3137 v11 += 4; | |
3138 --uHalfWidth; | |
3139 if ( !uHalfWidth ) | |
3140 goto LABEL_21; | |
3141 } | |
3142 } | |
3143 } | |
3144 v11 += 4; | |
3145 --uHalfWidth; | |
3146 if ( !uHalfWidth ) | |
3147 { | |
3148 LABEL_21: | |
3149 v10 += v21; | |
3150 v11 += v22; | |
3151 uHalfWidth = v20; | |
3152 if ( !--uNumLines ) | |
3153 { | |
3154 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3155 return; | |
3156 } | |
3157 } | |
3158 }*/ | |
3159 } | |
2154 | 3160 //} |
3161 } | |
3162 } | |
3163 | |
0 | 3164 |
3165 //----- (0049FFFB) -------------------------------------------------------- | |
1802 | 3166 bool Render::InitializeFullscreen() |
0 | 3167 { |
3168 //Render *v2; // esi@1 | |
3169 //HWND v3; // ebx@1 | |
3170 //void *v4; // eax@2 | |
3171 //RenderD3D *v5; // eax@3 | |
3172 unsigned int v6; // edx@5 | |
3173 RenderD3D__DevInfo *v7; // ecx@5 | |
3174 bool v8; // eax@6 | |
3175 RenderD3D *v9; // ecx@13 | |
3176 unsigned int v10; // eax@13 | |
3177 RenderD3D *v11; // eax@25 | |
2334 | 3178 // HRESULT v12; // eax@25 |
0 | 3179 int v13; // ecx@25 |
3180 int v14; // eax@27 | |
3181 signed int v15; // ebx@31 | |
2069 | 3182 //bool v16; // eax@35 |
3183 //char v17; // zf@35 | |
2334 | 3184 // IDirectDraw4 *v18; // eax@38 |
3185 // HRESULT v19; // eax@38 | |
2069 | 3186 //int *v20; // eax@39 |
0 | 3187 int *v22; // eax@42 |
3188 int v23; // ecx@42 | |
3189 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3190 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3191 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
2334 | 3192 // DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 |
0 | 3193 void *v28; // [sp+2FCh] [bp-10h]@2 |
3194 int v29; // [sp+308h] [bp-4h]@2 | |
3195 | |
2069 | 3196 __debugbreak(); // Nomad |
3197 | |
0 | 3198 //v2 = this; |
2069 | 3199 this->using_software_screen_buffer = 0; |
2154 | 3200 //this->pColorKeySurface4 = 0; |
0 | 3201 this->pBackBuffer4 = 0; |
3202 this->pFrontBuffer4 = 0; | |
3203 this->pDirectDraw4 = 0; | |
2069 | 3204 //this->bColorKeySupported = 0; |
0 | 3205 Release(); |
3206 //v3 = hWnd; | |
1802 | 3207 this->window = window; |
0 | 3208 CreateZBuffer(); |
1802 | 3209 |
3210 /*if (!bUserDirect3D) | |
3211 { | |
3212 CreateDirectDraw(); | |
3213 SetDirectDrawCooperationMode(hWnd, 1); | |
3214 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3215 CreateDirectDrawPrimarySurface(); | |
3216 v15 = 1; | |
3217 } | |
3218 else | |
3219 {*/ | |
0 | 3220 pRenderD3D = new RenderD3D; |
3221 v28 = pRenderD3D; | |
3222 v6 = uDesiredDirect3DDevice; | |
3223 v29 = -1; | |
3224 v7 = pRenderD3D->pAvailableDevices; | |
3225 if ( v7[v6].bIsDeviceCompatible ) | |
3226 { | |
2069 | 3227 v8 = pRenderD3D->CreateDevice(v6, /*0*/true, window); |
0 | 3228 } |
3229 else | |
3230 { | |
3231 if ( v7[1].bIsDeviceCompatible ) | |
3232 { | |
2069 | 3233 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window); |
0 | 3234 } |
3235 else | |
3236 { | |
3237 if ( !v7->bIsDeviceCompatible ) | |
1545 | 3238 Error("There aren't any D3D devices to create."); |
3239 | |
2069 | 3240 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window); |
0 | 3241 } |
3242 } | |
3243 if ( !v8 ) | |
1545 | 3244 Error("D3Drend->Init failed."); |
3245 | |
0 | 3246 v9 = pRenderD3D; |
3247 pBackBuffer4 = v9->pBackBuffer; | |
3248 pFrontBuffer4 = v9->pFrontBuffer; | |
3249 pDirectDraw4 = v9->pHost; | |
3250 v10 = pRenderD3D->GetDeviceCaps(); | |
3251 if ( v10 & 1 ) | |
3252 { | |
3253 if ( pRenderD3D ) | |
3254 { | |
3255 pRenderD3D->Release(); | |
3256 delete pRenderD3D; | |
3257 } | |
3258 pRenderD3D = 0; | |
3259 pBackBuffer4 = 0; | |
3260 pFrontBuffer4 = 0; | |
3261 pDirectDraw4 = 0; | |
1545 | 3262 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3263 } |
3264 if ( v10 & 0x3E ) | |
3265 { | |
3266 if ( pRenderD3D ) | |
3267 { | |
3268 pRenderD3D->Release(); | |
3269 delete pRenderD3D; | |
3270 } | |
2154 | 3271 //pColorKeySurface4 = 0; |
0 | 3272 pRenderD3D = 0; |
3273 pBackBuffer4 = 0; | |
3274 pFrontBuffer4 = 0; | |
3275 pDirectDraw4 = 0; | |
1545 | 3276 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3277 } |
3278 if ( (v10 & 0x80u) != 0 ) | |
3279 { | |
3280 if ( pRenderD3D ) | |
3281 { | |
3282 pRenderD3D->Release(); | |
3283 delete pRenderD3D; | |
3284 } | |
3285 pRenderD3D = 0; | |
3286 pBackBuffer4 = 0; | |
3287 pFrontBuffer4 = 0; | |
3288 pDirectDraw4 = 0; | |
1545 | 3289 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3290 } |
2154 | 3291 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; |
0 | 3292 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3293 memset(&halCaps, 0, 0xFCu); | |
3294 halCaps.dwSize = 252; | |
3295 memset(&refCaps, 0, 0xFCu); | |
3296 v11 = pRenderD3D; | |
3297 refCaps.dwSize = 252; | |
3298 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
3299 v13 = halCaps.dwMinTextureWidth; | |
3300 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3301 v13 = halCaps.dwMinTextureHeight; | |
3302 v14 = halCaps.dwMaxTextureWidth; | |
3303 uMinDeviceTextureDim = v13; | |
3304 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
3305 v14 = halCaps.dwMaxTextureHeight; | |
3306 uMaxDeviceTextureDim = v14; | |
3307 if ( (unsigned int)v13 < 4 ) | |
3308 uMinDeviceTextureDim = 4; | |
3309 v15 = 1; | |
3310 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3311 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
2154 | 3312 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2)); |
0 | 3313 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); |
3314 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3315 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
2154 | 3316 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); |
3317 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
3318 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
3319 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3)); | |
3320 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2)); | |
0 | 3321 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); |
2154 | 3322 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2)); |
3323 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
0 | 3324 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); |
2154 | 3325 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4)); |
1802 | 3326 //} |
2069 | 3327 ddpfPrimarySuface.dwSize = 32; |
3328 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3329 ParseTargetPixelFormat(); |
2069 | 3330 |
3331 if (!pRenderD3D) | |
3332 { | |
3333 __debugbreak(); | |
3334 pBeforePresentFunction = 0;//nullsub_1; | |
3335 } | |
3336 //else | |
3337 //{ | |
3338 /*v16 = IsColorKeySupported(pDirectDraw4); | |
0 | 3339 v17 = uAcquiredDirect3DDevice == v15; |
3340 bColorKeySupported = v16; | |
3341 if ( !v17 ) | |
3342 bColorKeySupported = 0; | |
3343 if ( bColorKeySupported ) | |
3344 { | |
3345 memset(&ddsd2, 0, 0x7Cu); | |
3346 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3347 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3348 v18 = pDirectDraw4; | |
3349 ddsd2.dwSize = 124; | |
3350 ddsd2.dwFlags = 65543; | |
3351 ddsd2.ddsCaps.dwCaps = 2112; | |
3352 ddsd2.dwWidth = 640; | |
3353 ddsd2.dwHeight = 480; | |
3354 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3355 pBeforePresentFunction = Present_ColorKey; | |
3356 } | |
2069 | 3357 else*/ |
0 | 3358 { |
3359 pTargetSurface = 0; | |
2069 | 3360 pTargetSurface_unaligned = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3361 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32); |
2069 | 3362 if ( !pTargetSurface_unaligned |
0 | 3363 || (memset(&pDesc, 0, 0x7Cu), |
3364 pDesc.dwSize = 124, | |
3365 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
3366 return 0; | |
3367 pBackBuffer4->Unlock(0); | |
2069 | 3368 v22 = (int *)pTargetSurface_unaligned + 4; |
0 | 3369 v23 = (unsigned int)pDesc.lpSurface & 7; |
3370 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3371 uTargetSurfacePitch = window->GetWidth(); |
0 | 3372 pBeforePresentFunction = Present_NoColorKey; |
3373 v15 = 1; | |
2069 | 3374 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23); |
3375 } | |
3376 using_software_screen_buffer = v15; | |
3377 //} | |
0 | 3378 bWindowMode = 0; |
3379 pParty->uFlags |= 2u; | |
2151 | 3380 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
3381 return v15 != 0; |
0 | 3382 } |
3383 | |
3384 //----- (004A05F3) -------------------------------------------------------- | |
1802 | 3385 bool Render::SwitchToWindow() |
0 | 3386 { |
3387 //Render *v2; // esi@1 | |
3388 //void *v3; // eax@2 | |
3389 //RenderD3D *v4; // eax@3 | |
3390 //unsigned int v5; // edx@5 | |
3391 //RenderD3D__DevInfo *v6; // ecx@5 | |
3392 bool v7; // eax@7 | |
3393 //RenderD3D *v8; // ecx@12 | |
3394 unsigned int v9; // eax@12 | |
2334 | 3395 // RenderD3D *v10; // eax@24 |
3396 // HRESULT v11; // eax@24 | |
0 | 3397 int v12; // eax@24 |
3398 int v13; // eax@26 | |
2069 | 3399 //bool v14; // eax@32 |
3400 //char v15; // zf@32 | |
2334 | 3401 // IDirectDraw4 *v16; // eax@35 |
3402 // HRESULT v17; // eax@35 | |
2069 | 3403 //int *v18; // eax@36 |
2334 | 3404 // int *v19; // edx@38 |
3405 // int v20; // eax@38 | |
3406 // unsigned int v21; // ecx@38 | |
3407 // int v22; // eax@41 | |
0 | 3408 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 |
3409 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3410 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
2334 | 3411 // DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 |
0 | 3412 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 |
3413 int v29; // [sp+308h] [bp-4h]@2 | |
3414 | |
2069 | 3415 pParty->uFlags |= PARTY_FLAGS_1_0002; |
2151 | 3416 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
2069 | 3417 using_software_screen_buffer = 0; |
0 | 3418 Release(); |
2154 | 3419 //pColorKeySurface4 = 0; |
0 | 3420 pBackBuffer4 = 0; |
3421 pFrontBuffer4 = 0; | |
3422 pDirectDraw4 = 0; | |
2069 | 3423 //bColorKeySupported = 0; |
0 | 3424 CreateZBuffer(); |
1802 | 3425 /*if (!bUserDirect3D) |
3426 { | |
3427 CreateDirectDraw(); | |
3428 SetDirectDrawCooperationMode(hWnd, 0); | |
3429 field_4004C = 1; | |
3430 CreateFrontBuffer(); | |
3431 CreateClipper(hWnd); | |
3432 CreateBackBuffer(); | |
3433 field_40030 = 0; | |
3434 field_18_locked_pitch = 0; | |
3435 } | |
3436 else | |
3437 {*/ | |
1631 | 3438 /*v3 = malloc(0x148u); |
0 | 3439 thisa = (RenderD3D *)v3; |
3440 v29 = 0; | |
3441 if ( v3 ) | |
3442 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3443 else | |
3444 v4 = 0;*/ | |
3445 pRenderD3D = new RenderD3D; | |
3446 //v4 = pRenderD3D; | |
3447 //v5 = uDesiredDirect3DDevice; | |
3448 v29 = -1; | |
3449 //v6 = pRenderD3D->pAvailableDevices; | |
3450 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
3451 uDesiredDirect3DDevice != 1 ) | |
3452 { | |
2069 | 3453 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window); |
0 | 3454 } |
3455 else | |
3456 { | |
3457 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
1545 | 3458 Error("There aren't any D3D devices to init."); |
3459 | |
2069 | 3460 v7 = pRenderD3D->CreateDevice(0, true, window); |
0 | 3461 } |
3462 if ( !v7 ) | |
1545 | 3463 Error("D3Drend->Init failed."); |
0 | 3464 |
3465 //v8 = pRenderD3D; | |
2154 | 3466 //pColorKeySurface4 = 0; |
0 | 3467 pBackBuffer4 = pRenderD3D->pBackBuffer; |
3468 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3469 pDirectDraw4 = pRenderD3D->pHost; | |
3470 v9 = pRenderD3D->GetDeviceCaps(); | |
3471 if ( v9 & 1 ) | |
3472 { | |
3473 if (pRenderD3D) | |
3474 { | |
3475 pRenderD3D->Release(); | |
3476 delete pRenderD3D; | |
3477 } | |
3478 pRenderD3D = 0; | |
3479 pBackBuffer4 = 0; | |
3480 pFrontBuffer4 = 0; | |
3481 pDirectDraw4 = 0; | |
1545 | 3482 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3483 } |
3484 if ( v9 & 0x3E ) | |
3485 { | |
3486 if (pRenderD3D) | |
3487 { | |
3488 pRenderD3D->Release(); | |
3489 delete pRenderD3D; | |
3490 } | |
2154 | 3491 //pColorKeySurface4 = 0; |
0 | 3492 pRenderD3D = 0; |
3493 pBackBuffer4 = 0; | |
3494 pFrontBuffer4 = 0; | |
3495 pDirectDraw4 = 0; | |
1545 | 3496 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3497 } |
2154 | 3498 if (v9 & 0x80) |
0 | 3499 { |
3500 if (pRenderD3D) | |
3501 { | |
3502 pRenderD3D->Release(); | |
3503 delete pRenderD3D; | |
3504 } | |
3505 pRenderD3D = 0; | |
3506 pBackBuffer4 = 0; | |
3507 pFrontBuffer4 = 0; | |
3508 pDirectDraw4 = 0; | |
1545 | 3509 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3510 } |
2154 | 3511 //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; |
0 | 3512 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3513 memset(&halCaps, 0, 0xFCu); | |
3514 halCaps.dwSize = 252; | |
3515 memset(&refCaps, 0, 0xFCu); | |
3516 //v10 = v2->pRenderD3D; | |
3517 refCaps.dwSize = 252; | |
3518 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3519 v12 = halCaps.dwMinTextureWidth; | |
2069 | 3520 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight ) |
0 | 3521 v12 = halCaps.dwMinTextureHeight; |
3522 uMinDeviceTextureDim = v12; | |
3523 v13 = halCaps.dwMaxTextureWidth; | |
3524 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3525 v13 = halCaps.dwMaxTextureHeight; | |
3526 uMaxDeviceTextureDim = v13; | |
3527 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
3528 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
3529 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3530 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
3531 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
3532 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3533 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3534 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3535 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3536 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3537 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3538 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3539 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3540 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3541 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
1802 | 3542 //} |
3543 | |
2069 | 3544 ddpfPrimarySuface.dwSize = 32; |
3545 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3546 ParseTargetPixelFormat(); |
2069 | 3547 |
0 | 3548 if ( !pRenderD3D ) |
3549 { | |
2069 | 3550 __debugbreak(); |
3551 //pBeforePresentFunction = 0;//nullsub_1; | |
3552 //goto LABEL_47; | |
3553 } | |
3554 /*v14 = IsColorKeySupported(pDirectDraw4); | |
0 | 3555 v15 = uAcquiredDirect3DDevice == 1; |
3556 bColorKeySupported = v14; | |
3557 if ( !v15 ) | |
2069 | 3558 bColorKeySupported = 0;*/ |
3559 //if ( bColorKeySupported ) | |
3560 if (false) | |
3561 { | |
3562 /*memset(&ddsd2, 0, 0x7Cu); | |
0 | 3563 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; |
3564 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3565 v16 = pDirectDraw4; | |
3566 ddsd2.dwSize = 124; | |
3567 ddsd2.dwFlags = 65543; | |
3568 ddsd2.ddsCaps.dwCaps = 2112; | |
3569 ddsd2.dwWidth = 640; | |
3570 ddsd2.dwHeight = 480; | |
3571 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
2069 | 3572 pBeforePresentFunction = Present_ColorKey;*/ |
0 | 3573 LABEL_45: |
2069 | 3574 using_software_screen_buffer = 1; |
3575 //LABEL_47: | |
0 | 3576 bWindowMode = 1; |
1802 | 3577 //hWnd = hWnd; |
0 | 3578 return 0; |
3579 } | |
3580 pTargetSurface = 0; | |
2069 | 3581 pTargetSurface_unaligned = 0; |
3582 | |
3583 uint num_pixels = window->GetWidth() * window->GetHeight(); | |
3584 pTargetSurface_unaligned = new unsigned int[num_pixels]; | |
3585 | |
3586 if (!pTargetSurface_unaligned) | |
3587 return false; | |
3588 | |
3589 memset(&pDesc, 0, 0x7Cu); | |
3590 pDesc.dwSize = 124; | |
3591 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT)) | |
3592 { | |
3593 delete [] pTargetSurface_unaligned; | |
3594 return false; | |
3595 } | |
3596 | |
3597 memset32(pTargetSurface_unaligned, -1, num_pixels); | |
3598 | |
3599 | |
0 | 3600 pRenderer->pBackBuffer4->Unlock(0); |
2069 | 3601 /*v19 = pTargetSurface_unaligned; |
0 | 3602 v20 = (unsigned int)pDesc.lpSurface & 7; |
3603 v21 = (unsigned int)ptr_400E8 & 7; | |
3604 if ( v21 == v20 ) | |
3605 { | |
3606 pTargetSurface = (unsigned __int16 *)v19; | |
3607 } | |
3608 else | |
3609 { | |
3610 if ( (signed int)v21 >= v20 ) | |
3611 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
3612 else | |
3613 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
3614 pTargetSurface = (unsigned __int16 *)v22; | |
2069 | 3615 }*/ |
3616 pTargetSurface = pTargetSurface_unaligned; | |
3617 uTargetSurfacePitch = window->GetWidth(); | |
0 | 3618 pBeforePresentFunction = Present_NoColorKey; |
3619 goto LABEL_45; | |
3620 } | |
3621 | |
2154 | 3622 |
3623 //----- (0044F2B2) -------------------------------------------------------- | |
3624 bool Render::IsGammaSupported() | |
3625 { | |
2334 | 3626 // bool result; // eax@3 |
3627 // HRESULT v1; // eax@4 | |
2154 | 3628 |
3629 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
3630 { | |
3631 DDCAPS halCaps; // [sp+0h] [bp-180h]@4 | |
3632 memset(&halCaps, 0, sizeof(DDCAPS)); | |
3633 halCaps.dwSize = sizeof(DDCAPS); | |
3634 | |
3635 ErrD3D(pDirectDraw4->GetCaps(&halCaps, 0)); | |
3636 return (halCaps.dwCaps2 >> 17) & 1; | |
3637 } | |
3638 /*else | |
3639 return false;*/ | |
3640 } | |
3641 | |
0 | 3642 //----- (004A0BEE) -------------------------------------------------------- |
2102 | 3643 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) |
3644 { | |
2198 | 3645 signed int lower_bound; // eax@17 |
2334 | 3646 // signed int left_bound; |
0 | 3647 unsigned int v21; // edi@46 |
3648 int v22; // esi@47 | |
3649 int v23; // ebx@47 | |
3650 signed int v24; // edx@50 | |
3651 signed int v25; // esi@52 | |
3652 unsigned __int16 *v26; // ecx@52 | |
3653 int v27; // ebx@54 | |
3654 int v28; // edi@55 | |
3655 int v29; // edx@55 | |
3656 int v30; // ebx@60 | |
3657 int v31; // edx@61 | |
3658 int v32; // edi@61 | |
2198 | 3659 signed int upper_bound; // [sp+18h] [bp-4h]@28 |
0 | 3660 unsigned int uXa; // [sp+24h] [bp+8h]@49 |
3661 int uYb; // [sp+28h] [bp+Ch]@47 | |
2245 | 3662 bool left_border_x = false; |
3663 bool right_border_x = false; | |
3664 bool left_border_z = false; | |
3665 bool right_border_z = false; | |
3666 bool upper_border_y = false; | |
3667 bool bottom_border_y = false; | |
3668 bool upper_border_w = false; | |
3669 bool bottom_border_w = false; | |
3670 | |
2101 | 3671 if ( uX < this->raster_clip_x )// x âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2245 | 3672 left_border_x = true; |
2101 | 3673 if ( uX > this->raster_clip_z )// x âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
2245 | 3674 right_border_x = true; |
2097 | 3675 |
2101 | 3676 if ( uZ < this->raster_clip_x )// z âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2245 | 3677 left_border_z = true; |
2101 | 3678 if ( uZ > this->raster_clip_z )// z âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
2245 | 3679 right_border_z = true; |
2101 | 3680 |
3681 if ( uY < this->raster_clip_y )// y âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
2245 | 3682 upper_border_y = true; |
2101 | 3683 if ( uY > this->raster_clip_w )// y âûõîäèò çà ðàìêè íèæíåé ãðàíèöû |
2245 | 3684 bottom_border_y = true; |
2101 | 3685 |
3686 if ( uW < this->raster_clip_y )// w âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
2245 | 3687 upper_border_w = true; |
2101 | 3688 if ( uW > this->raster_clip_w )// w âûõîäèò çà ðàìêè íèæíåé ãðàíèöû |
2245 | 3689 bottom_border_w = true; |
3690 | |
3691 if ( (left_border_x && left_border_z) || (right_border_x && right_border_z ) | |
3692 || (upper_border_y && upper_border_w) || (bottom_border_y && bottom_border_w)) | |
2102 | 3693 return; |
3694 | |
2245 | 3695 if ( left_border_x || left_border_z || right_border_x || right_border_z |
3696 || upper_border_y || upper_border_w || bottom_border_y || bottom_border_w) | |
3697 { | |
3698 if ( left_border_x || left_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left (ëåâàÿ ãðàíèöà) | |
3699 { | |
3700 if ( left_border_x )//left_border = true; õ ìåíüøå ëåâîé ãðàíèöû | |
3701 { | |
3702 uY += (uW - uY) * ((this->raster_clip_x - uX) / (uZ - uX));//t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
2199 | 3703 uX = this->raster_clip_x; |
3704 } | |
2245 | 3705 else if ( left_border_z )//z ìåíüøå ëåâîé ãðàíèöû |
2199 | 3706 { |
3707 uZ = this->raster_clip_x; | |
2245 | 3708 uW += (uY - uW) * ((this->raster_clip_x - uZ) / (uX - uZ)); |
3709 } | |
3710 } | |
3711 | |
3712 if ( right_border_x || right_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )//for right (ïðàâàÿ ãðàíèöà) | |
3713 { | |
3714 if ( right_border_x ) //right_border = true; õ áîëüøå ïðàâîé ãðàíèöû | |
3715 { | |
3716 uY += (uY - uW) * ((this->raster_clip_z - uX) / (uZ - uX)); | |
2199 | 3717 uX = this->raster_clip_z; |
0 | 3718 } |
2245 | 3719 else if ( right_border_z )//z áîëüøå ïðàâîé ãðàíèöû |
3720 { | |
3721 uW += (uW - uY) * ((this->raster_clip_z - uZ) / (uX - uZ)); | |
2199 | 3722 uZ = this->raster_clip_z; |
3723 } | |
3724 } | |
2245 | 3725 |
2199 | 3726 upper_bound = 0; |
3727 if ( uY < this->raster_clip_y ) | |
3728 upper_bound = 2; | |
3729 if ( uY > this->raster_clip_w ) | |
3730 upper_bound |= 1; | |
3731 | |
3732 lower_bound = 0; | |
3733 if ( uW < this->raster_clip_y ) | |
3734 lower_bound = 2; | |
3735 if ( uW > this->raster_clip_w ) | |
3736 lower_bound |= 1; | |
3737 | |
3738 if ( !(lower_bound & upper_bound) )//for up and down(äëÿ âåðõà è íèçà) | |
3739 { | |
3740 lower_bound ^= upper_bound; | |
3741 if ( lower_bound & 2 ) | |
3742 { | |
3743 if ( upper_bound & 2 ) | |
3744 { | |
2245 | 3745 uX += (uZ - uX) * ((this->raster_clip_y - uY) / (uW - uY)); |
2199 | 3746 uY = this->raster_clip_y; |
3747 } | |
3748 else | |
3749 { | |
2245 | 3750 uZ += (uX - uZ) * ((this->raster_clip_y - uW) / (uY - uW)); |
2199 | 3751 uW = this->raster_clip_y; |
3752 } | |
3753 } | |
3754 if ( lower_bound & 1 ) | |
3755 { | |
3756 if ( upper_bound & 1 ) | |
3757 { | |
2245 | 3758 uX += (uZ - uX) * ((this->raster_clip_w - uY) / (uW - uY)); |
2199 | 3759 uY = this->raster_clip_w; |
3760 } | |
3761 else | |
0 | 3762 { |
2245 | 3763 uZ += (uX - uZ) * ((this->raster_clip_w - uW) / (uY - uW)); |
2199 | 3764 uW = this->raster_clip_w; |
3765 } | |
3766 } | |
3767 } | |
3768 } | |
3769 v21 = pRenderer->uTargetSurfacePitch; | |
3770 if ( pRenderer->uTargetSurfacePitch ) | |
3771 { | |
3772 //v12 = uX + uY * pRenderer->uTargetSurfacePitch; | |
3773 v22 = uW - uY; | |
3774 v23 = v22; | |
3775 uYb = v22; | |
3776 if ( v22 < 0 ) | |
3777 { | |
3778 v23 = -v22; | |
3779 uYb = -v22; | |
3780 v21 = -pRenderer->uTargetSurfacePitch; | |
3781 } | |
3782 uXa = uZ - uX; | |
3783 if ((signed)(uZ - uX) >= 0) | |
3784 v24 = 1; | |
3785 else | |
3786 { | |
3787 uXa = -uXa; | |
3788 v24 = -1; | |
3789 } | |
3790 v25 = 0; | |
3791 | |
3792 v26 = (unsigned __int16 *)this->pTargetSurface; | |
3793 if ( v26 ) | |
3794 { | |
3795 if ( (signed int)uXa <= v23 )//ðèñóåì âåðòèêàëüíóþ ëèíèþ | |
3796 { | |
3797 v30 = v23 + 1; | |
3798 if ( v30 > 0 ) | |
3799 { | |
3800 v31 = 2 * v24; | |
3801 v32 = 2 * v21; | |
3802 //v12 = (int)&v26[v12]; | |
3803 int y = 0; | |
3804 int x = 0; | |
3805 for ( v30; v30; --v30 ) | |
0 | 3806 { |
2199 | 3807 v25 += uXa; |
3808 //*(short *)v12 = uColor; | |
3809 //v12 += v32; | |
3810 WritePixel16(uX + x, uY + y, uColor); | |
3811 if ( v32 >= 0 ) | |
3812 y += 1; | |
3813 else | |
3814 y -= 1; | |
3815 if ( v25 > 0 ) | |
0 | 3816 { |
2199 | 3817 v25 -= uYb; |
3818 //v12 += v31; | |
3819 if ( v31 >= 0 ) | |
2096 | 3820 x += 1; |
3821 else | |
3822 x -= 1; | |
0 | 3823 } |
3824 } | |
3825 } | |
3826 } | |
2199 | 3827 else//ðèñóåì ãîðèçîíòàëüíóþ ëèíèþ |
3828 { | |
3829 v27 = uXa + 1; | |
3830 if ( (signed int)(uXa + 1) > 0 ) | |
3831 { | |
3832 v28 = 2 * v21; | |
3833 v29 = 2 * v24; | |
3834 int y = 0; | |
3835 int x = 0; | |
3836 //v12 = (int)&v26[v12]; | |
3837 for ( v27; v27; --v27 ) | |
3838 { | |
3839 v25 += uYb; | |
3840 //*(short *)v12 = uColor; | |
3841 //v12 += v29; | |
3842 WritePixel16(uX + x, uY + y, uColor); | |
3843 if ( v29 >= 0 ) | |
3844 x += 1; | |
3845 else | |
3846 x -= 1; | |
3847 if ( v25 > (signed int)uXa ) | |
3848 { | |
3849 v25 -= uXa; | |
3850 //v12 += v28; | |
3851 if ( v28 >= 0 ) | |
3852 y += 1; | |
3853 else | |
3854 y -= 1; | |
3855 } | |
3856 } | |
3857 } | |
3858 } | |
3859 } | |
0 | 3860 } |
2102 | 3861 return; |
0 | 3862 } |
3863 | |
3864 //----- (004A0E80) -------------------------------------------------------- | |
3865 void Render::ClearZBuffer(int a2, int a3) | |
3866 { | |
2245 | 3867 memset32(this->pActiveZBuffer, -65536, 0x4B000); |
0 | 3868 } |
3869 | |
3870 //----- (004A0E97) -------------------------------------------------------- | |
709 | 3871 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
3872 { | |
3873 this->raster_clip_x = uX; | |
3874 this->raster_clip_y = uY; | |
3875 this->raster_clip_z = uZ; | |
3876 this->raster_clip_w = uW; | |
0 | 3877 } |
3878 | |
3879 //----- (004A0EB6) -------------------------------------------------------- | |
3880 void Render::ParseTargetPixelFormat() | |
3881 { | |
3882 signed int v2; // ecx@1 | |
3883 DWORD uRedMask; // edx@1 | |
3884 unsigned int uGreenMask; // esi@5 | |
3885 signed int v5; // ecx@5 | |
3886 unsigned int uBlueMask; // edx@9 | |
3887 signed int v7; // ecx@9 | |
2069 | 3888 //unsigned int v8; // ecx@13 |
0 | 3889 |
3890 v2 = 0; | |
2132 | 3891 uRedMask = this->ddpfPrimarySuface.dwRBitMask; |
3892 this->uTargetBBits = 0; | |
3893 this->uTargetGBits = 0; | |
3894 this->uTargetRBits = 0; | |
0 | 3895 do |
3896 { | |
3897 if ( (1 << v2) & uRedMask ) | |
2132 | 3898 ++this->uTargetRBits; |
0 | 3899 ++v2; |
3900 } | |
2069 | 3901 while ( v2 < 32 ); |
2132 | 3902 uGreenMask = this->ddpfPrimarySuface.dwGBitMask; |
0 | 3903 v5 = 0; |
3904 do | |
3905 { | |
3906 if ( (1 << v5) & uGreenMask ) | |
2132 | 3907 ++this->uTargetGBits; |
0 | 3908 ++v5; |
3909 } | |
2069 | 3910 while ( v5 < 32 ); |
2132 | 3911 uBlueMask = this->ddpfPrimarySuface.dwBBitMask; |
0 | 3912 v7 = 0; |
3913 do | |
3914 { | |
3915 if ( (1 << v7) & uBlueMask ) | |
2132 | 3916 ++this->uTargetBBits; |
0 | 3917 ++v7; |
3918 } | |
2069 | 3919 while ( v7 < 32 ); |
2132 | 3920 this->uTargetGMask = uGreenMask; |
3921 this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask; | |
3922 this->uTargetBMask = uBlueMask; | |
0 | 3923 } |
3924 | |
3925 //----- (004A0F40) -------------------------------------------------------- | |
3926 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
3927 { | |
2132 | 3928 //IDirectDrawSurface4 *v4; // esi@1 |
168 | 3929 HRESULT result; // eax@1 |
0 | 3930 HRESULT v6; // eax@4 |
2334 | 3931 // int v7; // [sp-8h] [bp-14h]@10 |
3932 // unsigned int v8; // [sp-4h] [bp-10h]@10 | |
0 | 3933 char v9; // [sp+Bh] [bp-1h]@1 |
3934 | |
2132 | 3935 //v4 = pSurface; |
0 | 3936 v9 = 1; |
3937 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
3938 if ( result == DDERR_SURFACELOST ) | |
3939 { | |
2132 | 3940 v6 = pSurface->Restore(); |
0 | 3941 if ( v6 ) |
3942 { | |
3943 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
3944 { | |
3945 LABEL_20: | |
3946 v9 = 0; | |
3947 result = (bool)memset(pDesc, 0, 4u); | |
3948 goto LABEL_21; | |
3949 } | |
3950 pRenderer->pFrontBuffer4->Restore(); | |
2132 | 3951 pSurface->Restore(); |
3952 } | |
3953 result = pSurface->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
0 | 3954 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) |
3955 goto LABEL_20; | |
3956 ErrD3D(result); | |
3957 if ( result ) | |
3958 { | |
3959 //v8 = 0; | |
3960 //v7 = 2161; | |
2334 | 3961 //LABEL_19: |
0 | 3962 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); |
3963 goto LABEL_20; | |
3964 } | |
3965 if ( pRenderer->pRenderD3D ) | |
3966 pRenderD3D->HandleLostResources(); | |
3967 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
3968 } | |
3969 else | |
3970 { | |
3971 if ( result ) | |
3972 { | |
3973 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3974 goto LABEL_20; | |
3975 ErrD3D(result); | |
3976 //v8 = 0; | |
3977 //v7 = 2199; | |
3978 //goto LABEL_19; | |
3979 } | |
3980 } | |
3981 LABEL_21: | |
3982 LOBYTE(result) = v9; | |
3983 return result; | |
3984 } | |
3985 | |
3986 | |
3987 //----- (004A10E4) -------------------------------------------------------- | |
3988 void Render::CreateDirectDraw() | |
3989 { | |
3990 Render *v1; // edi@1 | |
2334 | 3991 // HRESULT v2; // eax@1 |
3992 // HRESULT v3; // eax@5 | |
3993 // int v6; // [sp-Ch] [bp-20h]@3 | |
3994 // unsigned int v9; // [sp+0h] [bp-14h]@0 | |
0 | 3995 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 |
3996 | |
3997 v1 = this; | |
3998 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
3999 | |
4000 pDirectDraw4 = nullptr; | |
4001 | |
2152 | 4002 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); |
0 | 4003 |
4004 lpDD->Release(); | |
4005 lpDD = nullptr; | |
4006 } | |
4007 | |
4008 //----- (004A1169) -------------------------------------------------------- | |
4009 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
4010 { | |
4011 DWORD flags; // eax@1 | |
2334 | 4012 // IDirectDraw *v4; // ecx@3 |
4013 //// HRESULT v5; // eax@5 | |
4014 // int v6; // [sp-8h] [bp-8h]@3 | |
4015 // unsigned int v7; // [sp-4h] [bp-4h]@3 | |
0 | 4016 |
4017 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
4018 DDSCL_NORMAL; | |
4019 | |
2152 | 4020 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); |
0 | 4021 } |
4022 | |
4023 //----- (004A11C6) -------------------------------------------------------- | |
4024 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
4025 { | |
2152 | 4026 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); |
0 | 4027 } |
4028 | |
4029 //----- (004A121C) -------------------------------------------------------- | |
4030 void Render::CreateFrontBuffer() | |
4031 { | |
4032 Render *v1; // esi@1 | |
4033 IDirectDraw *pDD; // eax@3 | |
4034 IDirectDrawSurface **pOutSurf; // esi@3 | |
4035 struct _DDSURFACEDESC *v4; // edx@3 | |
2334 | 4036 //// HRESULT v5; // eax@5 |
0 | 4037 int v6; // [sp-8h] [bp-8Ch]@3 |
4038 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4039 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4040 | |
4041 v1 = this; | |
2152 | 4042 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4043 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4044 { |
4045 memset(&a2, 0, 0x7Cu); | |
4046 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
4047 a2.dwSize = 124; | |
4048 a2.dwFlags = 1; | |
4049 v7 = 0; | |
4050 a2.ddsCaps.dwCaps = 512; | |
4051 v6 = 2357; | |
4052 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
4053 v4 = (struct _DDSURFACEDESC *)&a2; | |
4054 } | |
2152 | 4055 /*else |
0 | 4056 { |
4057 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
4058 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
4059 a2.lPitch = 108; | |
4060 a2.dwBackBufferCount = 1; | |
4061 v7 = 0; | |
4062 a2.dwTextureStage = 512; | |
4063 v6 = 2346; | |
4064 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
4065 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
2152 | 4066 }*/ |
0 | 4067 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); |
4068 } | |
4069 | |
4070 //----- (004A12CD) -------------------------------------------------------- | |
4071 void Render::CreateBackBuffer() | |
4072 { | |
4073 Render *v1; // esi@1 | |
4074 IDirectDraw *v2; // eax@3 | |
4075 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
4076 struct _DDSURFACEDESC *v4; // edx@3 | |
2334 | 4077 // HRESULT v5; // eax@5 |
0 | 4078 int v6; // [sp-8h] [bp-8Ch]@3 |
4079 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4080 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4081 | |
4082 v1 = this; | |
2152 | 4083 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4084 // pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4085 { |
4086 memset(&a2, 0, 0x7Cu); | |
4087 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
4088 a2.dwSize = 124; | |
4089 a2.dwFlags = 7; | |
4090 v7 = 0; | |
4091 a2.ddsCaps.dwCaps = 2112; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
4092 a2.dwWidth = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
4093 a2.dwHeight = window->GetHeight(); |
0 | 4094 v6 = 2387; |
4095 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4096 v4 = (struct _DDSURFACEDESC *)&a2; | |
4097 } | |
2152 | 4098 /*else |
0 | 4099 { |
4100 memset(&a2.lPitch, 0, 0x6Cu); | |
4101 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4102 a2.lPitch = 108; | |
4103 a2.dwBackBufferCount = 7; | |
4104 v7 = 0; | |
4105 a2.dwTextureStage = 2112; | |
4106 a2.dwAlphaBitDepth = 640; | |
4107 a2.dwMipMapCount = 480; | |
4108 v6 = 2374; | |
4109 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4110 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
2152 | 4111 }*/ |
0 | 4112 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); |
4113 } | |
4114 | |
4115 //----- (004A139A) -------------------------------------------------------- | |
4116 void Render::CreateDirectDrawPrimarySurface() | |
4117 { | |
4118 Render *v1; // esi@1 | |
2154 | 4119 //int v2; // ebx@3 |
2334 | 4120 // IDirectDraw2 *v3; // eax@3 |
4121 // HRESULT v4; // eax@3 | |
0 | 4122 IDirectDrawSurface *pFrontBuffer; // eax@3 |
4123 DDSCAPS2 *v6; // edx@3 | |
4124 IDirectDraw4 *v7; // eax@4 | |
2334 | 4125 // HRESULT v8; // eax@4 |
0 | 4126 int v9; // ST14_4@5 |
4127 IDirectDrawSurface *v10; // ST10_4@5 | |
2334 | 4128 // HRESULT v11; // eax@5 |
0 | 4129 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 |
2334 | 4130 // const char *v13; // [sp+0h] [bp-A0h]@0 |
4131 // int v14; // [sp+4h] [bp-9Ch]@0 | |
4132 // unsigned int v15; // [sp+8h] [bp-98h]@0 | |
0 | 4133 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 |
4134 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
2334 | 4135 // int a4; // [sp+98h] [bp-8h]@3 |
0 | 4136 |
4137 v1 = this; | |
2152 | 4138 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4139 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4140 { |
2154 | 4141 //v2 = 0; |
4142 //this->field_4004C = 1; | |
0 | 4143 memset(&ddsd2, 0, 0x7Cu); |
4144 v7 = v1->pDirectDraw4; | |
4145 ddsd2.dwBackBufferCount = 1; | |
4146 ddsd2.dwSize = 0x7Cu; | |
4147 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4148 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4149 ErrD3D(v7->CreateSurface( | |
4150 &ddsd2, | |
4151 &pFrontBuffer4, | |
4152 0)); | |
4153 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
4154 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4155 } | |
2152 | 4156 /*else |
0 | 4157 { |
4158 v2 = 0; | |
4159 this->field_4004C = 1; | |
4160 | |
4161 DDSURFACEDESC ddsd; | |
4162 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4163 | |
4164 ddsd.lpSurface = (LPVOID)1; | |
4165 ddsd.lPitch = 108; | |
4166 ddsd.dwBackBufferCount = 33; | |
4167 ddsd.ddsCaps.dwCaps = 8728; | |
4168 ErrD3D(pDirectDraw2->CreateSurface( | |
4169 &ddsd, | |
4170 (IDirectDrawSurface **)&pFrontBuffer2, | |
4171 0)); | |
4172 | |
4173 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4174 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
2152 | 4175 }*/ |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4176 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used |
0 | 4177 v9 = (int)v6; |
4178 v10 = pFrontBuffer; // BUG | |
4179 | |
4180 v17.dwCaps = 4; | |
4181 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4182 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
2154 | 4183 //v1->field_40030 = v2; |
4184 //v1->field_18_locked_pitch = v2; | |
0 | 4185 } |
4186 | |
4187 //----- (004A14F4) -------------------------------------------------------- | |
4188 void Render::CreateClipper(HWND a2) | |
4189 { | |
2152 | 4190 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); |
4191 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4192 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
0 | 4193 } |
4194 | |
4195 //----- (004A15D8) -------------------------------------------------------- | |
4196 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4197 { | |
2152 | 4198 pFrontBuffer4->GetPixelFormat(pOut); |
0 | 4199 } |
4200 | |
4201 //----- (004A1605) -------------------------------------------------------- | |
4202 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4203 { | |
4204 signed int v4; // eax@3 | |
4205 | |
2152 | 4206 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4207 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4208 { |
4209 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4210 memset(&pDesc, 0, 0x7Cu); | |
4211 pDesc.dwSize = 124; | |
2132 | 4212 LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4213 *pOutSurfacePtr = pDesc.lpSurface; |
4214 v4 = pDesc.lPitch; | |
4215 } | |
2152 | 4216 /*else |
0 | 4217 { |
4218 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4219 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4220 pDesc.lPitch = 108; | |
2132 | 4221 LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1); |
0 | 4222 *pOutSurfacePtr = (void *)pDesc.lpSurface; |
4223 v4 = pDesc.dwReserved; | |
2152 | 4224 }*/ |
0 | 4225 *pOutPixelsPerRow = v4 >> 1; |
4226 } | |
4227 | |
4228 //----- (004A16E1) -------------------------------------------------------- | |
4229 void Render::UnlockBackBuffer() | |
4230 { | |
2152 | 4231 ErrD3D(pBackBuffer4->Unlock(0)); |
0 | 4232 } |
4233 | |
4234 //----- (004A172E) -------------------------------------------------------- | |
4235 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4236 { | |
4237 signed int v4; // eax@3 | |
4238 | |
2152 | 4239 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4240 { |
4241 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4242 memset(&pDesc, 0, 0x7Cu); | |
4243 pDesc.dwSize = 124; | |
2132 | 4244 LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4245 *pOutSurface = pDesc.lpSurface; |
4246 v4 = pDesc.lPitch; | |
4247 } | |
2152 | 4248 /*else |
0 | 4249 { |
4250 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4251 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4252 pDesc.lPitch = 108; | |
2132 | 4253 LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1); |
0 | 4254 *pOutSurface = (void *)pDesc.lpSurface; |
4255 v4 = pDesc.dwReserved; | |
2152 | 4256 }*/ |
0 | 4257 *pOutPixelsPerRow = v4 >> 1; |
4258 } | |
4259 | |
4260 //----- (004A17C7) -------------------------------------------------------- | |
4261 void Render::UnlockFrontBuffer() | |
4262 { | |
2152 | 4263 ErrD3D(pFrontBuffer4->Unlock(0)); |
0 | 4264 } |
4265 | |
4266 //----- (004A1814) -------------------------------------------------------- | |
4267 void Render::RestoreFrontBuffer() | |
4268 { | |
2152 | 4269 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST ) |
4270 pFrontBuffer4->Restore(); | |
0 | 4271 } |
4272 | |
4273 //----- (004A184C) -------------------------------------------------------- | |
2152 | 4274 void Render::RestoreBackBuffer() |
4275 { | |
4276 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST ) | |
4277 pBackBuffer4->Restore(); | |
0 | 4278 } |
4279 | |
4280 //----- (004A18F5) -------------------------------------------------------- | |
4281 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4282 { | |
2152 | 4283 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); |
0 | 4284 } |
4285 | |
4286 //----- (004A194A) -------------------------------------------------------- | |
4287 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
4288 { | |
4289 IDirectDrawSurface *pFront; // eax@3 | |
4290 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
4291 | |
2152 | 4292 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4293 { |
4294 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4295 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4296 } | |
2152 | 4297 /*else |
0 | 4298 { |
4299 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4300 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
2152 | 4301 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4302 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 4303 } |
4304 | |
4305 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4306 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4307 { |
0 | 4308 unsigned int v7; // edx@6 |
2166 | 4309 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4310 if (uNumBillboardsToDraw >= 999 ) |
0 | 4311 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4312 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4313 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4314 uNumBillboardsToDraw = 1; |
0 | 4315 return 0; |
4316 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4317 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4318 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4319 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4320 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4321 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4322 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4323 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4324 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4325 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4326 |
2166 | 4327 if (z > pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4328 { |
4329 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
4330 v7 = pRenderer->uNumBillboardsToDraw; | |
4331 else | |
4332 { | |
4333 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4334 { | |
2166 | 4335 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
0 | 4336 { |
2166 | 4337 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], |
4338 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - (i + 1)], | |
4339 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
0 | 4340 } |
4341 } | |
4342 ++v7; | |
4343 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4344 uNumBillboardsToDraw++; |
0 | 4345 return v7; |
4346 } | |
2166 | 4347 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4348 { |
4349 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4350 { | |
2166 | 4351 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
4352 { | |
4353 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], | |
4354 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw -(i + 1)], | |
4355 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
4356 } | |
4357 } | |
717 | 4358 uNumBillboardsToDraw++; |
4359 return v7; | |
0 | 4360 } |
4361 return v7; | |
4362 } | |
4363 | |
4364 //----- (004A1E9D) -------------------------------------------------------- | |
4365 unsigned int Render::GetBillboardDrawListSize() | |
4366 { | |
4367 return pRenderer->uNumBillboardsToDraw; | |
4368 } | |
4369 | |
4370 //----- (004A1EA3) -------------------------------------------------------- | |
4371 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
4372 { | |
2002 | 4373 return pRenderer->pBillboardRenderListD3D[uBillboardID].sParentBillboardID; |
0 | 4374 } |
4375 | |
4376 //----- (004A1EB6) -------------------------------------------------------- | |
4377 void Render::BeginSceneD3D() | |
4378 { | |
4379 if (!uNumD3DSceneBegins++) | |
4380 { | |
2154 | 4381 //if (pRenderD3D) |
0 | 4382 { |
4383 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
4384 pRenderer->uNumBillboardsToDraw = 0; | |
4385 pRenderD3D->pDevice->BeginScene(); | |
1390 | 4386 |
0 | 4387 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
4388 uFogColor = GetLevelFogColor(); | |
4389 else | |
4390 uFogColor = 0; | |
4391 | |
4392 if ( uFogColor & 0xFF000000 ) | |
4393 { | |
4394 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
4395 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
4396 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4397 bUsingSpecular = true; | |
4398 } | |
4399 else | |
4400 { | |
4401 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
4402 bUsingSpecular = 0; | |
4403 } | |
4404 } | |
2154 | 4405 /*else |
0 | 4406 { |
4407 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
4408 if (pTargetSurface) | |
4409 field_18_locked_pitch = uTargetSurfacePitch; | |
4410 else | |
4411 --uNumD3DSceneBegins; | |
2154 | 4412 }*/ |
0 | 4413 } |
4414 } | |
4415 | |
4416 //----- (004A1FE1) -------------------------------------------------------- | |
4417 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
4418 { | |
4419 --uNumD3DSceneBegins; | |
4420 if (uNumD3DSceneBegins) | |
4421 return; | |
4422 | |
4423 if (pRenderD3D) | |
4424 { | |
4425 pGame->draw_debug_outlines(); | |
161 | 4426 DoRenderBillboards_D3D(); |
0 | 4427 pGame->pStru6Instance->RenderSpecialEffects(); |
4428 pRenderD3D->pDevice->EndScene(); | |
4429 } | |
4430 else | |
4431 pGame->pStru6Instance->RenderSpecialEffects(); | |
4432 } | |
4433 | |
4434 //----- (004A2031) -------------------------------------------------------- | |
349 | 4435 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
4436 { | |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4437 // __debugbreak(); // should not fire outside decal builder |
349 | 4438 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 4439 } |
4440 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4441 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 4442 { |
4443 int v5; // ebx@1 | |
4444 int v6; // edi@1 | |
4445 int v8; // eax@7 | |
4446 float v9; // eax@12 | |
4447 float *v10; // esi@12 | |
4448 float v11; // ecx@14 | |
4449 double v12; // st7@14 | |
4450 double v13; // st7@14 | |
4451 double v14; // st7@14 | |
4452 signed int v15; // eax@14 | |
4453 int v16; // eax@15 | |
4454 float v17; // ST48_4@15 | |
4455 char v18; // zf@17 | |
4456 int v19; // eax@18 | |
4457 int v20; // eax@18 | |
4458 int v21; // edx@20 | |
4459 signed int v22; // ecx@20 | |
4460 int v23; // eax@20 | |
4461 const char *v24; // ST4C_4@20 | |
4462 unsigned int v25; // ST50_4@20 | |
4463 int v26; // ST54_4@20 | |
4464 int v27; // eax@20 | |
4465 _UNKNOWN *v28; // eax@21 | |
4466 int v29; // ecx@23 | |
4467 int v30; // eax@23 | |
4468 int v31; // eax@23 | |
4469 int v32; // eax@24 | |
4470 int v33; // eax@25 | |
4471 int v34; // eax@25 | |
4472 int v35; // eax@25 | |
4473 int v36; // eax@25 | |
4474 signed int v37; // ecx@26 | |
4475 int v38; // eax@26 | |
4476 _UNKNOWN *v39; // eax@27 | |
4477 int v40; // edx@28 | |
4478 int v41; // eax@29 | |
4479 int v42; // eax@29 | |
4480 int v43; // eax@29 | |
4481 int v44; // eax@29 | |
4482 unsigned int v46; // eax@29 | |
4483 int v47; // eax@30 | |
4484 int v48; // eax@30 | |
4485 int v49; // eax@30 | |
4486 double v52; // st6@35 | |
4487 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
4488 int v57; // [sp+5Ch] [bp-Ch]@3 | |
4489 signed int v59; // [sp+60h] [bp-8h]@12 | |
4490 int v61; // [sp+64h] [bp-4h]@4 | |
4491 int i; | |
4492 | |
4493 v6 = (int)this; | |
4494 v5 = 0; | |
4495 if (!this->uNumD3DSceneBegins) | |
4496 return; | |
4497 | |
4498 | |
4499 | |
4500 | |
186 | 4501 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 4502 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
4503 if (this->bUsingSpecular) | |
4504 { | |
186 | 4505 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4506 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4507 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 4508 } |
4509 | |
4510 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
4511 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
1637 | 4512 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4513 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); |
4514 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
4515 pVertices[0].specular = 0; | |
4516 pVertices[0].texcoord.x = array_50AC10[0].u; | |
4517 pVertices[0].texcoord.y = array_50AC10[0].v; | |
4518 | |
4519 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
4520 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
1637 | 4521 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4522 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); |
4523 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
4524 pVertices[1].specular = 0; | |
4525 pVertices[1].texcoord.x = array_50AC10[3].u; | |
4526 pVertices[1].texcoord.y = array_50AC10[3].v; | |
4527 | |
4528 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
4529 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
1637 | 4530 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4531 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); |
4532 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
4533 pVertices[2].specular = 0; | |
4534 pVertices[2].texcoord.x = array_50AC10[1].u; | |
4535 pVertices[2].texcoord.y = array_50AC10[1].v; | |
4536 | |
4537 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
4538 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
4539 | |
4540 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
4541 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
1637 | 4542 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4543 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); |
4544 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
4545 pVertices[5].specular = 0; | |
4546 pVertices[5].texcoord.x = array_50AC10[2].u; | |
4547 pVertices[5].texcoord.y = array_50AC10[2].v; | |
4548 | |
4549 | |
4550 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4551 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
4552 | |
186 | 4553 }*/ |
4554 | |
0 | 4555 //----- (004A26BC) -------------------------------------------------------- |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4556 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
186 | 4557 { |
4558 //RenderVertexSoft *pVertices; // esi@0 | |
4559 //int v7; // edi@1 | |
0 | 4560 unsigned int v8; // ebx@1 |
2334 | 4561 // LightmapBuilder *v9; // esi@3 |
4562 // unsigned int v10; // edx@3 | |
0 | 4563 int v11; // eax@5 |
2334 | 4564 // int v12; // eax@11 |
4565 // char *v13; // esi@11 | |
4566 // double v14; // st7@13 | |
4567 // double v15; // st7@13 | |
4568 // signed int v16; // eax@13 | |
4569 // int v17; // ecx@13 | |
4570 // double v18; // st7@13 | |
4571 // float v19; // ST78_4@14 | |
0 | 4572 int v20; // eax@14 |
2334 | 4573 // char v21; // zf@16 |
4574 // HRESULT v22; // eax@17 | |
4575 // HRESULT v23; // eax@17 | |
4576 // HRESULT v24; // eax@19 | |
4577 // HRESULT v25; // eax@19 | |
4578 // unsigned int v26; // ecx@19 | |
4579 // char *v27; // eax@20 | |
4580 // HRESULT v28; // eax@22 | |
4581 // HRESULT v29; // eax@22 | |
4582 // HRESULT v30; // eax@23 | |
4583 // HRESULT v31; // eax@24 | |
4584 // HRESULT v32; // eax@24 | |
4585 // HRESULT v33; // eax@24 | |
4586 // HRESULT v34; // eax@24 | |
4587 // HRESULT v35; // eax@25 | |
4588 // HRESULT v36; // eax@25 | |
4589 // unsigned int v37; // ecx@25 | |
4590 // char *v38; // eax@26 | |
4591 // int v39; // edx@27 | |
4592 // HRESULT v40; // eax@28 | |
4593 // HRESULT v41; // eax@28 | |
4594 // HRESULT v42; // eax@28 | |
4595 // HRESULT v43; // eax@28 | |
0 | 4596 //IDirect3DDevice3Vtbl *v44; // ebx@28 |
4597 unsigned int v45; // eax@28 | |
2334 | 4598 // HRESULT v46; // eax@29 |
4599 // HRESULT v47; // eax@29 | |
4600 // HRESULT v48; // eax@29 | |
186 | 4601 //IDirect3DDevice3 *v49; // eax@35 |
0 | 4602 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
2334 | 4603 // int v51; // eax@40 |
4604 // char *v52; // esi@40 | |
4605 // double v53; // st7@42 | |
4606 // double v54; // st7@42 | |
4607 // signed int v55; // eax@42 | |
4608 // int v56; // ecx@42 | |
4609 // double v57; // st7@42 | |
4610 // float v58; // ST7C_4@43 | |
4611 // int v59; // eax@43 | |
186 | 4612 //signed int v60; // [sp+78h] [bp-14h]@31 |
4613 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
2334 | 4614 // const char *v62; // [sp+80h] [bp-Ch]@0 |
4615 // const char *v63; // [sp+80h] [bp-Ch]@19 | |
4616 // int v64; // [sp+84h] [bp-8h]@0 | |
4617 // LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
4618 // unsigned int v66; // [sp+88h] [bp-4h]@40 | |
4619 // unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
4620 // int a7; | |
186 | 4621 |
4622 //v7 = (int)this; | |
0 | 4623 v8 = 0; |
186 | 4624 if (!this->uNumD3DSceneBegins) |
75 | 4625 return; |
4626 if ( uNumVertices < 3) | |
4627 return; | |
4628 | |
186 | 4629 //v61 = pVertices; |
4630 | |
75 | 4631 /* v9 = pGame->pLightmapBuilder; |
0 | 4632 v65 = v9; |
75 | 4633 v10 = v9->std__vector_000004_size;*/ |
2155 | 4634 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 4635 { |
638 | 4636 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 4637 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); |
0 | 4638 } |
4639 else | |
4640 { | |
186 | 4641 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 4642 byte_4D864C && pGame->uFlags & 2 ) |
4643 { | |
186 | 4644 if (clampAtTextureBorders) |
4645 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 4646 else |
186 | 4647 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
4648 | |
4649 if (transparent || this->bUsingSpecular) | |
4650 { | |
4651 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4652 if (transparent) | |
0 | 4653 { |
186 | 4654 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
4655 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
4656 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
4657 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 4658 } |
4659 else | |
4660 { | |
186 | 4661 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
4662 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 4663 } |
186 | 4664 } |
1073 | 4665 |
4666 for (uint i = 0; i < uNumVertices; ++i) | |
4667 { | |
4668 | |
4669 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4670 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4671 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4672 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4673 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4674 if ( this->bUsingSpecular ) | |
0 | 4675 { |
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
|
4676 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4677 } |
1073 | 4678 else |
4679 { | |
4680 d3d_vertex_buffer[i].specular = 0; | |
4681 } | |
4682 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4683 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4684 } | |
4685 | |
4686 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4687 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
186 | 4688 if (transparent) |
4689 { | |
4690 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
4691 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4692 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4693 } |
4694 } | |
4695 else | |
4696 { | |
1073 | 4697 for (uint i = 0; i < uNumVertices; ++i) |
4698 { | |
4699 | |
4700 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4701 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4702 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4703 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4704 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4705 if ( this->bUsingSpecular ) | |
0 | 4706 { |
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
|
4707 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4708 } |
1073 | 4709 else |
4710 { | |
4711 d3d_vertex_buffer[i].specular = 0; | |
4712 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4713 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
1073 | 4714 d3d_vertex_buffer[i].specular = v20; |
4715 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4716 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4717 } | |
186 | 4718 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4719 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4720 if (pRenderer->bUsingSpecular) | |
4721 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 4722 |
4723 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 4724 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 4725 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4726 d3d_vertex_buffer, |
0 | 4727 uNumVertices, |
4728 16)); | |
4729 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 4730 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 4731 //(*(void (**)(void))(*(int *)v63 + 88))(); |
1394 | 4732 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
1073 | 4733 for (uint i = 0; i < uNumVertices; ++i) |
4734 { | |
4735 d3d_vertex_buffer[i].diffuse = -1; | |
4736 } | |
0 | 4737 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 4738 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4739 if ( !pRenderer->bUsingSpecular ) |
4740 { | |
186 | 4741 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4742 } | |
4743 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4744 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4745 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
4746 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4747 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4748 d3d_vertex_buffer, |
0 | 4749 uNumVertices, |
4750 16)); | |
4751 if ( pRenderer->bUsingSpecular ) | |
4752 { | |
186 | 4753 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4754 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 4755 for (uint i = 0; i < uNumVertices; ++i) |
4756 { | |
4757 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4758 d3d_vertex_buffer[i].specular = 0; | |
4759 } | |
4760 | |
75 | 4761 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 4762 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4763 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
4764 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4765 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4766 d3d_vertex_buffer, |
0 | 4767 uNumVertices, |
4768 16)); | |
186 | 4769 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4770 //v44 = pRenderer->pRenderD3D->pDevice; |
4771 v45 = GetLevelFogColor(); | |
4772 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
4773 v8 = 0; | |
4774 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
4775 } | |
186 | 4776 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4777 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4778 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
4779 } | |
4780 } | |
186 | 4781 |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
4782 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
1642 | 4783 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
|
4784 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 4785 } |
4786 // 4A26BC: could not find valid save-restore pair for esi | |
4787 // 4D864C: using guessed type char byte_4D864C; | |
4788 | |
4789 //----- (004A2DA3) -------------------------------------------------------- | |
1923 | 4790 void Render::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
852 | 4791 { |
67 | 4792 int v7; // eax@7 |
4793 | |
4794 if ( !this->uNumD3DSceneBegins ) | |
4795 return; | |
4796 if ( uNumVertices >= 3 ) | |
4797 { | |
186 | 4798 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 4799 if ( this->bUsingSpecular ) |
4800 { | |
186 | 4801 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4802 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4803 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 4804 } |
1427 | 4805 for ( uint i = 0; i < uNumVertices; ++i ) |
67 | 4806 { |
4807 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4808 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4809 pVertices[i].pos.z = 0.99989998; | |
168 | 4810 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 4811 |
840 | 4812 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 4813 v7 = 0; |
4814 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
|
4815 v7 = sub_47C3D7_get_fog_specular(0, 1, array_50AC10[i].vWorldViewPosition.x); |
67 | 4816 pVertices[i].specular = v7; |
4817 pVertices[i].texcoord.x = array_50AC10[i].u; | |
4818 pVertices[i].texcoord.y = array_50AC10[i].v; | |
4819 } | |
4820 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4821 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 4822 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 4823 } |
4824 } | |
4825 | |
4826 //----- (004A2ED5) -------------------------------------------------------- | |
1923 | 4827 void Render::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
0 | 4828 { |
4829 int v5; // eax@3 | |
4830 | |
4831 if ( this->uNumD3DSceneBegins ) | |
4832 { | |
1923 | 4833 if ( uNumVertices >= 3 ) |
0 | 4834 { |
186 | 4835 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1923 | 4836 v5 = 31 - (pSkyPolygon->dimming_level & 0x1F); |
638 | 4837 if ( v5 < pOutdoor->max_terrain_dimming_level ) |
4838 v5 = pOutdoor->max_terrain_dimming_level; | |
1937 | 4839 for (uint i = 0; i < uNumVertices; ++i) |
4840 { | |
4841 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
4842 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
1999 | 4843 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); |
1937 | 4844 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; |
4845 d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); | |
4846 d3d_vertex_buffer[i].specular = 0; | |
4847 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
4848 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
4849 } | |
1923 | 4850 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
1936 | 4851 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
4852 d3d_vertex_buffer, uNumVertices, 28)); | |
0 | 4853 } |
4854 } | |
4855 } | |
4856 | |
1390 | 4857 //----- (00479A53) -------------------------------------------------------- |
1923 | 4858 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID) |
1390 | 4859 { |
4860 BLVFace *pFace; // esi@1 | |
4861 double v5; // st7@3 | |
4862 signed __int64 v6; // qax@3 | |
4863 int v12; // edx@7 | |
4864 int v13; // eax@7 | |
2334 | 4865 // void *v15; // ecx@9 |
1390 | 4866 int v17; // edi@9 |
4867 double v18; // st7@9 | |
4868 signed int v19; // ebx@9 | |
4869 void *v20; // ecx@9 | |
4870 int v21; // ebx@11 | |
4871 int v22; // eax@14 | |
4872 signed __int64 v23; // qtt@16 | |
2334 | 4873 // double v24; // st7@16 |
4874 // unsigned __int8 v25; // sf@16 | |
4875 // unsigned __int8 v26; // of@16 | |
1390 | 4876 double v28; // st7@20 |
2334 | 4877 // char *v29; // ebx@20 |
4878 // char *v30; // edx@20 | |
4879 // unsigned __int8 v31; // c0@21 | |
4880 // unsigned __int8 v32; // c3@21 | |
1390 | 4881 double v33; // st6@23 |
2334 | 4882 // char *v34; // esi@30 |
1390 | 4883 const void *v35; // ecx@31 |
4884 int v36; // eax@31 | |
4885 const void *v37; // edi@31 | |
4886 signed __int64 v38; // qax@31 | |
4887 int v39; // ecx@31 | |
4888 int v40; // ebx@33 | |
4889 int v41; // eax@36 | |
4890 signed __int64 v42; // qtt@39 | |
4891 int v43; // eax@39 | |
2334 | 4892 // char v44; // zf@39 |
4893 // double v45; // st7@39 | |
4894 // double v46; // st7@39 | |
4895 // unsigned int v47; // edx@40 | |
1390 | 4896 double v48; // st7@41 |
2334 | 4897 // RenderVertexSoft *v49; // ebx@41 |
4898 // void *v50; // edi@43 | |
1390 | 4899 double v51; // st7@46 |
2334 | 4900 // RenderVertexSoft *v52; // edx@46 |
4901 // void *v53; // edi@48 | |
4902 // signed int v59; // [sp-4h] [bp-178h]@17 | |
4903 // struct Polygon *v60; // [sp+0h] [bp-174h]@17 | |
4904 // IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 | |
1981 | 4905 struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6 |
1390 | 4906 unsigned int v63; // [sp+120h] [bp-54h]@7 |
4907 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
4908 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4909 //float v67; // [sp+130h] [bp-44h]@7 |
1390 | 4910 __int64 v69; // [sp+13Ch] [bp-38h]@3 |
4911 int v70; // [sp+144h] [bp-30h]@3 | |
4912 int X; // [sp+148h] [bp-2Ch]@9 | |
4913 int v72; // [sp+14Ch] [bp-28h]@7 | |
4914 float v73; // [sp+150h] [bp-24h]@16 | |
4915 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
1999 | 4916 unsigned int v74_; // [sp+154h] [bp-20h]@3 |
1390 | 4917 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 |
4918 float v76; // [sp+15Ch] [bp-18h]@9 | |
4919 int v77; // [sp+160h] [bp-14h]@9 | |
4920 int v78; // [sp+164h] [bp-10h]@7 | |
4921 void *v79; // [sp+168h] [bp-Ch]@9 | |
4922 float v80; // [sp+16Ch] [bp-8h]@3 | |
4923 const void *v81; // [sp+170h] [bp-4h]@7 | |
4924 | |
4925 pFace = &pIndoor->pFaces[uFaceID]; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4926 //for floor and wall(for example Selesta)------------------- |
1644 | 4927 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor) |
4928 { | |
4929 int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x; | |
4930 int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y; | |
4931 for (uint i = 0; i < uNumVertices; ++i) | |
4932 { | |
4933 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f; | |
4934 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f; | |
4935 } | |
4936 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0); | |
1390 | 4937 return; |
4938 } | |
1981 | 4939 //--------------------------------------- |
4940 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179 | |
1641 | 4941 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) |
1390 | 4942 * 65536.0) |
1922 | 4943 + (double)pBLVRenderParams->uViewportCenterY); |
1981 | 4944 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0 |
4945 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183 | |
1641 | 4946 - (double)pBLVRenderParams->fov_rad_fixpoint |
1644 | 4947 / ((cos(v5) * 16192.0 + 0.0000001) |
1390 | 4948 * 65535.0) |
1922 | 4949 * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); |
1644 | 4950 |
1999 | 4951 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); |
1981 | 4952 pSkyPolygon.Create_48607B(&stru_8019C8); |
4953 pSkyPolygon.uTileBitmapID = pFace->uBitmapID; | |
4954 | |
4955 pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID); | |
4956 if ( !pSkyPolygon.pTexture ) | |
1390 | 4957 return; |
1644 | 4958 |
1981 | 4959 pSkyPolygon.dimming_level = 0; |
4960 pSkyPolygon.uNumVertices = uNumVertices; | |
4961 | |
4962 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4963 pSkyPolygon.v_18.y = 0; | |
4964 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4965 | |
1644 | 4966 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices])); |
1981 | 4967 pSkyPolygon.field_24 = 0x2000000; |
1644 | 4968 |
4969 extern float _calc_fov(int viewport_width, int angle_degree); | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4970 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4971 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); |
1644 | 4972 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74); |
1981 | 4973 v12 = pSkyPolygon.pTexture->uWidthMinus1; |
4974 v13 = pSkyPolygon.pTexture->uHeightMinus1; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4975 //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth; |
1390 | 4976 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; |
4977 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
4978 v78 = 0; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4979 //v81 = 0; |
1981 | 4980 float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight; |
4981 if ( (signed int)pSkyPolygon.uNumVertices <= 0 ) | |
4982 return; | |
1644 | 4983 |
4984 int _507D30_idx = 0; | |
1999 | 4985 for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ ) |
1390 | 4986 { |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4987 //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)); |
2207 | 4988 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1981 | 4989 v74 = v77 + pSkyPolygon.ptr_38->angle_from_north; |
4990 | |
2207 | 4991 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1999 | 4992 v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east; |
1981 | 4993 |
2207 | 4994 v79 = (void *)(fixpoint_mul(pSkyPolygon.v_18.z, v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))); |
1644 | 4995 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX); |
4996 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0; | |
1981 | 4997 v19 = -pSkyPolygon.field_24; |
4998 v77 = -pSkyPolygon.field_24; | |
4999 X = (int)((char *)v79 + pSkyPolygon.v_18.x); | |
1390 | 5000 LODWORD(v76) = (signed __int64)v18; |
5001 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
5002 while ( 1 ) | |
5003 { | |
5004 v79 = v20; | |
5005 if ( !X ) | |
5006 goto LABEL_14; | |
5007 v21 = abs(v19 >> 14); | |
1999 | 5008 if ( v21 <= abs(X) )//0x800 <= 0x28652 |
1390 | 5009 break; |
5010 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5011 break; | |
5012 v19 = v77; | |
5013 v20 = v79; | |
5014 LABEL_14: | |
2207 | 5015 v79 = (void *)fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); |
5016 v22 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); | |
1390 | 5017 --LODWORD(v76); |
5018 v20 = (char *)v20 + v72; | |
1981 | 5019 X = v22 + pSkyPolygon.v_18.x; |
1390 | 5020 v78 = 1; |
5021 } | |
5022 if ( !v78 ) | |
5023 { | |
5024 LODWORD(v23) = v77 << 16; | |
1981 | 5025 HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000 |
1997 | 5026 v79 = (void *)(v23 / X);//X = FFFF9014(-28652) |
1390 | 5027 v77 = v17; |
2207 | 5028 signed __int64 s = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v17);// s = 0xFFFFFFFF FFFF3EE6 |
5029 LODWORD(v80) = v66 + ((signed int)fixpoint_mul(SLODWORD(s), v23 / X) >> 4); | |
1981 | 5030 array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); |
5031 | |
2207 | 5032 signed __int64 s2 = v74_ + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v17); |
5033 LODWORD(v80) = v63 + ((signed int)fixpoint_mul(SLODWORD(s2), v23 / X) >> 4); | |
1981 | 5034 array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68; |
5035 | |
2207 | 5036 v77 = fixpoint_mul(SLODWORD(s), v23 / X); |
5037 LODWORD(v73) = fixpoint_mul(SLODWORD(s2), v23 / X); | |
1644 | 5038 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5039 |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5040 //if ( (int)v81 >= pSkyPolygon.uNumVertices ) |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5041 //{ |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5042 // pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5043 // pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5044 // return; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5045 //} |
1390 | 5046 continue; |
5047 } | |
5048 break; | |
5049 } | |
1999 | 5050 if ( _507D30_idx >= pSkyPolygon.uNumVertices ) |
5051 { | |
5052 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, | |
5053 pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5054 return; | |
5055 } | |
1390 | 5056 LODWORD(v73) = 0; |
5057 v80 = v76; | |
1981 | 5058 if ( (signed int)pSkyPolygon.uNumVertices > 0 ) |
1390 | 5059 { |
5060 v28 = (double)SLODWORD(v76); | |
5061 LODWORD(v76) = (int)(char *)array_50AC10 + 28; | |
1997 | 5062 uint i = 0; |
5063 for ( v78 = pSkyPolygon.uNumVertices; v78; --v78 ) | |
5064 { | |
1390 | 5065 ++LODWORD(v73); |
1997 | 5066 memcpy(&array_50AC10[i], &array_507D30[i], 0x30u); |
1390 | 5067 LODWORD(v76) += 48; |
1997 | 5068 if ( v28 < array_507D30[i].vWorldViewProjY | v28 == array_507D30[i].vWorldViewProjY |
5069 || v28 >= array_507D30[i + 1].vWorldViewProjY ) | |
5070 { | |
5071 if ( v28 >= array_507D30[i].vWorldViewProjY || v28 <= array_507D30[i + 1].vWorldViewProjY ) | |
5072 { | |
5073 i++; | |
5074 continue; | |
5075 } | |
5076 v33 = (array_507D30[i + 1].vWorldViewProjX - array_507D30[i].vWorldViewProjX) * v28 / (array_507D30[i + 1].vWorldViewProjY - array_507D30[i].vWorldViewProjY) | |
5077 + array_507D30[i + 1].vWorldViewProjX; | |
1390 | 5078 } |
5079 else | |
5080 { | |
1997 | 5081 v33 = (array_507D30[i].vWorldViewProjX - array_507D30[i + 1].vWorldViewProjX) * v28 / (array_507D30[i].vWorldViewProjY - array_507D30[i + 1].vWorldViewProjY) |
5082 + array_507D30[i].vWorldViewProjX; | |
5083 } | |
5084 array_50AC10[i + 1].vWorldViewProjX = v33; | |
1390 | 5085 ++LODWORD(v73); |
5086 *(unsigned int *)LODWORD(v76) = v28; | |
5087 LODWORD(v76) += 48; | |
1997 | 5088 i++; |
5089 } | |
1390 | 5090 } |
5091 if ( SLODWORD(v73) <= 0 ) | |
5092 goto LABEL_40; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5093 //v34 = (char *)&array_50AC10[0].vWorldViewProjY; |
1997 | 5094 uint j = 0; |
1390 | 5095 v65 = v77 >> 14; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5096 //HIDWORD(v69) = LODWORD(v73); |
1997 | 5097 for ( int t = (int)LODWORD(v73); t > 1; t-- ) |
5098 { | |
5099 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjY)); | |
5100 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5101 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east; |
2207 | 5102 //v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v35); |
5103 v36 = (int)(fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, (int)v35) + pSkyPolygon.ptr_38->angle_from_north); | |
1997 | 5104 |
1390 | 5105 v81 = v35; |
5106 v74 = v36; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5107 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south; |
2207 | 5108 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, (int)v35); |
1390 | 5109 v78 = (int)v35; |
1981 | 5110 v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east); |
2207 | 5111 //v81 = (const void *)pSkyPolygon.v_18.z; |
5112 v78 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v35); | |
5113 v37 = (const void *)(v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX)); | |
1997 | 5114 v38 = (signed __int64)(array_50AC10[j].vWorldViewProjY - 1.0); |
1390 | 5115 v81 = 0; |
5116 LODWORD(v76) = v38; | |
5117 v39 = v72 * (v70 - v38); | |
5118 while ( 1 ) | |
5119 { | |
5120 v78 = v39; | |
5121 if ( !X ) | |
5122 goto LABEL_36; | |
5123 v40 = abs(X); | |
5124 if ( abs((signed __int64)v65) <= v40 ) | |
5125 break; | |
5126 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5127 break; | |
5128 v39 = v78; | |
5129 LABEL_36: | |
1981 | 5130 v78 = pSkyPolygon.v_18.z; |
2207 | 5131 v41 = fixpoint_mul(pSkyPolygon.v_18.z, v39); |
1390 | 5132 --LODWORD(v76); |
5133 v39 += v72; | |
1981 | 5134 X = v41 + pSkyPolygon.v_18.x; |
1390 | 5135 v81 = (const void *)1; |
5136 } | |
5137 if ( v81 ) | |
5138 { | |
1981 | 5139 v79 = (void *)pSkyPolygon.v_18.z; |
1390 | 5140 v78 = 2 * LODWORD(v76); |
2207 | 5141 v81 = (const void *)fixpoint_mul(pSkyPolygon.v_18.z, (((double)v70 - ((double)(2 * LODWORD(v76)) - array_50AC10[j].vWorldViewProjY)) |
5142 * (double)v72)); | |
1981 | 5143 X = (int)((char *)v81 + pSkyPolygon.v_18.x); |
1390 | 5144 } |
5145 LODWORD(v42) = v77 << 16; | |
5146 HIDWORD(v42) = v77 >> 16; | |
5147 v79 = (void *)(v42 / X); | |
5148 v81 = v37; | |
1997 | 5149 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5150 //v78 = pSkyPolygon.ptr_38->angle_from_west; |
2207 | 5151 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); |
5152 v43 = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); | |
1390 | 5153 v74 = (unsigned int)v37; |
5154 LODWORD(v76) = v43; | |
1997 | 5155 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5156 //v78 = pSkyPolygon.ptr_38->angle_from_south; |
2207 | 5157 v75 = (RenderVertexSoft *)((char *)v75 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, (int)v37)); |
5158 //v74 = fixpoint_mul(v43, v42 / X); | |
5159 v81 = (const void *)fixpoint_mul((int)v75, v42 / X); | |
1997 | 5160 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5161 //v34 += 48; |
2207 | 5162 //v78 = v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4); |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5163 //v44 = HIDWORD(v69)-- == 1; |
2207 | 5164 //v45 = (double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022; |
5165 //v78 = v63 + ((signed int)fixpoint_mul((int)v75, v42 / X) >> 4); | |
5166 array_50AC10[j].u = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); | |
5167 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
|
5168 //v46 = (double)(signed int)v79; |
1997 | 5169 array_50AC10[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79; |
5170 array_50AC10[j]._rhw = 65536.0 / (double)(signed int)v79; | |
5171 ++j; | |
5172 } | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5173 //while ( !v44 ); |
1390 | 5174 LABEL_40: |
1997 | 5175 uint i = 0; |
1390 | 5176 if ( SLODWORD(v73) > 0 ) |
5177 { | |
5178 v48 = (double)SLODWORD(v80); | |
1997 | 5179 for ( HIDWORD(v69) = LODWORD(v73); HIDWORD(v69); --HIDWORD(v69) ) |
5180 { | |
5181 if ( v48 >= array_50AC10[i].vWorldViewProjY ) | |
5182 { | |
5183 ++i; | |
5184 memcpy(&array_507D30[i], &array_50AC10[i], 0x30u); | |
5185 } | |
5186 } | |
5187 } | |
5188 pSkyPolygon.uNumVertices = i; | |
5189 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5190 int pNumVertices = 0; | |
1390 | 5191 if ( SLODWORD(v73) > 0 ) |
5192 { | |
5193 v51 = (double)SLODWORD(v80); | |
1997 | 5194 for ( v80 = v73; v80 != 0.0; --LODWORD(v80) ) |
5195 { | |
5196 if ( v51 <= array_50AC10[pNumVertices].vWorldViewProjY ) | |
5197 { | |
5198 ++pNumVertices; | |
5199 memcpy(&array_507D30[pNumVertices], &array_50AC10[pNumVertices], 0x30u); | |
5200 } | |
5201 } | |
5202 } | |
5203 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
1390 | 5204 } |
5205 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5206 |
0 | 5207 //----- (004A2FC0) -------------------------------------------------------- |
5208 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
5209 { | |
5210 //Render *v8; // edi@1 | |
5211 //unsigned int v9; // esi@3 | |
2334 | 5212 // RenderVertexSoft *v12; // ecx@9 |
5213 // RenderVertexD3D3 *v13; // eax@9 | |
5214 // double v14; // st6@10 | |
5215 // int v15; // edx@10 | |
5216 // Texture *v16; // edx@10 | |
5217 // double v17; // st6@10 | |
0 | 5218 //char v18; // zf@10 |
2334 | 5219 // Texture *v19; // edx@10 |
595 | 5220 //Texture *v23; // edx@16 |
5221 //char *v24; // ecx@16 | |
5222 //char *v25; // eax@16 | |
5223 //double v26; // st6@17 | |
5224 //int v27; // esi@17 | |
5225 //double v28; // st6@17 | |
5226 //unsigned int v33; // ecx@18 | |
5227 //char *v34; // eax@19 | |
0 | 5228 //Texture *v45; // edx@23 |
5229 //char *v46; // ecx@23 | |
5230 //char *v47; // eax@23 | |
5231 //double v48; // st6@24 | |
5232 //int v49; // esi@24 | |
5233 //double v50; // st6@24 | |
2334 | 5234 // const char *v53; // [sp-Ch] [bp-20h]@21 |
0 | 5235 //int v54; // [sp-8h] [bp-1Ch]@21 |
5236 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
2334 | 5237 // const char *v56; // [sp+0h] [bp-14h]@0 |
5238 // int v57; // [sp+4h] [bp-10h]@0 | |
5239 // unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
0 | 5240 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 |
5241 //int a3a; // [sp+10h] [bp-4h]@4 | |
5242 | |
5243 //v8 = this; | |
5244 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
5245 return; | |
5246 | |
5247 //auto a3 = pFace; | |
5248 //auto a6 = uPackedID; | |
5249 //v59 = pGame->pLightmapBuilder; | |
5250 //v9 = v59->std__vector_000004_size; | |
5251 | |
2006 | 5252 int sCorrectedColor = uColor; |
0 | 5253 if (pGame->pLightmapBuilder->std__vector_000004_size) |
2006 | 5254 sCorrectedColor = -1; |
5255 pGame->AlterGamma_BLV(pFace, &sCorrectedColor); | |
0 | 5256 |
792 | 5257 |
5258 if (pFace->uAttributes & FACE_OUTLINED) | |
5259 { | |
2334 | 5260 // int color; |
792 | 5261 if (GetTickCount() % 300 >= 150) |
2006 | 5262 uColor = sCorrectedColor = 0xFF20FF20; |
5263 else uColor = sCorrectedColor = 0xFF109010; | |
792 | 5264 } |
5265 | |
2155 | 5266 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 5267 { |
5268 __debugbreak(); | |
5269 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 5270 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 5271 for (uint i = 0; i < uNumVertices; ++i) |
5272 { | |
5273 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5274 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5275 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5276 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5277 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
1072 | 5278 d3d_vertex_buffer[i].specular = 0; |
5279 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5280 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5281 } | |
5282 | |
186 | 5283 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5284 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
5285 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
5286 D3DPT_TRIANGLEFAN, | |
5287 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5288 d3d_vertex_buffer, |
0 | 5289 uNumVertices, |
5290 28)); | |
1394 | 5291 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
0 | 5292 } |
5293 else | |
5294 { | |
5295 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
5296 byte_4D864C && pGame->uFlags & 2) | |
5297 { | |
5298 for (uint i = 0; i < uNumVertices; ++i) | |
5299 { | |
186 | 5300 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
5301 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5302 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5303 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5304 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
186 | 5305 d3d_vertex_buffer[i].specular = 0; |
5306 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5307 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5308 } | |
5309 | |
5310 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 5311 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
5312 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5313 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5314 d3d_vertex_buffer, |
0 | 5315 uNumVertices, |
5316 28)); | |
5317 } | |
5318 else | |
5319 { | |
595 | 5320 for (uint i = 0; i < uNumVertices; ++i) |
5321 { | |
5322 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5323 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5324 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5325 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5326 d3d_vertex_buffer[i].diffuse = uColor; | |
5327 d3d_vertex_buffer[i].specular = 0; | |
5328 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5329 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5330 } | |
5331 //__debugbreak(); | |
5332 //if ( (signed int)uNumVertices > 0 ) | |
5333 //{ | |
5334 //v23 = pTex; | |
5335 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
5336 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
5337 //pTex = (Texture *)uNumVertices; | |
5338 //uint v18; | |
5339 //do | |
5340 //{ | |
5341 //v26 = *(float *)v24 * 0.061758894; | |
5342 //v27 = *((int *)v24 + 3); | |
5343 //*((int *)v25 + 4) = 0; | |
5344 //*((int *)v25 - 1) = v27; | |
5345 //*(int *)v25 = *((int *)v24 + 4); | |
5346 //*((int *)v25 + 3) = uColor; | |
5347 //v25 += 32; | |
5348 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
5349 //v28 = 1.0 / *(float *)v24; | |
5350 //v24 += 48; | |
5351 //v18 = pTex == (Texture *)1; | |
5352 //pTex = (Texture *)((char *)pTex - 1); | |
5353 //*((float *)v25 - 6) = v28; | |
0 | 5354 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 5355 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 5356 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 5357 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
5358 //} | |
5359 //while ( !v18 ); | |
5360 //} | |
0 | 5361 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 5362 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5363 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 5364 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5365 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5366 d3d_vertex_buffer, |
0 | 5367 uNumVertices, |
5368 28)); | |
595 | 5369 |
5370 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1394 | 5371 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
595 | 5372 |
5373 for (uint i = 0; i < uNumVertices; ++i) | |
2006 | 5374 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
595 | 5375 /*v33 = uNumVertices; |
0 | 5376 if ( (signed int)uNumVertices > 0 ) |
5377 { | |
186 | 5378 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 5379 do |
5380 { | |
5381 *(int *)v34 = uCorrectedColor; | |
5382 v34 += 32; | |
5383 --v33; | |
5384 } | |
5385 while ( v33 ); | |
595 | 5386 }*/ |
0 | 5387 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5388 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
5389 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5390 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5391 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5392 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
5393 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 5394 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5395 d3d_vertex_buffer, |
0 | 5396 uNumVertices, |
5397 28)); | |
186 | 5398 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
5399 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5400 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 5401 } |
5402 } | |
5403 } | |
5404 // 4D864C: using guessed type char byte_4D864C; | |
5405 | |
5406 //----- (004A43B1) -------------------------------------------------------- | |
717 | 5407 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
5408 { | |
5409 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
5410 //double v5; // st7@2 | |
5411 //float v6; // ST08_4@2 | |
0 | 5412 unsigned int v7; // eax@2 |
717 | 5413 //int v8; // ecx@2 |
5414 //unsigned int v9; // esi@2 | |
5415 //Sprite *v10; // edi@5 | |
0 | 5416 signed int v11; // eax@9 |
5417 signed int v12; // eax@9 | |
717 | 5418 //double v13; // st7@12 |
5419 //double v14; // st6@12 | |
0 | 5420 double v15; // st5@12 |
5421 double v16; // st4@12 | |
5422 double v17; // st3@12 | |
5423 double v18; // st2@12 | |
5424 int v19; // ecx@14 | |
5425 double v20; // st3@14 | |
5426 int v21; // ecx@16 | |
5427 double v22; // st3@16 | |
717 | 5428 //IDirect3DTexture2 *v23; // eax@18 |
5429 //signed int v24; // [sp+18h] [bp-18h]@5 | |
5430 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
5431 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 5432 float v27; // [sp+24h] [bp-Ch]@5 |
5433 int v28; // [sp+28h] [bp-8h]@2 | |
5434 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 5435 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 5436 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 5437 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 5438 float a1; // [sp+40h] [bp+10h]@5 |
5439 | |
717 | 5440 //v26 = this; |
0 | 5441 if ( this->uNumD3DSceneBegins ) |
5442 { | |
717 | 5443 //v4 = pSoftBillboard; |
5444 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
5445 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
5446 //v6 = pSoftBillboard->zbuffer_depth; | |
5447 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
5448 //v8 = dimming_level; | |
5449 //v9 = v7; | |
657 | 5450 v28 = dimming_level & 0xFF000000; |
5451 if ( dimming_level & 0xFF000000 ) | |
2155 | 5452 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3; |
0 | 5453 else |
2155 | 5454 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent; |
717 | 5455 //v10 = a3; |
5456 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
5457 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
2002 | 5458 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID; |
717 | 5459 //v25 = pSoftBillboard->uScreenSpaceX; |
5460 //v24 = pSoftBillboard->uScreenSpaceY; | |
5461 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
5462 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
5463 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5464 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
5465 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5466 v31 = v31 * -1.0; |
2006 | 5467 if ( pSoftBillboard->sTintColor && this->bTinting ) |
717 | 5468 { |
5469 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
2006 | 5470 v12 = BlendColors(pSoftBillboard->sTintColor, v11); |
0 | 5471 if ( v28 ) |
5472 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
5473 } | |
5474 else | |
5475 { | |
717 | 5476 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
5477 } | |
5478 //v13 = (double)v25; | |
1390 | 5479 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; |
5480 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
5481 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
717 | 5482 //v14 = (double)v24; |
5483 //v32 = v14; | |
1390 | 5484 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; |
717 | 5485 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); |
1390 | 5486 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; |
717 | 5487 v16 = 1.0 / pSoftBillboard->zbuffer_depth; |
1390 | 5488 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; |
5489 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
5490 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
717 | 5491 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); |
5492 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
5493 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5494 v17 = v17 * -1.0; |
1390 | 5495 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; |
5496 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
5497 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
5498 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
5499 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
5500 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
5501 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
5502 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
717 | 5503 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; |
5504 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5505 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5506 v20 = v20 * -1.0; |
1390 | 5507 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; |
5508 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
5509 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
5510 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
5511 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
5512 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
5513 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
5514 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
717 | 5515 v21 = pSprite->uBufferHeight - pSprite->uAreaY; |
5516 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5517 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5518 v22 = v22 * -1.0; |
1390 | 5519 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; |
5520 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
5521 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
5522 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
5523 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
5524 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
5525 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
5526 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
717 | 5527 //v23 = pSprite->pTexture; |
5528 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
5529 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
5530 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 5531 } |
5532 } | |
5533 | |
5534 //----- (004A354F) -------------------------------------------------------- | |
5535 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5536 { | |
743 | 5537 //double v5; // st7@3 |
5538 //float v6; // ST20_4@3 | |
5539 //float v7; // ST00_4@3 | |
0 | 5540 unsigned int v8; // esi@3 |
743 | 5541 //int v9; // eax@3 |
5542 //int v10; // ebx@3 | |
0 | 5543 float v11; // ST28_4@3 |
743 | 5544 //double v12; // st7@3 |
5545 //float v13; // ST24_4@3 | |
5546 //double v14; // st6@3 | |
5547 //float v15; // ST1C_4@3 | |
0 | 5548 float v16; // ST2C_4@3 |
5549 float v17; // ST30_4@3 | |
5550 signed int v18; // ST18_4@3 | |
5551 signed int v19; // ST14_4@3 | |
5552 signed int v20; // ST10_4@3 | |
5553 signed int v21; // eax@3 | |
5554 double v22; // st6@3 | |
5555 float v23; // ST2C_4@3 | |
5556 float v24; // ST30_4@3 | |
5557 signed int v25; // ST10_4@3 | |
5558 signed int v26; // ST14_4@3 | |
5559 signed int v27; // ST18_4@3 | |
5560 signed int v28; // eax@3 | |
5561 double v29; // st6@3 | |
5562 float v30; // ecx@3 | |
5563 float v31; // ST2C_4@3 | |
5564 float v32; // ST30_4@3 | |
5565 signed int v33; // ST10_4@3 | |
5566 signed int v34; // ST14_4@3 | |
5567 signed int v35; // ST18_4@3 | |
5568 signed int v36; // eax@3 | |
5569 float v37; // ecx@3 | |
5570 double v38; // st6@3 | |
5571 float v39; // ST2C_4@3 | |
5572 float v40; // ST30_4@3 | |
5573 signed int v41; // ST10_4@3 | |
5574 signed int v42; // ST14_4@3 | |
5575 signed int v43; // ST18_4@3 | |
5576 signed int v44; // eax@3 | |
5577 double v45; // st6@3 | |
5578 float v46; // eax@3 | |
5579 | |
5580 if ( this->uNumD3DSceneBegins ) | |
5581 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5582 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5583 { |
743 | 5584 //v5 = (double)a2->zbuffer_depth; |
5585 //v6 = v5; | |
5586 //v7 = v5; | |
5587 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
2155 | 5588 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5589 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5590 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5591 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
743 | 5592 //v9 = a2->uScreenSpaceX; |
5593 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5594 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 5595 //v12 = (double) a2->uScreenSpaceX; |
5596 //v13 = v12; | |
5597 //v14 = (double)(a2->uScreenSpaceY - 12); | |
5598 //v15 = v14; | |
5599 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5600 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5601 v18 = stru_5C6E00->Cos(angle); |
5602 v19 = stru_5C6E00->Sin(angle); | |
5603 v20 = stru_5C6E00->Sin(angle); | |
5604 v21 = stru_5C6E00->Cos(angle); | |
1390 | 5605 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5606 + (double)(v18 >> 16)) |
5607 * v16 | |
5608 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
5609 + (double)(v19 >> 16)) | |
5610 * v17) | |
743 | 5611 * v11 + (double) a2->uScreenSpaceX; |
0 | 5612 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
5613 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
5614 - 12.0) | |
5615 * v11 | |
5616 + (double)a2->uScreenSpaceY; | |
1390 | 5617 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5618 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5619 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
5620 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
5621 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5622 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5623 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
743 | 5624 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5625 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5626 v25 = stru_5C6E00->Cos(angle); |
5627 v26 = stru_5C6E00->Sin(angle); | |
5628 v27 = stru_5C6E00->Sin(angle); | |
5629 v28 = stru_5C6E00->Cos(angle); | |
1390 | 5630 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
0 | 5631 + (double)(v25 >> 16)) |
740 | 5632 * v31 |
0 | 5633 - ((double)(unsigned __int16)v26 * 0.000015259022 |
5634 + (double)(v26 >> 16)) | |
740 | 5635 * v32) |
743 | 5636 * v11 + (double) a2->uScreenSpaceX; |
740 | 5637 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
5638 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 5639 - 12.0) |
5640 * v11 | |
5641 + (double)a2->uScreenSpaceY; | |
1390 | 5642 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5643 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5644 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
5645 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5646 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
5647 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5648 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5649 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
743 | 5650 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
5651 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5652 v33 = stru_5C6E00->Cos(angle); |
5653 v34 = stru_5C6E00->Sin(angle); | |
5654 v35 = stru_5C6E00->Sin(angle); | |
5655 v36 = stru_5C6E00->Cos(angle); | |
1390 | 5656 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
0 | 5657 + (double)(v33 >> 16)) |
740 | 5658 * v23 |
0 | 5659 - ((double)(unsigned __int16)v34 * 0.000015259022 |
5660 + (double)(v34 >> 16)) | |
740 | 5661 * v24) |
743 | 5662 * v11 + (double) a2->uScreenSpaceX; |
1390 | 5663 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
740 | 5664 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
5665 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 5666 - 12.0) |
5667 * v11 | |
5668 + (double)a2->uScreenSpaceY; | |
1390 | 5669 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5670 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
5671 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5672 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5673 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
5674 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5675 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
743 | 5676 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5677 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5678 v41 = stru_5C6E00->Cos(angle); |
5679 v42 = stru_5C6E00->Sin(angle); | |
5680 v43 = stru_5C6E00->Sin(angle); | |
5681 v44 = stru_5C6E00->Cos(angle); | |
1390 | 5682 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
0 | 5683 + (double)(v41 >> 16)) |
5684 * v39 | |
5685 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
5686 + (double)(v42 >> 16)) | |
5687 * v40) | |
743 | 5688 * v11 + (double) a2->uScreenSpaceX; |
0 | 5689 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
5690 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
5691 - 12.0) | |
5692 * v11 | |
5693 + (double)a2->uScreenSpaceY; | |
1390 | 5694 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5695 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5696 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
5697 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5698 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5699 pBillboardRenderListD3D[v8].pTexture = a3; |
743 | 5700 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 5701 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5702 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; |
5703 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5704 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5705 } |
5706 } | |
5707 } | |
5708 | |
5709 //----- (004A3AD9) -------------------------------------------------------- | |
5710 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5711 { | |
5712 double v5; // st7@2 | |
5713 float v6; // ST28_4@2 | |
5714 float v7; // ST00_4@2 | |
5715 unsigned int v8; // esi@2 | |
5716 int v9; // eax@2 | |
5717 int v10; // ebx@2 | |
5718 float v11; // ST34_4@2 | |
5719 double v12; // st7@2 | |
5720 float v13; // ST2C_4@2 | |
5721 double v14; // st6@2 | |
5722 float v15; // ST24_4@2 | |
5723 float v16; // ST38_4@2 | |
5724 float v17; // ST3C_4@2 | |
5725 signed int v18; // ST1C_4@2 | |
5726 int v19; // ST30_4@2 | |
5727 signed int v20; // ST20_4@2 | |
5728 signed int v21; // ST18_4@2 | |
5729 signed int v22; // eax@2 | |
5730 double v23; // st6@2 | |
5731 float v24; // ST20_4@2 | |
5732 float v25; // ST1C_4@2 | |
5733 float v26; // ST38_4@2 | |
5734 float v27; // ST3C_4@2 | |
5735 signed int v28; // ST18_4@2 | |
5736 signed int v29; // ST14_4@2 | |
5737 signed int v30; // ST10_4@2 | |
5738 signed int v31; // eax@2 | |
5739 double v32; // st6@2 | |
5740 float v33; // ST38_4@2 | |
5741 float v34; // ST3C_4@2 | |
5742 signed int v35; // ST10_4@2 | |
5743 signed int v36; // ST14_4@2 | |
5744 signed int v37; // ST18_4@2 | |
5745 signed int v38; // eax@2 | |
5746 double v39; // st6@2 | |
5747 float v40; // ST38_4@2 | |
5748 float v41; // ST3C_4@2 | |
5749 signed int v42; // ST10_4@2 | |
5750 signed int v43; // ST14_4@2 | |
5751 signed int v44; // ST18_4@2 | |
5752 signed int v45; // eax@2 | |
5753 double v46; // st6@2 | |
5754 | |
5755 if ( this->uNumD3DSceneBegins ) | |
5756 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5757 v5 = (double)a2->zbuffer_depth; |
0 | 5758 v6 = v5; |
5759 v7 = v5; | |
5760 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
2155 | 5761 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5762 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5763 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5764 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
0 | 5765 v9 = a2->uScreenSpaceX; |
5766 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5767 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 5768 v12 = (double)v9; |
5769 v13 = v12; | |
5770 v14 = (double)(v10 - 12); | |
5771 v15 = v14; | |
5772 v16 = (double)(v9 - 12) - v12; | |
5773 v17 = (double)(v10 - 25) - v14; | |
323 | 5774 v18 = stru_5C6E00->Cos(angle); |
0 | 5775 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 5776 v20 = stru_5C6E00->Sin(angle); |
5777 v21 = stru_5C6E00->Sin(angle); | |
5778 v22 = stru_5C6E00->Cos(angle); | |
1390 | 5779 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5780 + (double)(v18 >> 16)) |
5781 * v16 | |
5782 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
5783 + (double)(v20 >> 16)) | |
5784 * v17) | |
5785 * v11 + v13; | |
5786 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
5787 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
5788 - 12.0) | |
5789 * v11 | |
5790 + (double)a2->uScreenSpaceY; | |
1390 | 5791 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5792 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5793 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
1637 | 5794 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5795 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; |
0 | 5796 v25 = 1.0 / v6; |
1390 | 5797 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; |
5798 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5799 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
0 | 5800 v26 = (double)(a2->uScreenSpaceX - 12) - v13; |
5801 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 5802 v28 = stru_5C6E00->Cos(angle); |
5803 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5804 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5805 v31 = stru_5C6E00->Cos(angle); | |
1390 | 5806 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
0 | 5807 + (double)(v28 >> 16)) |
5808 * v26 | |
5809 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
5810 + (double)(v29 >> 16)) | |
5811 * v27) | |
5812 * v11 + v13; | |
5813 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
5814 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
5815 - 12.0) | |
5816 * v11 | |
5817 + (double)a2->uScreenSpaceY; | |
1390 | 5818 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; |
5819 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
5820 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5821 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
5822 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5823 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5824 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
0 | 5825 v33 = (double)(a2->uScreenSpaceX + 12) - v13; |
5826 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 5827 v35 = stru_5C6E00->Cos(angle); |
5828 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5829 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5830 v38 = stru_5C6E00->Cos(angle); | |
1390 | 5831 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
0 | 5832 + (double)(v35 >> 16)) |
5833 * v33 | |
5834 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
5835 + (double)(v36 >> 16)) | |
5836 * v34) | |
5837 * v11 + v13; | |
5838 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
5839 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
5840 - 12.0) | |
5841 * v11 | |
5842 + (double)a2->uScreenSpaceY; | |
1390 | 5843 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5844 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
5845 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
5846 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5847 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
5848 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5849 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
0 | 5850 v40 = (double)(a2->uScreenSpaceX + 12) - v13; |
5851 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 5852 v42 = stru_5C6E00->Cos(angle); |
5853 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5854 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5855 v45 = stru_5C6E00->Cos(angle); | |
1390 | 5856 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
0 | 5857 + (double)(v42 >> 16)) |
5858 * v40 | |
5859 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
5860 + (double)(v43 >> 16)) | |
5861 * v41) | |
5862 * v11 + v13; | |
5863 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
5864 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
5865 - 12.0) | |
5866 * v11 | |
5867 + (double)a2->uScreenSpaceY; | |
1390 | 5868 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; |
5869 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
5870 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
5871 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5872 pBillboardRenderListD3D[v8].pTexture = a3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5873 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 5874 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5875 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; |
5876 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5877 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5878 } |
5879 } | |
5880 | |
5881 //----- (004A4023) -------------------------------------------------------- | |
657 | 5882 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
|
5883 { |
0 | 5884 unsigned int v8; // esi@2 |
5885 double v14; // st6@14 | |
5886 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5887 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5888 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5889 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5890 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5891 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5892 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5893 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5894 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5895 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5896 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 5897 float v29; // [sp+28h] [bp-8h]@5 |
5898 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5899 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5900 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5901 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5902 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5903 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5904 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5905 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5906 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
|
5907 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
|
5908 |
657 | 5909 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); |
2006 | 5910 if (a2->sTintColor & 0x00FFFFFF && bTinting) |
5911 { | |
5912 diffuse = BlendColors(a2->sTintColor, diffuse); | |
5913 if (a2->sTintColor & 0xFF000000) | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5914 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5915 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5916 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5917 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5918 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
|
5919 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
|
5920 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5921 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5922 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5923 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5924 v14 *= -1.0; |
1390 | 5925 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; |
5926 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5927 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5928 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5929 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; |
5930 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
5931 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5932 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5933 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5934 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5935 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5936 if ( a2->uFlags & 4 ) |
0 | 5937 v14 = v14 * -1.0; |
1390 | 5938 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; |
5939 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
5940 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5941 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5942 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5943 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; |
5944 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5945 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5946 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5947 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
|
5948 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5949 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5950 v14 *= -1.0; |
1390 | 5951 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; |
5952 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
5953 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5954 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5955 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5956 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; |
5957 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5958 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5959 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5960 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
|
5961 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5962 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5963 v14 *= -1.0; |
1390 | 5964 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; |
5965 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
5966 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5967 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5968 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5969 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; |
5970 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5971 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5972 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5973 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5974 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5975 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5976 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5977 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
2002 | 5978 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5979 |
2006 | 5980 if (a2->sTintColor & 0xFF000000) |
2155 | 5981 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5982 else |
2155 | 5983 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent; |
0 | 5984 } |
5985 | |
5986 | |
5987 //----- (004A49D0) -------------------------------------------------------- | |
5988 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
5989 { | |
1159 | 5990 int absXDifference; // eax@1 |
5991 int absYDifference; // eax@1 | |
5992 unsigned int smallerabsdiff; // ebx@1 | |
5993 unsigned int largerabsdiff; | |
0 | 5994 double v16; // st7@7 |
5995 double v17; // st7@7 | |
5996 double v18; // st6@7 | |
5997 double v20; // st4@8 | |
5998 double v21; // st4@10 | |
5999 double v22; // st4@10 | |
6000 double v23; // st4@10 | |
6001 double v25; // st4@11 | |
6002 double v26; // st4@13 | |
6003 double v28; // st4@13 | |
6004 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
1159 | 6005 int xDifference; // [sp+88h] [bp-Ch]@1 |
0 | 6006 signed int v32; // [sp+8Ch] [bp-8h]@1 |
1159 | 6007 int yDifference; // [sp+90h] [bp-4h]@1 |
6008 | |
6009 xDifference = bankersRounding(dstX - srcX); | |
6010 yDifference = bankersRounding(dstY - srcY); | |
6011 absYDifference = abs(yDifference); | |
6012 absXDifference = abs(xDifference); | |
6013 smallerabsdiff = min(absXDifference, absYDifference); | |
6014 largerabsdiff = max(absXDifference, absYDifference); | |
6015 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
0 | 6016 v16 = 1.0 / (double)v32; |
1159 | 6017 v17 = (double)yDifference * v16 * a4; |
6018 v18 = (double)xDifference * v16 * a4; | |
6019 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
6020 { | |
1637 | 6021 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
6022 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
1159 | 6023 } |
6024 else | |
6025 { | |
6026 v20 = a3 * 0.061758894; | |
6027 v25 = a7 * 0.061758894; | |
6028 } | |
6029 v21 = 1.0 / a3; | |
6030 v22 = (double)yDifference * v16 * a8; | |
6031 v23 = (double)xDifference * v16 * a8; | |
6032 v26 = 1.0 - 1.0 / v25; | |
6033 v28 = 1.0 / a7; | |
0 | 6034 v29[0].pos.x = srcX + v17; |
6035 v29[0].pos.y = srcY - v18; | |
1159 | 6036 v29[0].pos.z = 1.0 - 1.0 / v20; |
6037 v29[0].rhw = v21; | |
0 | 6038 v29[0].diffuse = -1; |
6039 v29[0].specular = 0; | |
6040 v29[0].texcoord.x = 1.0; | |
6041 v29[0].texcoord.y = 0.0; | |
1159 | 6042 |
0 | 6043 v29[1].pos.x = v22 + dstX; |
6044 v29[1].pos.y = dstY - v23; | |
1159 | 6045 v29[1].pos.z = v26; |
6046 v29[1].rhw = v28; | |
0 | 6047 v29[1].diffuse = -16711936; |
6048 v29[1].specular = 0; | |
6049 v29[1].texcoord.x = 1.0; | |
6050 v29[1].texcoord.y = 1.0; | |
1159 | 6051 |
6052 v29[2].pos.x = dstX - v22; | |
6053 v29[2].pos.y = v23 + dstY; | |
6054 v29[2].pos.z = v26; | |
0 | 6055 v29[2].rhw = v28; |
1159 | 6056 v29[2].diffuse = -1; |
6057 v29[2].specular = 0; | |
0 | 6058 v29[2].texcoord.x = 0.0; |
6059 v29[2].texcoord.y = 1.0; | |
1159 | 6060 |
0 | 6061 v29[3].pos.x = srcX - v17; |
6062 v29[3].pos.y = v18 + srcY; | |
1159 | 6063 v29[3].pos.z = v29[0].pos.z; |
6064 v29[3].rhw = v21; | |
6065 v29[3].diffuse = -1; | |
6066 v29[3].specular = 0; | |
0 | 6067 v29[3].texcoord.x = 0.0; |
6068 v29[3].texcoord.y = 0.0; | |
186 | 6069 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
6070 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6071 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
6072 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6073 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6074 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 6075 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
6076 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
6077 D3DPT_TRIANGLEFAN, | |
6078 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6079 v29, | |
6080 4, | |
6081 24)); | |
186 | 6082 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
6083 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6084 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6085 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6086 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6087 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 6088 } |
6089 | |
6090 //----- (004A4CC9) -------------------------------------------------------- | |
1390 | 6091 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) |
6092 { | |
0 | 6093 unsigned int v5; // eax@7 |
2334 | 6094 // char *v7; // edx@8 |
0 | 6095 double v10; // st6@9 |
6096 double v11; // st6@10 | |
6097 int v12; // ebx@13 | |
1390 | 6098 |
6099 if (a1->uNumVertices < 3) | |
6100 return; | |
6101 | |
6102 float depth = 1000000.0; | |
6103 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6104 { | |
6105 if (a1->field_104[i].z < depth) | |
6106 depth = a1->field_104[i * 4].z; | |
6107 } | |
6108 | |
6109 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
6110 pBillboardRenderListD3D[v5].field_90 = 0; | |
2002 | 6111 pBillboardRenderListD3D[v5].sParentBillboardID = -1; |
2155 | 6112 pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2; |
1390 | 6113 pBillboardRenderListD3D[v5].pTexture = 0; |
6114 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
6115 pBillboardRenderListD3D[v5].z_order = depth; | |
6116 | |
6117 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6118 { | |
6119 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
6120 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
6121 | |
6122 v10 = a1->field_104[i].z; | |
6123 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
6124 v11 = v10 * 0.061758894; | |
6125 else | |
1637 | 6126 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
1390 | 6127 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; |
6128 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
6129 | |
6130 if (diffuse & 0xFF000000) | |
6131 v12 = a1->field_104[i].diffuse; | |
6132 else | |
6133 v12 = diffuse; | |
6134 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
6135 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
6136 | |
6137 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
6138 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
0 | 6139 } |
6140 } | |
6141 | |
6142 //----- (004A4DE1) -------------------------------------------------------- | |
6143 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
6144 { | |
2334 | 6145 // HRESULT v12; // eax@14 |
0 | 6146 unsigned __int16 *v13; // ecx@19 |
6147 unsigned __int16 *v14; // eax@19 | |
6148 DWORD v15; // edx@20 | |
2334 | 6149 // HRESULT v16; // eax@23 |
0 | 6150 stru350 Dst; // [sp+Ch] [bp-F8h]@12 |
6151 | |
1980 | 6152 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); |
0 | 6153 if ( pHWLTexture ) |
6154 { | |
6155 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
6156 if ( !pRenderD3D->CreateTexture( | |
6157 pHWLTexture->uWidth, | |
6158 pHWLTexture->uHeight, | |
6159 pOutSurface, | |
6160 pOutTexture, | |
6161 true, | |
6162 bMipMaps, | |
6163 uMinDeviceTextureDim) ) | |
1545 | 6164 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6165 //v10 = *pOutSurface; |
6166 //v11 = 0; | |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1574
diff
changeset
|
6167 if (bMipMaps) |
0 | 6168 { |
6169 Dst._450DDE(); | |
6170 //v20 = 0; | |
6171 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
6172 | |
6173 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
6174 while ( 1 ) | |
6175 { | |
6176 DDSCAPS2 v19; | |
6177 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6178 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6179 | |
6180 DDSURFACEDESC2 desc; | |
6181 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6182 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6183 | |
168 | 6184 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6185 { |
1831 | 6186 Dst.sub_451007_scale_image_bicubic( |
0 | 6187 pHWLTexture->pPixels, |
6188 pHWLTexture->uWidth, | |
6189 pHWLTexture->uHeight, | |
6190 pHWLTexture->uWidth, | |
6191 (unsigned short *)desc.lpSurface, | |
6192 desc.dwWidth, | |
6193 desc.dwHeight, | |
6194 desc.lPitch >> 1, | |
6195 0, | |
1831 | 6196 0); |
0 | 6197 ErrD3D(pNextSurf->Unlock(0)); |
6198 //bMipMaps = 0x4D86ACu; | |
6199 } | |
6200 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
6201 break; | |
6202 //v10 = (IDirectDrawSurface4 *)pName; | |
6203 //v11 = 0; | |
6204 } | |
6205 //v20 = -1; | |
6206 //nullsub_1(); | |
6207 } | |
6208 else | |
6209 { | |
6210 DDSCAPS2 v19; | |
6211 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6212 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6213 | |
6214 DDSURFACEDESC2 desc; | |
6215 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6216 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6217 | |
168 | 6218 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6219 { |
6220 bMipMaps = 0; | |
6221 v13 = pHWLTexture->pPixels; | |
6222 v14 = (unsigned __int16 *)desc.lpSurface; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6223 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
|
6224 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6225 for (v15 = 0; v15 < desc.dwWidth; v15++) |
0 | 6226 { |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6227 *v14 = *v13; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6228 ++v14; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6229 ++v13; |
0 | 6230 } |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6231 v14 += (desc.lPitch >> 1) - desc.dwWidth; |
0 | 6232 } |
6233 ErrD3D((*pOutSurface)->Unlock(0)); | |
6234 } | |
6235 } | |
6236 delete [] pHWLTexture->pPixels; | |
6237 delete pHWLTexture; | |
6238 return true; | |
6239 } | |
6240 return false; | |
6241 } | |
6242 | |
6243 //----- (004A5048) -------------------------------------------------------- | |
670 | 6244 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
6245 { | |
6246 | |
6247 HWLTexture *sprite_texture; // eax@1 | |
0 | 6248 unsigned __int16 *v9; // edx@5 |
6249 LPVOID v10; // eax@5 | |
6250 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6251 | |
670 | 6252 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
6253 if ( sprite_texture ) | |
6254 { | |
6255 pSprite->uAreaX = sprite_texture->uAreaX; | |
6256 pSprite->uAreaY = sprite_texture->uAreaY; | |
6257 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
6258 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
6259 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
6260 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6261 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6262 //v7 = v3->pRenderD3D; |
670 | 6263 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
1545 | 6264 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6265 //pSprite = v2->pTextureSurface; |
6266 //pSprite = (Sprite *)pSprite->pName; | |
6267 //v8 = pSprite; | |
670 | 6268 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 6269 Dst.dwSize = 124; |
670 | 6270 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
6271 { | |
6272 v9 = sprite_texture->pPixels; | |
6273 v10 = Dst.lpSurface; | |
6274 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 6275 { |
670 | 6276 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
6277 { | |
0 | 6278 *(int *)v10 = *(int *)v9; |
6279 v9 += 2; | |
6280 v10 = (char *)v10 + 4; | |
670 | 6281 } |
6282 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 6283 } |
670 | 6284 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
6285 } | |
6286 free(sprite_texture->pPixels); | |
6287 free(sprite_texture); | |
6288 return true; | |
6289 } | |
6290 return false; | |
0 | 6291 } |
6292 | |
6293 //----- (004A51CB) -------------------------------------------------------- | |
6294 void Render::BeginScene() | |
6295 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6296 //Render *v1; // esi@1 |
0 | 6297 unsigned int v2; // eax@1 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6298 /*int v3; // eax@5 |
0 | 6299 unsigned __int16 **v4; // edi@6 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6300 char *v5; // ebx@7*/ |
2334 | 6301 // DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 |
0 | 6302 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6303 //v1 = this; |
0 | 6304 v2 = this->uNumSceneBegins; |
6305 this->uNumSceneBegins = v2 + 1; | |
6306 if ( !v2 ) | |
6307 { | |
6308 if ( this->pRenderD3D ) | |
6309 { | |
2069 | 6310 /*if ( this->bColorKeySupported ) |
0 | 6311 { |
6312 memset(&Dst, 0, 0x7Cu); | |
6313 Dst.dwSize = 124; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6314 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
|
6315 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6316 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6317 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6318 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
|
6319 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6320 --this->uNumSceneBegins; |
2069 | 6321 }*/ |
0 | 6322 } |
6323 else | |
6324 { | |
6325 if ( !this->pTargetSurface ) | |
6326 { | |
6327 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
2154 | 6328 /*if ( this->pTargetSurface ) |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6329 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6330 this->field_18_locked_pitch = this->uTargetSurfacePitch; |
2154 | 6331 }*/ |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6332 --this->uNumSceneBegins; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6333 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6334 } |
0 | 6335 RestoreFrontBuffer(); |
6336 } | |
6337 } | |
6338 | |
6339 //----- (004A527D) -------------------------------------------------------- | |
6340 void Render::EndScene() | |
6341 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6342 if ( this->uNumSceneBegins ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6343 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6344 this->uNumSceneBegins--; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6345 if ( !this->uNumSceneBegins ) |
0 | 6346 { |
6347 if ( this->pRenderD3D ) | |
6348 { | |
2069 | 6349 /*if ( this->bColorKeySupported ) |
0 | 6350 { |
6351 this->pTargetSurface = 0; | |
6352 this->uTargetSurfacePitch = 0; | |
6353 this->field_18_locked_pitch = 0; | |
6354 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
2069 | 6355 }*/ |
0 | 6356 } |
6357 else | |
6358 { | |
6359 this->pTargetSurface = 0; | |
6360 this->uTargetSurfacePitch = 0; | |
2154 | 6361 //this->field_18_locked_pitch = 0; |
0 | 6362 UnlockBackBuffer(); |
6363 } | |
6364 } | |
6365 } | |
6366 } | |
6367 | |
2155 | 6368 //----- (004A52F1) -------------------------------------------------------- |
6369 void Render::ScreenFade(unsigned int color, float t) | |
0 | 6370 { |
6371 unsigned int v3; // esi@1 | |
2155 | 6372 //double v4; // st7@2 |
6373 //double v5; // st7@6 | |
0 | 6374 double v6; // st6@6 |
6375 unsigned int v7; // eax@6 | |
6376 double v8; // st5@6 | |
6377 double v9; // st4@6 | |
2334 | 6378 // HRESULT v10; // eax@6 |
6379 // HRESULT v11; // eax@6 | |
6380 // unsigned int result; // eax@6 | |
6381 // unsigned int v13; // eax@7 | |
6382 // unsigned __int16 *v14; // ecx@7 | |
6383 // int *v15; // eax@7 | |
6384 // unsigned int v16; // ecx@8 | |
6385 // __int16 v17; // ax@10 | |
6386 // int v18; // esi@10 | |
6387 // float v19; // edi@10 | |
6388 // void *v20; // esi@10 | |
6389 // int v21; // edx@10 | |
6390 // int v22; // ecx@11 | |
6391 // int v23; // edx@12 | |
6392 // __int16 v24; // ax@15 | |
6393 // int v25; // esi@15 | |
6394 // float v26; // edi@15 | |
6395 // char *v27; // esi@15 | |
6396 // int v28; // edx@15 | |
6397 // int v29; // ecx@16 | |
6398 // int v30; // edx@17 | |
6399 // int v31; // [sp-Ch] [bp-ACh]@11 | |
6400 // int v32; // [sp-Ch] [bp-ACh]@16 | |
6401 // const char *v33; // [sp+0h] [bp-A0h]@0 | |
6402 // int v34; // [sp+4h] [bp-9Ch]@0 | |
6403 // unsigned int v35; // [sp+8h] [bp-98h]@0 | |
0 | 6404 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 |
2334 | 6405 // unsigned int v37; // [sp+8Ch] [bp-14h]@7 |
6406 // int v38; // [sp+90h] [bp-10h]@7 | |
6407 // double v39; // [sp+94h] [bp-Ch]@6 | |
2155 | 6408 int v40; // [sp+9Ch] [bp-4h]@6 |
6409 | |
0 | 6410 v3 = 0; |
1574 | 6411 |
6412 //{ | |
2155 | 6413 if (t > 1.0f) |
6414 t = 1.0f; | |
6415 else if (t < 0.0f) | |
6416 t = 0.0f; | |
6417 | |
6418 v40 = (char)floorf(t * 255.0f + 0.5f); | |
6419 //v5 = (double)(signed int)pViewport->uViewportTL_X; | |
6420 v36[0].pos.x = pViewport->uViewportTL_X; | |
693 | 6421 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
2155 | 6422 v7 = color | (v40 << 24); |
6423 //this_ = pViewport->uViewportBR_Y + 1; | |
0 | 6424 v36[0].specular = 0; |
6425 v36[0].pos.y = v6; | |
6426 v36[0].diffuse = v7; | |
6427 v36[1].diffuse = v7; | |
6428 v36[0].pos.z = 0.0; | |
6429 v36[2].diffuse = v7; | |
6430 v36[3].diffuse = v7; | |
6431 v36[0].rhw = 1.0; | |
6432 v36[1].specular = 0; | |
6433 v36[0].texcoord.x = 0.0; | |
6434 v36[2].specular = 0; | |
6435 v36[3].specular = 0; | |
6436 v36[0].texcoord.y = 0.0; | |
2155 | 6437 v36[1].pos.x = pViewport->uViewportTL_X; |
693 | 6438 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 6439 v36[1].pos.y = v8; |
6440 v36[1].pos.z = 0.0; | |
6441 v36[1].rhw = 1.0; | |
6442 v36[1].texcoord.x = 0.0; | |
6443 v36[1].texcoord.y = 0.0; | |
693 | 6444 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 6445 v36[2].pos.x = v9; |
6446 v36[2].pos.y = v8; | |
6447 v36[2].pos.z = 0.0; | |
6448 v36[2].rhw = 1.0; | |
6449 v36[2].texcoord.x = 0.0; | |
6450 v36[2].texcoord.y = 0.0; | |
6451 v36[3].pos.x = v9; | |
6452 v36[3].pos.y = v6; | |
6453 v36[3].pos.z = 0.0; | |
6454 v36[3].rhw = 1.0; | |
6455 v36[3].texcoord.x = 0.0; | |
6456 v36[3].texcoord.y = 0.0; | |
6457 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 6458 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
6459 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6460 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6461 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
6462 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
6463 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6464 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 6465 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
6466 D3DPT_TRIANGLEFAN, | |
6467 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6468 v36, | |
6469 4, | |
6470 28)); | |
186 | 6471 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
6472 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6473 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
6474 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6475 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6476 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
1574 | 6477 /*} |
0 | 6478 else |
6479 { | |
6480 v40 = (1.0 - a3) * 65536.0; | |
6481 v39 = v40 + 6.7553994e15; | |
6482 LODWORD(a3) = LODWORD(v39); | |
693 | 6483 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
6484 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
6485 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
6486 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 6487 v37 = 2 * v13; |
6488 LODWORD(v40) = (int)v14; | |
6489 | |
6490 int __i = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
6491 v15 = dword_F1B430.data(); |
0 | 6492 do |
6493 { | |
6494 v16 = v3; | |
6495 v3 += LODWORD(a3); | |
6496 dword_F1B430[__i++] = v16 >> 16; | |
6497 } | |
6498 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
6499 while (__i < 32); | |
6500 | |
6501 if ( pRenderer->uTargetGBits == 6 ) | |
6502 { | |
1574 | 6503 v17 = sr_42690D_colors_cvt(this_); |
0 | 6504 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); |
6505 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); | |
6506 v19 = v40; | |
6507 v20 = off_4EFDB0; | |
6508 v21 = HIDWORD(v39); | |
6509 do | |
6510 { | |
6511 v22 = v38; | |
6512 v31 = v21; | |
6513 do | |
6514 { | |
6515 v23 = (*(int *)((char *)v20 | |
6516 + ((((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; | |
6517 result = this_ | |
6518 + (*((int *)v20 | |
6519 + (((unsigned __int8)(*((char *)v20 | |
6520 + ((((unsigned __int16)(*(short *)((char *)v20 | |
6521 + ((*(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); | |
6522 *(unsigned int *)LODWORD(v19) = result; | |
6523 LODWORD(v19) += 4; | |
6524 --v22; | |
6525 } | |
6526 while ( v22 ); | |
6527 LODWORD(v19) += v37; | |
6528 v21 = v31 - 1; | |
6529 } | |
6530 while ( v31 != 1 ); | |
6531 } | |
6532 else | |
6533 { | |
1574 | 6534 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_); |
0 | 6535 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); |
6536 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
6537 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
6538 v26 = v40; | |
6539 v27 = (char *)off_4EFDB0; | |
6540 v28 = HIDWORD(v39); | |
6541 do | |
6542 { | |
6543 v29 = v38; | |
6544 v32 = v28; | |
6545 do | |
6546 { | |
6547 v30 = 32 | |
6548 * *(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; | |
6549 result = this_ | |
6550 + (*(int *)&v27[4 | |
6551 * (((unsigned __int8)(32 | |
6552 * 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); | |
6553 *(unsigned int *)LODWORD(v26) = result; | |
6554 LODWORD(v26) += 4; | |
6555 --v29; | |
6556 } | |
6557 while ( v29 ); | |
6558 LODWORD(v26) += v37; | |
6559 v28 = v32 - 1; | |
6560 } | |
6561 while ( v32 != 1 ); | |
6562 } | |
1574 | 6563 }*/ |
0 | 6564 } |
6565 | |
6566 //----- (004A5B81) -------------------------------------------------------- | |
727 | 6567 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 6568 { |
6569 this->bClip = 1; | |
6570 this->uClipY = uY; | |
6571 this->uClipX = uX; | |
6572 this->uClipW = uW; | |
6573 this->uClipZ = uZ; | |
6574 } | |
6575 | |
6576 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 6577 void Render::ResetTextureClipRect() |
0 | 6578 { |
6579 this->uClipY = 0; | |
6580 this->uClipX = 0; | |
6581 this->bClip = 1; | |
6582 this->uClipW = 480; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
6583 this->uClipZ = window->GetWidth(); |
0 | 6584 } |
6585 | |
2069 | 6586 unsigned __int32 Color32(unsigned __int16 color16) |
6587 { | |
6588 unsigned __int32 c = color16; | |
6589 unsigned int b = (c & 31) * 8; | |
6590 unsigned int g = ((c >> 5) & 63) * 4; | |
6591 unsigned int r = ((c >> 11) & 31) * 8; | |
6592 | |
2078 | 6593 return (r << 16) | (g << 8) | b;// |
2069 | 6594 } |
6595 | |
6596 //----- (0040DEF3) -------------------------------------------------------- | |
6597 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b) | |
6598 { | |
6599 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + | |
6600 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + | |
6601 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
6602 return (b >> (8 - 5)) | | |
6603 0x7E0 & (g << (6 + 5 - 8)) | | |
6604 0xF800 & (r << (6 + 5 + 5 - 8)); | |
6605 } | |
6606 | |
6607 | |
0 | 6608 //----- (004A5BE3) -------------------------------------------------------- |
6609 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
6610 { | |
6611 int v4; // edi@3 | |
2069 | 6612 //unsigned __int16 *v5; // edx@3 |
0 | 6613 unsigned __int16 *v6; // esi@3 |
6614 unsigned int v8; // eax@5 | |
2334 | 6615 unsigned int v9; // ebx@5 |
0 | 6616 unsigned int v11; // eax@7 |
6617 unsigned int v12; // ebx@8 | |
6618 unsigned int v15; // eax@14 | |
2334 | 6619 int v19; // [sp+10h] [bp-8h]@3 |
6620 // unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
0 | 6621 int v23; // [sp+28h] [bp+10h]@3 |
6622 | |
6623 if ( this->uNumSceneBegins && a4 ) | |
6624 { | |
6625 v4 = a4->uWidth; | |
2069 | 6626 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6627 v6 = a4->pPixels; |
6628 v23 = a4->uHeight; | |
2334 | 6629 v19 = v4; |
0 | 6630 if ( this->bClip ) |
6631 { | |
1152 | 6632 if ( (signed int)uOutX < (signed int)this->uClipX ) |
6633 { | |
6634 v8 = this->uClipX - uOutX; | |
2334 | 6635 v9 = uOutX - this->uClipX; |
0 | 6636 v8 *= 2; |
2334 | 6637 v4 += v9; |
0 | 6638 v6 = (unsigned __int16 *)((char *)v6 + v8); |
2069 | 6639 //v5 = (unsigned __int16 *)((char *)v5 + v8); |
0 | 6640 } |
1152 | 6641 if ( (signed int)uOutY < (signed int)this->uClipY ) |
6642 { | |
6643 v11 = this->uClipY - uOutY; | |
2334 | 6644 v6 += v19 * v11; |
0 | 6645 v23 += uOutY - this->uClipY; |
2069 | 6646 //v5 += this->uTargetSurfacePitch * v11; |
0 | 6647 } |
1152 | 6648 v12 = max(this->uClipX, uOutX); |
6649 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | |
2334 | 6650 { |
1152 | 6651 v4 = this->uClipZ - max(this->uClipX, uOutX); |
2334 | 6652 } |
1152 | 6653 v15 = max(this->uClipY, uOutY); |
6654 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) | |
2334 | 6655 { |
1152 | 6656 v23 = this->uClipW - max(this->uClipY, uOutY); |
2334 | 6657 } |
1152 | 6658 } |
6659 | |
2069 | 6660 for (int y = 0; y < v23; y++) |
6661 { | |
6662 for (int x = 0; x < v4; x++) | |
6663 { | |
6664 WritePixel16(uOutX + x, uOutY + y, *v6); | |
6665 //*v5 = *v6; | |
6666 //++v5; | |
1152 | 6667 ++v6; |
6668 } | |
2334 | 6669 v6 += v19 - v4; |
2069 | 6670 //v5 += this->uTargetSurfacePitch - v4; |
0 | 6671 } |
6672 } | |
6673 } | |
6674 | |
6675 //----- (004A5D33) -------------------------------------------------------- | |
1675 | 6676 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) |
0 | 6677 { |
2069 | 6678 //unsigned __int16 *v7; // ebx@3 |
1675 | 6679 int full_width; // ecx@3 |
6680 int full_height; // edi@3 | |
2069 | 6681 //int v23; // edi@23 |
0 | 6682 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 |
6683 | |
6684 if ( this->uNumSceneBegins && pTexture ) | |
6685 { | |
2069 | 6686 /*auto v7 = this->pTargetSurface; |
6687 if (FORCE_16_BITS) | |
6688 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2); | |
6689 else | |
6690 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/ | |
1675 | 6691 full_width = pTexture->uWidth - move_X; |
6692 full_height = pTexture->uHeight - move_Y; | |
6693 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth]; | |
6694 if ( this->bClip ) | |
6695 { | |
6696 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó | |
6697 { | |
6698 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX))); | |
6699 full_width += pX - this->uClipX; | |
2069 | 6700 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX))); |
1675 | 6701 } |
6702 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó | |
6703 { | |
6704 pTexturea += pTexture->uWidth * (this->uClipY - pY); | |
6705 full_height += pY - this->uClipY; | |
2069 | 6706 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY)); |
1675 | 6707 } |
6708 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà | |
6709 this->uClipX = pX; | |
6710 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà | |
6711 this->uClipY = pY; | |
6712 if ( (full_width + this->uClipX) > this->uClipZ )//åñëè øèðèíà êàäðà âûõîäèò çà ïðàâóþ ãðàíèöó | |
6713 { | |
6714 if ( this->uClipX < pX ) | |
6715 this->uClipX = pX; | |
6716 full_width = this->uClipZ - this->uClipX; | |
6717 } | |
6718 if ( (full_height + this->uClipY) > this->uClipW )//åñëè âûñîòà êàäðà âûõîäèò çà íèæíþþ ãðàíèöó | |
6719 { | |
6720 if ( this->uClipY < pY ) | |
6721 this->uClipY = pY; | |
6722 full_height = this->uClipW - this->uClipY; | |
6723 } | |
6724 } | |
2069 | 6725 |
6726 for (int y = 0; y < full_height; ++y) | |
6727 { | |
6728 for (int x = 0; x < full_width; ++x) | |
6729 { | |
6730 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) ) | |
6731 { | |
6732 WritePixel16(pX + x, pY + y, *pTexturea); | |
6733 /*if (FORCE_16_BITS) | |
6734 *(unsigned __int16 *)v7 = *pTexturea; | |
6735 else | |
6736 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/ | |
6737 } | |
0 | 6738 ++pTexturea; |
2069 | 6739 //++v7; |
0 | 6740 } |
2069 | 6741 //v7 += this->uTargetSurfacePitch - full_width; |
1675 | 6742 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width)); |
2069 | 6743 } |
0 | 6744 } |
6745 } | |
6746 | |
6747 //----- (004A6E7E) -------------------------------------------------------- | |
2155 | 6748 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 6749 { |
2069 | 6750 //unsigned __int16 *v4; // eax@4 |
0 | 6751 int v5; // edx@4 |
6752 unsigned int v6; // edi@4 | |
6753 unsigned int v7; // edx@5 | |
6754 unsigned int v8; // edx@6 | |
6755 unsigned int v9; // edx@7 | |
6756 unsigned int v10; // edx@8 | |
6757 unsigned int v11; // ebx@9 | |
6758 unsigned int v12; // esi@11 | |
6759 unsigned int v13; // edx@12 | |
6760 unsigned int v14; // ebx@15 | |
6761 unsigned int v15; // esi@17 | |
6762 unsigned int v16; // edi@18 | |
2334 | 6763 // char v17; // zf@29 |
0 | 6764 int v18; // [sp+14h] [bp-Ch]@4 |
6765 int v19; // [sp+18h] [bp-8h]@4 | |
6766 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
2334 | 6767 // int v21; // [sp+28h] [bp+8h]@25 |
6768 // int v22; // [sp+28h] [bp+8h]@34 | |
6769 // unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
6770 // unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
0 | 6771 |
6772 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
6773 { | |
2069 | 6774 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
710 | 6775 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 6776 v5 = a4->uTextureWidth; |
6777 v6 = a4->uTextureHeight; | |
6778 v19 = a4->uTextureWidth; | |
6779 v18 = a4->uTextureWidth; | |
2069 | 6780 int clipped_out_x = a2; |
6781 int clipped_out_y = a3; | |
0 | 6782 if ( this->bClip ) |
6783 { | |
6784 v7 = this->uClipX; | |
6785 if ( (signed int)a2 < (signed int)v7 ) | |
6786 { | |
6787 v8 = v7 - a2; | |
6788 v20 += v8; | |
6789 v19 += a2 - this->uClipX; | |
2069 | 6790 //v4 += v8; |
6791 clipped_out_x = uClipX; | |
0 | 6792 } |
6793 v9 = this->uClipY; | |
6794 if ( (signed int)a3 < (signed int)v9 ) | |
6795 { | |
6796 v10 = v9 - a3; | |
6797 v20 += v18 * v10; | |
6798 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
2069 | 6799 //v4 += this->uTargetSurfacePitch * v10; |
6800 clipped_out_y = uClipY; | |
0 | 6801 } |
6802 v11 = this->uClipX; | |
6803 v5 = v19; | |
6804 if ( (signed int)v11 < (signed int)a2 ) | |
6805 v11 = a2; | |
6806 v12 = this->uClipZ; | |
6807 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
6808 { | |
6809 v13 = this->uClipX; | |
6810 if ( (signed int)v13 < (signed int)a2 ) | |
6811 v13 = a2; | |
6812 v5 = v12 - v13; | |
6813 } | |
6814 v14 = this->uClipY; | |
6815 if ( (signed int)v14 < (signed int)a3 ) | |
6816 v14 = a3; | |
6817 v15 = this->uClipW; | |
6818 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
6819 { | |
6820 v16 = this->uClipY; | |
6821 if ( (signed int)v16 < (signed int)a3 ) | |
6822 v16 = a3; | |
6823 v6 = v15 - v16; | |
6824 } | |
6825 } | |
2069 | 6826 |
6827 for (int y = 0; y < v6; ++y) | |
6828 { | |
6829 for (int x = 0; x < v5; ++x) | |
6830 { | |
6831 if ( *v20 ) | |
6832 WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF); | |
6833 ++v20; | |
6834 } | |
6835 v20 += v18 - v5; | |
6836 } | |
6837 | |
6838 /*if ( pRenderer->uTargetGBits == 5 ) | |
0 | 6839 { |
6840 if ( (signed int)v6 > 0 ) | |
6841 { | |
6842 v23 = v6; | |
6843 do | |
6844 { | |
6845 if ( v5 > 0 ) | |
6846 { | |
6847 v21 = v5; | |
6848 do | |
6849 { | |
6850 if ( *v20 ) | |
6851 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
6852 ++v4; | |
6853 ++v20; | |
6854 --v21; | |
6855 } | |
6856 while ( v21 ); | |
6857 } | |
6858 v20 += v18 - v5; | |
6859 v17 = v23-- == 1; | |
6860 v4 += this->uTargetSurfacePitch - v5; | |
6861 } | |
6862 while ( !v17 ); | |
6863 } | |
6864 } | |
6865 else | |
6866 { | |
6867 if ( (signed int)v6 > 0 ) | |
6868 { | |
6869 v24 = v6; | |
6870 do | |
6871 { | |
6872 if ( v5 > 0 ) | |
6873 { | |
6874 v22 = v5; | |
6875 do | |
6876 { | |
6877 if ( *v20 ) | |
6878 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
6879 ++v4; | |
6880 ++v20; | |
6881 --v22; | |
6882 } | |
6883 while ( v22 ); | |
6884 } | |
6885 v20 += v18 - v5; | |
6886 v17 = v24-- == 1; | |
6887 v4 += this->uTargetSurfacePitch - v5; | |
6888 } | |
6889 while ( !v17 ); | |
6890 } | |
2069 | 6891 }*/ |
0 | 6892 } |
6893 } | |
6894 | |
6895 //----- (004A6DF5) -------------------------------------------------------- | |
2069 | 6896 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) |
0 | 6897 { |
2219 | 6898 int width; // ecx@3 |
6899 unsigned __int16 *pixels; // ebx@4 | |
6900 int height; // esi@4 | |
0 | 6901 |
2069 | 6902 if ( !pBitmap || !pTarget) |
6903 return; | |
6904 | |
2219 | 6905 width = a7->z - a7->x; |
6906 height = a7->w - a7->y; | |
6907 pixels = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; | |
6908 for ( int y = 0; y < height; ++y ) | |
6909 { | |
6910 for ( int x = 0; x < width; ++x ) | |
6911 { | |
6912 WritePixel16(a7->x + x, a7->y + y, *pixels); | |
6913 ++pixels; | |
6914 } | |
6915 pixels += uTargetPitch - width; | |
2093 | 6916 } |
0 | 6917 } |
6918 | |
6919 //----- (004A6D87) -------------------------------------------------------- | |
6920 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
6921 { | |
6922 if (!uNumSceneBegins) | |
6923 return; | |
6924 | |
6925 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
6926 for (uint y = 0; y < uHeight; ++y) | |
6927 { | |
2069 | 6928 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch); |
6929 | |
6930 memset32(pDst, | |
2098 | 6931 FORCE_16_BITS ? twoColors : 0xFF000000 | Color32(uColor16), // two colors per int (16bit) or 1 (32bit) |
2069 | 6932 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit) |
6933 | |
6934 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit | |
6935 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16; | |
0 | 6936 } |
6937 } | |
6938 | |
6939 //----- (004A6C4F) -------------------------------------------------------- | |
2073 | 6940 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, |
6941 unsigned int uCharHeight, unsigned __int16 *pFontPalette, | |
6942 unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
0 | 6943 { |
6944 unsigned int v9; // edi@2 | |
6945 unsigned int v10; // esi@2 | |
2069 | 6946 //unsigned __int16 *v11; // eax@2 |
0 | 6947 unsigned int v12; // ebx@3 |
6948 signed int v13; // edx@5 | |
6949 int v14; // edx@6 | |
6950 signed int v15; // ebx@7 | |
6951 unsigned int v16; // edx@9 | |
6952 signed int v17; // edi@10 | |
6953 signed int v18; // ebx@13 | |
6954 unsigned int v19; // edx@15 | |
6955 signed int v20; // esi@16 | |
2069 | 6956 //unsigned int v21; // esi@22 |
0 | 6957 unsigned __int16 v22; // dx@24 |
2069 | 6958 //char v23; // zf@28 |
0 | 6959 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 |
2069 | 6960 //unsigned int uOutXa; // [sp+18h] [bp+8h]@20 |
6961 | |
6962 if (!this->uNumSceneBegins) | |
6963 return; | |
6964 | |
0 | 6965 v9 = uCharWidth; |
6966 v10 = uCharHeight; | |
2069 | 6967 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6968 v24 = pFontPixels; |
2069 | 6969 |
6970 int clipped_out_x = uOutX, clipped_out_y = uOutY; | |
0 | 6971 if ( this->bClip ) |
6972 { | |
6973 v12 = this->uClipX; | |
6974 if ( uOutX < (signed int)v12 ) | |
6975 { | |
6976 v24 = &pFontPixels[v12 - uOutX]; | |
2069 | 6977 //v11 += v12 - uOutX; |
6978 clipped_out_x = uClipX; | |
0 | 6979 v9 = uCharWidth + uOutX - v12; |
6980 } | |
6981 v13 = this->uClipY; | |
6982 if ( uOutY < v13 ) | |
6983 { | |
6984 v14 = v13 - uOutY; | |
6985 v24 += uCharWidth * v14; | |
6986 v10 = uCharHeight + uOutY - this->uClipY; | |
2069 | 6987 //v11 += this->uTargetSurfacePitch * v14; |
6988 clipped_out_y = uClipY; | |
0 | 6989 } |
6990 v15 = this->uClipX; | |
6991 if ( v15 < uOutX ) | |
6992 v15 = uOutX; | |
6993 v16 = this->uClipZ; | |
6994 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
6995 { | |
6996 v17 = this->uClipX; | |
6997 if ( v17 < uOutX ) | |
6998 v17 = uOutX; | |
6999 v9 = v16 - v17; | |
7000 } | |
7001 v18 = this->uClipY; | |
7002 if ( v18 < uOutY ) | |
7003 v18 = uOutY; | |
7004 v19 = this->uClipW; | |
7005 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
7006 { | |
7007 v20 = this->uClipY; | |
7008 if ( v20 < uOutY ) | |
7009 v20 = uOutY; | |
7010 v10 = v19 - v20; | |
7011 } | |
7012 } | |
2069 | 7013 |
7014 for (int y = 0; y < v10; ++y) | |
7015 { | |
7016 for (int x = 0; x < v9; ++x) | |
7017 { | |
7018 if (*v24) | |
0 | 7019 { |
2069 | 7020 v22 = uShadowColor; |
7021 if ( *v24 != 1 ) | |
7022 v22 = uFaceColor; | |
2073 | 7023 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22); |
0 | 7024 } |
2073 | 7025 ++v24; |
7026 } | |
7027 v24 += uCharWidth - v9; | |
2069 | 7028 //v23 = uOutXa-- == 1; |
7029 //v11 += this->uTargetSurfacePitch - v9; | |
7030 } | |
0 | 7031 } |
7032 | |
7033 //----- (004A6A68) -------------------------------------------------------- | |
1496 | 7034 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) |
7035 { | |
0 | 7036 Texture tex; // [sp+Ch] [bp-48h]@1 |
1496 | 7037 |
0 | 7038 memcpy(&tex, a4, sizeof(tex)); |
1496 | 7039 tex.uTextureHeight = a4->uTextureHeight - height; |
7040 if ( (signed __int16)tex.uTextureHeight > 0 ) | |
0 | 7041 DrawTextureIndexed(a2, a3, &tex); |
7042 } | |
7043 | |
7044 //----- (004A6AB1) -------------------------------------------------------- | |
1268 | 7045 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
7046 { | |
0 | 7047 int v8; // edi@2 |
7048 unsigned int v9; // esi@2 | |
2069 | 7049 //unsigned __int16 *v10; // eax@2 |
0 | 7050 unsigned char *v11; // edx@2 |
7051 unsigned int v12; // ebx@3 | |
7052 signed int v13; // edx@5 | |
7053 int v14; // edx@6 | |
7054 signed int v15; // ebx@7 | |
7055 unsigned int v16; // edx@9 | |
7056 signed int v17; // edi@10 | |
7057 signed int v18; // ebx@13 | |
7058 unsigned int v19; // edx@15 | |
7059 signed int v20; // esi@16 | |
2334 | 7060 // int v21; // ebx@22 |
7061 // char v22; // zf@28 | |
7062 // int v23; // ebx@31 | |
0 | 7063 unsigned __int16 v24; // si@35 |
7064 int v25; // [sp+Ch] [bp-4h]@2 | |
2334 | 7065 // int v26; // [sp+1Ch] [bp+Ch]@24 |
7066 // int v27; // [sp+1Ch] [bp+Ch]@33 | |
0 | 7067 unsigned int v28; // [sp+20h] [bp+10h]@30 |
2334 | 7068 // unsigned int v29; // [sp+24h] [bp+14h]@22 |
7069 // unsigned int v30; // [sp+24h] [bp+14h]@31 | |
0 | 7070 |
1980 | 7071 int a2 = x; |
7072 int a3 = y; | |
7073 uint a6 = uFontHeight; | |
2069 | 7074 if (!this->uNumSceneBegins) |
7075 return; | |
7076 | |
0 | 7077 v8 = a5; |
7078 v9 = a6; | |
2069 | 7079 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; |
1268 | 7080 v11 = (unsigned char *)font_pixels; |
7081 v25 = (int)font_pixels; | |
2069 | 7082 int clipped_out_x = x; |
7083 int clipped_out_y = y; | |
0 | 7084 if ( this->bClip ) |
7085 { | |
7086 v12 = this->uClipX; | |
7087 if ( a2 < (signed int)v12 ) | |
7088 { | |
1268 | 7089 v25 = v12 - a2 + (int)font_pixels; |
2069 | 7090 //v10 += v12 - a2; |
0 | 7091 v8 = a5 + a2 - v12; |
2069 | 7092 clipped_out_x = uClipX; |
0 | 7093 } |
7094 v13 = this->uClipY; | |
7095 if ( a3 < v13 ) | |
7096 { | |
7097 v14 = v13 - a3; | |
7098 v25 += a5 * v14; | |
7099 v9 = a6 + a3 - this->uClipY; | |
2069 | 7100 //v10 += this->uTargetSurfacePitch * v14; |
7101 clipped_out_y = uClipY; | |
0 | 7102 } |
7103 v15 = this->uClipX; | |
7104 if ( v15 < a2 ) | |
7105 v15 = a2; | |
7106 v16 = this->uClipZ; | |
7107 if ( v8 + v15 > (signed int)v16 ) | |
7108 { | |
7109 v17 = this->uClipX; | |
7110 if ( v17 < a2 ) | |
7111 v17 = a2; | |
7112 v8 = v16 - v17; | |
7113 } | |
7114 v18 = this->uClipY; | |
7115 if ( v18 < a3 ) | |
7116 v18 = a3; | |
7117 v19 = this->uClipW; | |
7118 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
7119 { | |
7120 v20 = this->uClipY; | |
7121 if ( v20 < a3 ) | |
7122 v20 = a3; | |
7123 v9 = v19 - v20; | |
7124 } | |
7125 v11 = (unsigned char *)v25; | |
7126 } | |
2069 | 7127 |
0 | 7128 if ( a8 ) |
7129 { | |
2069 | 7130 v28 = 0x7FF; // 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask; |
7131 for (int dy = 0; dy < v9; ++dy) | |
7132 { | |
7133 for (int dx = 0; dx < v8; ++dx) | |
7134 { | |
7135 if ( *v11 ) | |
7136 v24 = pPalette[*v11]; | |
7137 else | |
7138 v24 = v28; | |
7139 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24); | |
7140 //*v10 = v24; | |
7141 //++v10; | |
2074 | 7142 ++v11; |
2069 | 7143 //--v27; |
2074 | 7144 |
2069 | 7145 } |
7146 v11 += a5 - v8; | |
7147 } | |
7148 /*if ( (signed int)v9 > 0 ) | |
0 | 7149 { |
7150 v23 = a5; | |
7151 v30 = v9; | |
7152 do | |
7153 { | |
7154 if ( v8 > 0 ) | |
7155 { | |
7156 v27 = v8; | |
7157 do | |
7158 { | |
7159 if ( *v11 ) | |
7160 v24 = pPalette[*v11]; | |
7161 else | |
7162 v24 = v28; | |
7163 *v10 = v24; | |
7164 ++v10; | |
7165 ++v11; | |
7166 --v27; | |
7167 } | |
7168 while ( v27 ); | |
7169 } | |
7170 v11 += v23 - v8; | |
7171 v22 = v30-- == 1; | |
7172 v10 += this->uTargetSurfacePitch - v8; | |
7173 } | |
7174 while ( !v22 ); | |
2069 | 7175 }*/ |
0 | 7176 } |
7177 else | |
7178 { | |
2069 | 7179 for (int dy = 0; dy < v9; ++dy) |
7180 { | |
7181 for (int dx = 0; dx < v8; ++dx) | |
7182 { | |
2074 | 7183 if ( *v11 ) |
2069 | 7184 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]); |
7185 //*v10 = v24; | |
7186 //++v10; | |
2074 | 7187 ++v11; |
2069 | 7188 //--v27; |
7189 } | |
7190 v11 += a5 - v8; | |
7191 } | |
7192 | |
7193 /*if ( (signed int)v9 > 0 ) | |
0 | 7194 { |
7195 v21 = a5; | |
7196 v29 = v9; | |
7197 do | |
7198 { | |
7199 if ( v8 > 0 ) | |
7200 { | |
7201 v26 = v8; | |
7202 do | |
7203 { | |
7204 if ( *v11 ) | |
7205 *v10 = pPalette[*v11]; | |
7206 ++v10; | |
7207 ++v11; | |
7208 --v26; | |
7209 } | |
7210 while ( v26 ); | |
7211 } | |
7212 v11 += v21 - v8; | |
7213 v22 = v29-- == 1; | |
7214 v10 += this->uTargetSurfacePitch - v8; | |
7215 } | |
7216 while ( !v22 ); | |
2069 | 7217 }*/ |
7218 } | |
0 | 7219 } |
7220 | |
7221 //----- (004A68EF) -------------------------------------------------------- | |
7222 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
7223 { | |
2069 | 7224 DrawMasked(a2, a3, pTexture, 0x07E0); |
7225 } | |
7226 | |
0 | 7227 |
7228 //----- (004A6776) -------------------------------------------------------- | |
315 | 7229 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 7230 { |
2069 | 7231 DrawMasked(a2, a3, a4, 0xF800); |
7232 /*Texture *v4; // edi@2 | |
0 | 7233 unsigned int v5; // ebx@4 |
7234 unsigned __int16 *v6; // eax@4 | |
7235 unsigned int v7; // edx@5 | |
7236 unsigned int v8; // edx@6 | |
7237 unsigned int v9; // edx@7 | |
7238 unsigned int v10; // edx@8 | |
7239 unsigned int v11; // edx@9 | |
7240 unsigned int v12; // esi@12 | |
7241 unsigned int v13; // esi@15 | |
7242 unsigned int v14; // edx@17 | |
7243 unsigned int v15; // esi@18 | |
7244 unsigned __int8 *v16; // ebx@22 | |
7245 char v17; // zf@28 | |
7246 int v18; // [sp+10h] [bp-10h]@4 | |
7247 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7248 int v20; // [sp+1Ch] [bp-4h]@4 | |
7249 int a2a; // [sp+28h] [bp+8h]@24 | |
7250 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
7251 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
7252 | |
7253 if ( this->uNumSceneBegins ) | |
7254 { | |
7255 v4 = a4; | |
7256 if ( a4 ) | |
7257 { | |
7258 if ( a4->pPalette16 ) | |
7259 { | |
7260 v5 = a4->uTextureHeight; | |
7261 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7262 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7263 v20 = a4->uTextureWidth; |
7264 v18 = a4->uTextureWidth; | |
7265 if ( this->bClip ) | |
7266 { | |
7267 v7 = this->uClipX; | |
7268 if ( (signed int)a2 < (signed int)v7 ) | |
7269 { | |
7270 v8 = v7 - a2; | |
7271 v19 += v8; | |
7272 v20 += a2 - this->uClipX; | |
7273 v6 += v8; | |
7274 } | |
7275 v9 = this->uClipY; | |
7276 v5 = a4->uTextureHeight; | |
7277 if ( (signed int)a3 < (signed int)v9 ) | |
7278 { | |
7279 v10 = v9 - a3; | |
7280 v19 += v18 * v10; | |
7281 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
7282 v4 = a4; | |
7283 v6 += this->uTargetSurfacePitch * v10; | |
7284 } | |
7285 v11 = this->uClipX; | |
7286 if ( (signed int)v11 < (signed int)a2 ) | |
7287 v11 = a2; | |
7288 a4a = this->uClipZ; | |
7289 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
7290 { | |
7291 v12 = this->uClipX; | |
7292 if ( (signed int)v12 < (signed int)a2 ) | |
7293 v12 = a2; | |
7294 v20 = a4a - v12; | |
7295 } | |
7296 v13 = this->uClipY; | |
7297 if ( (signed int)v13 < (signed int)a3 ) | |
7298 v13 = a3; | |
7299 v14 = this->uClipW; | |
7300 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7301 { | |
7302 v15 = this->uClipY; | |
7303 if ( (signed int)v15 < (signed int)a3 ) | |
7304 v15 = a3; | |
7305 v5 = v14 - v15; | |
7306 } | |
7307 } | |
7308 if ( (signed int)v5 > 0 ) | |
7309 { | |
7310 a3a = v5; | |
7311 v16 = v19; | |
7312 do | |
7313 { | |
7314 if ( v20 > 0 ) | |
7315 { | |
7316 a2a = v20; | |
7317 do | |
7318 { | |
7319 if ( *v16 ) | |
7320 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
7321 ++v6; | |
7322 ++v16; | |
7323 --a2a; | |
7324 } | |
7325 while ( a2a ); | |
7326 } | |
7327 v16 += v18 - v20; | |
7328 v17 = a3a-- == 1; | |
7329 v6 += this->uTargetSurfacePitch - v20; | |
7330 } | |
7331 while ( !v17 ); | |
7332 } | |
7333 } | |
7334 } | |
2069 | 7335 }*/ |
7336 } | |
7337 | |
7338 //----- (004A68EF) -------------------------------------------------------- | |
7339 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask) | |
7340 { | |
7341 unsigned int v5; // ebx@4 | |
7342 int v10; // edx@8 | |
7343 signed int v11; // edx@9 | |
7344 signed int v12; // esi@12 | |
7345 signed int v13; // esi@15 | |
7346 signed int v15; // esi@18 | |
7347 unsigned __int8 *v16; // ebx@22 | |
2334 | 7348 // char v17; // zf@28 |
2069 | 7349 int v18; // [sp+10h] [bp-10h]@4 |
7350 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7351 int v20; // [sp+1Ch] [bp-4h]@4 | |
2334 | 7352 // int v21; // [sp+28h] [bp+8h]@24 |
7353 // unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
2069 | 7354 |
7355 if (!uNumSceneBegins || !pTexture) | |
7356 return; | |
7357 | |
2325 | 7358 if ( pTexture->pPalette16 ) |
7359 { | |
7360 v5 = pTexture->uTextureHeight; | |
7361 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
7362 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; | |
7363 v20 = pTexture->uTextureWidth; | |
7364 v18 = pTexture->uTextureWidth; | |
7365 int clipped_out_x = a2; | |
7366 int clipped_out_y = a3; | |
7367 if ( this->bClip ) | |
7368 { | |
7369 if ( a2 < this->uClipX ) | |
7370 { | |
7371 v19 += this->uClipX - a2; | |
7372 v20 += a2 - this->uClipX; | |
7373 clipped_out_x = uClipX; | |
7374 } | |
7375 v5 = pTexture->uTextureHeight; | |
7376 if ( a3 < this->uClipY ) | |
7377 { | |
7378 v10 = this->uClipY - a3; | |
7379 v19 += v18 * v10; | |
7380 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7381 clipped_out_y = uClipY; | |
7382 } | |
7383 v11 = this->uClipX; | |
7384 if ( this->uClipX < a2 ) | |
7385 v11 = a2; | |
7386 if ( v11 + v20 > (signed int)this->uClipZ ) | |
7387 { | |
7388 v12 = this->uClipX; | |
7389 if ( v12 < a2 ) | |
7390 v12 = a2; | |
7391 v20 = this->uClipZ - v12; | |
2069 | 7392 } |
7393 v13 = this->uClipY; | |
2325 | 7394 if ( this->uClipY < a3 ) |
2069 | 7395 v13 = a3; |
2325 | 7396 if ( (signed int)(v5 + v13) > (signed int)this->uClipW ) |
2069 | 7397 { |
7398 v15 = this->uClipY; | |
2325 | 7399 if ( this->uClipY < a3 ) |
2069 | 7400 v15 = a3; |
2325 | 7401 v5 = this->uClipW - v15; |
2069 | 7402 } |
7403 } | |
7404 | |
7405 v16 = v19; | |
7406 for (int y = 0; y < v5; ++y) | |
7407 { | |
7408 for (int x = 0; x < v20; ++x) | |
7409 { | |
7410 if ( *v16 ) | |
2325 | 7411 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v16] & mask); |
2069 | 7412 ++v16; |
7413 } | |
7414 v16 += v18 - v20; | |
7415 } | |
7416 | |
7417 /*if ( (signed int)v5 > 0 ) | |
7418 { | |
7419 v22 = v5; | |
7420 v16 = v19; | |
7421 do | |
7422 { | |
7423 if ( v20 > 0 ) | |
7424 { | |
7425 v21 = v20; | |
7426 do | |
7427 { | |
7428 if ( *v16 ) | |
7429 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7430 ++v6; | |
7431 ++v16; | |
7432 --v21; | |
7433 } | |
7434 while ( v21 ); | |
7435 } | |
7436 v16 += v18 - v20; | |
7437 v17 = v22-- == 1; | |
7438 v6 += this->uTargetSurfacePitch - v20; | |
7439 } | |
7440 while ( !v17 ); | |
7441 }*/ | |
7442 } | |
7443 } | |
7444 | |
0 | 7445 |
7446 //----- (004A65CC) -------------------------------------------------------- | |
7447 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
7448 { | |
2198 | 7449 unsigned int uHeight; // edi@6 |
0 | 7450 unsigned int v14; // edx@11 |
7451 unsigned int v16; // edx@14 | |
7452 unsigned int v17; // edx@17 | |
7453 unsigned int v19; // edx@20 | |
7454 int v20; // eax@27 | |
7455 int v21; // edx@29 | |
2334 | 7456 // int v23; // [sp+Ch] [bp-Ch]@24 |
0 | 7457 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 |
2334 | 7458 // int xa; // [sp+20h] [bp+8h]@26 |
7459 // unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
2198 | 7460 int Width; // [sp+2Ch] [bp+14h]@6 |
0 | 7461 |
7462 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
7463 { | |
710 | 7464 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7465 Width = a4->uTextureWidth; |
7466 uHeight = a4->uTextureHeight; | |
2069 | 7467 int clipped_out_x = x; |
7468 int clipped_out_y = y; | |
0 | 7469 if ( this->bClip ) |
7470 { | |
2198 | 7471 if ( (signed int)x < (signed int)this->uClipX ) |
7472 { | |
7473 v24 += this->uClipX - x; | |
7474 Width += x - this->uClipX; | |
2069 | 7475 clipped_out_x = uClipX; |
0 | 7476 } |
2198 | 7477 if ( (signed int)y < (signed int)this->uClipY ) |
7478 { | |
7479 v24 += a4->uTextureWidth * (this->uClipY - y); | |
7480 uHeight = y - this->uClipY + a4->uTextureHeight; | |
2069 | 7481 clipped_out_y = uClipY; |
0 | 7482 } |
7483 v14 = this->uClipX; | |
2198 | 7484 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7485 v14 = x; |
2198 | 7486 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7487 { |
7488 v16 = this->uClipX; | |
2198 | 7489 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7490 v16 = x; |
2198 | 7491 Width = this->uClipZ - v16; |
0 | 7492 } |
7493 v17 = this->uClipY; | |
2198 | 7494 if ( (signed int)this->uClipY < (signed int)y ) |
0 | 7495 v17 = y; |
2198 | 7496 if ( (signed int)(uHeight + v17) > (signed int)this->uClipW ) |
0 | 7497 { |
7498 v19 = this->uClipY; | |
7499 if ( (signed int)v19 < (signed int)y ) | |
7500 v19 = y; | |
2198 | 7501 uHeight = this->uClipW - v19; |
7502 } | |
7503 } | |
7504 | |
7505 for (int dy = 0; dy < uHeight; ++dy) | |
7506 { | |
7507 for (int dx = 0; dx < Width; ++dx) | |
7508 { | |
7509 v20 = *v24; | |
7510 if ( v20 >= a7 && v20 <= a8 ) | |
7511 { | |
7512 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7513 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7514 v21 = 2 * a8 - v21 - a7; | |
7515 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]); | |
7516 } | |
7517 ++v24; | |
7518 } | |
7519 v24 += a4->uTextureWidth - Width; | |
2069 | 7520 } |
7521 /*if ( (signed int)v9 > 0 ) | |
0 | 7522 { |
7523 ya = v9; | |
7524 v23 = v22 - v27; | |
7525 do | |
7526 { | |
7527 if ( v27 > 0 ) | |
7528 { | |
7529 xa = v27; | |
7530 do | |
7531 { | |
7532 v20 = *v24; | |
7533 if ( v20 >= a7 && v20 <= a8 ) | |
7534 { | |
7535 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7536 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7537 v21 = 2 * a8 - v21 - a7; | |
7538 *v8 = a4->pPalette16[v21]; | |
7539 } | |
7540 ++v8; | |
7541 ++v24; | |
7542 --xa; | |
7543 } | |
7544 while ( xa ); | |
7545 } | |
7546 v8 += this->uTargetSurfacePitch - v27; | |
7547 v24 += v23; | |
7548 --ya; | |
7549 } | |
7550 while ( ya ); | |
2069 | 7551 }*/ |
0 | 7552 } |
7553 } | |
7554 | |
7555 //----- (004A63E6) -------------------------------------------------------- | |
1455 | 7556 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) |
0 | 7557 { |
7558 unsigned int v14; // edx@11 | |
7559 unsigned int v16; // edx@14 | |
7560 unsigned int v17; // edx@17 | |
7561 unsigned int v19; // edx@20 | |
7562 int v20; // eax@27 | |
7563 int v21; // edx@29 | |
2334 | 7564 // int v23; // [sp+Ch] [bp-Ch]@24 |
2198 | 7565 int Height; // [sp+10h] [bp-8h]@6 |
7566 int Width; // [sp+14h] [bp-4h]@6 | |
0 | 7567 int v27; // [sp+24h] [bp+Ch]@23 |
7568 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
7569 | |
7570 if ( this->uNumSceneBegins ) | |
7571 { | |
7572 if ( a4 ) | |
7573 { | |
7574 if ( a4->pPalette16 ) | |
7575 { | |
7576 if ( a5 ) | |
7577 { | |
7578 if ( a5->pPalette16 ) | |
7579 { | |
710 | 7580 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7581 Width = a4->uTextureWidth; |
7582 Height = a4->uTextureHeight; | |
2069 | 7583 int clipped_out_x = a2; |
7584 int clipped_out_y = a3; | |
0 | 7585 if ( this->bClip ) |
7586 { | |
2198 | 7587 if ( (signed int)a2 < (signed int)this->uClipX ) |
0 | 7588 { |
2198 | 7589 v28 += this->uClipX - a2; |
7590 Width += a2 - this->uClipX; | |
2069 | 7591 clipped_out_x = uClipX; |
0 | 7592 } |
2198 | 7593 |
7594 if ( (signed int)a3 < (signed int)this->uClipY ) | |
0 | 7595 { |
2198 | 7596 v28 += a4->uTextureWidth * (this->uClipY - a3); |
7597 Height += a3 - this->uClipY; | |
2069 | 7598 clipped_out_y = uClipY; |
0 | 7599 } |
2198 | 7600 |
0 | 7601 v14 = this->uClipX; |
2198 | 7602 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7603 v14 = a2; |
2198 | 7604 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7605 { |
7606 v16 = this->uClipX; | |
2198 | 7607 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7608 v16 = a2; |
2198 | 7609 Width = this->uClipZ - v16; |
0 | 7610 } |
2198 | 7611 |
0 | 7612 v17 = this->uClipY; |
2198 | 7613 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7614 v17 = a3; |
2198 | 7615 if ( (signed int)(Height + v17) > (signed int)this->uClipW ) |
0 | 7616 { |
7617 v19 = this->uClipY; | |
2198 | 7618 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7619 v19 = a3; |
2198 | 7620 Height = this->uClipW - v19; |
0 | 7621 } |
7622 } | |
2069 | 7623 |
0 | 7624 v27 = 0; |
2198 | 7625 for (int y = 0; y < Height; ++y) |
2069 | 7626 { |
2198 | 7627 for (int x = 0; x < Width; ++x) |
2069 | 7628 { |
7629 if ( *v28 ) | |
7630 { | |
2101 | 7631 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); |
2069 | 7632 if ( v20 >= a7 ) |
7633 { | |
7634 if ( v20 <= a8 ) | |
7635 { | |
7636 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7637 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7638 v21 = 2 * a8 - v21 - a7; | |
7639 //v9 = a5; | |
7640 //*v10 = a5->pPalette16[v21]; | |
7641 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]); | |
7642 } | |
7643 } | |
7644 } | |
7645 v28++; | |
7646 } | |
2198 | 7647 v28 += a4->uTextureWidth - Width; |
2069 | 7648 } |
7649 | |
7650 /*if ( v24 > 0 ) | |
0 | 7651 { |
7652 v23 = v22 - v25; | |
7653 do | |
7654 { | |
7655 for ( i = 0; i < v25; ++v28 ) | |
7656 { | |
7657 if ( *v28 ) | |
7658 { | |
710 | 7659 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 7660 if ( v20 >= a7 ) |
7661 { | |
7662 if ( v20 <= a8 ) | |
7663 { | |
7664 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7665 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7666 v21 = 2 * a8 - v21 - a7; | |
7667 v9 = a5; | |
7668 *v10 = a5->pPalette16[v21]; | |
7669 } | |
7670 } | |
7671 } | |
7672 ++i; | |
7673 ++v10; | |
7674 } | |
7675 ++v27; | |
7676 v10 += this->uTargetSurfacePitch - v25; | |
7677 v28 += v23; | |
7678 } | |
7679 while ( v27 < v24 ); | |
2069 | 7680 }*/ |
7681 | |
0 | 7682 } |
7683 } | |
7684 } | |
7685 } | |
7686 } | |
7687 } | |
7688 | |
7689 //----- (004A6274) -------------------------------------------------------- | |
7690 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
7691 { | |
7692 int uHeight; // ebx@4 | |
7693 unsigned int v11; // edx@9 | |
7694 unsigned int v12; // esi@12 | |
7695 unsigned int v13; // esi@15 | |
7696 unsigned int v15; // esi@18 | |
7697 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7698 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
7699 | |
7700 if ( this->uNumSceneBegins ) | |
7701 { | |
7702 if ( pTexture ) | |
7703 { | |
7704 if ( pTexture->pPalette16 ) | |
7705 { | |
7706 uHeight = pTexture->uTextureHeight; | |
710 | 7707 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7708 uWidth = pTexture->uTextureWidth; |
2069 | 7709 |
7710 int clipped_out_x = uX; | |
7711 int clipped_out_y = uY; | |
0 | 7712 if ( this->bClip ) |
7713 { | |
2198 | 7714 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 7715 { |
2198 | 7716 v19 += this->uClipX - uX; |
0 | 7717 uWidth += uX - this->uClipX; |
2069 | 7718 clipped_out_x = uClipX; |
0 | 7719 } |
2198 | 7720 |
0 | 7721 uHeight = pTexture->uTextureHeight; |
2198 | 7722 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 7723 { |
2198 | 7724 v19 += pTexture->uTextureWidth * (this->uClipY - uY); |
0 | 7725 uHeight = uY - this->uClipY + pTexture->uTextureHeight; |
2069 | 7726 clipped_out_y = uClipY; |
0 | 7727 } |
7728 v11 = this->uClipX; | |
2198 | 7729 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7730 v11 = uX; |
2198 | 7731 |
7732 if ( (signed int)(v11 + uWidth) > (signed int)this->uClipZ ) | |
0 | 7733 { |
7734 v12 = this->uClipX; | |
2198 | 7735 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7736 v12 = uX; |
2198 | 7737 uWidth = this->uClipZ - v12; |
0 | 7738 } |
7739 v13 = this->uClipY; | |
2198 | 7740 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7741 v13 = uY; |
2198 | 7742 |
7743 if ( (signed int)(uHeight + v13) > (signed int)this->uClipW ) | |
0 | 7744 { |
7745 v15 = this->uClipY; | |
2198 | 7746 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7747 v15 = uY; |
2198 | 7748 uHeight = this->uClipW - v15; |
0 | 7749 } |
7750 } | |
2198 | 7751 |
2069 | 7752 for (int y = 0; y < uHeight; ++y) |
7753 { | |
7754 for (int x = 0; x < uWidth; ++x) | |
7755 { | |
2198 | 7756 if ( *v19 ) |
7757 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); | |
7758 ++v19; | |
2069 | 7759 } |
2198 | 7760 v19 += pTexture->uTextureWidth - uWidth; |
2069 | 7761 } |
7762 /*if ( (signed int)uHeight > 0 ) | |
0 | 7763 { |
7764 uYa = uHeight; | |
7765 v16 = v19; | |
7766 do | |
7767 { | |
7768 if ( uWidth > 0 ) | |
7769 { | |
7770 uXa = uWidth; | |
7771 do | |
7772 { | |
7773 if ( *v16 ) | |
7774 *v6 = pCurrentTexture->pPalette16[*v16]; | |
7775 ++v6; | |
7776 ++v16; | |
7777 } | |
7778 while ( uXa-- !=1 ); | |
7779 } | |
7780 v16 += v18 - uWidth; | |
7781 uFlag = uYa-- == 1; | |
7782 v6 += this->uTargetSurfacePitch - uWidth; | |
7783 } | |
7784 while ( !uFlag ); | |
2069 | 7785 }*/ |
0 | 7786 } |
7787 } | |
7788 } | |
7789 } | |
7790 | |
7791 //----- (004A612A) -------------------------------------------------------- | |
710 | 7792 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 7793 { |
7794 Texture *v5; // eax@2 | |
7795 unsigned int v6; // edx@3 | |
7796 int v7; // ebx@3 | |
7797 int v8; // edi@3 | |
7798 signed int v9; // eax@4 | |
7799 int v10; // eax@5 | |
7800 unsigned int v11; // esi@6 | |
7801 signed int v12; // esi@8 | |
7802 unsigned int v13; // eax@10 | |
7803 signed int v14; // esi@11 | |
7804 unsigned int v15; // esi@14 | |
7805 unsigned int v16; // eax@16 | |
7806 unsigned int v17; // ecx@17 | |
7807 int v18; // edx@23 | |
7808 int v19; // [sp+Ch] [bp-Ch]@3 | |
7809 int v20; // [sp+10h] [bp-8h]@3 | |
7810 int uOutXa; // [sp+20h] [bp+8h]@21 | |
7811 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
7812 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
7813 | |
7814 if ( this->uNumSceneBegins ) | |
7815 { | |
7816 v5 = pTexture; | |
7817 if ( pTexture ) | |
7818 { | |
7819 v6 = uOutY; | |
7820 v7 = pTexture->uTextureHeight; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7821 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; |
710 | 7822 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7823 v8 = v5->uTextureWidth; |
7824 v20 = v5->uTextureWidth; | |
7825 v19 = v5->uTextureWidth; | |
7826 if ( this->bClip ) | |
7827 { | |
7828 v9 = this->uClipX; | |
7829 if ( uOutX < v9 ) | |
7830 { | |
7831 v10 = v9 - uOutX; | |
7832 uOutYa += v10; | |
7833 v8 += uOutX - this->uClipX; | |
7834 v20 = v8; | |
7835 pZBuffer += v10; | |
7836 } | |
7837 v11 = this->uClipY; | |
7838 if ( (signed int)v6 < (signed int)v11 ) | |
7839 { | |
7840 uOutYa += v19 * (v11 - v6); | |
7841 v7 += v6 - v11; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7842 pZBuffer += window->GetWidth() * (v11 - v6); |
0 | 7843 v8 = v20; |
7844 } | |
7845 v12 = this->uClipX; | |
7846 if ( v12 < uOutX ) | |
7847 v12 = uOutX; | |
7848 v13 = this->uClipZ; | |
7849 if ( v8 + v12 > (signed int)v13 ) | |
7850 { | |
7851 v14 = this->uClipX; | |
7852 if ( v14 < uOutX ) | |
7853 v14 = uOutX; | |
7854 v8 = v13 - v14; | |
7855 } | |
7856 v15 = this->uClipY; | |
7857 if ( (signed int)v15 < (signed int)v6 ) | |
7858 v15 = v6; | |
7859 v16 = this->uClipW; | |
7860 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
7861 { | |
7862 v17 = this->uClipY; | |
7863 if ( (signed int)v17 >= (signed int)v6 ) | |
7864 v6 = v17; | |
7865 v7 = v16 - v6; | |
7866 } | |
7867 } | |
7868 if ( v7 > 0 ) | |
7869 { | |
7870 uOutXa = v7; | |
7871 do | |
7872 { | |
7873 if ( v8 > 0 ) | |
7874 { | |
7875 v18 = v8; | |
7876 do | |
7877 { | |
7878 if ( *uOutYa ) | |
7879 *pZBuffer = zVal; | |
7880 ++pZBuffer; | |
7881 ++uOutYa; | |
7882 --v18; | |
7883 } | |
7884 while ( v18 ); | |
7885 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7886 pZBuffer += window->GetWidth() - v8; |
0 | 7887 uOutYa += v19 - v8; |
7888 --uOutXa; | |
7889 } | |
7890 while ( uOutXa ); | |
7891 } | |
7892 } | |
7893 } | |
7894 } | |
7895 | |
7896 //----- (004A601E) -------------------------------------------------------- | |
991 | 7897 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 7898 { |
7899 signed int v5; // edx@3 | |
7900 int v6; // ebx@3 | |
7901 int v7; // esi@3 | |
7902 void *v8; // esi@3 | |
7903 unsigned int v9; // eax@4 | |
7904 unsigned int v10; // eax@6 | |
7905 signed int v11; // edi@8 | |
7906 unsigned int v12; // eax@10 | |
7907 signed int v13; // edi@11 | |
7908 unsigned int v14; // edi@14 | |
7909 unsigned int v15; // eax@16 | |
7910 unsigned int v16; // ecx@17 | |
7911 int v17; // [sp+18h] [bp+Ch]@3 | |
7912 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
7913 | |
7914 if ( this->uNumSceneBegins && pTexture ) | |
7915 { | |
7916 v5 = a3; | |
7917 v6 = pTexture->uTextureHeight; | |
7918 v7 = 5 * a3; | |
7919 v17 = pTexture->uTextureHeight; | |
7920 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
7921 pTexturea = pTexture->uTextureWidth; | |
7922 if ( this->bClip ) | |
7923 { | |
7924 v9 = this->uClipX; | |
7925 if ( a2 < (signed int)v9 ) | |
7926 { | |
7927 pTexturea += a2 - v9; | |
7928 v8 = (char *)v8 + 4 * (v9 - a2); | |
7929 } | |
7930 v10 = this->uClipY; | |
7931 if ( v5 < (signed int)v10 ) | |
7932 { | |
7933 v17 += v5 - v10; | |
7934 v8 = (char *)v8 + 2560 * (v10 - v5); | |
7935 } | |
7936 v11 = this->uClipX; | |
7937 if ( v11 < a2 ) | |
7938 v11 = a2; | |
7939 v12 = this->uClipZ; | |
7940 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
7941 { | |
7942 v13 = this->uClipX; | |
7943 if ( v13 < a2 ) | |
7944 v13 = a2; | |
7945 pTexturea = v12 - v13; | |
7946 } | |
7947 v14 = this->uClipY; | |
7948 if ( (signed int)v14 < v5 ) | |
7949 v14 = v5; | |
7950 v6 = v17; | |
7951 v15 = this->uClipW; | |
7952 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
7953 { | |
7954 v16 = this->uClipY; | |
7955 if ( (signed int)v16 < v5 ) | |
7956 v16 = v5; | |
7957 v6 = v15 - v16; | |
7958 } | |
7959 } | |
7960 if ( v6 > 0 ) | |
7961 { | |
7962 do | |
7963 { | |
7964 if ( (signed int)pTexturea > 0 ) | |
7965 { | |
7966 memset32(v8, a5, pTexturea); | |
7967 v8 = (char *)v8 + 4 * pTexturea; | |
7968 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7969 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea); |
0 | 7970 --v6; |
7971 } | |
7972 while ( v6 ); | |
7973 } | |
7974 } | |
7975 } | |
7976 | |
7977 //----- (004A5EB2) -------------------------------------------------------- | |
7978 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
7979 { | |
2069 | 7980 int v5; // ebx@4 |
0 | 7981 unsigned int v8; // edx@6 |
7982 unsigned int v10; // edx@8 | |
7983 unsigned int v11; // edx@9 | |
7984 unsigned int v12; // esi@12 | |
7985 unsigned int v13; // esi@15 | |
7986 unsigned int v15; // esi@18 | |
2334 | 7987 // char v17; // zf@26 |
0 | 7988 int v18; // [sp+10h] [bp-10h]@4 |
7989 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7990 int v20; // [sp+1Ch] [bp-4h]@4 | |
2334 | 7991 // int uXa; // [sp+28h] [bp+8h]@24 |
7992 // unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
0 | 7993 |
7994 if ( this->uNumSceneBegins ) | |
7995 { | |
7996 if ( a4 ) | |
7997 { | |
7998 if ( a4->pPalette16 ) | |
7999 { | |
8000 v5 = a4->uTextureHeight; | |
2069 | 8001 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
710 | 8002 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8003 v20 = a4->uTextureWidth; |
8004 v18 = a4->uTextureWidth; | |
2069 | 8005 |
8006 int clipped_out_x = uX; | |
8007 int clipped_out_y = uY; | |
0 | 8008 if ( this->bClip ) |
8009 { | |
2198 | 8010 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 8011 { |
2198 | 8012 v8 = this->uClipX - uX; |
0 | 8013 v19 += v8; |
8014 v20 += uX - this->uClipX; | |
2069 | 8015 clipped_out_x = uClipX; |
0 | 8016 } |
2198 | 8017 |
0 | 8018 v5 = a4->uTextureHeight; |
2198 | 8019 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 8020 { |
2198 | 8021 v10 = this->uClipY - uY; |
0 | 8022 v19 += v18 * v10; |
8023 v5 = uY - this->uClipY + a4->uTextureHeight; | |
2198 | 8024 //v4 = a4; |
2069 | 8025 clipped_out_y = uClipY; |
0 | 8026 } |
2198 | 8027 |
0 | 8028 v11 = this->uClipX; |
8029 if ( (signed int)v11 < (signed int)uX ) | |
8030 v11 = uX; | |
2198 | 8031 |
8032 if ( (signed int)(v11 + v20) > (signed int)this->uClipZ ) | |
0 | 8033 { |
8034 v12 = this->uClipX; | |
8035 if ( (signed int)v12 < (signed int)uX ) | |
8036 v12 = uX; | |
2198 | 8037 v20 = this->uClipZ - v12; |
0 | 8038 } |
2198 | 8039 |
0 | 8040 v13 = this->uClipY; |
8041 if ( (signed int)v13 < (signed int)uY ) | |
8042 v13 = uY; | |
2069 | 8043 |
8044 if ( (signed int)(v5 + v13) > (signed int)uClipW ) | |
0 | 8045 { |
8046 v15 = this->uClipY; | |
8047 if ( (signed int)v15 < (signed int)uY ) | |
8048 v15 = uY; | |
2069 | 8049 v5 = uClipW - v15; |
0 | 8050 } |
8051 } | |
2198 | 8052 |
2069 | 8053 for (int y = 0; y < v5; ++y) |
8054 { | |
8055 for (int x = 0; x < v20; ++x) | |
8056 { | |
2198 | 8057 if ( a4->pPalette16[*v19] != 0x7FF )// 2047 |
8058 WritePixel16(clipped_out_x + x, clipped_out_y + y, a4->pPalette16[*v19]); | |
8059 ++v19; | |
2069 | 8060 } |
2198 | 8061 v19 += v18 - v20; |
2069 | 8062 } |
8063 /*if ( (signed int)v5 > 0 ) | |
0 | 8064 { |
8065 uYa = v5; | |
8066 v16 = v19; | |
8067 do | |
8068 { | |
8069 if ( v20 > 0 ) | |
8070 { | |
8071 uXa = v20; | |
8072 do | |
8073 { | |
8074 *pTarget = v4->pPalette16[*v16]; | |
8075 ++pTarget; | |
8076 ++v16; | |
8077 --uXa; | |
8078 } | |
8079 while ( uXa ); | |
8080 } | |
8081 v16 += v18 - v20; | |
8082 v17 = uYa-- == 1; | |
8083 pTarget += this->uTargetSurfacePitch - v20; | |
8084 } | |
8085 while ( !v17 ); | |
2069 | 8086 }*/ |
0 | 8087 } |
8088 } | |
8089 } | |
8090 } | |
8091 | |
8092 //----- (004667E9) -------------------------------------------------------- | |
8093 void Render::ChangeBetweenWinFullscreenModes() | |
8094 { | |
8095 float v0; // ST14_4@17 | |
8096 int v4; // edx@26 | |
8097 ObjectDesc *v5; // eax@26 | |
8098 RGBTexture *v6; // esi@33 | |
8099 const char *v8; // [sp-4h] [bp-28h]@33 | |
2334 | 8100 // struct tagRECT Rect; // [sp+14h] [bp-10h]@15 |
0 | 8101 |
2061 | 8102 /*if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) |
0 | 8103 { |
1458 | 8104 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 | 8105 return; |
2061 | 8106 }*/ |
2154 | 8107 if ( pRenderer->bWindowMode || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8108 { |
0 | 8109 if ( pEventTimer->bPaused ) |
2061 | 8110 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0800; |
0 | 8111 else |
8112 pEventTimer->Pause(); | |
8113 if ( pMiscTimer->bPaused ) | |
2061 | 8114 dword_6BE364_game_settings_1 |= GAME_SETTINGS_1000; |
0 | 8115 else |
8116 pMiscTimer->Pause(); | |
8117 pMouse->bActive = 0; | |
8118 if ( pRenderer->pRenderD3D ) | |
8119 { | |
8120 pBitmaps_LOD->ReleaseHardwareTextures(); | |
8121 pSprites_LOD->ReleaseAll(); | |
8122 } | |
8123 if ( pRenderer->bWindowMode ) | |
8124 { | |
1802 | 8125 //SetMenu(hWnd, 0); |
8126 //SetWindowLongA(hWnd, -20, 0); | |
8127 //SetWindowLongA(hWnd, -16, 0x10000000u); | |
8128 window->SetFullscreenMode(); | |
8129 pRenderer->InitializeFullscreen(); | |
0 | 8130 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; |
8131 pGame->pGammaController->Initialize(v0); | |
8132 } | |
8133 else | |
8134 { | |
1802 | 8135 //ClipCursor(0); |
8136 window->SetWindowedMode(window->GetWidth(), window->GetHeight()); | |
8137 pRenderer->SwitchToWindow(); | |
0 | 8138 } |
8139 if ( pRenderer->pRenderD3D ) | |
8140 { | |
8141 pBitmaps_LOD->_410423_move_textures_to_device(); | |
8142 pSprites_LOD->MoveSpritesToVideoMemory(); | |
8143 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8144 if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits |
0 | 8145 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8146 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8147 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8148 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8149 pPaletteManager->RecalculateAll(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8150 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8151 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8152 for (int i = 0; i < pObjectList->uNumObjects; i++) |
0 | 8153 { |
8154 BYTE3(v4) = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8155 v5 = &pObjectList->pObjects[i]; |
0 | 8156 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; |
8157 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
8158 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8159 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8160 SetUserInterface(pParty->alignment, true); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8161 if ( pVideoPlayer->pVideoFrame.pPixels ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8162 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); |
2006 | 8163 if ( sCurrentMenuID != MENU_CREATEPARTY ) |
8164 { | |
8165 if ( sCurrentMenuID == MENU_CREDITSPROC ) | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8166 dword_A74C88 = 1; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8167 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8168 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8169 { |
2006 | 8170 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8171 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8172 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8173 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8174 v8 = "makeme.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8175 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8176 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8177 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8178 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8179 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8180 v8 = "title.pcx"; |
2006 | 8181 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8182 v8 = "lsave640.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8183 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8184 v6->Load(v8, 0); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8185 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8186 } |
0 | 8187 viewparams->bRedrawGameUI = 1; |
688 | 8188 viewparams->InitGrayPalette(); |
0 | 8189 pMouse->SetCurrentCursorBitmap(); |
1802 | 8190 /*if ( pRenderer->bWindowMode ) |
0 | 8191 { |
1655 | 8192 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); |
8193 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); | |
1586 | 8194 ShowWindow(hWnd, SW_SHOWNORMAL); |
1802 | 8195 }*/ |
8196 pMouse->bActive = true; | |
0 | 8197 if ( pVideoPlayer->AnyMovieLoaded() ) |
898 | 8198 pVideoPlayer->SelectMovieType(); |
2061 | 8199 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0800) |
8200 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0800; | |
0 | 8201 else |
8202 pEventTimer->Resume(); | |
2061 | 8203 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_1000) |
8204 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_1000; | |
0 | 8205 else |
8206 pMiscTimer->Resume(); | |
8207 } | |
8208 } | |
8209 | |
8210 | |
8211 //----- (004524D8) -------------------------------------------------------- | |
8212 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
8213 { | |
1583 | 8214 //int v11; // eax@13 |
8215 //int v12; // ecx@13 | |
0 | 8216 void *v13; // eax@13 |
1583 | 8217 //unsigned __int8 v14; // zf@13 |
8218 //unsigned __int8 v15; // sf@13 | |
0 | 8219 int v16; // esi@14 |
8220 int v17; // ecx@16 | |
8221 int v18; // esi@16 | |
8222 unsigned __int16 *v19; // eax@16 | |
8223 int v20; // edx@16 | |
8224 int v21; // ecx@16 | |
8225 int v22; // eax@16 | |
8226 int v23; // esi@16 | |
8227 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
8228 int v27; // [sp+28h] [bp-Ch]@14 | |
8229 int v28; // [sp+2Ch] [bp-8h]@13 | |
8230 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
8231 | |
8232 //v3 = this; | |
8233 //sprintf(Str1, "%s", pName); | |
8234 //v4 = uNumItems; | |
8235 if (!uNumItems) | |
8236 return nullptr; | |
8237 | |
8238 //{ | |
8239 //v5 = 0, pDesta = uNumItems; | |
8240 uint idx1 = 0, | |
8241 idx2 = uNumItems; | |
8242 while (true) | |
8243 { | |
1980 | 8244 uint i = idx1 + (idx2 - idx1) / 2; |
8245 | |
8246 int res = _stricmp(pName, pSpriteNames[i]); | |
0 | 8247 if (!res) |
8248 { | |
8249 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
8250 break; | |
8251 } | |
8252 else if (res < 0) | |
8253 idx2 = idx1 + (idx2 - idx1) / 2; | |
8254 else | |
8255 idx1 = i + 1; | |
8256 | |
8257 if ( idx1 >= idx2 ) | |
8258 return false; | |
8259 } | |
8260 | |
8261 | |
8262 uint uCompressedSize = 0; | |
8263 fread(&uCompressedSize, 4, 1, pFile); | |
8264 | |
1980 | 8265 HWLTexture* pTex = new HWLTexture; |
670 | 8266 fread(&pTex->uBufferWidth, 4, 1, pFile); |
8267 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
8268 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
8269 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 8270 fread(&pTex->uWidth, 4, 1, pFile); |
8271 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 8272 fread(&pTex->uAreaX, 4, 1, pFile); |
8273 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 8274 |
8275 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
8276 if (uCompressedSize) | |
8277 { | |
1980 | 8278 char* pCompressedData = new char[uCompressedSize]; |
0 | 8279 { |
8280 fread(pCompressedData, 1, uCompressedSize, pFile); | |
1980 | 8281 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); |
0 | 8282 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); |
8283 } | |
8284 delete [] pCompressedData; | |
8285 } | |
8286 else | |
8287 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
8288 | |
1583 | 8289 if ( scale_hwls_to_half ) |
8290 { | |
8291 pTex->uHeight /= 2; | |
8292 pTex->uWidth /= 2; | |
8293 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
0 | 8294 v28 = 0; |
8295 v26 = (unsigned __int16 *)v13; | |
1583 | 8296 if ( pTex->uHeight > 0 ) |
0 | 8297 { |
8298 v16 = pTex->uWidth; | |
8299 v27 = 1; | |
8300 do | |
8301 { | |
8302 pDestb = 0; | |
8303 if ( v16 > 0 ) | |
8304 { | |
8305 do | |
8306 { | |
8307 v17 = v16 * v27; | |
8308 v18 = v28 * v16; | |
8309 v19 = pTex->pPixels; | |
8310 v20 = pDestb + 2 * v18; | |
8311 v21 = (int)&v19[2 * (pDestb + v17)]; | |
8312 v22 = (int)&v19[2 * v20]; | |
8313 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
8314 LOWORD(v21) = *(unsigned short *)v21; | |
8315 v23 = pDestb++ + v18; | |
1583 | 8316 extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); |
8317 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
0 | 8318 v16 = pTex->uWidth; |
8319 } | |
8320 while (pDestb < pTex->uWidth); | |
8321 } | |
8322 ++v28; | |
8323 v27 += 2; | |
8324 } | |
8325 while ( v28 < (signed int)pTex->uHeight ); | |
8326 } | |
8327 delete [] pTex->pPixels; | |
8328 pTex->pPixels = v26; | |
8329 } | |
8330 return pTex; | |
8331 } | |
8332 | |
8333 //----- (0045271F) -------------------------------------------------------- | |
8334 bool RenderHWLContainer::Release() | |
8335 { | |
8336 __int32 v4; // eax@6 | |
8337 FILE *v5; // ST24_4@6 | |
8338 FILE *File; // [sp+4h] [bp-4h]@6 | |
8339 | |
1162 | 8340 if ( this->bDumpDebug) |
0 | 8341 { |
8342 File = fopen("logd3d.txt", "w"); | |
1162 | 8343 v4 = ftell(this->pFile); |
8344 v5 = this->pFile; | |
8345 this->uDataOffset = v4; | |
8346 fwrite(&this->uNumItems, 4u, 1u, v5); | |
8347 for (int i = 0; i < this->uNumItems; i++) | |
8348 { | |
8349 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
8350 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
8351 } | |
8352 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
8353 fseek(this->pFile, 4, 0); | |
8354 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
8355 fclose(this->pFile); | |
0 | 8356 fclose(File); |
8357 } | |
8358 else | |
8359 { | |
8360 fclose(this->pFile); | |
1162 | 8361 for (int i = 0; i < this->uNumItems; i++) |
8362 { | |
8363 free(this->pSpriteNames[i]); | |
0 | 8364 } |
8365 } | |
1093 | 8366 return true; |
0 | 8367 } |
8368 | |
8369 //----- (00452347) -------------------------------------------------------- | |
8370 RenderHWLContainer::RenderHWLContainer(): | |
8371 bDumpDebug(false) | |
8372 { | |
8373 this->pFile = 0; | |
8374 uSignature = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8375 this->uDataOffset = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8376 memset(&this->uNumItems, 0, 0x61A84u); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8377 this->uNumItems = 0; |
1583 | 8378 this->scale_hwls_to_half = false; |
0 | 8379 } |
8380 | |
8381 //----- (0045237F) -------------------------------------------------------- | |
8382 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
8383 { | |
8384 pFile = _wfopen(pFilename, L"rb"); | |
8385 if (!pFile) | |
8386 { | |
8387 Log::Warning(L"Failed to open file: %s", pFilename); | |
8388 return false; | |
8389 } | |
8390 | |
8391 fread(&uSignature, 1, 4, pFile); | |
8392 if (uSignature != 'TD3D') | |
8393 { | |
8394 Log::Warning(L"Invalid format: %s", pFilename); | |
8395 return false; | |
8396 } | |
8397 | |
8398 fread(&uDataOffset, 4, 1, pFile); | |
8399 fseek(pFile, uDataOffset, SEEK_SET); | |
8400 fread(&uNumItems, 4, 1, pFile); | |
8401 | |
8402 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
8403 for (uint i = 0; i < uNumItems; ++i) | |
8404 { | |
8405 pSpriteNames[i] = new char[20]; | |
8406 fread(pSpriteNames[i], 1, 20, pFile); | |
8407 } | |
8408 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
8409 | |
8410 return true; | |
8411 } | |
8412 | |
8413 //----- (004A1C1E) -------------------------------------------------------- | |
2153 | 8414 void Render::DoRenderBillboards_D3D() |
8415 { | |
8416 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
8417 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8418 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8419 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8420 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8421 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8422 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8423 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8424 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8425 { |
1390 | 8426 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; |
8427 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
8428 } | |
8429 p->pQuads[0].pos.x = 10; | |
8430 p->pQuads[0].pos.y = 10; | |
8431 | |
8432 p->pQuads[1].pos.x = 10; | |
8433 p->pQuads[1].pos.y = 200; | |
8434 | |
8435 p->pQuads[2].pos.x = 100; | |
8436 p->pQuads[2].pos.y = 200; | |
8437 | |
8438 p->pQuads[3].pos.x = 100; | |
8439 p->pQuads[3].pos.y = 10; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8440 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8441 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8442 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8443 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8444 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8445 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8446 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8447 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8448 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8449 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8450 }*/ |
0 | 8451 |
2153 | 8452 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) |
8453 { | |
2155 | 8454 if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend) |
8455 SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity); | |
2114 | 8456 |
2153 | 8457 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture); |
8458 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
8459 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8460 pBillboardRenderListD3D[i].pQuads, pBillboardRenderListD3D[i].uNumVertices, | |
8461 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); | |
8462 } | |
8463 | |
8464 if (bFogEnabled) | |
8465 { | |
8466 bFogEnabled = false; | |
8467 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8468 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8469 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8470 } | |
8471 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
8472 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8473 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8474 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8475 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8476 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8477 } |
8478 | |
8479 //----- (004A1DA8) -------------------------------------------------------- | |
2153 | 8480 void Render::SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) |
0 | 8481 { |
8482 switch (a1) | |
8483 { | |
8484 case RenderBillboardD3D::Transparent: | |
8485 { | |
2153 | 8486 if (bFogEnabled) |
8487 { | |
8488 bFogEnabled = false; | |
8489 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8490 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8491 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8492 } | |
8493 | |
8494 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
8495 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
8496 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8497 } |
8498 break; | |
8499 | |
8500 case RenderBillboardD3D::Opaque_1: | |
8501 case RenderBillboardD3D::Opaque_2: | |
8502 case RenderBillboardD3D::Opaque_3: | |
8503 { | |
2153 | 8504 if (bUsingSpecular) |
8505 { | |
8506 if (!bFogEnabled) | |
0 | 8507 { |
2153 | 8508 bFogEnabled = true; |
8509 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
186 | 8510 } |
8511 } | |
8512 | |
2153 | 8513 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
8514 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8515 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 8516 } |
8517 break; | |
8518 | |
8519 default: | |
8520 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8521 assert(false); |
0 | 8522 break; |
8523 } | |
1787 | 8524 } |
1903 | 8525 //----- (00424CD7) -------------------------------------------------------- |
8526 int ODM_NearClip(unsigned int num_vertices) | |
8527 { | |
8528 bool current_vertices_flag; // edi@1 | |
8529 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 | |
8530 double t; // st6@10 | |
2320 | 8531 bool bFound; |
8532 | |
8533 bFound = false; | |
1903 | 8534 |
8535 if (!num_vertices) | |
8536 return 0; | |
2320 | 8537 for (uint i = 0; i < num_vertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû |
8538 { | |
8539 if ( array_50AC10[i].vWorldViewPosition.x > 8.0 ) | |
8540 { | |
8541 bFound = true; | |
8542 break; | |
8543 } | |
8544 } | |
8545 if ( !bFound ) | |
8546 return 0; | |
1903 | 8547 |
2318 | 8548 memcpy(&array_50AC10[num_vertices], &array_50AC10[0], sizeof(array_50AC10[0])); |
8549 current_vertices_flag = false; | |
8550 next_vertices_flag = false; | |
8551 if ( array_50AC10[0].vWorldViewPosition.x <= 8.0 ) | |
8552 current_vertices_flag = true; | |
2320 | 8553 //check for near clip plane(ïðîâåðêà ïî áëèæíåé ãðàíèöå) |
8554 // | |
8555 // v3.__________________. v0 | |
8556 // | | | |
8557 // | | | |
8558 // | | | |
8559 // ----------------------- 8.0(near_clip - 8.0) | |
8560 // | | | |
8561 // .__________________. | |
8562 // v2 v1 | |
1903 | 8563 |
8564 int out_num_vertices = 0; | |
8565 for (int i = 0; i < num_vertices; ++i) | |
8566 { | |
2318 | 8567 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x <= 8.0;// |
8568 if ( current_vertices_flag ^ next_vertices_flag ) | |
8569 { | |
8570 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé | |
1903 | 8571 { |
2191 | 8572 //t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) |
1903 | 8573 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
2318 | 8574 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; |
8575 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t; | |
8576 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t; | |
8577 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t; | |
8578 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t; | |
8579 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
8580 } | |
8581 else// òåêóùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé | |
8582 { | |
8583 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); | |
8584 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; | |
8585 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t; | |
8586 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t; | |
8587 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t; | |
8588 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t; | |
8589 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
8590 } | |
1904 | 8591 //array_507D30[out_num_vertices]._rhw = 0x3E000000u; |
1903 | 8592 ++out_num_vertices; |
8593 } | |
2318 | 8594 if ( !next_vertices_flag ) |
8595 { | |
8596 memcpy(&array_507D30[out_num_vertices], &array_50AC10[i + 1], sizeof(array_50AC10[i + 1])); | |
8597 out_num_vertices++; | |
1903 | 8598 } |
8599 current_vertices_flag = next_vertices_flag; | |
8600 } | |
8601 return out_num_vertices >= 3 ? out_num_vertices : 0; | |
8602 } | |
2321 | 8603 |
1787 | 8604 //----- (00424EE0) -------------------------------------------------------- |
1903 | 8605 int ODM_FarClip(unsigned int uNumVertices) |
1787 | 8606 { |
2318 | 8607 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 |
8608 bool next_vertices_flag; // edi@1 | |
1787 | 8609 double t; // st6@10 |
8610 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 | |
2318 | 8611 bool bFound; |
1787 | 8612 //Äîï èíôî "Ïðîãðàììèðîâàíèå òð¸õìåðíûõ èãð äëÿ windows" Ëàìîò ñòð 910 |
8613 | |
2318 | 8614 bFound = false; |
8615 | |
8616 memcpy(&array_50AC10[uNumVertices], &array_50AC10[0], sizeof(array_50AC10[uNumVertices])); | |
1787 | 8617 depth_num_vertices = 0; |
2318 | 8618 current_vertices_flag = false; |
8619 if ( array_50AC10[0].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist ) | |
8620 current_vertices_flag = true;//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè | |
1787 | 8621 if ( (signed int)uNumVertices <= 0 ) |
8622 return 0; | |
2318 | 8623 for (uint i = 0; i < uNumVertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû |
8624 { | |
8625 if ( array_50AC10[i].vWorldViewPosition.x < pODMRenderParams->shading_dist_mist ) | |
8626 { | |
8627 bFound = true; | |
8628 break; | |
8629 } | |
8630 } | |
8631 if ( !bFound ) | |
8632 return 0; | |
8633 //check for far clip plane(ïðîâåðêà ïî äàëüíåé ãðàíèöå) | |
8634 // | |
8635 // v3.__________________. v0 | |
8636 // | | | |
8637 // | | | |
8638 // | | | |
8639 // ----------------------- 8192.0(far_clip - 0x2000) | |
8640 // | | | |
8641 // .__________________. | |
8642 // v2 v1 | |
8643 | |
8644 for ( uint i = 0; i < uNumVertices; ++i ) | |
8645 { | |
8646 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist; | |
8647 if ( current_vertices_flag ^ next_vertices_flag )//îäíà èç ãðàíåé çà ãðàíèöåé âèäèìîñòè | |
8648 { | |
8649 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(íàñòîÿùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v3 | |
8650 { | |
8651 //t = far_clip - v2.x / v3.x - v2.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
2320 | 8652 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); |
2318 | 8653 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; |
8654 //New_y = v2.y + (v3.y - v2.y)*t | |
2320 | 8655 array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t; |
2318 | 8656 //New_z = v2.z + (v3.z - v2.z)*t |
2320 | 8657 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t; |
8658 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t; | |
8659 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t; | |
2318 | 8660 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; |
8661 } | |
8662 else//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(ñëåäóþùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v0 | |
1787 | 8663 { |
8664 //t = far_clip - v1.x / v0.x - v1.x | |
2318 | 8665 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
8666 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; | |
8667 //New_y = (v0.y - v1.y)*t + v1.y | |
2320 | 8668 array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t; |
2318 | 8669 //New_z = (v0.z - v1.z)*t + v1.z |
2320 | 8670 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t; |
8671 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t; | |
8672 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t; | |
2318 | 8673 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; |
8674 } | |
1787 | 8675 ++depth_num_vertices; |
8676 } | |
2318 | 8677 if ( !next_vertices_flag )//îáà â ãðàíèöå âèäèìîñòè |
8678 { | |
8679 memcpy(&array_507D30[depth_num_vertices], &array_50AC10[i + 1], sizeof(array_507D30[depth_num_vertices])); | |
8680 depth_num_vertices++; | |
8681 } | |
8682 current_vertices_flag = next_vertices_flag; | |
8683 } | |
8684 return depth_num_vertices >= 3 ? depth_num_vertices : 0; | |
1787 | 8685 } |
8686 | |
8687 //----- (0047840D) -------------------------------------------------------- | |
8688 void Render::DrawBuildingsD3D() | |
8689 { | |
8690 int v9; // ecx@8 | |
8691 Texture *pFaceTexture; // eax@10 | |
8692 unsigned int v16; // edi@22 | |
8693 int v27; // eax@57 | |
2334 | 8694 // int vertex_id; // eax@58 |
1787 | 8695 unsigned int v34; // eax@80 |
8696 int v40; // [sp-4h] [bp-5Ch]@2 | |
8697 int v49; // [sp+2Ch] [bp-2Ch]@10 | |
8698 int v50; // [sp+30h] [bp-28h]@34 | |
8699 int v51; // [sp+34h] [bp-24h]@35 | |
8700 int v52; // [sp+38h] [bp-20h]@36 | |
8701 int v53; // [sp+3Ch] [bp-1Ch]@8 | |
8702 int uNumVertices; // [sp+4Ch] [bp-Ch]@34 | |
8703 int unused; // [sp+50h] [bp-8h]@3 | |
8704 | |
8705 if ( !pRenderer->pRenderD3D ) | |
8706 { | |
8707 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); | |
8708 } | |
8709 | |
8710 unused = 0; | |
8711 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
8712 { | |
8713 for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++ ) | |
8714 { | |
8715 if ( IsBModelVisible(model_id, &unused) ) | |
8716 { | |
8717 pOutdoor->pBModels[model_id].field_40 |= 1; | |
8718 if ( pOutdoor->pBModels[model_id].uNumFaces > 0 ) | |
8719 { | |
8720 for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ ) | |
8721 { | |
8722 if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible()) | |
8723 { | |
8724 v53 = 0; | |
8725 array_77EC08[pODMRenderParams->uNumPolygons].flags = 0; | |
8726 array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0; | |
8727 v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID; | |
8728 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME) | |
8729 v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); | |
8730 pFaceTexture = pBitmaps_LOD->GetTexture(v9); | |
8731 array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture; | |
8732 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID) | |
8733 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2; | |
1922 | 8734 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_INDOOR_SKY ) |
1787 | 8735 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
2166 | 8736 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW8 ) |
1787 | 8737 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
8738 else | |
8739 { | |
2166 | 8740 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW9 ) |
1787 | 8741 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8; |
8742 } | |
2166 | 8743 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW10) |
1787 | 8744 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000; |
8745 else | |
8746 { | |
8747 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE) | |
8748 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10u; | |
8749 } | |
8750 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU; | |
8751 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV; | |
8752 v16 = GetTickCount() >> 4; | |
8753 if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 ) | |
8754 { | |
8755 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8756 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8757 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8758 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8759 } | |
8760 else | |
8761 { | |
8762 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8763 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8764 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8765 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8766 } | |
8767 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 ) | |
8768 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8769 else | |
8770 { | |
8771 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 ) | |
8772 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8773 } | |
8774 v50 = 0; | |
8775 v49 = 0; | |
8776 uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8777 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 ) | |
8778 { | |
8779 for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ ) | |
8780 { | |
8781 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; | |
8782 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; | |
8783 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; | |
8784 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); | |
8785 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); | |
8786 } | |
8787 for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ ) | |
8788 { | |
8789 if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z ) | |
8790 ++v53; | |
8791 pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); | |
8792 if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) | |
8793 { | |
8794 if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 ) | |
8795 v49 = 1; | |
8796 else | |
8797 v50 = 1; | |
8798 } | |
8799 else | |
8800 pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); | |
8801 } | |
8802 } | |
8803 if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices ) | |
8804 LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1; | |
8805 array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8806 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8807 array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5; | |
2207 | 8808 v51 = fixpoint_mul(-pOutdoor->vSunlight.x, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x); |
8809 v53 = fixpoint_mul(-pOutdoor->vSunlight.y, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y); | |
8810 v52 = fixpoint_mul(-pOutdoor->vSunlight.z, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z); | |
8811 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - fixpoint_mul(20, v51 + v53 + v52); | |
1787 | 8812 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 ) |
8813 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0; | |
8814 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 ) | |
8815 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31; | |
8816 if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) | |
8817 return; | |
2169 | 8818 if ( ODMFace::IsBackfaceCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) |
1787 | 8819 { |
8820 pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1; | |
8821 array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id; | |
8822 array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id; | |
8823 v27 = 8 * (face_id | (model_id << 6)); | |
8824 LOBYTE(v27) = v27 | 6; | |
8825 array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27; | |
8826 for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id) | |
8827 { | |
8828 memcpy(&array_50AC10[vertex_id], &array_73D150[vertex_id], sizeof(array_50AC10[vertex_id])); | |
8829 array_50AC10[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001); | |
8830 } | |
8831 static stru154 static_RenderBuildingsD3D_stru_73C834; | |
8832 /*static bool __init_flag = false; | |
8833 if (!__init_flag) | |
8834 { | |
8835 __init_flag = true; | |
8836 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; | |
8837 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); | |
8838 atexit(loc_4789D4); | |
8839 }*/ | |
8840 | |
8841 v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8842 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8843 pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8844 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
8845 int v31 = 0; | |
8846 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
8847 { | |
8848 v31 = v50 ? 3 : v49 != 0 ? 5 : 0; | |
8849 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices); | |
8850 if ( pDecalBuilder->uNumDecals > 0 ) | |
8851 { | |
8852 v40 = -1; | |
8853 pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834, | |
8854 pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, array_50AC10, 0, (char)v31, -1); | |
8855 } | |
8856 } | |
8857 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
8858 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); | |
8859 if ( v50 ) | |
8860 { | |
1903 | 8861 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8862 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8863 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8864 } | |
8865 if ( v49 ) | |
8866 { | |
1903 | 8867 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8868 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8869 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8870 } | |
8871 if ( uNumVertices ) | |
8872 { | |
8873 if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 ) | |
8874 { | |
8875 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C ) | |
8876 v34 = pRenderer->pHDWaterBitmapIDs[0]; | |
8877 else | |
8878 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
8879 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; | |
8880 } | |
8881 else | |
8882 v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; | |
8883 pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40); | |
8884 } | |
8885 } | |
8886 } | |
8887 } | |
8888 } | |
8889 } | |
8890 } | |
8891 } | |
8892 return; | |
1911 | 8893 } |
8894 //----- (00479543) -------------------------------------------------------- | |
1923 | 8895 void Render::DrawOutdoorSkyD3D() |
1911 | 8896 { |
8897 int v9; // eax@4 | |
8898 int v10; // ebx@4 | |
8899 int v13; // edi@6 | |
8900 int v14; // ecx@6 | |
8901 int v15; // eax@8 | |
8902 int v16; // eax@12 | |
8903 signed __int64 v17; // qtt@13 | |
8904 signed int v18; // ecx@13 | |
8905 struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1 | |
8906 int v30; // [sp+134h] [bp-30h]@1 | |
8907 int v32; // [sp+13Ch] [bp-28h]@6 | |
8908 int v33; // [sp+140h] [bp-24h]@2 | |
8909 signed __int64 v34; // [sp+144h] [bp-20h]@1 | |
8910 int v35; // [sp+148h] [bp-1Ch]@4 | |
8911 int v36; // [sp+14Ch] [bp-18h]@2 | |
8912 int v37; // [sp+154h] [bp-10h]@8 | |
8913 int v38; // [sp+158h] [bp-Ch]@1 | |
8914 int v39; // [sp+15Ch] [bp-8h]@4 | |
2120 | 8915 |
8916 v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z) | |
1911 | 8917 / ((double)pODMRenderParams->int_fov_rad + 8192.0) |
2119 | 8918 + (double)(pViewport->uScreenCenterY)); |
8919 v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192 | |
2120 | 8920 v38 = (signed __int64)((double)(pViewport->uScreenCenterY) |
1911 | 8921 - (double)pODMRenderParams->int_fov_rad |
8922 / (v34 + 0.0000001) | |
8923 * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) | |
8924 * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist | |
8925 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); | |
8926 pSkyPolygon.Create_48607B(&stru_8019C8);//çàïîëíÿåòñÿ ptr_38 | |
8927 pSkyPolygon.ptr_38->_48694B_frustum_sky(); | |
2006 | 8928 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166) |
8929 pSkyPolygon.pTexture = (Texture *)(SLOWORD(pOutdoor->sSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->sSky_TextureID)] : 0); | |
1911 | 8930 if ( pSkyPolygon.pTexture ) |
8931 { | |
8932 pSkyPolygon.dimming_level = 0; | |
8933 pSkyPolygon.uNumVertices = 4; | |
2119 | 8934 //centering(öåíòðóåì)----------------------------------------------------------------- |
2120 | 8935 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8936 pSkyPolygon.v_18.y = 0; |
2120 | 8937 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8938 |
8939 //sky wiew position(ïîëîæåíèå íåáà íà ýêðàíå)------------------------------------------ | |
8940 // X | |
8941 // 0._____________________________.3 | |
8942 // |8,8 468,8 | | |
8943 // | | | |
8944 // | | | |
8945 // Y| | | |
8946 // | | | |
8947 // |8,351 468,351 | | |
8948 // 1._____________________________.2 | |
8949 // | |
2119 | 8950 array_50AC10[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 |
8951 array_50AC10[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8952 | |
8953 array_50AC10[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 | |
8954 array_50AC10[1].vWorldViewProjY = (double)v38;//247 | |
8955 | |
8956 array_50AC10[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8957 array_50AC10[2].vWorldViewProjY = (double)v38;//247 | |
8958 | |
8959 array_50AC10[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8960 array_50AC10[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8961 | |
8962 pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8963 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8964 | |
8965 pSkyPolygon.field_24 = 0x2000000u;//maybe attributes | |
2120 | 8966 v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2) / tan(0.6457717418670654) + 0.5); |
1911 | 8967 for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i ) |
8968 { | |
8969 //rotate skydome(âðàùåíèå êóïîëà íåáà)-------------------------------------- | |
8970 //  èãðå ïðèíÿòà ñâîÿ ñèñòåìà èçìåðåíèÿ óãëîâ. Ïîëíûé óãîë (180). Çíà÷åíèþ óãëà 0 ñîîòâåòñòâóåò | |
8971 // íàïðàâëåíèå íà ñåâåð è/èëè þã (ëèáî íà âîñòîê è/èëè çàïàä), çíà÷åíèþ 65536 åäåíèöàì(0õ10000) ñîîòâåòñòâóåò óãîë 90. | |
2119 | 8972 // äâå ïåðåìåííûå õðàíÿò äàííûå ïî óãëó îáçîðà. field_14 ïî çàïàäó è âîñòîêó. field_20 ïî þãó è ñåâåðó |
1911 | 8973 // îò -25080 äî 25080 |
2207 | 8974 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8975 v35 = v39 + pSkyPolygon.ptr_38->angle_from_north; |
8976 | |
2207 | 8977 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f))); |
2120 | 8978 v36 = v39 + pSkyPolygon.ptr_38->angle_from_east; |
8979 | |
2207 | 8980 v9 = fixpoint_mul(pSkyPolygon.v_18.z, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8981 v10 = pSkyPolygon.v_18.x + v9; |
2119 | 8982 if ( v10 > 0 ) |
1911 | 8983 v10 = 0; |
2120 | 8984 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX); |
8985 v34 = -pSkyPolygon.field_24; | |
8986 v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0; | |
8987 v14 = v33 * (v30 - v32); | |
1911 | 8988 while ( 1 ) |
8989 { | |
2120 | 8990 if ( v10 ) |
1911 | 8991 { |
2120 | 8992 v37 = abs((int)v34 >> 14); |
8993 v15 = abs(v10); | |
8994 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportTL_Y ) | |
8995 { | |
8996 if ( v10 <= 0 ) | |
8997 break; | |
8998 } | |
1911 | 8999 } |
2207 | 9000 v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14); |
1911 | 9001 --v32; |
9002 v14 += v33; | |
9003 v10 = pSkyPolygon.v_18.x + v16; | |
9004 } | |
9005 LODWORD(v17) = LODWORD(v34) << 16; | |
2120 | 9006 HIDWORD(v17) = v34 >> 16; |
9007 v18 = v17 / v10; | |
1911 | 9008 if ( v18 < 0 ) |
9009 v18 = pODMRenderParams->shading_dist_mist; | |
2207 | 9010 v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v13); |
9011 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v37, v18) >> 3); | |
2120 | 9012 array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0); |
9013 | |
2207 | 9014 v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v13); |
9015 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v36, v18) >> 3); | |
2120 | 9016 array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0); |
2119 | 9017 |
9018 array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192 | |
2120 | 9019 array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16); |
1911 | 9020 } |
1923 | 9021 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
2120 | 9022 array_50AC10[0].vWorldViewProjY = (double)v10; |
1911 | 9023 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; |
9024 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; | |
2120 | 9025 array_50AC10[3].vWorldViewProjY = (double)v10; |
1923 | 9026 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
1911 | 9027 return; |
9028 } | |
1913 | 9029 } |
9030 //----- (004226C2) -------------------------------------------------------- | |
9031 bool PauseGameDrawing() | |
9032 { | |
9033 if ( pCurrentScreen != SCREEN_GAME | |
9034 && pCurrentScreen != SCREEN_NPC_DIALOGUE | |
9035 && pCurrentScreen != SCREEN_CHANGE_LOCATION ) | |
9036 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2135
diff
changeset
|
9037 if (pCurrentScreen == SCREEN_INPUT_BLV) |
2356 | 9038 return pMovie;//pSmackerMovie != 0; |
1913 | 9039 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) |
9040 return true; | |
9041 } | |
9042 return false; | |
2154 | 9043 } |
9044 | |
9045 | |
9046 //----- (0045E03A) -------------------------------------------------------- | |
9047 unsigned short *Render::MakeScreenshot(signed int width, signed int height) | |
9048 { | |
9049 unsigned __int16 *v3; // ebx@1 | |
9050 int v4; // edx@7 | |
9051 unsigned __int8 v5; // cf@9 | |
9052 unsigned int v6; // ecx@9 | |
9053 unsigned __int16 *v7; // edi@9 | |
9054 int j; // ecx@9 | |
2334 | 9055 // unsigned int screen_x; // qax@18 |
9056 // HRESULT v14; // eax@21 | |
9057 // int v15; // edi@29 | |
9058 // signed __int64 v16; // qax@30 | |
9059 // signed int v17; // edx@34 | |
9060 // unsigned __int16 *v18; // edi@36 | |
9061 // int k; // ecx@36 | |
2154 | 9062 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 |
9063 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 | |
9064 float interval_x; // [sp+84h] [bp-20h]@1 | |
2334 | 9065 //unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 |
2154 | 9066 float interval_y; // [sp+8Ch] [bp-18h]@1 |
2334 | 9067 // unsigned int screen_y; // [sp+90h] [bp-14h]@17 |
9068 // int v28; // [sp+98h] [bp-Ch]@16 | |
9069 // int v29; // [sp+9Ch] [bp-8h]@15 | |
2154 | 9070 |
9071 interval_x = game_viewport_width / (double)width; | |
9072 interval_y = game_viewport_height / (double)height; | |
9073 | |
9074 pPixels = (unsigned __int16 *)malloc(2 * height * width); | |
9075 memset(pPixels, 0 , 2 * height * width); | |
9076 | |
9077 v3 = pPixels; | |
9078 | |
2182 | 9079 BeginSceneD3D(); |
9080 | |
9081 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9082 pIndoor->Draw(); | |
9083 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
9084 pOutdoor->Draw(); | |
9085 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
9086 memset(&Dst, 0, 0x7C); | |
9087 Dst.dwSize = sizeof(Dst); | |
9088 | |
9089 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
9090 { | |
9091 for (uint y = 0; y < height; ++y) | |
9092 { | |
9093 for (uint x = 0; x < width; ++x) | |
9094 { | |
9095 //*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 | 9096 /* |
9097 if (ddpfPrimarySuface.dwRGBBitCount == 32) | |
9098 { | |
9099 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
9100 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
9101 } | |
9102 else if (ddpfPrimarySuface.dwRGBBitCount == 16) | |
9103 { | |
9104 auto p = (unsigned __int16 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
9105 *v3 = *p; | |
9106 } | |
9107 */ | |
9108 pRenderer->pTargetSurface; | |
2182 | 9109 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) |
2154 | 9110 { |
2182 | 9111 auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch; |
9112 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
9113 } | |
9114 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) | |
9115 { | |
9116 auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; | |
9117 *v3 = *p; | |
2154 | 9118 } |
2182 | 9119 else __debugbreak(); |
9120 ++v3; | |
9121 } | |
9122 } | |
9123 ErrD3D(pBackBuffer4->Unlock(0)); | |
9124 } | |
9125 else | |
9126 { | |
9127 __debugbreak(); // unrefactored - black screenshot | |
9128 v4 = height; | |
9129 if ( height > 0 ) | |
9130 { | |
9131 do | |
9132 { | |
9133 if ( width > 0 ) | |
2154 | 9134 { |
2182 | 9135 v5 = width & 1; |
9136 v6 = (unsigned int)width / 2; | |
9137 memset(v3, 0, 4 * ((unsigned int)width / 2)); | |
9138 v7 = &v3[2 * v6]; | |
9139 for ( j = v5; j; --j ) | |
2154 | 9140 { |
2182 | 9141 *v7 = 0; |
9142 ++v7; | |
2154 | 9143 } |
2182 | 9144 v3 += width; |
2154 | 9145 } |
2182 | 9146 --v4; |
9147 } | |
9148 while ( v4 ); | |
9149 } | |
9150 } | |
9151 | |
2154 | 9152 /*if (!pRenderer->pRenderD3D) |
9153 { | |
9154 pRenderer->BeginScene(); | |
9155 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
9156 { | |
9157 pIndoor->Draw(); | |
9158 } | |
9159 else | |
9160 { | |
9161 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
9162 pOutdoor->Draw(); | |
9163 } | |
9164 _this = pRenderer->pTargetSurface; | |
9165 v26 = pRenderer->uTargetSurfacePitch; | |
9166 if ( pRenderer->pTargetSurface ) | |
9167 { | |
9168 if ( height > 0 ) | |
9169 { | |
9170 for ( v29 = 0; v29 < height; ++v29 ) | |
9171 { | |
9172 if ( width > 0 ) | |
9173 { | |
9174 v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); | |
9175 for ( v28 = 0; v28 < width; v28++ ) | |
9176 { | |
9177 *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)]; | |
9178 ++v3; | |
9179 } | |
9180 } | |
9181 } | |
9182 } | |
9183 } | |
9184 else | |
9185 { | |
9186 if ( height > 0 ) | |
9187 { | |
9188 for ( v17 = height; v17; --v17 ) | |
9189 { | |
9190 if ( width > 0 ) | |
9191 { | |
9192 memset(v3, 0, 4 * ((unsigned int)width >> 1)); | |
9193 v18 = &v3[2 * ((unsigned int)width >> 1)]; | |
9194 for ( k = width & 1; k; --k ) | |
9195 { | |
9196 *v18 = 0; | |
9197 ++v18; | |
9198 } | |
9199 v3 += width; | |
9200 } | |
9201 } | |
9202 } | |
9203 } | |
9204 pRenderer->EndScene(); | |
9205 }*/ | |
9206 return pPixels; | |
9207 } | |
9208 //----- (0045E26C) -------------------------------------------------------- | |
9209 void Render::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height) | |
9210 { | |
9211 auto pixels = pRenderer->MakeScreenshot(width, height); | |
9212 pRenderer->SavePCXImage(pFilename, pixels, width, height); | |
9213 free(pixels); | |
9214 } | |
9215 | |
9216 void Render::PackScreenshot(unsigned int width, unsigned int height, void *data, unsigned int data_size, unsigned int *out_screenshot_size) | |
9217 { | |
9218 auto pixels = pRenderer->MakeScreenshot(150, 112); | |
9219 pRenderer->PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size); | |
9220 free(pixels); | |
9221 } | |
2155 | 9222 |
9223 | |
9224 //----- (0046A7C8) -------------------------------------------------------- | |
2182 | 9225 int Render::_46À6ÀÑ_GetActorsInViewport(int pDepth) |
9226 { | |
9227 unsigned int v3; // eax@2 ïðèìåíÿåòñÿ â çàêëå Æàð ïå÷è äëÿ ïîäñ÷¸òà êîë-âà ìîíñòðîâ âèäèìûõ ãðóïïå è çàïîëíåíèÿ ìàññèâà id âèäèìûõ ìîíñòðîâ | |
2155 | 9228 unsigned int v5; // eax@2 |
9229 unsigned int v6; // eax@4 | |
9230 unsigned int v12; // [sp+10h] [bp-14h]@1 | |
2182 | 9231 int mon_num; // [sp+1Ch] [bp-8h]@1 |
2155 | 9232 unsigned int a1a; // [sp+20h] [bp-4h]@1 |
9233 | |
2182 | 9234 mon_num = 0; |
2155 | 9235 v12 = GetBillboardDrawListSize(); |
9236 if ( (signed int)GetBillboardDrawListSize() > 0 ) | |
9237 { | |
9238 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) | |
9239 { | |
9240 v3 = GetParentBillboardID(a1a); | |
9241 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; | |
9242 if ( PID_TYPE(v5) == OBJECT_Actor) | |
9243 { | |
2182 | 9244 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) ) |
2155 | 9245 { |
9246 v6 = PID_ID(v5); | |
9247 if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed | |
9248 && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) | |
9249 { | |
2182 | 9250 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) ) |
2155 | 9251 { |
2182 | 9252 if ( mon_num < 100 ) |
2155 | 9253 { |
2182 | 9254 _50BF30_actors_in_viewport_ids[mon_num] = v6; |
9255 mon_num++; | |
2155 | 9256 } |
9257 } | |
9258 } | |
9259 } | |
9260 } | |
9261 } | |
9262 } | |
2182 | 9263 return mon_num; |
2155 | 9264 } |
9265 | |
9266 | |
9267 | |
9268 | |
9269 void Render::BeginLightmaps() | |
9270 { | |
9271 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9272 | |
9273 if (bUsingSpecular) | |
9274 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); | |
9275 | |
9276 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9277 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9278 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9279 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9280 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9281 } | |
9282 | |
9283 void Render::EndLightmaps() | |
9284 { | |
9285 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9286 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9287 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9288 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9289 | |
9290 if (bUsingSpecular) | |
9291 { | |
9292 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9293 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor)); | |
9294 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
9295 } | |
9296 } | |
9297 | |
9298 | |
9299 void Render::BeginLightmaps2() | |
9300 { | |
9301 if (bUsingSpecular) | |
9302 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9303 | |
9304 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9305 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9306 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9307 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9308 | |
9309 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9310 | |
9311 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9312 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9313 } | |
9314 | |
9315 | |
9316 void Render::EndLightmaps2() | |
9317 { | |
9318 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9319 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9320 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9321 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9322 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9323 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9324 | |
9325 if (bUsingSpecular) | |
9326 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9327 } | |
9328 | |
9329 | |
9330 | |
9331 //----- (00437C96) -------------------------------------------------------- | |
9332 void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) | |
9333 { | |
9334 double v6; // st7@2 | |
9335 //IDirect3DDevice3 *v7; // eax@2 | |
2334 | 9336 // HRESULT v8; // eax@2 |
2155 | 9337 std::string v9; // [sp-18h] [bp-60h]@3 |
2334 | 9338 // const char *v10; // [sp-Ch] [bp-54h]@2 |
9339 // const char *v11; // [sp-8h] [bp-50h]@2 | |
9340 // int v12; // [sp-4h] [bp-4Ch]@2 | |
2155 | 9341 RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2 |
9342 | |
9343 //if ( pRenderer->pRenderD3D ) | |
9344 { | |
9345 v6 = 0.001 - z_stuff; | |
9346 memcpy(v13, pLineBegin, 0x20u); | |
9347 memcpy(&v13[1], pLineEnd, sizeof(v13[1])); | |
9348 v13[0].pos.z = v6; | |
9349 v13[1].pos.z = v6; | |
9350 v13[0].diffuse = sDiffuseBegin; | |
9351 v13[1].diffuse = sDiffuseEnd; | |
9352 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9353 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
9354 D3DPT_LINELIST, | |
9355 452, | |
9356 v13, | |
9357 2, | |
9358 16)); | |
9359 } | |
9360 } | |
9361 | |
9362 | |
9363 void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9364 { | |
9365 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9366 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, | |
9367 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9368 (void *)vertices, | |
9369 num_vertices, | |
9370 D3DDP_DONOTLIGHT)); | |
9371 } | |
9372 | |
9373 | |
9374 void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9375 { | |
9376 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
9377 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); | |
9378 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9379 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9380 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9381 | |
9382 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9383 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9384 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9385 (void *)vertices, | |
9386 num_vertices, | |
9387 28)); | |
9388 | |
9389 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9390 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9391 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9392 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); | |
9393 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9394 } | |
9395 | |
9396 | |
9397 void Render::BeginDecals() | |
9398 { | |
9399 // code chunk from 0049C304 | |
9400 if (bUsingSpecular) | |
9401 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9402 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9403 | |
9404 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9405 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9406 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9407 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9408 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9409 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9410 | |
9411 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); | |
9412 } | |
9413 | |
9414 | |
9415 void Render::EndDecals() | |
9416 { | |
9417 // code chunk from 0049C304 | |
9418 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9419 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9420 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9421 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9422 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9423 | |
9424 if (bUsingSpecular) | |
9425 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9426 } | |
9427 | |
9428 | |
9429 | |
9430 //----- (0049C095) -------------------------------------------------------- | |
9431 void Render::DrawDecal(Decal *pDecal, float z_bias) | |
9432 { | |
9433 signed int v21; // [sp+Ch] [bp-864h]@15 | |
9434 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6 | |
9435 | |
9436 if (pDecal->uNumVertices < 3) | |
9437 { | |
9438 Log::Warning(L"Decal has < 3 vertices"); | |
9439 return; | |
9440 } | |
9441 | |
9442 float color_mult; | |
9443 if ( pDecal->field_C1C & 1 ) | |
9444 color_mult = 1.0; | |
9445 else | |
9446 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time(); | |
9447 | |
9448 for (uint i = 0; i < pDecal->uNumVertices; ++i) | |
9449 { | |
9450 uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr); | |
9451 | |
9452 uint uTintR = (uTint >> 16) & 0xFF, | |
9453 uTintG = (uTint >> 8) & 0xFF, | |
9454 uTintB = uTint & 0xFF; | |
9455 | |
9456 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF, | |
9457 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF, | |
9458 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF; | |
9459 | |
9460 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f), | |
9461 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f), | |
9462 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f); | |
9463 | |
9464 | |
9465 float v15; | |
9466 if (fabs(z_bias) < 1e-5) | |
9467 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); | |
9468 else | |
9469 { | |
9470 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; | |
9471 if (v15 < 0.000099999997) | |
9472 v15 = 0.000099999997; | |
9473 } | |
9474 | |
9475 pVerticesD3D[i].pos.z = v15; | |
9476 | |
9477 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX; | |
9478 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY; | |
9479 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u; | |
9480 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v; | |
9481 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB; | |
9482 pVerticesD3D[i].specular = 0; | |
9483 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x; | |
9484 } | |
9485 | |
9486 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9487 v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; | |
9488 else | |
9489 v21 = D3DDP_DONOTLIGHT; | |
9490 | |
9491 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9492 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9493 pVerticesD3D, | |
9494 pDecal->uNumVertices, | |
9495 v21)); | |
9496 } | |
9497 | |
9498 | |
9499 void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) | |
9500 { | |
9501 ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture)); | |
9502 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9503 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9504 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9505 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9506 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9507 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9508 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
9509 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9510 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9511 (void *)vertices, 4, 28)); | |
9512 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9513 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9514 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9515 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9516 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9517 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
9518 } |