Mercurial > mm7
annotate Render.cpp @ 2320:847aba0b7f82
draw terrain distance
author | Ritor1 |
---|---|
date | Fri, 21 Mar 2014 01:12:52 +0600 |
parents | 133882370e83 |
children | 53c9d34024d6 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2245
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2245
diff
changeset
|
2 |
2153 | 3 #include "Render.h" |
1277 | 4 #include "Outdoor_stuff.h" |
1016 | 5 #include "VideoPlayer.h" |
6 #include "Sprites.h" | |
7 #include "Mouse.h" | |
8 #include "GammaControl.h" | |
9 #include "stru6.h" | |
1183 | 10 #include "GUIWindow.h" |
1016 | 11 #include "DecalBuilder.h" |
12 #include "ParticleEngine.h" | |
0 | 13 #include "Outdoor.h" |
14 #include "Party.h" | |
15 #include "LOD.h" | |
16 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2016
diff
changeset
|
17 #include "OurMath.h" |
0 | 18 #include "PaletteManager.h" |
2044 | 19 #include "Timer.h" |
0 | 20 #include "Game.h" |
21 #include "LightmapBuilder.h" | |
22 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
23 #include "SpriteObject.h" |
0 | 24 #include "DecorationList.h" |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
25 #include "Actor.h" |
0 | 26 #include "Log.h" |
179 | 27 #include "TileFrameTable.h" |
189 | 28 #include "texts.h" |
0 | 29 #include "mm7_data.h" |
860 | 30 #include "MM7.h" |
1262 | 31 #include "Lights.h" |
1828
35c1e4ff6ba7
party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents:
1814
diff
changeset
|
32 #include "Level/Decoration.h" |
2155 | 33 #include "Vis.h" |
0 | 34 |
1924
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
35 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") |
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
36 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") |
0 | 37 |
38 struct IDirectDrawClipper *pDDrawClipper; | |
39 struct Render *pRenderer; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
40 struct RenderVertexD3D3 pVertices[50]; |
0 | 41 int uNumDecorationsDrawnThisFrame; // weak |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
42 RenderBillboard pBillboardRenderList[500]; |
0 | 43 unsigned int uNumBillboardsToDraw; |
44 int uNumSpritesDrawnThisFrame; // weak | |
45 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
46 RenderVertexSoft array_507D30[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
47 RenderVertexSoft array_50AC10[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
48 RenderVertexSoft array_73D150[20]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
49 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
50 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 51 |
52 /* 384 */ | |
53 #pragma pack(push, 1) | |
54 struct PCXHeader_1 | |
55 { | |
56 char manufacturer; | |
57 char version; | |
58 char encoding; | |
59 char bpp; | |
60 __int16 left; | |
61 __int16 up; | |
62 __int16 right; | |
63 __int16 bottom; | |
64 __int16 hdpi; | |
65 __int16 vdpi; | |
66 }; | |
67 #pragma pack(pop) | |
68 | |
69 /* 385 */ | |
70 #pragma pack(push, 1) | |
71 struct PCXHeader_2 | |
72 { | |
73 char reserved; | |
74 char planes; | |
75 __int16 pitch; | |
76 __int16 palette_info; | |
77 }; | |
78 #pragma pack(pop) | |
79 | |
80 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
81 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
82 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
83 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
84 | |
85 //----- (0049E79F) -------------------------------------------------------- | |
2154 | 86 bool Render::CheckTextureStages() |
0 | 87 { |
88 bool v0; // edi@1 | |
89 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
90 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
91 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
92 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
93 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
94 | |
95 v0 = false; | |
2154 | 96 pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); |
97 pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
98 | |
99 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
100 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
101 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2)); | |
102 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
103 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
104 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
105 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1)); | |
106 | |
107 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
108 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
109 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1)); | |
110 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7)); | |
111 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2)); | |
112 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1)); | |
113 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2)); | |
114 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2)); | |
115 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1)); | |
116 | |
117 if ( !pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
0 | 118 v0 = true; |
2154 | 119 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); |
0 | 120 pTexture1->Release(); |
121 pTexture2->Release(); | |
122 pSurface1->Release(); | |
123 pSurface2->Release(); | |
124 return v0; | |
125 } | |
126 | |
2002 | 127 |
0 | 128 //----- (00440CB8) -------------------------------------------------------- |
129 void Render::DrawBillboardList_BLV() | |
130 { | |
131 __int16 v2; // ax@3 | |
132 int v5; // eax@11 | |
133 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
134 | |
2002 | 135 soft_billboard.sParentBillboardID = -1; |
0 | 136 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; |
137 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
138 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
139 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
140 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
141 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
142 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
143 | |
1637 | 144 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw; |
617 | 145 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 146 { |
1980 | 147 RenderBillboard* p = &pBillboardRenderList[i]; |
0 | 148 |
149 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
2002 | 150 soft_billboard.sParentBillboardID = i; |
0 | 151 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
152 soft_billboard._screenspace_x_scaler_packedfloat = p->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
153 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 154 soft_billboard.sZValue = p->sZValue; |
155 soft_billboard.uFlags = p->field_1E; | |
2006 | 156 soft_billboard.sTintColor = p->sTintColor; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
157 v2 = p->HwSpriteID; |
0 | 158 if ( v2 != -1 ) |
159 { | |
160 if ( pRenderer->pRenderD3D ) | |
657 | 161 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 162 else |
163 { | |
657 | 164 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 165 if (p->field_1E & 0x0100) |
166 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
167 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
168 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
169 v5 = p->HwSpriteID; |
0 | 170 if ( v5 >= 0 ) |
733 | 171 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 172 } |
173 } | |
174 } | |
175 } | |
176 | |
177 //----- (004A16A5) -------------------------------------------------------- | |
2154 | 178 bool Render::AreRenderSurfacesOk() |
179 { | |
180 return pFrontBuffer4 && pBackBuffer4; | |
0 | 181 } |
182 | |
2152 | 183 |
184 //----- (004A19D8) -------------------------------------------------------- | |
185 unsigned int BlendColors(unsigned int a1, unsigned int a2) | |
186 { | |
187 /*signed __int64 v2; // ST10_8@1 | |
188 double v3; // st7@1 | |
189 float v4; // ST24_4@1 | |
190 double v5; // ST10_8@1 | |
191 int v6; // ST1C_4@1 | |
192 float v7; // ST24_4@1 | |
193 double v8; // ST10_8@1 | |
194 unsigned __int8 v9; // ST20_1@1 | |
195 float v10; // ST24_4@1 | |
196 double v11; // ST10_8@1 | |
197 float v12; // ST24_4@1 | |
198 double v13; // ST08_8@1*/ | |
199 | |
200 uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f * | |
201 (a2 >> 24) / 255.0f * 255.0f), | |
202 red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f * | |
203 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f), | |
204 green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f * | |
205 ((a2 >> 8) & 0xFF) / 255.0f * 255.0f), | |
206 blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f * | |
207 ((a2 >> 0) & 0xFF) / 255.0f * 255.0f); | |
208 return (alpha << 24) | (red << 16) | (green << 8) | blue; | |
209 /*v2 = a1 >> 24; | |
210 v3 = (double)v2 / 255.0f; | |
211 HIDWORD(v2) = 0; | |
212 LODWORD(v2) = a2 >> 24; | |
213 v4 = v3 * (double)v2 / 255.0f * 255.0; | |
214 v5 = v4 + 6.7553994e15; | |
215 v6 = LODWORD(v5); | |
216 v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0; | |
217 v8 = v7 + 6.7553994e15; | |
218 v9 = LOBYTE(v8); | |
219 v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0; | |
220 v11 = v10 + 6.7553994e15; | |
221 v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0; | |
222 v13 = v12 + 6.7553994e15; | |
223 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ | |
224 } | |
225 | |
226 | |
1338 | 227 void Render::RenderTerrainD3D() // New function |
86 | 228 { |
229 int v6; // ecx@8 | |
1427 | 230 struct Polygon *pTilePolygon; // ebx@8 |
2251 | 231 float a3a; |
186 | 232 |
233 //warning: the game uses CW culling by default, ccw is incosistent | |
234 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
235 | |
1338 | 236 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ |
237 | |
238 //Ãåíåðàöèÿ ìåñòîïîëîæåíèÿ âåðøèí------------------------------------------------------------------------- | |
239 //ðåø¸òêà âåðøèí äåëèòñÿ íà äâå ÷àñòè îò -64 äî 0 è îò 0 äî 64 | |
240 // | |
241 // -64 X 0 64 | |
242 // --------------- 64 | |
243 // | | | | |
244 // | | | | |
245 // | | | | |
246 // 0|------+------| Z | |
247 // | | | | |
248 // | | | | |
249 // | | | | |
250 // --------------- | |
251 // -64 | |
252 | |
253 int blockScale = 512; | |
254 int heightScale = 32; | |
255 for (unsigned int z = 0; z < 128; ++z) | |
256 { | |
257 for (unsigned int x = 0; x < 128; ++x) | |
258 { | |
259 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
260 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
261 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 262 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
263 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 264 } |
265 } | |
2318 | 266 //-------(Îòñå÷åíèå íåâèäèìîé ÷àñòè êàðòû)------------------------------------------------------------------------------------------ |
267 float direction = pGame->pIndoorCameraD3D->sRotationY / 256;//direction of the camera(íàïðâëåíèå êàìåðû) | |
2316 | 268 //0-East(B) |
269 //1-NorthEast(CB) | |
270 //2-North(C) | |
271 //3-WestNorth(CÇ) | |
272 //4-West(Ç) | |
273 //5-SouthWest(ÞÇ) | |
274 //6-South(Þ) | |
275 //7-SouthEast(ÞÂ) | |
276 int Start_X, End_X, Start_Z, End_Z; | |
2318 | 277 if ( direction >= 0 && direction < 1.0 )//East(B) - NorthEast(CB) |
278 { | |
279 Start_X = pODMRenderParams->uMapGridCellX, End_X = 127; | |
280 Start_Z = 0, End_Z = 127; | |
281 } | |
282 else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CÇ) | |
283 { | |
2316 | 284 Start_X = 0, End_X = 127; |
285 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ; | |
2318 | 286 } |
287 else if (direction >= 3.0 && direction < 5.0)//WestNorth(CÇ) - SouthWest(ÞÇ) | |
288 { | |
289 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 1; | |
290 Start_Z = 0, End_Z = 127; | |
291 } | |
292 else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ÞÇ) - //SouthEast(ÞÂ) | |
293 { | |
294 Start_X = 0, End_X = 127; | |
295 Start_Z = pODMRenderParams->uMapGridCellZ - 1, End_Z = 127; | |
296 } | |
297 else//SouthEast(ÞÂ) - East(B) | |
298 { | |
299 Start_X = pODMRenderParams->uMapGridCellX, End_X = 127; | |
300 Start_Z = 0, End_Z = 127; | |
2316 | 301 } |
302 for (unsigned int z = Start_Z; z < End_Z; ++z) | |
303 { | |
304 for (unsigned int x = Start_X; x < End_X; ++x) | |
1338 | 305 { |
1637 | 306 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; |
1427 | 307 pTilePolygon->flags = 0; |
308 pTilePolygon->field_32 = 0; | |
309 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
310 pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; | |
311 if (pTilePolygon->uTileBitmapID == 0xFFFF) | |
106 | 312 continue; |
186 | 313 |
1338 | 314 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1427 | 315 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); |
316 pTilePolygon->field_32 = 0; | |
317 pTilePolygon->field_59 = 1; | |
318 pTilePolygon->sTextureDeltaU = 0; | |
319 pTilePolygon->sTextureDeltaV = 0; | |
1338 | 320 // x,z x+1,z |
321 // .____________. | |
322 // | | | |
323 // | | | |
324 // | | | |
325 // | | | |
326 // | | | |
327 // .____________. | |
328 // x,z+1 x+1,z+1 | |
329 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
106 | 330 array_73D150[0].u = 0; |
331 array_73D150[0].v = 0; | |
1338 | 332 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z |
106 | 333 array_73D150[1].u = 1; |
334 array_73D150[1].v = 0; | |
1338 | 335 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 |
106 | 336 array_73D150[2].u = 1; |
337 array_73D150[2].v = 1; | |
1338 | 338 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 |
106 | 339 array_73D150[3].u = 0; |
340 array_73D150[3].v = 1; | |
1338 | 341 //v58 = 0; |
342 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
343 //pTile->field_32 |= 0x0001; | |
1427 | 344 pTilePolygon->pODMFace = nullptr; |
345 pTilePolygon->uNumVertices = 4; | |
346 pTilePolygon->field_59 = 5; | |
1338 | 347 |
348 //shading (çàòåíåíèå)---------------------------------------------------------------------------- | |
349 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
1424 | 350 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; |
638 | 351 assert(norm_idx < uNumTerrainNormals); |
352 | |
1980 | 353 Vec3_float_* norm = &pTerrainNormals[norm_idx]; |
1338 | 354 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
355 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
356 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
1427 | 357 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); |
2274 | 358 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 ) |
359 norm = 0; | |
360 else | |
361 norm = &pTerrainNormals[norm_idx]; | |
2320 | 362 //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &a3a, array_50AC10, 4, 1);//Ritor1: slows |
363 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &a3a, array_50AC10, 4, 1); | |
1338 | 364 //----------------------------------------------------------------------------------------------- |
638 | 365 |
1637 | 366 ++pODMRenderParams->uNumPolygons; |
367 ++pODMRenderParams->field_44; | |
368 assert(pODMRenderParams->uNumPolygons < 20000); | |
265 | 369 |
1427 | 370 pTilePolygon->uBModelID = 0; |
371 pTilePolygon->uBModelFaceID = 0; | |
372 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
373 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
106 | 374 { |
375 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 376 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 377 } |
2318 | 378 //---------Draw distance(Äàëüíîñòü îòðèñîâêè)------------------------------- |
2320 | 379 int temp = pODMRenderParams->shading_dist_mist; |
380 if ( draw_terrain_dist_mist ) | |
381 pODMRenderParams->shading_dist_mist = 0x5000; | |
2318 | 382 bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0 |
383 || array_73D150[1].vWorldViewPosition.x < 8.0 | |
384 || array_73D150[2].vWorldViewPosition.x < 8.0 | |
385 || array_73D150[3].vWorldViewPosition.x < 8.0; | |
386 bool far_clip = (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x | |
387 || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x | |
388 || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x | |
389 || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x; | |
390 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) | |
391 { | |
392 if ( neer_clip ) | |
393 { | |
394 pTilePolygon->uNumVertices = ODM_NearClip(pTilePolygon->uNumVertices); | |
2320 | 395 ODM_Project(pTilePolygon->uNumVertices); |
2318 | 396 } |
397 if ( far_clip ) | |
398 { | |
399 pTilePolygon->uNumVertices = ODM_FarClip(pTilePolygon->uNumVertices); | |
2320 | 400 ODM_Project(pTilePolygon->uNumVertices); |
2318 | 401 } |
402 } | |
2320 | 403 pODMRenderParams->shading_dist_mist = temp; |
140 | 404 |
1338 | 405 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))---------------------- |
186 | 406 bool transparent = false; |
1427 | 407 if ( !( pTilePolygon->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable |
408 { | |
409 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id) | |
1338 | 410 { |
411 //transparent = false; | |
412 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
413 } | |
414 else | |
415 { | |
1427 | 416 v6 = pTilePolygon->uTileBitmapID; |
417 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) ) | |
1338 | 418 transparent = true; |
419 } | |
179 | 420 |
140 | 421 assert(v6 < 1000); // many random crashes here |
186 | 422 |
423 // for all shore tiles - draw a tile water under them since they're half-empty | |
1427 | 424 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX |
2153 | 425 DrawBorderTiles(pTilePolygon); |
1427 | 426 |
427 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1338 | 428 } |
429 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû | |
430 //pTile->DrawBorderTiles(); | |
431 //-------------------------------------------------------------------------------------------------------------------------------- | |
186 | 432 |
1637 | 433 --pODMRenderParams->uNumPolygons; |
434 --pODMRenderParams->field_44; | |
106 | 435 } |
436 } | |
437 } | |
0 | 438 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
439 |
2153 | 440 //----- (004811A3) -------------------------------------------------------- |
441 void Render::DrawBorderTiles(struct Polygon *poly) | |
442 { | |
443 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); | |
444 DrawTerrainPolygon(poly->uNumVertices, poly, | |
445 pBitmaps_LOD->pHardwareTextures[pHDWaterBitmapIDs[hd_water_current_frame]], false, true); | |
446 | |
447 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); | |
448 //DrawTerrainPolygon(poly->uNumVertices, poly, pBitmaps_LOD->pHardwareTextures[poly->uTileBitmapID], true, true); | |
449 } | |
450 | |
0 | 451 |
452 //----- (0047BACF) -------------------------------------------------------- | |
453 void Render::TransformBillboardsAndSetPalettesODM() | |
454 { | |
142 | 455 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
456 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
457 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
458 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
459 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
460 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
461 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
462 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
463 //int v8; // ebx@4 |
0 | 464 unsigned __int16 *v9; // eax@7 |
465 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
466 //DWORD v11; // eax@13 |
0 | 467 int v12; // eax@13 |
468 int v13; // eax@14 | |
469 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
470 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 471 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
472 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 473 int v18; // [sp+60h] [bp-4h]@13 |
474 | |
2002 | 475 billboard.sParentBillboardID = -1; |
0 | 476 billboard.pTarget = pRenderer->pTargetSurface; |
477 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
478 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 479 billboard.uViewportX = pViewport->uViewportTL_X; |
480 billboard.uViewportY = pViewport->uViewportTL_Y; | |
481 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
482 billboard.uViewportW = pViewport->uViewportBR_Y; | |
1637 | 483 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw; |
142 | 484 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
485 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 486 { |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
487 billboard.uScreenSpaceX = pBillboardRenderList[i].uScreenSpaceX; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
488 billboard.uScreenSpaceY = pBillboardRenderList[i].uScreenSpaceY; |
2002 | 489 billboard.sParentBillboardID = i; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
490 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
|
491 billboard.sTintColor = pBillboardRenderList[i].sTintColor; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
492 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
|
493 billboard.sZValue = pBillboardRenderList[i].sZValue; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
494 billboard.uFlags = pBillboardRenderList[i].field_1E; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
495 if (pBillboardRenderList[i].HwSpriteID != -1) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
496 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
497 if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
498 //if (pRenderer->pRenderD3D) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
499 pRenderer->TransformBillboard(&billboard, |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
500 &pSprites_LOD->pHardwareSprites[pBillboardRenderList[i].HwSpriteID], |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
501 pBillboardRenderList[i].dimming_level, &pBillboardRenderList[i]); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
502 /*else |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
503 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
504 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
505 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
506 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 507 if ( *(v1 - 10) & 2 ) |
508 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
509 else | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
510 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 511 v10 = (*(v1 - 9) & 1) == 0; |
512 billboard.pPalette = v9; | |
513 if ( !v10 ) | |
514 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
515 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
516 { | |
323 | 517 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 518 v15 = abs(v12); |
519 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
520 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
521 } | |
522 v13 = *((short *)v1 - 8); | |
523 if ( v13 >= 0 ) | |
733 | 524 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
525 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
526 } |
0 | 527 } |
528 } | |
529 | |
530 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
531 void Render::DrawSpriteObjects_ODM() |
0 | 532 { |
2206 | 533 SpriteFrame *frame; // eax@10 |
0 | 534 unsigned int v6; // eax@10 |
535 int v9; // ecx@10 | |
536 int v17; // ecx@25 | |
537 int v18; // eax@25 | |
538 int v22; // ST3C_4@29 | |
539 signed __int64 v23; // qtt@30 | |
540 int v26; // eax@31 | |
541 char v27; // zf@31 | |
542 int v30; // [sp+14h] [bp-2Ch]@23 | |
543 int v37; // [sp+1Ch] [bp-24h]@23 | |
544 int a6; // [sp+20h] [bp-20h]@10 | |
545 int v42; // [sp+2Ch] [bp-14h]@23 | |
546 int y; // [sp+30h] [bp-10h]@10 | |
547 int x; // [sp+34h] [bp-Ch]@10 | |
548 int z; // [sp+38h] [bp-8h]@10 | |
549 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
550 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
551 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
552 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
|
553 { |
1980 | 554 SpriteObject* object = &pSpriteObjects[i]; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
555 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
556 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
557 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
558 //{ |
430 | 559 if (!object->uObjectDescID) // item probably pciked up |
560 continue; | |
561 | |
562 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
1980 | 563 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID]; |
430 | 564 if (object_desc->NoSprite()) |
565 continue; | |
566 | |
567 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
568 //if ( !(v1->uFlags & 1) ) | |
569 //{ | |
570 //v2 = *((short *)v0 - 14) | |
2206 | 571 //v2 = object->uType; |
572 if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600) | |
573 || pGame->pStru6Instance->_4A81CA(object) ) | |
430 | 574 { |
575 //a5 = *(short *)v0; | |
576 x = object->vPosition.x; | |
577 y = object->vPosition.y; | |
578 z = object->vPosition.z; | |
2206 | 579 frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); |
580 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
|
581 v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
430 | 582 //LOWORD(v7) = object->uFacing; |
583 //v8 = v36; | |
2206 | 584 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
|
585 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[v9]; |
2206 | 586 if ( frame->uFlags & 0x20 ) |
587 { | |
588 //v8 = v36; | |
589 z -= fixpoint_mul(frame->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)frame->pHwSpriteIDs[v9]].uHeight) / 2; | |
590 } | |
591 v46 = 0; | |
592 if ( frame->uFlags & 2 ) | |
593 v46 = 2; | |
594 //v11 = (int *)(256 << v9); | |
595 if ( (256 << v9) & frame->uFlags ) | |
596 v46 |= 4u; | |
597 if ( frame->uFlags & 0x40000 ) | |
598 v46 |= 0x40u; | |
599 if ( frame->uFlags & 0x20000 ) | |
600 LOBYTE(v46) = v46 | 0x80; | |
601 if ( a6 ) | |
602 { | |
603 //LOBYTE(v11) = _4E94D3_light_type; | |
604 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type); | |
605 } | |
606 if (pGame->pIndoorCameraD3D->sRotationX) | |
607 { | |
608 v30 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
609 + fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
610 v37 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
611 v42 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x) | |
612 + fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_cosine_x); | |
613 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
614 { | |
615 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - v37; | |
616 v18 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) | |
617 - fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_sine_x); | |
618 if ( abs(v42) >= abs(v17) ) | |
619 { | |
620 LODWORD(v23) = 0; | |
621 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
622 | |
623 object->uAttributes |= 1; | |
624 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
625 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
626 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
627 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
628 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
629 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
630 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
631 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
632 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
633 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
634 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
635 HIWORD(v26) = HIWORD(v42); | |
636 LOWORD(v26) = 0; | |
637 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
638 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
639 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
640 if ( !(object->uAttributes & 0x20) ) | |
0 | 641 { |
2206 | 642 if ( !pRenderer->pRenderD3D ) |
643 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
0 | 644 } |
2206 | 645 //if (::uNumBillboardsToDraw >= 500) |
646 // return; | |
647 assert(::uNumBillboardsToDraw < 500); | |
648 ++::uNumBillboardsToDraw; | |
649 ++uNumSpritesDrawnThisFrame; | |
0 | 650 } |
2206 | 651 } |
652 } | |
653 else | |
654 { | |
655 v42 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y) | |
656 + fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y); | |
657 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
658 { | |
659 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
660 - fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y); | |
661 v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; | |
662 if ( abs(v42) >= abs(v17) ) | |
663 { | |
664 LODWORD(v23) = 0; | |
665 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
666 | |
667 object->uAttributes |= 1; | |
668 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
669 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
670 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
671 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
672 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
673 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
674 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
675 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
676 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
677 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
678 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
679 HIWORD(v26) = HIWORD(v42); | |
680 LOWORD(v26) = 0; | |
681 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
682 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
683 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
684 if ( !(object->uAttributes & 0x20) ) | |
685 { | |
686 if ( !pRenderer->pRenderD3D ) | |
687 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
688 } | |
689 //if (::uNumBillboardsToDraw >= 500) | |
690 // return; | |
691 assert(::uNumBillboardsToDraw < 500); | |
692 ++::uNumBillboardsToDraw; | |
693 ++uNumSpritesDrawnThisFrame; | |
694 } | |
695 } | |
696 } | |
697 } | |
0 | 698 } |
699 } | |
700 | |
701 //----- (0049D9BC) -------------------------------------------------------- | |
702 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
703 { | |
704 size_t v4; // eax@1 | |
705 size_t v5; // eax@1 | |
706 IUnknown *v6; // eax@10 | |
707 size_t v7; // eax@13 | |
708 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
709 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
710 int v11; // [sp+430h] [bp-CCh]@16 | |
711 int v12; // [sp+434h] [bp-C8h]@16 | |
712 int v13; // [sp+438h] [bp-C4h]@16 | |
713 int v14; // [sp+474h] [bp-88h]@16*/ | |
714 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
715 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
716 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
717 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
718 int v19; // [sp+4C8h] [bp-34h]@16 | |
719 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
720 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
721 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
722 | |
723 v4 = strlen(lpDriverName); | |
724 v20.pDriverName = new char[v4 + 1]; | |
725 v5 = strlen(lpDevDesc); | |
726 v20.pDeviceDesc = new char[v5 + 1]; | |
727 strcpy(v20.pDriverName, lpDriverName); | |
728 strcpy(v20.pDeviceDesc, lpDevDesc); | |
729 if ( lpGUID ) | |
730 { | |
731 v20.pGUID = new GUID; | |
732 memcpy(v20.pGUID, lpGUID, 0x10u); | |
733 } | |
734 else | |
735 v20.pGUID = 0; | |
736 | |
737 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
738 { | |
739 delete [] v20.pDriverName; | |
740 delete [] v20.pDeviceDesc; | |
741 if ( v20.pGUID ) | |
742 delete v20.pGUID; | |
743 } | |
744 else | |
745 { | |
746 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
747 { | |
748 delete [] v20.pDriverName; | |
749 delete [] v20.pDeviceDesc; | |
750 if ( v20.pGUID ) | |
751 delete v20.pGUID; | |
752 v6 = (IUnknown *)pDirectDraw; | |
753 } | |
754 else | |
755 { | |
756 pDirectDraw->Release(); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
757 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1))) |
0 | 758 v20.pDDraw4DevDesc = 0; |
759 else | |
760 { | |
761 v7 = strlen(ddDevId.szDescription); | |
762 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
763 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
764 } | |
765 memset(&ddsCaps, 0, 0x10u); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
766 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem))) |
0 | 767 v20.uVideoMem = 0; |
768 memset(&v10, 0, 0x7Cu); | |
769 v10.dwSize = 124; | |
770 v10.dwFlags = 6; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
771 v10.dwHeight = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
772 v10.dwWidth = window->GetHeight(); |
0 | 773 v10.ddpfPixelFormat.dwSize = 32; |
774 | |
775 v19 = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
776 if ( FAILED(pDirectDraw4->EnumDisplayModes(0, 0, &v19, (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) |
0 | 777 || !v19 |
778 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
779 { | |
780 delete [] v20.pDriverName; | |
781 delete [] v20.pDeviceDesc; | |
782 if ( v20.pDDraw4DevDesc ) | |
783 free(v20.pDDraw4DevDesc); | |
784 if ( v20.pGUID ) | |
785 delete v20.pGUID; | |
786 v6 = (IUnknown *)pDirectDraw4; | |
787 } | |
788 else | |
789 { | |
790 aux.pInfo = pOut; | |
791 aux.ptr_4 = &v20; | |
792 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
793 delete [] v20.pDriverName; | |
794 delete [] v20.pDeviceDesc; | |
795 if ( v20.pDDraw4DevDesc ) | |
796 free(v20.pDDraw4DevDesc); | |
797 if ( v20.pGUID ) | |
798 delete v20.pGUID; | |
799 pDirectDraw4->Release(); | |
800 v6 = (IUnknown *)pDirect3D3; | |
801 pDirectDraw4 = 0; | |
802 } | |
803 } | |
804 v6->Release(); | |
805 } | |
806 return 1; | |
807 } | |
808 | |
809 //----- (0049D784) -------------------------------------------------------- | |
810 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
811 { | |
812 int v6; // eax@1 | |
813 signed int v7; // edi@1 | |
814 signed int v8; // edi@14 | |
815 size_t v9; // eax@30 | |
816 size_t v10; // eax@30 | |
817 size_t v11; // eax@30 | |
818 size_t v12; // eax@30 | |
819 size_t v13; // eax@30 | |
820 | |
821 v6 = pHWDesc->dwFlags; | |
822 v7 = -1; | |
823 if ( v6 ) | |
824 { | |
825 if ( !a6->ptr_4->pGUID ) | |
826 v7 = 0; | |
827 if ( v6 && a6->ptr_4->pGUID ) | |
828 v7 = 1; | |
829 } | |
830 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
831 v7 = 2; | |
832 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
833 v7 = 3; | |
834 if ( v7 != -1 ) | |
835 { | |
836 v8 = v7; | |
837 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
838 a6->pInfo[v8].uCaps = 0; | |
839 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
840 a6->pInfo[v8].uCaps |= 2u; | |
841 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
842 a6->pInfo[v8].uCaps |= 4u; | |
843 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
844 a6->pInfo[v8].uCaps |= 8u; | |
845 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
846 a6->pInfo[v8].uCaps |= 0x10u; | |
847 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
848 a6->pInfo[v8].uCaps |= 0x20u; | |
849 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
850 a6->pInfo[v8].uCaps |= 0x40u; | |
851 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
852 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
853 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
854 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
855 v9 = strlen(lpDeviceName); | |
856 a6->pInfo[v8].pName = new char[v9 + 1]; | |
857 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
858 v10 = strlen(lpDeviceDesc); | |
859 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
860 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
1631 | 861 a6->pInfo[v8].pGUID = new GUID; |
0 | 862 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); |
863 v11 = strlen(a6->ptr_4->pDriverName); | |
864 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
865 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
866 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
867 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
868 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
869 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
870 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
871 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
872 if ( a6->ptr_4->pGUID ) | |
873 { | |
874 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
875 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
876 } | |
877 else | |
878 { | |
879 a6->pInfo[v8].pDirectDrawGUID = 0; | |
880 } | |
881 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
882 } | |
883 return 1; | |
884 } | |
885 | |
886 //----- (0049D75C) -------------------------------------------------------- | |
887 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
888 { | |
889 HRESULT result; // eax@3 | |
890 | |
891 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
892 { | |
893 *a2 = 1; | |
894 result = 0; | |
895 } | |
896 else | |
897 result = 1; | |
898 return result; | |
899 } | |
900 | |
901 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
902 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
903 { |
0 | 904 unsigned int v6; // edi@9 |
905 int v7; // eax@9 | |
906 SpriteFrame *v8; // eax@9 | |
907 unsigned __int16 *v10; // eax@9 | |
908 int v13; // ecx@9 | |
909 int v14; // ecx@20 | |
910 char v15; // dl@20 | |
911 signed int v16; // eax@20 | |
912 int v17; // eax@23 | |
913 int v18; // ecx@24 | |
914 int v19; // eax@24 | |
915 int v20; // ecx@24 | |
916 int v21; // ebx@26 | |
917 int v22; // eax@26 | |
918 signed __int64 v24; // qtt@31 | |
919 int v25; // ebx@31 | |
920 __int16 v29; // cx@37 | |
921 int v30; // ecx@37 | |
922 int v31; // ebx@37 | |
619 | 923 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
0 | 924 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
925 int v38; // [sp+88h] [bp-1Ch]@9 | |
926 int v40; // [sp+90h] [bp-14h]@24 | |
927 int v41; // [sp+94h] [bp-10h]@24 | |
928 int v42; // [sp+98h] [bp-Ch]@9 | |
929 int b; // [sp+A0h] [bp-4h]@22 | |
930 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
931 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
932 { |
2274 | 933 //LevelDecoration* decor = &pLevelDecorations[i]; |
934 if ((!(pLevelDecorations[i].uFlags & LEVEL_DECORATION_OBELISK_CHEST) | |
935 || pLevelDecorations[i].IsObeliskChestActive()) && !(pLevelDecorations[i].uFlags & LEVEL_DECORATION_INVISIBLE)) | |
936 { | |
937 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
|
938 if ( (char)decor_desc->uFlags >= 0 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
939 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
940 if ( !(decor_desc->uFlags & 0x22) ) |
0 | 941 { |
1490 | 942 v6 = pMiscTimer->uTotalGameTimeElapsed; |
2274 | 943 v7 = abs(pLevelDecorations[i].vPosition.x + pLevelDecorations[i].vPosition.y); |
1490 | 944 |
945 #pragma region "New: seasons change" | |
946 extern bool change_seasons; | |
947 if (change_seasons) | |
948 switch (pParty->uCurrentMonth) | |
949 { | |
950 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
951 case 11: case 0: case 1: // winter | |
952 switch (decor_desc->uSpriteID) | |
953 { | |
954 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
955 case 548: // flower10 | |
956 case 547: // flower09 | |
957 case 541: // flower03 | |
958 case 539: continue; // flower01 | |
959 | |
960 case 483: // tree01 | |
961 case 486: // tree04 | |
962 case 492: // tree10 | |
963 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); | |
964 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
965 break; | |
966 | |
967 default: | |
968 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
969 } | |
970 break; | |
971 | |
972 case 2: case 3: case 4: // spring | |
973 switch (decor_desc->uSpriteID) | |
974 { | |
975 } | |
976 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
977 break; | |
978 | |
979 case 8: case 9: case 10: // autumn | |
980 switch (decor_desc->uSpriteID) | |
981 { | |
982 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
983 case 548: // flower10 | |
984 case 547: // flower09 | |
985 case 541: // flower03 | |
986 case 539: continue; // flower01 | |
987 | |
988 case 483: // tree01 | |
989 case 486: // tree04 | |
990 case 492: // tree10 | |
991 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); | |
992 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
993 break; | |
994 | |
995 default: | |
996 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
997 } | |
998 break; | |
999 | |
1000 case 5: case 6: case 7: // summer | |
1001 //all green by default | |
1002 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1003 break; | |
1004 | |
1005 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
1006 } | |
1007 else | |
1008 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1009 #pragma endregion | |
1010 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1011 | |
2274 | 1012 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, |
1013 pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); | |
1490 | 1014 v38 = 0; |
2274 | 1015 v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + pLevelDecorations[i].field_10_y_rot - (signed int)v10) >> 8) & 7; |
1490 | 1016 v37 = (unsigned __int16 *)v13; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1017 if ( v8->uFlags & 2 ) |
1490 | 1018 v38 = 2; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1019 if ( (256 << v13) & v8->uFlags ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1020 v38 |= 4; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1021 if ( v8->uFlags & 0x40000 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1022 v38 |= 0x40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1023 if ( v8->uFlags & 0x20000 ) |
1490 | 1024 LOBYTE(v38) = v38 | 0x80; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1025 if ( v8->uGlowRadius ) |
0 | 1026 { |
1490 | 1027 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) |
0 | 1028 { |
1490 | 1029 v14 = decor_desc->uColoredLightRed; |
1030 v15 = decor_desc->uColoredLightGreen; | |
1031 v16 = decor_desc->uColoredLightBlue; | |
0 | 1032 } |
1033 else | |
1034 { | |
1490 | 1035 v16 = 255; |
1036 v14 = 255; | |
1037 v15 = 255; | |
1038 } | |
2274 | 1039 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
|
1040 v8->uGlowRadius, v14, v15, v16, _4E94D0_light_type); |
1490 | 1041 } |
2274 | 1042 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
|
1043 if (pGame->pIndoorCameraD3D->sRotationX) |
1490 | 1044 { |
2274 | 1045 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
2207 | 1046 v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1047 v41 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 1048 v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x); |
2274 | 1049 v20 = v19 + fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 1050 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1051 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1052 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1053 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
|
1054 if ( 2 * abs(v20) >= abs(v21) ) |
0 | 1055 { |
1490 | 1056 LODWORD(v24) = 0; |
1637 | 1057 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1058 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
|
1059 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
|
1060 v41 = fixpoint_mul(v8->scale, v24 / v20); |
1490 | 1061 if ( pRenderer->pRenderD3D ) |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1062 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41); |
1490 | 1063 else |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1064 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41); |
1490 | 1065 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
1066 { | |
1067 if (::uNumBillboardsToDraw >= 500) | |
1068 return; | |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1069 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1070 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1071 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
1490 | 1072 v29 = v38; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1073 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1074 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1075 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1076 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
2274 | 1077 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; |
1078 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1079 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
|
1080 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1081 HIWORD(v30) = HIWORD(v20); |
1490 | 1082 v31 = PID(OBJECT_Decoration,i); |
1083 LOWORD(v30) = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1084 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1085 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1086 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1087 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1088 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1089 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1090 ++uNumDecorationsDrawnThisFrame; |
1490 | 1091 } |
0 | 1092 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1093 continue; |
1490 | 1094 } |
1095 } | |
1096 else | |
1097 { | |
2274 | 1098 v42 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
1099 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
|
1100 v20 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2207 | 1101 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1102 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1103 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1104 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
|
1105 v42 = v22; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1106 if ( 2 * abs(v20) >= abs(v21) ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1107 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1108 LODWORD(v24) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1109 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1110 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
|
1111 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
|
1112 v41 = fixpoint_mul(v8->scale, v24 / v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1113 if ( pRenderer->pRenderD3D ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1114 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
|
1115 else |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1116 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
|
1117 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
|
1118 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1119 if (::uNumBillboardsToDraw >= 500) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1120 return; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1121 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1122 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1123 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1124 v29 = v38; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1125 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1126 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1127 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1128 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
2274 | 1129 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; |
1130 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1131 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
|
1132 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1133 HIWORD(v30) = HIWORD(v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1134 v31 = PID(OBJECT_Decoration,i); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1135 LOWORD(v30) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1136 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1137 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1138 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1139 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1140 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1141 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1142 ++uNumDecorationsDrawnThisFrame; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1143 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1144 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1145 continue; |
0 | 1146 } |
1147 } | |
1148 } | |
1490 | 1149 } |
1150 else | |
1151 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1152 memset(&local_0, 0, 0x68); |
1490 | 1153 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
1154 local_0.uDiffuse = 0xFF3C1E; | |
2274 | 1155 local_0.x = (double)pLevelDecorations[i].vPosition.x; |
1156 local_0.y = (double)pLevelDecorations[i].vPosition.y; | |
1157 local_0.z = (double)pLevelDecorations[i].vPosition.z; | |
1490 | 1158 local_0.r = 0.0; |
1159 local_0.g = 0.0; | |
1160 local_0.b = 0.0; | |
1161 local_0.flt_28 = 1.0; | |
1162 local_0.timeToLive = (rand() & 0x80) + 128; | |
1163 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
1164 pGame->pParticleEngine->AddParticle(&local_0); | |
1165 } | |
1166 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1167 } |
0 | 1168 } |
1169 | |
1170 //----- (0049D717) -------------------------------------------------------- | |
1171 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1172 { | |
2069 | 1173 if ( Src->dwFlags & (0x400 | 0x2000)) |
0 | 1174 { |
1175 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1176 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1177 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1178 return 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1179 } |
0 | 1180 if ( !Dst->dwSize ) |
1181 { | |
2078 | 1182 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1183 return 1; |
0 | 1184 } |
1185 } | |
1186 return 1; | |
1187 } | |
1188 | |
1189 //----- (0049DC28) -------------------------------------------------------- | |
1190 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1191 { | |
1192 RenderD3D__DevInfo *v2; // eax@1 | |
1193 | |
1194 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1195 *pOutDevices = v2; | |
1196 memset(v2, 0, 0xA0u); | |
1985 | 1197 DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)RenderD3D__DeviceEnumerator, *pOutDevices, DDENUM_ATTACHEDSECONDARYDEVICES); |
0 | 1198 } |
1199 | |
1200 //----- (0049DC58) -------------------------------------------------------- | |
1201 RenderD3D::RenderD3D() | |
1202 { | |
1203 this->pHost = 0; | |
1204 this->pDirect3D = 0; | |
1205 this->pUnk = 0; | |
1206 this->pBackBuffer = 0; | |
1207 this->pFrontBuffer = 0; | |
1208 this->pZBuffer = 0; | |
1209 this->pDevice = 0; | |
1210 this->pViewport = 0; | |
1211 this->field_40 = 1; | |
1212 this->field_44 = 10; | |
1213 GetAvailableDevices(&this->pAvailableDevices); | |
1214 } | |
1215 | |
1216 //----- (0049DC90) -------------------------------------------------------- | |
1217 void RenderD3D::Release() | |
1218 { | |
1219 RenderD3D *v1; // esi@1 | |
1220 IDirectDraw4 *v2; // eax@2 | |
1221 signed int v3; // edi@4 | |
1222 IDirect3DViewport3 *v4; // eax@22 | |
1223 IUnknown *v5; // eax@24 | |
1224 IDirectDrawSurface4 *v6; // eax@26 | |
1225 IDirect3DDevice3 *v7; // eax@28 | |
1226 IDirect3D3 *v8; // eax@30 | |
1227 IDirectDrawSurface4 *v9; // eax@32 | |
1228 IDirectDrawSurface4 *v10; // eax@34 | |
1229 IDirectDraw4 *v11; // eax@36 | |
1230 | |
1231 v1 = this; | |
1232 if ( !this->bWindowed ) | |
1233 { | |
1234 v2 = this->pHost; | |
1235 if ( v2 ) | |
1236 { | |
1237 v2->RestoreDisplayMode(); | |
1238 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
1239 v1->pHost->FlipToGDISurface(); | |
1240 } | |
1241 } | |
1242 v3 = 0; | |
1243 do | |
1244 { | |
1245 if ( v1->pAvailableDevices[v3].pDriverName ) | |
1246 { | |
1247 free(v1->pAvailableDevices[v3].pDriverName); | |
1248 v1->pAvailableDevices[v3].pDriverName = 0; | |
1249 } | |
1250 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
1251 { | |
1252 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
1253 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
1254 } | |
1255 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
1256 { | |
1257 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
1258 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
1259 } | |
1260 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
1261 { | |
1262 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
1263 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
1264 } | |
1265 if ( v1->pAvailableDevices[v3].pName ) | |
1266 { | |
1267 free(v1->pAvailableDevices[v3].pName); | |
1268 v1->pAvailableDevices[v3].pName = 0; | |
1269 } | |
1270 if ( v1->pAvailableDevices[v3].pDescription ) | |
1271 { | |
1272 free(v1->pAvailableDevices[v3].pDescription); | |
1273 v1->pAvailableDevices[v3].pDescription = 0; | |
1274 } | |
1275 if ( v1->pAvailableDevices[v3].pGUID ) | |
1276 { | |
1277 free(v1->pAvailableDevices[v3].pGUID); | |
1278 v1->pAvailableDevices[v3].pGUID = 0; | |
1279 } | |
1280 ++v3; | |
1281 } | |
1282 while ( v3 < 4 ); | |
1283 if ( v1->pAvailableDevices ) | |
1284 { | |
1285 free(v1->pAvailableDevices); | |
1286 v1->pAvailableDevices = 0; | |
1287 } | |
1288 v4 = v1->pViewport; | |
1289 if ( v4 ) | |
1290 { | |
1291 v4->Release(); | |
1292 v1->pViewport = 0; | |
1293 } | |
1294 v5 = v1->pUnk; | |
1295 if ( v5 ) | |
1296 { | |
1297 v5->Release(); | |
1298 v1->pUnk = 0; | |
1299 } | |
1300 v6 = v1->pZBuffer; | |
1301 if ( v6 ) | |
1302 { | |
1303 v6->Release(); | |
1304 v1->pZBuffer = 0; | |
1305 } | |
1306 v7 = v1->pDevice; | |
1307 if ( v7 ) | |
1308 { | |
1309 v7->Release(); | |
1310 v1->pDevice = 0; | |
1311 } | |
1312 v8 = v1->pDirect3D; | |
1313 if ( v8 ) | |
1314 { | |
1315 v8->Release(); | |
1316 v1->pDirect3D = 0; | |
1317 } | |
1318 v9 = v1->pBackBuffer; | |
1319 if ( v9 ) | |
1320 { | |
1321 v9->Release(); | |
1322 v1->pBackBuffer = 0; | |
1323 } | |
1324 v10 = v1->pFrontBuffer; | |
1325 if ( v10 ) | |
1326 { | |
1327 v10->Release(); | |
1328 v1->pFrontBuffer = 0; | |
1329 } | |
1330 v11 = v1->pHost; | |
1331 if ( v11 ) | |
1332 { | |
1333 v11->Release(); | |
1334 v1->pHost = 0; | |
1335 } | |
1336 } | |
1337 | |
1338 //----- (0049DE14) -------------------------------------------------------- | |
2069 | 1339 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window) |
0 | 1340 { |
1341 //IDirectDraw4 *v8; // eax@12 | |
1342 //IDirectDraw4 *v9; // eax@16 | |
1343 //IDirectDraw4 *v10; // eax@20 | |
1344 //IDirectDraw4 *v13; // eax@35 | |
1345 const char *v23; // [sp-4h] [bp-DCh]@9 | |
1346 const char *v24; // [sp-4h] [bp-DCh]@13 | |
1347 const char *v25; // [sp-4h] [bp-DCh]@19 | |
1348 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1349 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1350 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1351 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1352 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
1353 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1354 | |
2069 | 1355 auto hWnd = window->GetApiHandle(); |
1356 int game_width = window->GetWidth(); | |
1357 int game_height = window->GetHeight(); | |
1358 | |
0 | 1359 this->bWindowed = bWindowed; |
1360 this->hWindow = hWnd; | |
1361 | |
1362 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
1363 { | |
1364 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1365 return 0; | |
1366 } | |
1367 | |
1368 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1369 { | |
1370 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1371 if (lpDD) | |
1372 lpDD->Release(); | |
1373 return 0; | |
1374 } | |
1375 lpDD->Release(); | |
1376 lpDD = 0; | |
1377 | |
1378 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1379 { | |
1380 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
1381 { | |
1382 v23 = "Init - Failed to set cooperative level.\n"; | |
1383 sprintf(pErrorMessage, v23); | |
1384 LABEL_65: | |
1385 if (pHost) | |
1386 { | |
1387 pHost->Release(); | |
1388 pHost = 0; | |
1389 } | |
1390 return 0; | |
1391 } | |
1392 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1393 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1394 ddsd2.dwFlags = DDSD_CAPS; | |
1395 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
1396 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1397 { | |
1398 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1399 pHost->GetDisplayMode(&ddsd2); | |
2069 | 1400 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) |
0 | 1401 { |
1402 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
1403 goto LABEL_14; | |
1404 } | |
1405 | |
1406 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
1407 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
2069 | 1408 ddsd2.dwWidth = game_width; |
1409 ddsd2.dwHeight = game_height; | |
0 | 1410 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) |
1411 { | |
1412 v24 = "Init - Failed to create back buffer.\n"; | |
1413 LABEL_14: | |
1414 sprintf(pErrorMessage, v24); | |
1415 if (pFrontBuffer) | |
1416 { | |
1417 pFrontBuffer->Release(); | |
1418 pFrontBuffer = 0; | |
1419 } | |
1420 goto LABEL_65; | |
1421 } | |
1422 if ( pHost->CreateClipper(0, &v30, 0) ) | |
1423 { | |
1424 v25 = "Init - Failed to create clipper.\n"; | |
1425 goto LABEL_45; | |
1426 } | |
1427 v30->SetHWnd(0, hWnd); | |
1428 pFrontBuffer->SetClipper(v30); | |
1429 | |
1430 v30->Release(); | |
1431 v30 = 0; | |
1432 | |
1433 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1434 | |
1435 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1436 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
2069 | 1437 ddsd2.dwWidth = game_width; |
1438 ddsd2.dwHeight = game_height; | |
0 | 1439 |
1440 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1441 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1442 &ddsd2.ddpfPixelFormat) ) | |
1443 goto LABEL_21; | |
1444 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1445 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
1446 | |
1447 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1448 { | |
1449 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
1450 { | |
1451 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1452 pBackBuffer, | |
1453 &pDevice, | |
1454 0) ) | |
1455 { | |
1456 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1457 d3dvp2.dvClipWidth = 2.0; | |
1458 d3dvp2.dvClipY = 1.0; | |
1459 d3dvp2.dvClipHeight = 2.0; | |
1460 d3dvp2.dvMaxZ = 1.0; | |
1461 d3dvp2.dvMinZ = 0.0; | |
1462 goto LABEL_54; | |
1463 } | |
1464 LABEL_51: | |
1465 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1466 if (pDirect3D) | |
1467 { | |
1468 pDirect3D->Release(); | |
1469 pDirect3D = 0; | |
1470 } | |
1471 goto LABEL_59; | |
1472 } | |
1473 LABEL_48: | |
1474 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1475 if (pZBuffer) | |
1476 { | |
1477 pZBuffer->Release(); | |
1478 pZBuffer = 0; | |
1479 } | |
1480 goto LABEL_61; | |
1481 } | |
1482 goto LABEL_44; | |
1483 } | |
1484 LABEL_36: | |
1485 v23 = "Init - Failed to create front buffer.\n"; | |
1486 sprintf(pErrorMessage, v23); | |
1487 goto LABEL_65; | |
1488 } | |
1489 if ( uDeviceID == 1 ) | |
1490 v26 = 1045; | |
1491 else | |
1492 v26 = 1041; | |
1493 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
1494 { | |
1495 v23 = "Init - Failed to set cooperative level.\n"; | |
1496 sprintf(pErrorMessage, v23); | |
1497 goto LABEL_65; | |
1498 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1499 if (pHost->SetDisplayMode(window->GetWidth(), window->GetHeight(), 16, 0, 0) ) |
0 | 1500 { |
1501 v23 = "Init - Failed to set display mode.\n"; | |
1502 sprintf(pErrorMessage, v23); | |
1503 goto LABEL_65; | |
1504 } | |
1505 | |
1506 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1507 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1508 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
1509 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
1510 ddsd2.dwBackBufferCount = 1; | |
1511 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1512 goto LABEL_36; | |
1513 //a3a = &pBackBuffer; | |
1514 //v14 = *v34; | |
1515 memset(&v27, 0, sizeof(DDSCAPS2)); | |
1516 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
1517 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
1518 //hWnda = &pDirect3D; | |
1519 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1520 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
1521 { | |
1522 v25 = "Init - Failed to get D3D interface.\n"; | |
1523 goto LABEL_45; | |
1524 } | |
1525 | |
1526 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1527 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1528 ddsd2.dwWidth = 640; | |
1529 ddsd2.dwHeight = 480; | |
1530 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1531 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1532 &ddsd2.ddpfPixelFormat) ) | |
1533 { | |
1534 LABEL_21: | |
1535 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
1536 goto LABEL_45; | |
1537 } | |
1538 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1539 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
1540 //uDeviceIDa = &pZBuffer; | |
1541 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1542 { | |
1543 LABEL_44: | |
1544 v25 = "Init - Failed to create z-buffer.\n"; | |
1545 LABEL_45: | |
1546 sprintf(pErrorMessage, v25); | |
1547 if (pBackBuffer) | |
1548 { | |
1549 pBackBuffer->Release(); | |
1550 pBackBuffer = 0; | |
1551 } | |
1552 LABEL_63: | |
1553 //v19 = &pFrontBuffer; | |
1554 if (pFrontBuffer) | |
1555 { | |
1556 pFrontBuffer->Release(); | |
1557 pFrontBuffer= 0; | |
1558 } | |
1559 goto LABEL_65; | |
1560 } | |
1561 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
1562 goto LABEL_48; | |
1563 //v33 = &pDevice; | |
1564 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1565 pBackBuffer, | |
1566 &pDevice, | |
1567 0) ) | |
1568 goto LABEL_51; | |
1569 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1570 d3dvp2.dvClipWidth = 2.0; | |
1571 d3dvp2.dvClipY = 1.0; | |
1572 d3dvp2.dvClipHeight = 2.0; | |
1573 d3dvp2.dvMaxZ = 1.0; | |
1574 | |
1575 LABEL_54: | |
1576 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
1577 //v17 = *hWnda; | |
2069 | 1578 d3dvp2.dwWidth = game_width; |
1579 d3dvp2.dwHeight = game_height; | |
0 | 1580 d3dvp2.dvClipX = -1.0; |
1581 //v18 = v17->lpVtbl; | |
1582 //v32 = &v4->pViewport; | |
1583 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
1584 { | |
1585 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
1586 if (pDevice) | |
1587 { | |
1588 pDevice->Release(); | |
1589 pDevice = 0; | |
1590 } | |
1591 if (pDirect3D) | |
1592 { | |
1593 pDirect3D->Release(); | |
1594 pDirect3D = 0; | |
1595 } | |
1596 LABEL_59: | |
1597 if (pZBuffer) | |
1598 { | |
1599 pZBuffer->Release(); | |
1600 pZBuffer = 0; | |
1601 } | |
1602 LABEL_61: | |
1603 if (pBackBuffer) | |
1604 { | |
1605 pBackBuffer->Release(); | |
1606 pBackBuffer = 0; | |
1607 } | |
1608 goto LABEL_63; | |
1609 } | |
1610 | |
1611 pDevice->AddViewport(pViewport); | |
1612 pViewport->SetViewport2(&d3dvp2); | |
1613 pDevice->SetCurrentViewport(pViewport); | |
1614 return 1; | |
1615 } | |
1616 | |
1617 //----- (0049E444) -------------------------------------------------------- | |
1618 unsigned int RenderD3D::GetDeviceCaps() | |
1619 { | |
1620 unsigned int v1; // ebx@1 | |
1621 RenderD3D *v2; // edi@1 | |
1622 IDirect3DDevice3 *v3; // eax@1 | |
1623 unsigned int result; // eax@2 | |
1624 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
1625 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
1626 | |
1627 v1 = 0; | |
1628 v2 = this; | |
1629 memset(&halCaps, 0, 0xFCu); | |
1630 halCaps.dwSize = 252; | |
1631 memset(&refCaps, 0, 0xFCu); | |
1632 v3 = v2->pDevice; | |
1633 refCaps.dwSize = 252; | |
1634 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
1635 { | |
1636 result = 1; | |
1637 } | |
1638 else | |
1639 { | |
2154 | 1640 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) ) |
0 | 1641 v1 = 2; |
2154 | 1642 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1643 v1 |= 4u; |
2154 | 1644 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) ) |
0 | 1645 v1 |= 8u; |
2154 | 1646 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) ) |
0 | 1647 v1 |= 0x10u; |
2154 | 1648 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1649 v1 |= 0x20u; |
2154 | 1650 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) ) |
0 | 1651 v1 |= 0x40u; |
2154 | 1652 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ) |
1653 v1 |= 0x80; | |
0 | 1654 result = v1; |
1655 } | |
1656 return result; | |
1657 } | |
1658 | |
1659 //----- (0049E4FC) -------------------------------------------------------- | |
1660 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
1661 { | |
1662 uint uClearFlags = 0; | |
1663 | |
1664 if (bClearColor) | |
1665 uClearFlags |= D3DCLEAR_TARGET; | |
1666 if (bClearDepth) | |
1667 uClearFlags |= D3DCLEAR_ZBUFFER; | |
1668 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1669 D3DRECT rects[] = {{0, 0, window->GetWidth(), window->GetHeight()}}; |
0 | 1670 if (uClearFlags) |
1671 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
1672 } | |
1673 | |
1674 //----- (0049E54D) -------------------------------------------------------- | |
1675 void RenderD3D::Present(bool bForceBlit) | |
1676 { | |
1677 RECT v5; // [sp+18h] [bp-18h]@1 | |
1678 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
1679 | |
1680 v5.left = 0; | |
1681 v5.top = 0; | |
2217 | 1682 v5.bottom = 480;//window->GetHeight(); //Ritor1: ïðîáëåìà ñ êíîïêîé "ðàçâåðíóòü" |
1683 v5.right = 640; //window->GetWidth(); | |
0 | 1684 |
1685 if (bWindowed || bForceBlit) | |
1686 { | |
1687 RECT rc; | |
1688 GetClientRect(hWindow, &rc); | |
1689 Point.y = 0; | |
1690 Point.x = 0; | |
1691 ClientToScreen(hWindow, &Point); | |
1692 OffsetRect(&rc, Point.x, Point.y); | |
1693 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
1694 } | |
1695 else | |
1696 pFrontBuffer->Flip(0, 1); | |
1697 } | |
1698 | |
1699 //----- (0049E5D4) -------------------------------------------------------- | |
1700 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
1701 { | |
1702 unsigned int v8; // edx@4 | |
1703 unsigned int v9; // ebx@5 | |
1704 unsigned int v10; // eax@5 | |
1705 DWORD v11; // edx@5 | |
1706 //int v12; // edx@7 | |
1707 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
1708 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
1709 | |
1710 //v15 = this; | |
1711 memset(&ddsd2, 0, 0x7Cu); | |
1712 ddsd2.dwSize = 0x7Cu; | |
1713 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1714 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
1715 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
1716 ddsd2.dwHeight = uTextureHeight; | |
1717 ddsd2.dwWidth = uTextureWidth; | |
1718 if ( bMipmaps ) | |
1719 { | |
1720 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
1721 { | |
1722 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
1723 LABEL_8: | |
1724 ddsd2.dwMipMapCount = v8; | |
1725 if ( !v8 ) | |
1726 goto LABEL_12; | |
1727 goto LABEL_11; | |
1728 } | |
1729 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
1730 { | |
1731 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
1732 goto LABEL_8; | |
1733 } | |
1734 v9 = GetMaxMipLevels(uTextureWidth); | |
1735 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
1736 ddsd2.dwMipMapCount = v9 - v10; | |
1737 if ( v9 == v10 ) | |
1738 { | |
1739 ddsd2.dwFlags = 0x1007u; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
1740 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used |
0 | 1741 ddsd2.ddsCaps.dwCaps = v11; |
1742 goto LABEL_12; | |
1743 } | |
1744 } | |
1745 else | |
1746 { | |
1747 ddsd2.dwMipMapCount = 1; | |
1748 } | |
1749 LABEL_11: | |
1750 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1751 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1752 LABEL_12: | |
1753 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
1754 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
1755 if (bAlphaChannel) | |
1756 { | |
1757 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
1758 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
1759 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
1760 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1761 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
1762 } | |
1763 else | |
1764 { | |
1765 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
1766 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
1767 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
1768 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1769 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
1770 } | |
1771 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
1772 return false; | |
1773 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
1774 { | |
1775 (*pOutSurface)->Release(); | |
1776 *pOutSurface = 0; | |
1777 return false; | |
1778 } | |
1779 return true; | |
1780 } | |
1781 | |
1782 //----- (004A5190) -------------------------------------------------------- | |
1783 void RenderD3D::HandleLostResources() | |
1784 { | |
1785 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
1786 pBitmaps_LOD->_410423_move_textures_to_device(); | |
1787 pSprites_LOD->ReleaseLostHardwareSprites(); | |
1788 } | |
1789 | |
1790 //----- (004A2050) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
1791 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) |
0 | 1792 { |
1793 Render *v5; // edi@1 | |
1794 unsigned int v6; // ebx@1 | |
1795 LightmapBuilder *v7; // esi@3 | |
1796 int v8; // eax@7 | |
1797 ODMFace *v9; // eax@12 | |
1798 char *v10; // esi@12 | |
1799 double v11; // st7@14 | |
1800 double v12; // st7@14 | |
1801 int v13; // eax@14 | |
1802 ODMFace *v14; // ecx@14 | |
1803 double v15; // st7@14 | |
1804 float v16; // ST48_4@15 | |
1805 int v17; // eax@15 | |
1806 char v18; // zf@17 | |
1807 HRESULT v19; // eax@18 | |
1808 HRESULT v20; // eax@18 | |
1809 HRESULT v21; // eax@20 | |
1810 HRESULT v22; // eax@20 | |
1811 unsigned int v23; // ecx@20 | |
1812 char *v24; // eax@21 | |
1813 HRESULT v25; // eax@23 | |
1814 HRESULT v26; // eax@23 | |
1815 HRESULT v27; // eax@24 | |
1816 HRESULT v28; // eax@25 | |
1817 HRESULT v29; // eax@25 | |
1818 HRESULT v30; // eax@25 | |
1819 HRESULT v31; // eax@25 | |
1820 HRESULT v32; // eax@26 | |
1821 unsigned int v33; // ecx@26 | |
1822 char *v34; // eax@27 | |
1823 int v35; // edx@28 | |
1824 HRESULT v36; // eax@29 | |
1825 HRESULT v37; // eax@29 | |
1826 HRESULT v38; // eax@29 | |
1827 HRESULT v39; // eax@29 | |
1828 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
1829 unsigned int v41; // eax@29 | |
1830 HRESULT v42; // eax@30 | |
1831 HRESULT v43; // eax@30 | |
1832 HRESULT v44; // eax@30 | |
1833 char *v45; // esi@34 | |
1834 int v46; // ecx@35 | |
1835 double v47; // st6@35 | |
1836 int v48; // eax@36 | |
1837 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
1838 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
1839 int v51; // [sp+50h] [bp-18h]@0 | |
1840 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
1841 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
1842 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
1843 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
1844 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
1845 int v57; // [sp+60h] [bp-8h]@34 | |
2006 | 1846 signed int a2; // [sp+64h] [bp-4h]@4 |
0 | 1847 |
1848 v5 = this; | |
1849 v6 = 0; | |
1850 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
1851 { | |
1852 v7 = pGame->pLightmapBuilder; | |
1853 v53 = v7; | |
1854 v54 = v7->std__vector_000004_size; | |
1855 if ( v7->std__vector_000004_size) | |
2006 | 1856 a2 = -1; |
638 | 1857 pGame->AlterGamma_ODM(a4, &a2); |
2155 | 1858 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 1859 { |
638 | 1860 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 1861 v7->DrawLightmaps(/*v8, 0*/); |
0 | 1862 } |
1863 else | |
1864 { | |
1865 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
1866 { | |
323 | 1867 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1868 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
1869 if (bUsingSpecular) | |
1870 { | |
186 | 1871 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
1872 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1873 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1874 } |
1073 | 1875 for (uint i = 0; i < uNumVertices; ++i) |
1876 { | |
1877 | |
1878 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1879 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1880 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1881 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1882 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1883 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
1884 | |
1885 if ( this->bUsingSpecular ) | |
0 | 1886 { |
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
|
1887 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1888 } |
1073 | 1889 else |
1890 { | |
1891 d3d_vertex_buffer[i].specular = 0; | |
1892 } | |
1893 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1894 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1895 | |
1896 } | |
323 | 1897 |
1898 if (a4->uAttributes & FACE_OUTLINED) | |
1899 { | |
1900 int color; | |
1901 if (GetTickCount() % 300 >= 150) | |
1902 color = 0xFFFF2020; | |
1903 else color = 0xFF901010; | |
1904 | |
1905 for (uint i = 0; i < uNumVertices; ++i) | |
1906 d3d_vertex_buffer[i].diffuse = color; | |
1907 } | |
1908 | |
0 | 1909 pRenderD3D->pDevice->SetTexture(0, pTexture); |
1910 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1911 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1912 d3d_vertex_buffer, |
0 | 1913 uNumVertices, |
1914 D3DDP_DONOTLIGHT); | |
1915 } | |
1916 else | |
1917 { | |
1073 | 1918 for (uint i = 0; i < uNumVertices; ++i) |
1919 { | |
1920 | |
1921 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1922 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1923 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1924 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1925 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1926 if ( this->bUsingSpecular ) | |
0 | 1927 { |
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
|
1928 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1929 } |
1073 | 1930 else |
1931 { | |
1932 d3d_vertex_buffer[i].specular = 0; | |
1933 } | |
1934 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1935 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1936 | |
1937 } | |
1938 | |
186 | 1939 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
1940 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 1941 if (bUsingSpecular) |
186 | 1942 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 1943 |
1944 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
1945 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1946 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1947 d3d_vertex_buffer, |
0 | 1948 uNumVertices, |
1949 D3DDP_DONOTLIGHT)); | |
1950 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
1951 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1952 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
1394 | 1953 v53->DrawLightmaps(/*-1, 0*/); |
1073 | 1954 for (uint i = 0; i < uNumVertices; ++i) |
1955 { | |
1956 d3d_vertex_buffer[i].diffuse = a2; | |
1957 } | |
0 | 1958 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 1959 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1960 if ( !pRenderer->bUsingSpecular ) |
186 | 1961 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
1962 | |
1963 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
1964 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
1965 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 1966 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1967 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1968 d3d_vertex_buffer, |
0 | 1969 uNumVertices, |
1970 D3DDP_DONOTLIGHT)); | |
1971 if (bUsingSpecular) | |
1972 { | |
186 | 1973 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 1974 |
1073 | 1975 for (uint i = 0; i < uNumVertices; ++i) |
1976 { | |
1977 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
1978 d3d_vertex_buffer[i].specular = 0; | |
1979 } | |
1980 | |
0 | 1981 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 1982 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
1983 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 1984 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1985 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1986 d3d_vertex_buffer, |
0 | 1987 uNumVertices, |
1988 D3DDP_DONOTLIGHT)); | |
186 | 1989 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 1990 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
1991 v41 = GetLevelFogColor(); | |
1992 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
1993 v6 = 0; | |
1994 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
1995 } | |
186 | 1996 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
1997 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1998 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
1999 } | |
2000 } | |
2001 } | |
2002 } | |
2003 // 4D864C: using guessed type char byte_4D864C; | |
2004 | |
2005 //----- (0049EB79) -------------------------------------------------------- | |
2006 Render::~Render() | |
2007 { | |
2008 Render *v1; // esi@1 | |
2009 | |
2010 v1 = this; | |
1583 | 2011 free(this->pDefaultZBuffer); |
0 | 2012 v1->pD3DBitmaps.Release(); |
2013 v1->pD3DSprites.Release(); | |
2014 Release(); | |
2015 v1->bWindowMode = 1; | |
2016 //nullsub_1(); | |
2017 //nullsub_1(); | |
2018 } | |
2019 | |
2020 | |
2021 //----- (0049E992) -------------------------------------------------------- | |
2022 Render::Render() | |
2023 { | |
2216 | 2024 //Render *v1; // esi@1 |
0 | 2025 int v2; // eax@1 |
2026 char v3; // zf@1 | |
2027 | |
2216 | 2028 //v1 = this; |
0 | 2029 this->pDirectDraw4 = 0; |
2030 this->pFrontBuffer4 = 0; | |
2031 this->pBackBuffer4 = 0; | |
2154 | 2032 //this->pColorKeySurface4 = 0; |
2152 | 2033 //this->pDirectDraw2 = 0; |
2034 //this->pFrontBuffer2 = 0; | |
2035 //this->pBackBuffer2 = 0; | |
2036 //this->pSomeSurface2 = 0; | |
0 | 2037 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); |
2038 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2216 | 2039 this->bWindowMode = 1; |
2040 //this->field_40054 = 0; | |
2041 //this->field_10 = 640; | |
2042 //this->field_14 = 480; | |
2043 //this->field_40030 = 0; | |
2044 //this->field_4002C = 0; | |
2045 this->pActiveZBuffer = 0; | |
2046 this->pDefaultZBuffer = 0; | |
2047 this->raster_clip_y = 0; | |
2048 this->raster_clip_x = 0; | |
2049 this->raster_clip_z = 639; | |
2050 this->raster_clip_w = 479; | |
2051 //this->field_4003C = 0x004EED80; | |
2052 //this->field_40040 = dword_4EED78; | |
2053 this->uClipZ = 640; | |
2054 //this->field_40044 = 2; | |
2055 //this->field_40048 = 6; | |
2056 this->pFrontBuffer4 = 0; | |
2057 this->pBackBuffer4 = 0; | |
2058 //this->pColorKeySurface4 = 0; | |
2059 this->pDirectDraw4 = 0; | |
2060 this->pRenderD3D = 0; | |
2061 this->uNumSceneBegins = 0; | |
2062 this->uNumD3DSceneBegins = 0; | |
2063 this->using_software_screen_buffer = 0; | |
2064 this->pTargetSurface = 0; | |
2065 this->uTargetSurfacePitch = 0; | |
2066 this->uClipY = 0; | |
2067 this->uClipX = 0; | |
2068 this->uClipW = 480; | |
2069 this->bClip = 1; | |
2070 //this->bColorKeySupported = 0; | |
2071 this->bRequiredTextureStagesAvailable = 0; | |
2072 this->bTinting = 1; | |
2073 //LOBYTE(this->field_103668) = 0; | |
0 | 2074 uNumBillboardsToDraw = 0; |
2075 bFogEnabled = false; | |
265 | 2076 |
2077 hd_water_tile_id = -1; | |
2078 hd_water_current_frame = 0; | |
0 | 2079 } |
2080 | |
2069 | 2081 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
0 | 2082 { |
1802 | 2083 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); |
2084 | |
2085 this->window = window; | |
2069 | 2086 //bStartInWindow = true; |
1802 | 2087 //windowed_mode_width = windowed_width; |
2088 //windowed_mode_height = windowed_height; | |
2089 | |
1985 | 2090 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0); |
0 | 2091 |
2092 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
2093 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
2094 | |
2095 this->bTinting = bTinting; | |
2096 | |
1980 | 2097 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); |
2098 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
0 | 2099 |
2100 return r1 && r2; | |
2101 } | |
2102 | |
2103 | |
2104 //----- (0049ECC4) -------------------------------------------------------- | |
2105 void Render::ClearBlack() | |
2106 { | |
2154 | 2107 //if (pRenderD3D) |
0 | 2108 { |
2069 | 2109 if (using_software_screen_buffer) |
0 | 2110 pRenderD3D->ClearTarget(true, 0, false, 0.0); |
2111 } | |
2154 | 2112 //else |
2113 //memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
0 | 2114 } |
2115 | |
2116 //----- (0049ED18) -------------------------------------------------------- | |
2117 void Render::PresentBlackScreen() | |
2118 { | |
2119 IDirectDrawSurface *v2; // eax@3 | |
2120 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
2121 RECT x; // [sp+68h] [bp-10h]@3 | |
2122 | |
2123 memset(&v3, 0, sizeof(DDBLTFX)); | |
1802 | 2124 GetWindowRect(window->GetApiHandle(), &x); |
2152 | 2125 |
0 | 2126 { |
2127 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
2128 } | |
2152 | 2129 |
0 | 2130 v3.dwFillColor = 0; |
2131 v3.dwSize = 100; | |
2132 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
2133 pRenderer->Present(); | |
2134 } | |
2135 | |
2136 //----- (0049EDB6) -------------------------------------------------------- | |
2137 void Render::SavePCXScreenshot() | |
2138 { | |
2139 int v5; // eax@8 | |
2132 | 2140 FILE *pOutFile; // edi@10 |
2133 | 2141 unsigned short *v8; // eax@11 |
0 | 2142 int v9; // eax@13 |
2143 int v10; // ecx@15 | |
2144 signed int v12; // eax@18 | |
2145 HRESULT v14; // eax@29 | |
2146 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
2147 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2148 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2149 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2132 | 2150 char *lineB; // [sp+11Ch] [bp-48h]@14 |
2151 char *lineG; // [sp+120h] [bp-44h]@14 | |
2152 //int v24; // [sp+124h] [bp-40h]@11 | |
0 | 2153 FILE *File; // [sp+128h] [bp-3Ch]@3 |
2154 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2155 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2132 | 2156 char *lineRGB; // [sp+148h] [bp-1Ch]@10 |
2157 void *surface; // [sp+14Ch] [bp-18h]@8 | |
2158 int image_width; // [sp+150h] [bp-14h]@4 | |
2159 int pitch; // [sp+154h] [bp-10h]@4 | |
0 | 2160 char v31; // [sp+15Ah] [bp-Ah]@25 |
2132 | 2161 unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17 |
2162 unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10 | |
2163 byte test_byte; // [sp+163h] [bp-1h]@17 | |
2164 | |
2165 int num_r_bits = 5; | |
2166 int num_g_bits = 6; | |
2167 int num_b_bits = 5; | |
2168 | |
2169 int r_mask = 0xF800; | |
2170 int g_mask = 0x7E0; | |
2171 int b_mask = 0x1F; | |
2172 | |
2069 | 2173 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2174 { |
2132 | 2175 sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100); |
0 | 2176 File = fopen(Filename, "wb"); |
2177 if ( File ) | |
2178 { | |
2154 | 2179 pitch = this->GetRenderWidth(); |
2180 if ( pitch & 1 ) | |
2181 pitch = pitch + 1; | |
2132 | 2182 if ( this->pRenderD3D ) |
2183 { | |
2184 memset(&Dst, 0, 0x7C); | |
0 | 2185 Dst.dwSize = 124; |
168 | 2186 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 2187 return; |
2132 | 2188 surface = Dst.lpSurface; |
2189 v5 = Dst.lPitch / 2; | |
0 | 2190 } |
2191 else | |
2192 { | |
2193 pRenderer->BeginScene(); | |
2132 | 2194 surface = pRenderer->pTargetSurface; |
0 | 2195 v5 = pRenderer->uTargetSurfacePitch; |
2196 } | |
2154 | 2197 header1.right = GetRenderWidth() - 1; |
2132 | 2198 header1.left = 0; |
2154 | 2199 header1.bottom = this->GetRenderHeight() - 1; |
2132 | 2200 header1.up = 0; |
2201 header2.pitch = pitch; | |
0 | 2202 memset(color_map, 0, sizeof(color_map)); |
2203 memset(v15, 0, sizeof(v15)); | |
2204 header2.reserved = 0; | |
2205 header1.manufacturer = 10; | |
2132 | 2206 pOutFile = File; |
0 | 2207 header1.version = 5; |
2208 header1.encoding = 1; | |
2209 header1.bpp = 8; | |
2210 header1.hdpi = 75; | |
2211 header1.vdpi = 75; | |
2212 header2.planes = 3; | |
2213 header2.palette_info = 1; | |
2132 | 2214 fwrite(&header1, 1, 1, File); |
2215 fwrite(&header1.version, 1, 1, pOutFile); | |
2216 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2217 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2218 fwrite(&header1.left, 2, 1, pOutFile); | |
2219 fwrite(&header1.up, 2, 1, pOutFile); | |
2220 fwrite(&header1.right, 2, 1, pOutFile); | |
2221 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2222 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2223 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2224 fwrite(color_map, 0x30u, 1, pOutFile); | |
2225 fwrite(&header2, 1, 1, pOutFile); | |
2226 fwrite(&header2.planes, 1, 1, pOutFile); | |
2227 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2228 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2229 fwrite(v15, 0x3Au, 1, pOutFile); | |
2154 | 2230 lineRGB = (char *)malloc(3 * GetRenderWidth() + 6); |
2231 if ( this->GetRenderHeight() > 0 ) | |
2132 | 2232 { |
2233 image_width = 3 * pitch; | |
2234 //v24 = 2 * v5; | |
2235 v8 = (unsigned short *)surface; | |
2154 | 2236 for ( int y = 0; y < this->GetRenderHeight(); y++ ) |
0 | 2237 { |
2132 | 2238 line_picture_data = v8; |
2154 | 2239 if ( GetRenderWidth() > 0 ) |
0 | 2240 { |
2132 | 2241 lineG = (char *)lineRGB + pitch; |
2242 lineB = (char *)lineRGB + 2 * pitch; | |
2154 | 2243 for ( uint x = 0; x < this->GetRenderWidth(); x++ ) |
0 | 2244 { |
2221 | 2245 //int p = *line_picture_data; //0x2818 |
2246 //int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits );//16 = 8 + 8 | |
2247 //int value = (pRenderer->uTargetRMask & *line_picture_data);//0 = 0xFF0000 & 0x2818 | |
2248 //int result = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits ); | |
2133 | 2249 lineRGB[x] = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits );// + pRenderer->uTargetRBits - 8); |
2250 lineG[x] = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits);// + pRenderer->uTargetGBits - 8); | |
2221 | 2251 //int value2 = (pRenderer->uTargetGMask & *line_picture_data); //10240 = 0xFF00 & 0x2818 |
2252 //int result2 = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits); | |
2133 | 2253 lineB[x] = (pRenderer->uTargetBMask & *line_picture_data);// << (8 - pRenderer->uTargetBBits); |
2221 | 2254 //int value3 = (pRenderer->uTargetBMask & *line_picture_data);//24 = 0xFF & 0x2818 |
2132 | 2255 line_picture_data += 2; |
0 | 2256 } |
2257 } | |
2132 | 2258 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2259 { |
2132 | 2260 pict_byte = lineRGB[i]; |
2261 for ( test_byte = 1; test_byte < 0x3F; ++test_byte ) | |
0 | 2262 { |
2132 | 2263 v12 = i + test_byte; |
2264 if ( lineRGB[v12] != pict_byte ) | |
0 | 2265 break; |
2132 | 2266 if ( !(v12 % pitch) ) |
0 | 2267 break; |
2268 } | |
2132 | 2269 if ( i + test_byte > image_width ) |
2270 test_byte = 3 * pitch - i; | |
2271 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
2272 { | |
2273 v31 = test_byte | 0xC0; | |
2274 fwrite(&v31, 1, 1, pOutFile); | |
2275 } | |
2276 fwrite(&pict_byte, 1, 1, pOutFile); | |
0 | 2277 } |
2132 | 2278 v8 += v5; |
0 | 2279 } |
2280 } | |
2132 | 2281 if ( this->pRenderD3D ) |
0 | 2282 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2283 else | |
2284 pRenderer->EndScene(); | |
2132 | 2285 |
2286 free(lineRGB); | |
2287 fclose(pOutFile); | |
0 | 2288 } |
2289 } | |
2290 } | |
2291 | |
2292 //----- (0049F1BC) -------------------------------------------------------- | |
2069 | 2293 void Render::SaveWinnersCertificate(const char *a1) |
0 | 2294 { |
2295 unsigned int v6; // eax@8 | |
2133 | 2296 //FILE *v7; // edi@10 |
0 | 2297 int v8; // ecx@11 |
2133 | 2298 unsigned short *v9; // eax@11 |
0 | 2299 int v10; // eax@13 |
2300 signed int v13; // eax@18 | |
2301 char v14; // zf@27 | |
2302 HRESULT v15; // eax@29 | |
2133 | 2303 char v16[56]; // [sp+Ch] [bp-12Ch]@10 |
0 | 2304 __int16 v17; // [sp+44h] [bp-F4h]@10 |
2133 | 2305 DDSURFACEDESC2 Dst; // [sp+48h] [bp-F0h]@7 |
0 | 2306 int v19; // [sp+58h] [bp-E0h]@8 |
2307 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
2133 | 2308 char color_map[48]; // [sp+C4h] [bp-74h]@10 |
0 | 2309 unsigned int v22; // [sp+F4h] [bp-44h]@11 |
2133 | 2310 char *lineB; // [sp+F8h] [bp-40h]@14 |
2311 int image_width; // [sp+FCh] [bp-3Ch]@11 | |
0 | 2312 int v25; // [sp+100h] [bp-38h]@4 |
2313 FILE *File; // [sp+104h] [bp-34h]@3 | |
2314 char Str; // [sp+108h] [bp-30h]@10 | |
2315 char v28; // [sp+109h] [bp-2Fh]@10 | |
2316 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
2317 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
2318 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
2319 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
2320 __int16 v33; // [sp+110h] [bp-28h]@10 | |
2321 __int16 v34; // [sp+112h] [bp-26h]@10 | |
2322 __int16 v35; // [sp+114h] [bp-24h]@10 | |
2323 __int16 v36; // [sp+116h] [bp-22h]@10 | |
2324 char v37; // [sp+118h] [bp-20h]@10 | |
2325 char v38; // [sp+119h] [bp-1Fh]@10 | |
2326 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
2327 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
2133 | 2328 char *lineRGB; // [sp+120h] [bp-18h]@10 |
2329 void *surface; // [sp+124h] [bp-14h]@8 | |
2330 int pitch; // [sp+128h] [bp-10h]@4 | |
0 | 2331 char v44; // [sp+12Fh] [bp-9h]@25 |
2133 | 2332 char *lineG; // [sp+130h] [bp-8h]@10 |
2333 unsigned char pict_byte; // [sp+137h] [bp-1h]@17 | |
2334 byte test_byte; | |
2335 | |
2336 int num_r_bits = 5; | |
2337 int num_g_bits = 6; | |
2338 int num_b_bits = 5; | |
2339 | |
2340 int r_mask = 0xF800; | |
2341 int g_mask = 0x7E0; | |
2342 int b_mask = 0x1F; | |
2343 | |
2069 | 2344 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2345 { |
2154 | 2346 static int _4EFA84_num_winners_certificates = 0; |
2347 ++_4EFA84_num_winners_certificates; | |
2348 | |
0 | 2349 File = fopen(a1, "wb"); |
2350 if ( File ) | |
2351 { | |
2154 | 2352 v25 = this->GetRenderWidth(); |
2353 pitch = v25; | |
2354 if ( pitch & 1 ) | |
2355 pitch = pitch + 1; | |
2133 | 2356 if ( this->pRenderD3D ) |
2357 { | |
2358 memset(&Dst, 0, 0x7C); | |
2359 Dst.dwSize = 124; | |
168 | 2360 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 2361 return; |
2133 | 2362 surface = Dst.lpSurface; |
2363 v6 = Dst.lPitch / 2; | |
0 | 2364 } |
2365 else | |
2366 { | |
2367 pRenderer->BeginScene(); | |
2133 | 2368 surface = pRenderer->pTargetSurface; |
0 | 2369 v6 = pRenderer->uTargetSurfacePitch; |
2370 } | |
2154 | 2371 v33 = this->GetRenderWidth() - 1; |
2133 | 2372 v31 = 0; |
2154 | 2373 v34 = (short)this->GetRenderHeight() - 1; |
2133 | 2374 v32 = 0; |
2375 v39 = pitch; | |
2376 memset(&color_map, 0, sizeof(color_map)); | |
2377 memset(&v16, 0, sizeof(v16)); | |
0 | 2378 v37 = 0; |
2379 Str = 10; | |
2380 v17 = 0; | |
2381 v28 = 5; | |
2382 v29 = 1; | |
2383 v30 = 8; | |
2384 v35 = 75; | |
2385 v36 = 75; | |
2386 v38 = 3; | |
2387 v40 = 1; | |
2133 | 2388 fwrite(&Str, 1, 1, File); |
2389 fwrite(&v28, 1, 1, File); | |
2390 fwrite(&v29, 1, 1, File); | |
2391 fwrite(&v30, 1, 1, File); | |
2392 fwrite(&v31, 2, 1, File); | |
2393 fwrite(&v32, 2, 1, File); | |
2394 fwrite(&v33, 2, 1, File); | |
2395 fwrite(&v34, 2, 1, File); | |
2396 fwrite(&v35, 2, 1, File); | |
2397 fwrite(&v36, 2, 1, File); | |
2398 fwrite(&color_map, 0x30, 1, File); | |
2399 fwrite(&v37, 1, 1, File); | |
2400 fwrite(&v38, 1, 1, File); | |
2401 fwrite(&v39, 2, 1, File); | |
2402 fwrite(&v40, 2, 1, File); | |
2403 fwrite(&v16, 0x3A, 1, File); | |
2404 lineRGB = (char *)malloc(3 * (v25 + 2)); | |
2154 | 2405 if ( (signed int)this->GetRenderHeight() > 0 ) |
2133 | 2406 { |
2407 image_width = 3 * pitch; | |
2408 v9 = (unsigned short *)surface; | |
2154 | 2409 for ( uint j = 0; j < this->GetRenderHeight(); j++) |
0 | 2410 { |
2411 a1 = (const char *)v9; | |
2412 if ( v25 > 0 ) | |
2413 { | |
2133 | 2414 lineG = (char *)lineRGB + pitch; |
2415 lineB = (char *)lineRGB + 2 * pitch; | |
2416 for ( v10 = 0; v10 < v25; v10++ ) | |
0 | 2417 { |
2133 | 2418 lineRGB[v10] = (signed int)(r_mask & *(short *)a1) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2419 lineG[v10] = (signed int)(g_mask & *(short *)a1) >> (num_b_bits + num_g_bits - 8); | |
2420 lineB[v10] = (b_mask & *(short *)a1) << (8 - num_b_bits); | |
0 | 2421 a1 += 2; |
2422 } | |
2423 } | |
2133 | 2424 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2425 { |
2133 | 2426 pict_byte = lineRGB[i]; |
2427 for ( test_byte = 1; test_byte < 0x3F; test_byte ) | |
0 | 2428 { |
2133 | 2429 v13 = i + test_byte; |
2430 if ( lineRGB[v13] != pict_byte ) | |
0 | 2431 break; |
2133 | 2432 if ( !(v13 % pitch) ) |
0 | 2433 break; |
2434 } | |
2133 | 2435 if ( i + test_byte > image_width ) |
2436 test_byte = 3 * pitch - i; | |
2437 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
0 | 2438 { |
2133 | 2439 v44 = test_byte | 0xC0; |
2440 fwrite(&v44, 1, 1, File); | |
0 | 2441 } |
2133 | 2442 fwrite(&pict_byte, 1, 1, File); |
0 | 2443 } |
2133 | 2444 v9 += pitch; |
0 | 2445 } |
2446 } | |
2133 | 2447 if ( this->pRenderD3D ) |
0 | 2448 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2449 else | |
2450 pRenderer->EndScene(); | |
2133 | 2451 free(lineRGB); |
2452 fclose(File); | |
0 | 2453 } |
2454 } | |
2455 } | |
2456 | |
2457 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 2458 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
2127 | 2459 { |
0 | 2460 void *v8; // esi@3 |
2461 void *v9; // esi@3 | |
810 | 2462 unsigned short* v11; // eax@4 |
0 | 2463 int v13; // eax@8 |
2464 int v14; // ecx@8 | |
2465 signed int v15; // eax@11 | |
2466 char v16; // zf@20 | |
2467 int result; // eax@21 | |
2468 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
2469 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 2470 char *lineG; // [sp+78h] [bp-40h]@7 |
2471 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 2472 int v23; // [sp+80h] [bp-38h]@4 |
2473 int v24; // [sp+84h] [bp-34h]@4 | |
2474 int v25; // [sp+88h] [bp-30h]@4 | |
2475 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 2476 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
2477 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
2478 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
2479 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 2480 char v43; // [sp+B3h] [bp-5h]@18 |
2481 int i; // [sp+B4h] [bp-4h]@6 | |
2132 | 2482 unsigned short* line_picture_data; |
810 | 2483 byte test_byte; |
2484 unsigned char pict_byte; | |
0 | 2485 |
2131 | 2486 int num_r_bits = 5; |
2487 int num_g_bits = 6; | |
2488 int num_b_bits = 5; | |
2489 | |
2490 int r_mask = 0xF800; | |
2491 int g_mask = 0x7E0; | |
2492 int b_mask = 0x1F; | |
2493 | |
810 | 2494 pitch = wight; |
2495 if ( wight & 1 ) | |
2496 pitch = wight + 1; | |
2497 Src.left = 0; | |
2498 Src.up = 0; | |
2499 Src.right = wight - 1; | |
2500 Src.bottom = heidth - 1; | |
2501 v27.pitch = pitch; | |
0 | 2502 memset(&v20, 0, 0x30u); |
2503 memset(&v18, 0, 0x38u); | |
810 | 2504 v8 = data_buff; |
2505 v27.reserved = 0; | |
0 | 2506 *(_WORD *)&v18[56] = 0; |
810 | 2507 Src.manufacturer = 10; |
2508 Src.version = 5; | |
2509 Src.encoding = 1; | |
2510 Src.bpp = 8; | |
2511 Src.hdpi = 75; | |
2512 Src.vdpi = 75; | |
2513 v27.planes = 3; | |
2514 v27.palette_info = 1; | |
2128 | 2515 memcpy(data_buff, &Src, 1); |
0 | 2516 v8 = (char *)v8 + 1; |
2128 | 2517 memcpy(v8, &Src.version, 1); |
0 | 2518 v8 = (char *)v8 + 1; |
2128 | 2519 memcpy(v8, &Src.encoding, 1); |
0 | 2520 v8 = (char *)v8 + 1; |
2128 | 2521 memcpy(v8, &Src.bpp, 1); |
0 | 2522 v8 = (char *)v8 + 1; |
2128 | 2523 memcpy(v8, &Src.left, 2); |
0 | 2524 v8 = (char *)v8 + 2; |
2128 | 2525 memcpy(v8, &Src.up, 2); |
0 | 2526 v8 = (char *)v8 + 2; |
2128 | 2527 memcpy(v8, &Src.right, 2); |
0 | 2528 v8 = (char *)v8 + 2; |
2128 | 2529 memcpy(v8, &Src.bottom, 2); |
0 | 2530 v8 = (char *)v8 + 2; |
2127 | 2531 memcpy(v8, &Src.hdpi, 2); |
0 | 2532 v8 = (char *)v8 + 2; |
2127 | 2533 memcpy(v8, &Src.vdpi, 2); |
0 | 2534 v8 = (char *)v8 + 2; |
2535 memcpy(v8, &v20, 0x30u); | |
2536 v8 = (char *)v8 + 48; | |
810 | 2537 memcpy(v8, &v27, 1u); |
0 | 2538 v8 = (char *)v8 + 1; |
2127 | 2539 memcpy(v8, &v27.planes, 1); |
0 | 2540 v8 = (char *)v8 + 1; |
2127 | 2541 memcpy(v8, &v27.pitch, 2); |
0 | 2542 v8 = (char *)v8 + 2; |
2127 | 2543 memcpy(v8, &v27.palette_info, 2); |
0 | 2544 v8 = (char *)v8 + 2; |
2545 memcpy(v8, &v18, 0x3Au); | |
2546 v9 = (char *)v8 + 58; | |
810 | 2547 |
1583 | 2548 lineRGB = (char*)malloc(3 * (wight + 2)); |
810 | 2549 if ( heidth > 0 ) |
2550 { | |
2551 v26 = 3 * pitch; | |
2552 v23 = 2 * wight; | |
2553 v11 = picture_data; | |
2554 v24 = (int)picture_data; | |
2127 | 2555 for ( v25 = heidth; v25; v25-- ) |
0 | 2556 { |
2132 | 2557 line_picture_data = v11; |
810 | 2558 if ( wight > 0 ) |
2559 { | |
2560 lineG = (char *)lineRGB + pitch; | |
2561 lineB = (char *)lineRGB + 2 * pitch; | |
2127 | 2562 for ( uint i = 0; i < wight; i++ ) |
0 | 2563 { |
2132 | 2564 lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2565 lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8); | |
2566 lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits); | |
2567 line_picture_data += 1; | |
810 | 2568 } |
0 | 2569 } |
2570 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
2571 { | |
2128 | 2572 pict_byte = lineRGB[i]; |
2127 | 2573 for ( test_byte = 1; test_byte < 63; ++test_byte ) |
0 | 2574 { |
810 | 2575 v15 = i + test_byte; |
2128 | 2576 if ( lineRGB[v15] != pict_byte ) |
0 | 2577 break; |
810 | 2578 if ( !(v15 % pitch) ) |
0 | 2579 break; |
810 | 2580 } |
2581 if ( i + test_byte > v26 ) | |
2582 test_byte = 3 * pitch - i; | |
2127 | 2583 if ( test_byte > 1 || pict_byte >= 192 ) |
810 | 2584 { |
2585 v43 = test_byte | 0xC0; | |
2127 | 2586 memcpy(v9, &v43, 1); |
0 | 2587 v9 = (char *)v9 + 1; |
2588 } | |
2127 | 2589 memcpy(v9, &pict_byte, 1); |
810 | 2590 i += test_byte; |
2591 } | |
2128 | 2592 v11 += wight; |
810 | 2593 } |
2594 } | |
1583 | 2595 free(lineRGB); |
810 | 2596 *(int *)packed_size = (char *)v9 - data_buff; |
0 | 2597 } |
2598 | |
2599 //----- (0049F8B5) -------------------------------------------------------- | |
2155 | 2600 void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) |
0 | 2601 { |
2602 FILE *result; // eax@1 | |
2127 | 2603 FILE *pOutFile; // edi@4 |
2128 | 2604 unsigned short* v9; // eax@5 |
0 | 2605 int v10; // eax@7 |
2606 signed int v12; // eax@12 | |
2607 char v13; // zf@21 | |
2608 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
2609 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
2610 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
2611 int v18; // [sp+74h] [bp-30h]@5 | |
2612 char *v19; // [sp+78h] [bp-2Ch]@5 | |
2127 | 2613 int image_width; // [sp+7Ch] [bp-28h]@5 |
0 | 2614 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 |
2615 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
2128 | 2616 char *lineRGB; // [sp+98h] [bp-Ch]@4 |
2617 int pitch; // [sp+9Ch] [bp-8h]@2 | |
2618 char *lineB; // [sp+A0h] [bp-4h]@8 | |
2619 char *lineG; | |
2620 unsigned short* line_pictute_data; | |
2621 byte test_byte; | |
2622 char v43; | |
2127 | 2623 |
2624 int num_r_bits = 5; | |
2625 int num_g_bits = 6; | |
2626 int num_b_bits = 5; | |
2627 | |
2628 int r_mask = 0xF800; | |
2629 int g_mask = 0x7E0; | |
2630 int b_mask = 0x1F; | |
0 | 2631 |
2632 result = fopen(Filename, "wb"); | |
2633 Filename = (const char *)result; | |
2634 if ( result ) | |
2635 { | |
2128 | 2636 pitch = width; |
2127 | 2637 if ( width & 1 ) |
2128 | 2638 pitch = width + 1; |
0 | 2639 header1.left = 0; |
2640 header1.up = 0; | |
2127 | 2641 header1.right = width - 1; |
2642 header1.bottom = height - 1; | |
2128 | 2643 header2.pitch = pitch; |
0 | 2644 memset(color_map, 0, sizeof(color_map)); |
2645 header2.reserved = 0; | |
2646 memset(v14, 0, sizeof(v14)); | |
2647 v15 = 0; | |
2648 header1.manufacturer = 10; | |
2649 header1.version = 5; | |
2650 header1.encoding = 1; | |
2651 header1.bpp = 8; | |
2652 header1.hdpi = 75; | |
2653 header1.vdpi = 75; | |
2654 header2.planes = 3; | |
2655 header2.palette_info = 1; | |
2127 | 2656 fwrite(&header1, 1, 1, (FILE *)Filename); |
2657 pOutFile = (FILE *)Filename; | |
2658 fwrite(&header1.version, 1, 1, (FILE *)Filename); | |
2659 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2660 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2661 fwrite(&header1.left, 2, 1, pOutFile); | |
2662 fwrite(&header1.up, 2, 1, pOutFile); | |
2663 fwrite(&header1.right, 2, 1, pOutFile); | |
2664 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2665 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2666 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2667 fwrite(color_map, 0x30u, 1, pOutFile); | |
2668 fwrite(&header2, 1, 1, pOutFile); | |
2669 fwrite(&header2.planes, 1, 1, pOutFile); | |
2670 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2671 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2672 fwrite(v14, 0x3Au, 1, pOutFile); | |
2128 | 2673 |
2674 lineRGB = (char *)malloc(3 * (width + 2)); | |
2131 | 2675 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ |
2676 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî. | |
2128 | 2677 image_width = 3 * pitch; |
2678 v9 = picture_data; | |
2127 | 2679 for ( v18 = 0; v18 < height; v18++ )//ñòîëáåö |
2680 { | |
2128 | 2681 line_pictute_data = v9; |
2682 lineG = (char *)lineRGB + pitch; | |
2683 lineB = (char *)lineRGB + 2 * pitch; | |
2684 | |
2685 for ( int i = 0; i < width; i++ )//ñòðîêà | |
2686 { | |
2687 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); | |
2688 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); | |
2689 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); | |
2131 | 2690 line_pictute_data += 1; |
2128 | 2691 } |
2692 test_byte = 1; | |
2131 | 2693 for ( int i = 0; (signed int)i < image_width; i += test_byte ) |
2128 | 2694 { |
2695 unsigned char pic_byte = lineRGB[i]; | |
2696 for ( test_byte; test_byte < 63; ++test_byte )// ðàñ÷¸ò êîëè÷åñòâà îäèíàêîâûõ öâåòîâ | |
0 | 2697 { |
2128 | 2698 v12 = i + test_byte; |
2699 if ( lineRGB[v12] != pic_byte ) | |
2127 | 2700 break; |
2128 | 2701 if ( !(v12 % pitch) ) |
2127 | 2702 break; |
0 | 2703 } |
2128 | 2704 if ( i + test_byte > image_width ) |
2705 test_byte = 3 * pitch - i; | |
2706 if ( test_byte > 1 || pic_byte >= 0xC0 ) | |
0 | 2707 { |
2128 | 2708 v43 = test_byte | 0xC0;//òåñò-áàéò îáúåäèíåíèÿ |
2709 fwrite(&v43, 1, 1, pOutFile); | |
0 | 2710 } |
2128 | 2711 fwrite(&pic_byte, 1, 1, pOutFile); |
2712 } | |
2713 v9 += width; | |
2131 | 2714 } |
2128 | 2715 free(lineRGB); |
2155 | 2716 fclose(pOutFile); |
2717 } | |
0 | 2718 } |
2719 | |
2720 //----- (0049FBCD) -------------------------------------------------------- | |
2721 void Render::ClearTarget(unsigned int uColor) | |
2722 { | |
2154 | 2723 //if (pRenderD3D) |
0 | 2724 { |
2069 | 2725 if (using_software_screen_buffer) |
0 | 2726 pRenderD3D->ClearTarget(true, uColor, false, 0.0); |
2727 } | |
2154 | 2728 //else |
2729 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
0 | 2730 } |
2731 | |
2732 | |
2733 //----- (0049FC37) -------------------------------------------------------- | |
2734 void Render::Present() | |
2735 { | |
2217 | 2736 //struct tagRECT Rect; // [sp+8h] [bp-28h]@11 |
2737 //RECT a4; // [sp+18h] [bp-18h]@11 | |
2738 //struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
2739 | |
2069 | 2740 if ( !pRenderer->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2741 { |
2742 this->pBeforePresentFunction(); | |
2217 | 2743 if ( this->pRenderD3D ) |
2744 { | |
2745 if ( this->using_software_screen_buffer ) | |
0 | 2746 pRenderD3D->Present(false); |
2217 | 2747 } |
2748 else | |
2749 __debugbreak(); // no sr | |
1802 | 2750 /*{ |
2217 | 2751 if ( this->bWindowMode ) |
0 | 2752 { |
2753 RestoreFrontBuffer(); | |
2217 | 2754 GetClientRect(this->hWnd, &Rect); |
0 | 2755 Point.y = 0; |
2756 Point.x = 0; | |
2217 | 2757 ClientToScreen(this->hWnd, &Point); |
0 | 2758 OffsetRect(&Rect, Point.x, Point.y); |
2759 a4.top = 0; | |
2760 a4.bottom = 480; | |
2761 a4.left = 0; | |
2762 a4.right = 640; | |
2763 PresentRect(&Rect, &a4); | |
2764 } | |
2765 else | |
2766 { | |
2767 RestoreFrontBuffer(); | |
2768 a4.top = 0; | |
2769 a4.bottom = 480; | |
2770 a4.left = 0; | |
2771 a4.right = 640; | |
2772 BltBackToFontFast(0, 0, &a4); | |
2773 } | |
1802 | 2774 }*/ |
0 | 2775 } |
2776 } | |
2777 | |
2778 //----- (0049FD3A) -------------------------------------------------------- | |
2154 | 2779 void Render::_49FD3A_fullscreen() |
0 | 2780 { |
2781 Render *v2; // esi@1 | |
2782 IDirectDrawSurface4 *v3; // eax@6 | |
2783 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
2784 RECT v5; // [sp+8h] [bp-10h]@6 | |
2785 | |
1980 | 2786 Render* a1 = this; |
0 | 2787 v2 = a1; |
2788 if ( a1->pRenderD3D ) | |
2789 { | |
2790 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
2791 pFrontBuffer4->Restore(); | |
2792 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
2793 pBackBuffer4->Restore(); | |
2794 v3 = v2->pBackBuffer4; | |
2795 v4 = v2->pFrontBuffer4; | |
2796 v5.top = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2797 v5.bottom = window->GetHeight(); |
0 | 2798 v5.left = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2799 v5.right = window->GetWidth(); |
0 | 2800 v3->BltFast(0, 0, v4, &v5, 16u); |
2801 } | |
2802 } | |
2803 | |
2804 //----- (0049FDBF) -------------------------------------------------------- | |
2805 void Render::CreateZBuffer() | |
2806 { | |
2807 if (!pDefaultZBuffer) | |
2808 { | |
2809 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
1583 | 2810 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); |
871 | 2811 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 2812 } |
2813 } | |
2814 | |
2815 //----- (0049FE05) -------------------------------------------------------- | |
2816 void Render::Release() | |
2817 { | |
2818 Render *v1; // esi@1 | |
1802 | 2819 //RenderD3D *v2; // ecx@1 |
2820 //char v3; // zf@4 | |
2821 //void *v4; // ebx@6 | |
0 | 2822 IDirectDraw *v5; // eax@10 |
2823 IDirectDrawSurface2 *v6; // eax@11 | |
2824 IDirectDrawSurface2 *v7; // eax@13 | |
2825 IDirectDrawSurface2 *v8; // eax@15 | |
2826 IDirectDraw2 *v9; // eax@17 | |
2827 IDirectDraw4 *v10; // eax@19 | |
2828 IDirectDrawSurface4 *v11; // eax@20 | |
2829 IDirectDrawSurface4 *v12; // eax@22 | |
2830 IDirectDrawSurface4 *v13; // eax@24 | |
2831 IDirectDraw4 *v14; // eax@26 | |
2832 unsigned __int16 **v15; // ebx@28 | |
2833 void **v16; // esi@29 | |
2834 | |
2835 v1 = this; | |
1802 | 2836 if (pRenderD3D) |
0 | 2837 { |
2069 | 2838 if ( v1->using_software_screen_buffer ) |
0 | 2839 { |
1802 | 2840 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2841 pRenderD3D->Present(0); |
1802 | 2842 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2843 } |
2154 | 2844 //v1->pColorKeySurface4 = 0; |
0 | 2845 v1->pBackBuffer4 = 0; |
2846 v1->pFrontBuffer4 = 0; | |
2847 v1->pDirectDraw4 = 0; | |
1802 | 2848 if (v1->pTargetSurface) |
0 | 2849 { |
2069 | 2850 delete [] v1->pTargetSurface_unaligned; |
0 | 2851 v1->pTargetSurface = 0; |
2069 | 2852 v1->pTargetSurface_unaligned = 0; |
0 | 2853 } |
1802 | 2854 if (pRenderD3D) |
0 | 2855 { |
2856 pRenderD3D->Release(); | |
1802 | 2857 delete pRenderD3D; |
2858 } | |
2859 pRenderD3D = 0; | |
0 | 2860 } |
2861 else | |
1802 | 2862 ;//__debugbreak(); // no sr |
2863 /*{ | |
0 | 2864 if ( bWinNT4_0 == 1 ) |
2865 { | |
2866 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
2867 if ( !v5 ) | |
2868 return; | |
2869 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
2870 v1->pDirectDraw2->FlipToGDISurface(); | |
2871 v6 = v1->pSomeSurface2; | |
2872 if ( v6 ) | |
2873 { | |
2874 v6->Release(); | |
2875 v1->pSomeSurface2 = 0; | |
2876 } | |
2877 v7 = v1->pBackBuffer2; | |
2878 if ( v7 ) | |
2879 { | |
2880 v7->Release(); | |
2881 v1->pBackBuffer2 = 0; | |
2882 } | |
2883 v8 = v1->pFrontBuffer2; | |
2884 if ( v8 ) | |
2885 { | |
2886 v8->Release(); | |
2887 v1->pFrontBuffer2 = 0; | |
2888 } | |
2889 v9 = v1->pDirectDraw2; | |
2890 if ( v9 ) | |
2891 { | |
2892 v9->Release(); | |
2893 v1->pDirectDraw2 = 0; | |
2894 } | |
2895 } | |
2896 else | |
2897 { | |
2898 v10 = v1->pDirectDraw4; | |
2899 if ( !v10 ) | |
2900 return; | |
2901 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
2902 v1->pDirectDraw4->FlipToGDISurface(); | |
2903 v11 = v1->pColorKeySurface4; | |
2904 if ( v11 ) | |
2905 { | |
2906 v11->Release(); | |
2907 v1->pColorKeySurface4 = 0; | |
2908 } | |
2909 v12 = v1->pBackBuffer4; | |
2910 if ( v12 ) | |
2911 { | |
2912 v12->Release(); | |
2913 v1->pBackBuffer4 = 0; | |
2914 } | |
2915 v13 = v1->pFrontBuffer4; | |
2916 if ( v13 ) | |
2917 { | |
2918 v13->Release(); | |
2919 v1->pFrontBuffer4 = 0; | |
2920 } | |
2921 v14 = v1->pDirectDraw4; | |
2922 if ( v14 ) | |
2923 { | |
2924 v14->Release(); | |
2925 v1->pDirectDraw4 = 0; | |
2926 } | |
2927 } | |
2928 v15 = &v1->pTargetSurface; | |
2929 if ( v1->pTargetSurface ) | |
2930 { | |
2931 v16 = (void **)&v1->ptr_400E8; | |
2932 free(*v16); | |
2933 *v15 = 0; | |
2934 *v16 = 0; | |
2935 } | |
1802 | 2936 }*/ |
0 | 2937 } |
2938 | |
2152 | 2939 |
2940 | |
2941 | |
2942 void Present32(unsigned __int32 *src, unsigned int src_pitch, | |
2943 unsigned __int32 *dst, unsigned int dst_pitch) | |
2944 { | |
2945 for (uint y = 0; y < 8; ++y) | |
2946 memcpy(dst + y * dst_pitch, | |
2947 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2948 | |
2949 for (uint y = 8; y < 352; ++y) | |
2950 { | |
2951 memcpy(dst + y * dst_pitch, | |
2952 src + y * src_pitch, 8 * sizeof(__int32)); | |
2953 memcpy(dst + 8 + game_viewport_width + y * dst_pitch, | |
2954 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32)); | |
2955 } | |
2956 | |
2957 for (uint y = 352; y < 480; ++y) | |
2958 memcpy(dst + y * dst_pitch, | |
2959 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2960 | |
2961 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
2962 { | |
2963 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
2964 { | |
2965 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) | |
2155 | 2966 if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) |
2152 | 2967 dst[x + y * dst_pitch] = src[x + y * src_pitch]; |
2968 } | |
2969 } | |
2970 } | |
2971 | |
2972 //----- (004A597D) -------------------------------------------------------- | |
2973 void Present_NoColorKey() | |
2974 { | |
2975 //unsigned __int16 *v0; // eax@4 | |
2976 unsigned __int16 *v1; // esi@4 | |
2977 void *v2; // edi@4 | |
2978 //signed int v4; // ebx@4 | |
2979 //signed int v5; // ebx@6 | |
2980 //void *v6; // edi@7 | |
2981 //const void *v7; // esi@7 | |
2982 signed int v8; // ebx@8 | |
2983 int v9; // eax@10 | |
2984 unsigned int v10; // esi@10 | |
2985 unsigned __int32 v11; // edi@10 | |
2986 //int v12; // ecx@10 | |
2987 unsigned int v13; // ebx@10 | |
2988 int v14; // eax@11 | |
2989 int v15; // eax@13 | |
2990 int v16; // eax@14 | |
2991 int v17; // eax@16 | |
2992 HRESULT v18; // eax@22 | |
2993 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 | |
2994 //int v20; // [sp+88h] [bp-1Ch]@10 | |
2995 int v21; // [sp+8Ch] [bp-18h]@10 | |
2996 __int32 v22; // [sp+90h] [bp-14h]@10 | |
2997 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10 | |
2998 unsigned int v24; // [sp+98h] [bp-Ch]@4 | |
2999 //unsigned int _this; // [sp+9Ch] [bp-8h]@10 | |
3000 //LPVOID v26; // [sp+A0h] [bp-4h]@4 | |
3001 | |
3002 int r_mask = 0xF800; | |
3003 int g_mask = 0x7E0; | |
3004 int b_mask = 0x1F; | |
3005 | |
3006 if ( !pRenderer->uNumSceneBegins ) | |
3007 { | |
2154 | 3008 //if ( pRenderer->using_software_screen_buffer ) |
3009 //{ | |
2152 | 3010 memset(&Dst, 0, 0x7Cu); |
3011 Dst.dwSize = 124; | |
3012 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
3013 { | |
3014 //v26 = Dst.lpSurface; | |
3015 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; | |
3016 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16); | |
3017 //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; | |
3018 //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; | |
3019 //v1 = pRenderer->pTargetSurface; | |
3020 v2 = Dst.lpSurface; | |
3021 | |
3022 | |
3023 /*for (uint y = 0; y < 480; ++y) | |
3024 { | |
3025 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch); | |
3026 for (uint x = 0; x < 640; ++x) | |
3027 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; | |
3028 }*/ | |
3029 | |
3030 if (!FORCE_16_BITS) | |
3031 Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4); | |
3032 else | |
3033 { | |
3034 ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface; | |
3035 short* pDst = (__int16 *)Dst.lpSurface; | |
3036 | |
3037 for (uint y = 0; y < 8; ++y) | |
3038 memcpy(pDst + y * Dst.lPitch / 2, | |
3039 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3040 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
2152 | 3041 |
3042 for (uint y = 8; y < 352; ++y) | |
3043 { | |
3044 memcpy(pDst + y * Dst.lPitch / 2, | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3045 pSrc + y * window->GetWidth(), 8 * sizeof(__int16)); |
2152 | 3046 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
|
3047 pSrc + 8 + game_viewport_width/*462*/ + y * window->GetWidth(), 174/*172*/ * sizeof(__int16)); |
2152 | 3048 } |
3049 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3050 for (uint y = 352; y < window->GetHeight(); ++y) |
2152 | 3051 memcpy(pDst + y * Dst.lPitch / 2, |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3052 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3053 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3054 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3055 ushort* pSrc_x1y1 = pSrc + window->GetWidth() * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; |
2152 | 3056 //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)]; |
3057 short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; | |
3058 //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY)); | |
3059 v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1); | |
3060 //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1); | |
3061 v22 = 4 * ((Dst.lPitch / 4) + v9); | |
3062 v21 = 4 * v9 + 1280; | |
3063 | |
3064 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1; | |
3065 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1); | |
3066 v10 = (int)pSrc_x1y1; | |
3067 v11 = (int)pDst_x1y1; | |
3068 int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; | |
3069 v13 = v24; | |
3070 | |
3071 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
3072 { | |
3073 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, | |
3074 // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); | |
3075 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
3076 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3077 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
|
3078 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * window->GetWidth() + x]; |
2152 | 3079 } |
3080 } | |
3081 } | |
3082 | |
3083 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3084 | |
3085 /* while ( 1 ) | |
3086 { | |
3087 while ( 1 ) | |
3088 { | |
3089 v14 = *(int *)v10; | |
3090 v10 += 4; | |
3091 if ( v14 == v13 ) | |
3092 break; | |
3093 if ( (short)v14 == (short)v13 ) | |
3094 { | |
3095 *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000; | |
3096 v11 += 4; | |
3097 --uHalfWidth; | |
3098 if ( !uHalfWidth ) | |
3099 goto LABEL_21; | |
3100 } | |
3101 else | |
3102 { | |
3103 v15 = __ROL__(v14, 16); | |
3104 if ( (short)v15 == (short)v13 ) | |
3105 { | |
3106 v17 = __ROR__(v15, 16); | |
3107 *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17; | |
3108 v11 += 4; | |
3109 --uHalfWidth; | |
3110 if ( !uHalfWidth ) | |
3111 goto LABEL_21; | |
3112 } | |
3113 else | |
3114 { | |
3115 v16 = __ROR__(v15, 16); | |
3116 *(int *)v11 = v16; | |
3117 v11 += 4; | |
3118 --uHalfWidth; | |
3119 if ( !uHalfWidth ) | |
3120 goto LABEL_21; | |
3121 } | |
3122 } | |
3123 } | |
3124 v11 += 4; | |
3125 --uHalfWidth; | |
3126 if ( !uHalfWidth ) | |
3127 { | |
3128 LABEL_21: | |
3129 v10 += v21; | |
3130 v11 += v22; | |
3131 uHalfWidth = v20; | |
3132 if ( !--uNumLines ) | |
3133 { | |
3134 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3135 return; | |
3136 } | |
3137 } | |
3138 }*/ | |
3139 } | |
2154 | 3140 //} |
3141 } | |
3142 } | |
3143 | |
0 | 3144 |
3145 //----- (0049FFFB) -------------------------------------------------------- | |
1802 | 3146 bool Render::InitializeFullscreen() |
0 | 3147 { |
3148 //Render *v2; // esi@1 | |
3149 //HWND v3; // ebx@1 | |
3150 //void *v4; // eax@2 | |
3151 //RenderD3D *v5; // eax@3 | |
3152 unsigned int v6; // edx@5 | |
3153 RenderD3D__DevInfo *v7; // ecx@5 | |
3154 bool v8; // eax@6 | |
3155 RenderD3D *v9; // ecx@13 | |
3156 unsigned int v10; // eax@13 | |
3157 RenderD3D *v11; // eax@25 | |
3158 HRESULT v12; // eax@25 | |
3159 int v13; // ecx@25 | |
3160 int v14; // eax@27 | |
3161 signed int v15; // ebx@31 | |
2069 | 3162 //bool v16; // eax@35 |
3163 //char v17; // zf@35 | |
0 | 3164 IDirectDraw4 *v18; // eax@38 |
3165 HRESULT v19; // eax@38 | |
2069 | 3166 //int *v20; // eax@39 |
0 | 3167 int *v22; // eax@42 |
3168 int v23; // ecx@42 | |
3169 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3170 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3171 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
3172 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
3173 void *v28; // [sp+2FCh] [bp-10h]@2 | |
3174 int v29; // [sp+308h] [bp-4h]@2 | |
3175 | |
2069 | 3176 __debugbreak(); // Nomad |
3177 | |
0 | 3178 //v2 = this; |
2069 | 3179 this->using_software_screen_buffer = 0; |
2154 | 3180 //this->pColorKeySurface4 = 0; |
0 | 3181 this->pBackBuffer4 = 0; |
3182 this->pFrontBuffer4 = 0; | |
3183 this->pDirectDraw4 = 0; | |
2069 | 3184 //this->bColorKeySupported = 0; |
0 | 3185 Release(); |
3186 //v3 = hWnd; | |
1802 | 3187 this->window = window; |
0 | 3188 CreateZBuffer(); |
1802 | 3189 |
3190 /*if (!bUserDirect3D) | |
3191 { | |
3192 CreateDirectDraw(); | |
3193 SetDirectDrawCooperationMode(hWnd, 1); | |
3194 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3195 CreateDirectDrawPrimarySurface(); | |
3196 v15 = 1; | |
3197 } | |
3198 else | |
3199 {*/ | |
0 | 3200 pRenderD3D = new RenderD3D; |
3201 v28 = pRenderD3D; | |
3202 v6 = uDesiredDirect3DDevice; | |
3203 v29 = -1; | |
3204 v7 = pRenderD3D->pAvailableDevices; | |
3205 if ( v7[v6].bIsDeviceCompatible ) | |
3206 { | |
2069 | 3207 v8 = pRenderD3D->CreateDevice(v6, /*0*/true, window); |
0 | 3208 } |
3209 else | |
3210 { | |
3211 if ( v7[1].bIsDeviceCompatible ) | |
3212 { | |
2069 | 3213 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window); |
0 | 3214 } |
3215 else | |
3216 { | |
3217 if ( !v7->bIsDeviceCompatible ) | |
1545 | 3218 Error("There aren't any D3D devices to create."); |
3219 | |
2069 | 3220 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window); |
0 | 3221 } |
3222 } | |
3223 if ( !v8 ) | |
1545 | 3224 Error("D3Drend->Init failed."); |
3225 | |
0 | 3226 v9 = pRenderD3D; |
3227 pBackBuffer4 = v9->pBackBuffer; | |
3228 pFrontBuffer4 = v9->pFrontBuffer; | |
3229 pDirectDraw4 = v9->pHost; | |
3230 v10 = pRenderD3D->GetDeviceCaps(); | |
3231 if ( v10 & 1 ) | |
3232 { | |
3233 if ( pRenderD3D ) | |
3234 { | |
3235 pRenderD3D->Release(); | |
3236 delete pRenderD3D; | |
3237 } | |
3238 pRenderD3D = 0; | |
3239 pBackBuffer4 = 0; | |
3240 pFrontBuffer4 = 0; | |
3241 pDirectDraw4 = 0; | |
1545 | 3242 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3243 } |
3244 if ( v10 & 0x3E ) | |
3245 { | |
3246 if ( pRenderD3D ) | |
3247 { | |
3248 pRenderD3D->Release(); | |
3249 delete pRenderD3D; | |
3250 } | |
2154 | 3251 //pColorKeySurface4 = 0; |
0 | 3252 pRenderD3D = 0; |
3253 pBackBuffer4 = 0; | |
3254 pFrontBuffer4 = 0; | |
3255 pDirectDraw4 = 0; | |
1545 | 3256 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3257 } |
3258 if ( (v10 & 0x80u) != 0 ) | |
3259 { | |
3260 if ( pRenderD3D ) | |
3261 { | |
3262 pRenderD3D->Release(); | |
3263 delete pRenderD3D; | |
3264 } | |
3265 pRenderD3D = 0; | |
3266 pBackBuffer4 = 0; | |
3267 pFrontBuffer4 = 0; | |
3268 pDirectDraw4 = 0; | |
1545 | 3269 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3270 } |
2154 | 3271 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; |
0 | 3272 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3273 memset(&halCaps, 0, 0xFCu); | |
3274 halCaps.dwSize = 252; | |
3275 memset(&refCaps, 0, 0xFCu); | |
3276 v11 = pRenderD3D; | |
3277 refCaps.dwSize = 252; | |
3278 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
3279 v13 = halCaps.dwMinTextureWidth; | |
3280 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3281 v13 = halCaps.dwMinTextureHeight; | |
3282 v14 = halCaps.dwMaxTextureWidth; | |
3283 uMinDeviceTextureDim = v13; | |
3284 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
3285 v14 = halCaps.dwMaxTextureHeight; | |
3286 uMaxDeviceTextureDim = v14; | |
3287 if ( (unsigned int)v13 < 4 ) | |
3288 uMinDeviceTextureDim = 4; | |
3289 v15 = 1; | |
3290 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3291 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
2154 | 3292 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2)); |
0 | 3293 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); |
3294 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3295 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
2154 | 3296 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); |
3297 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
3298 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
3299 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3)); | |
3300 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2)); | |
0 | 3301 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); |
2154 | 3302 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2)); |
3303 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
0 | 3304 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); |
2154 | 3305 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4)); |
1802 | 3306 //} |
2069 | 3307 ddpfPrimarySuface.dwSize = 32; |
3308 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3309 ParseTargetPixelFormat(); |
2069 | 3310 |
3311 if (!pRenderD3D) | |
3312 { | |
3313 __debugbreak(); | |
3314 pBeforePresentFunction = 0;//nullsub_1; | |
3315 } | |
3316 //else | |
3317 //{ | |
3318 /*v16 = IsColorKeySupported(pDirectDraw4); | |
0 | 3319 v17 = uAcquiredDirect3DDevice == v15; |
3320 bColorKeySupported = v16; | |
3321 if ( !v17 ) | |
3322 bColorKeySupported = 0; | |
3323 if ( bColorKeySupported ) | |
3324 { | |
3325 memset(&ddsd2, 0, 0x7Cu); | |
3326 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3327 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3328 v18 = pDirectDraw4; | |
3329 ddsd2.dwSize = 124; | |
3330 ddsd2.dwFlags = 65543; | |
3331 ddsd2.ddsCaps.dwCaps = 2112; | |
3332 ddsd2.dwWidth = 640; | |
3333 ddsd2.dwHeight = 480; | |
3334 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3335 pBeforePresentFunction = Present_ColorKey; | |
3336 } | |
2069 | 3337 else*/ |
0 | 3338 { |
3339 pTargetSurface = 0; | |
2069 | 3340 pTargetSurface_unaligned = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3341 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32); |
2069 | 3342 if ( !pTargetSurface_unaligned |
0 | 3343 || (memset(&pDesc, 0, 0x7Cu), |
3344 pDesc.dwSize = 124, | |
3345 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
3346 return 0; | |
3347 pBackBuffer4->Unlock(0); | |
2069 | 3348 v22 = (int *)pTargetSurface_unaligned + 4; |
0 | 3349 v23 = (unsigned int)pDesc.lpSurface & 7; |
3350 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3351 uTargetSurfacePitch = window->GetWidth(); |
0 | 3352 pBeforePresentFunction = Present_NoColorKey; |
3353 v15 = 1; | |
2069 | 3354 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23); |
3355 } | |
3356 using_software_screen_buffer = v15; | |
3357 //} | |
0 | 3358 bWindowMode = 0; |
3359 pParty->uFlags |= 2u; | |
2151 | 3360 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
3361 return v15 != 0; |
0 | 3362 } |
3363 | |
3364 //----- (004A05F3) -------------------------------------------------------- | |
1802 | 3365 bool Render::SwitchToWindow() |
0 | 3366 { |
3367 //Render *v2; // esi@1 | |
3368 //void *v3; // eax@2 | |
3369 //RenderD3D *v4; // eax@3 | |
3370 //unsigned int v5; // edx@5 | |
3371 //RenderD3D__DevInfo *v6; // ecx@5 | |
3372 bool v7; // eax@7 | |
3373 //RenderD3D *v8; // ecx@12 | |
3374 unsigned int v9; // eax@12 | |
3375 RenderD3D *v10; // eax@24 | |
3376 HRESULT v11; // eax@24 | |
3377 int v12; // eax@24 | |
3378 int v13; // eax@26 | |
2069 | 3379 //bool v14; // eax@32 |
3380 //char v15; // zf@32 | |
0 | 3381 IDirectDraw4 *v16; // eax@35 |
3382 HRESULT v17; // eax@35 | |
2069 | 3383 //int *v18; // eax@36 |
0 | 3384 int *v19; // edx@38 |
3385 int v20; // eax@38 | |
3386 unsigned int v21; // ecx@38 | |
3387 int v22; // eax@41 | |
3388 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
3389 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3390 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
3391 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
3392 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
3393 int v29; // [sp+308h] [bp-4h]@2 | |
3394 | |
2069 | 3395 pParty->uFlags |= PARTY_FLAGS_1_0002; |
2151 | 3396 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
2069 | 3397 using_software_screen_buffer = 0; |
0 | 3398 Release(); |
2154 | 3399 //pColorKeySurface4 = 0; |
0 | 3400 pBackBuffer4 = 0; |
3401 pFrontBuffer4 = 0; | |
3402 pDirectDraw4 = 0; | |
2069 | 3403 //bColorKeySupported = 0; |
0 | 3404 CreateZBuffer(); |
1802 | 3405 /*if (!bUserDirect3D) |
3406 { | |
3407 CreateDirectDraw(); | |
3408 SetDirectDrawCooperationMode(hWnd, 0); | |
3409 field_4004C = 1; | |
3410 CreateFrontBuffer(); | |
3411 CreateClipper(hWnd); | |
3412 CreateBackBuffer(); | |
3413 field_40030 = 0; | |
3414 field_18_locked_pitch = 0; | |
3415 } | |
3416 else | |
3417 {*/ | |
1631 | 3418 /*v3 = malloc(0x148u); |
0 | 3419 thisa = (RenderD3D *)v3; |
3420 v29 = 0; | |
3421 if ( v3 ) | |
3422 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3423 else | |
3424 v4 = 0;*/ | |
3425 pRenderD3D = new RenderD3D; | |
3426 //v4 = pRenderD3D; | |
3427 //v5 = uDesiredDirect3DDevice; | |
3428 v29 = -1; | |
3429 //v6 = pRenderD3D->pAvailableDevices; | |
3430 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
3431 uDesiredDirect3DDevice != 1 ) | |
3432 { | |
2069 | 3433 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window); |
0 | 3434 } |
3435 else | |
3436 { | |
3437 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
1545 | 3438 Error("There aren't any D3D devices to init."); |
3439 | |
2069 | 3440 v7 = pRenderD3D->CreateDevice(0, true, window); |
0 | 3441 } |
3442 if ( !v7 ) | |
1545 | 3443 Error("D3Drend->Init failed."); |
0 | 3444 |
3445 //v8 = pRenderD3D; | |
2154 | 3446 //pColorKeySurface4 = 0; |
0 | 3447 pBackBuffer4 = pRenderD3D->pBackBuffer; |
3448 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3449 pDirectDraw4 = pRenderD3D->pHost; | |
3450 v9 = pRenderD3D->GetDeviceCaps(); | |
3451 if ( v9 & 1 ) | |
3452 { | |
3453 if (pRenderD3D) | |
3454 { | |
3455 pRenderD3D->Release(); | |
3456 delete pRenderD3D; | |
3457 } | |
3458 pRenderD3D = 0; | |
3459 pBackBuffer4 = 0; | |
3460 pFrontBuffer4 = 0; | |
3461 pDirectDraw4 = 0; | |
1545 | 3462 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3463 } |
3464 if ( v9 & 0x3E ) | |
3465 { | |
3466 if (pRenderD3D) | |
3467 { | |
3468 pRenderD3D->Release(); | |
3469 delete pRenderD3D; | |
3470 } | |
2154 | 3471 //pColorKeySurface4 = 0; |
0 | 3472 pRenderD3D = 0; |
3473 pBackBuffer4 = 0; | |
3474 pFrontBuffer4 = 0; | |
3475 pDirectDraw4 = 0; | |
1545 | 3476 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3477 } |
2154 | 3478 if (v9 & 0x80) |
0 | 3479 { |
3480 if (pRenderD3D) | |
3481 { | |
3482 pRenderD3D->Release(); | |
3483 delete pRenderD3D; | |
3484 } | |
3485 pRenderD3D = 0; | |
3486 pBackBuffer4 = 0; | |
3487 pFrontBuffer4 = 0; | |
3488 pDirectDraw4 = 0; | |
1545 | 3489 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3490 } |
2154 | 3491 //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; |
0 | 3492 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3493 memset(&halCaps, 0, 0xFCu); | |
3494 halCaps.dwSize = 252; | |
3495 memset(&refCaps, 0, 0xFCu); | |
3496 //v10 = v2->pRenderD3D; | |
3497 refCaps.dwSize = 252; | |
3498 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3499 v12 = halCaps.dwMinTextureWidth; | |
2069 | 3500 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight ) |
0 | 3501 v12 = halCaps.dwMinTextureHeight; |
3502 uMinDeviceTextureDim = v12; | |
3503 v13 = halCaps.dwMaxTextureWidth; | |
3504 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3505 v13 = halCaps.dwMaxTextureHeight; | |
3506 uMaxDeviceTextureDim = v13; | |
3507 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
3508 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
3509 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3510 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
3511 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
3512 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3513 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3514 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3515 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3516 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3517 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3518 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3519 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3520 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3521 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
1802 | 3522 //} |
3523 | |
2069 | 3524 ddpfPrimarySuface.dwSize = 32; |
3525 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3526 ParseTargetPixelFormat(); |
2069 | 3527 |
0 | 3528 if ( !pRenderD3D ) |
3529 { | |
2069 | 3530 __debugbreak(); |
3531 //pBeforePresentFunction = 0;//nullsub_1; | |
3532 //goto LABEL_47; | |
3533 } | |
3534 /*v14 = IsColorKeySupported(pDirectDraw4); | |
0 | 3535 v15 = uAcquiredDirect3DDevice == 1; |
3536 bColorKeySupported = v14; | |
3537 if ( !v15 ) | |
2069 | 3538 bColorKeySupported = 0;*/ |
3539 //if ( bColorKeySupported ) | |
3540 if (false) | |
3541 { | |
3542 /*memset(&ddsd2, 0, 0x7Cu); | |
0 | 3543 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; |
3544 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3545 v16 = pDirectDraw4; | |
3546 ddsd2.dwSize = 124; | |
3547 ddsd2.dwFlags = 65543; | |
3548 ddsd2.ddsCaps.dwCaps = 2112; | |
3549 ddsd2.dwWidth = 640; | |
3550 ddsd2.dwHeight = 480; | |
3551 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
2069 | 3552 pBeforePresentFunction = Present_ColorKey;*/ |
0 | 3553 LABEL_45: |
2069 | 3554 using_software_screen_buffer = 1; |
3555 //LABEL_47: | |
0 | 3556 bWindowMode = 1; |
1802 | 3557 //hWnd = hWnd; |
0 | 3558 return 0; |
3559 } | |
3560 pTargetSurface = 0; | |
2069 | 3561 pTargetSurface_unaligned = 0; |
3562 | |
3563 uint num_pixels = window->GetWidth() * window->GetHeight(); | |
3564 pTargetSurface_unaligned = new unsigned int[num_pixels]; | |
3565 | |
3566 if (!pTargetSurface_unaligned) | |
3567 return false; | |
3568 | |
3569 memset(&pDesc, 0, 0x7Cu); | |
3570 pDesc.dwSize = 124; | |
3571 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT)) | |
3572 { | |
3573 delete [] pTargetSurface_unaligned; | |
3574 return false; | |
3575 } | |
3576 | |
3577 memset32(pTargetSurface_unaligned, -1, num_pixels); | |
3578 | |
3579 | |
0 | 3580 pRenderer->pBackBuffer4->Unlock(0); |
2069 | 3581 /*v19 = pTargetSurface_unaligned; |
0 | 3582 v20 = (unsigned int)pDesc.lpSurface & 7; |
3583 v21 = (unsigned int)ptr_400E8 & 7; | |
3584 if ( v21 == v20 ) | |
3585 { | |
3586 pTargetSurface = (unsigned __int16 *)v19; | |
3587 } | |
3588 else | |
3589 { | |
3590 if ( (signed int)v21 >= v20 ) | |
3591 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
3592 else | |
3593 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
3594 pTargetSurface = (unsigned __int16 *)v22; | |
2069 | 3595 }*/ |
3596 pTargetSurface = pTargetSurface_unaligned; | |
3597 uTargetSurfacePitch = window->GetWidth(); | |
0 | 3598 pBeforePresentFunction = Present_NoColorKey; |
3599 goto LABEL_45; | |
3600 } | |
3601 | |
2154 | 3602 |
3603 //----- (0044F2B2) -------------------------------------------------------- | |
3604 bool Render::IsGammaSupported() | |
3605 { | |
3606 bool result; // eax@3 | |
3607 HRESULT v1; // eax@4 | |
3608 | |
3609 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
3610 { | |
3611 DDCAPS halCaps; // [sp+0h] [bp-180h]@4 | |
3612 memset(&halCaps, 0, sizeof(DDCAPS)); | |
3613 halCaps.dwSize = sizeof(DDCAPS); | |
3614 | |
3615 ErrD3D(pDirectDraw4->GetCaps(&halCaps, 0)); | |
3616 return (halCaps.dwCaps2 >> 17) & 1; | |
3617 } | |
3618 /*else | |
3619 return false;*/ | |
3620 } | |
3621 | |
0 | 3622 //----- (004A0BEE) -------------------------------------------------------- |
2102 | 3623 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) |
3624 { | |
2198 | 3625 signed int lower_bound; // eax@17 |
3626 signed int left_bound; | |
0 | 3627 unsigned int v21; // edi@46 |
3628 int v22; // esi@47 | |
3629 int v23; // ebx@47 | |
3630 signed int v24; // edx@50 | |
3631 signed int v25; // esi@52 | |
3632 unsigned __int16 *v26; // ecx@52 | |
3633 int v27; // ebx@54 | |
3634 int v28; // edi@55 | |
3635 int v29; // edx@55 | |
3636 int v30; // ebx@60 | |
3637 int v31; // edx@61 | |
3638 int v32; // edi@61 | |
2198 | 3639 signed int upper_bound; // [sp+18h] [bp-4h]@28 |
0 | 3640 unsigned int uXa; // [sp+24h] [bp+8h]@49 |
3641 int uYb; // [sp+28h] [bp+Ch]@47 | |
2245 | 3642 bool left_border_x = false; |
3643 bool right_border_x = false; | |
3644 bool left_border_z = false; | |
3645 bool right_border_z = false; | |
3646 bool upper_border_y = false; | |
3647 bool bottom_border_y = false; | |
3648 bool upper_border_w = false; | |
3649 bool bottom_border_w = false; | |
3650 | |
2101 | 3651 if ( uX < this->raster_clip_x )// x âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2245 | 3652 left_border_x = true; |
2101 | 3653 if ( uX > this->raster_clip_z )// x âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
2245 | 3654 right_border_x = true; |
2097 | 3655 |
2101 | 3656 if ( uZ < this->raster_clip_x )// z âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2245 | 3657 left_border_z = true; |
2101 | 3658 if ( uZ > this->raster_clip_z )// z âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
2245 | 3659 right_border_z = true; |
2101 | 3660 |
3661 if ( uY < this->raster_clip_y )// y âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
2245 | 3662 upper_border_y = true; |
2101 | 3663 if ( uY > this->raster_clip_w )// y âûõîäèò çà ðàìêè íèæíåé ãðàíèöû |
2245 | 3664 bottom_border_y = true; |
2101 | 3665 |
3666 if ( uW < this->raster_clip_y )// w âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
2245 | 3667 upper_border_w = true; |
2101 | 3668 if ( uW > this->raster_clip_w )// w âûõîäèò çà ðàìêè íèæíåé ãðàíèöû |
2245 | 3669 bottom_border_w = true; |
3670 | |
3671 if ( (left_border_x && left_border_z) || (right_border_x && right_border_z ) | |
3672 || (upper_border_y && upper_border_w) || (bottom_border_y && bottom_border_w)) | |
2102 | 3673 return; |
3674 | |
2245 | 3675 if ( left_border_x || left_border_z || right_border_x || right_border_z |
3676 || upper_border_y || upper_border_w || bottom_border_y || bottom_border_w) | |
3677 { | |
3678 if ( left_border_x || left_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left (ëåâàÿ ãðàíèöà) | |
3679 { | |
3680 if ( left_border_x )//left_border = true; õ ìåíüøå ëåâîé ãðàíèöû | |
3681 { | |
3682 uY += (uW - uY) * ((this->raster_clip_x - uX) / (uZ - uX));//t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
2199 | 3683 uX = this->raster_clip_x; |
3684 } | |
2245 | 3685 else if ( left_border_z )//z ìåíüøå ëåâîé ãðàíèöû |
2199 | 3686 { |
3687 uZ = this->raster_clip_x; | |
2245 | 3688 uW += (uY - uW) * ((this->raster_clip_x - uZ) / (uX - uZ)); |
3689 } | |
3690 } | |
3691 | |
3692 if ( right_border_x || right_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )//for right (ïðàâàÿ ãðàíèöà) | |
3693 { | |
3694 if ( right_border_x ) //right_border = true; õ áîëüøå ïðàâîé ãðàíèöû | |
3695 { | |
3696 uY += (uY - uW) * ((this->raster_clip_z - uX) / (uZ - uX)); | |
2199 | 3697 uX = this->raster_clip_z; |
0 | 3698 } |
2245 | 3699 else if ( right_border_z )//z áîëüøå ïðàâîé ãðàíèöû |
3700 { | |
3701 uW += (uW - uY) * ((this->raster_clip_z - uZ) / (uX - uZ)); | |
2199 | 3702 uZ = this->raster_clip_z; |
3703 } | |
3704 } | |
2245 | 3705 |
2199 | 3706 upper_bound = 0; |
3707 if ( uY < this->raster_clip_y ) | |
3708 upper_bound = 2; | |
3709 if ( uY > this->raster_clip_w ) | |
3710 upper_bound |= 1; | |
3711 | |
3712 lower_bound = 0; | |
3713 if ( uW < this->raster_clip_y ) | |
3714 lower_bound = 2; | |
3715 if ( uW > this->raster_clip_w ) | |
3716 lower_bound |= 1; | |
3717 | |
3718 if ( !(lower_bound & upper_bound) )//for up and down(äëÿ âåðõà è íèçà) | |
3719 { | |
3720 lower_bound ^= upper_bound; | |
3721 if ( lower_bound & 2 ) | |
3722 { | |
3723 if ( upper_bound & 2 ) | |
3724 { | |
2245 | 3725 uX += (uZ - uX) * ((this->raster_clip_y - uY) / (uW - uY)); |
2199 | 3726 uY = this->raster_clip_y; |
3727 } | |
3728 else | |
3729 { | |
2245 | 3730 uZ += (uX - uZ) * ((this->raster_clip_y - uW) / (uY - uW)); |
2199 | 3731 uW = this->raster_clip_y; |
3732 } | |
3733 } | |
3734 if ( lower_bound & 1 ) | |
3735 { | |
3736 if ( upper_bound & 1 ) | |
3737 { | |
2245 | 3738 uX += (uZ - uX) * ((this->raster_clip_w - uY) / (uW - uY)); |
2199 | 3739 uY = this->raster_clip_w; |
3740 } | |
3741 else | |
0 | 3742 { |
2245 | 3743 uZ += (uX - uZ) * ((this->raster_clip_w - uW) / (uY - uW)); |
2199 | 3744 uW = this->raster_clip_w; |
3745 } | |
3746 } | |
3747 } | |
3748 } | |
3749 v21 = pRenderer->uTargetSurfacePitch; | |
3750 if ( pRenderer->uTargetSurfacePitch ) | |
3751 { | |
3752 //v12 = uX + uY * pRenderer->uTargetSurfacePitch; | |
3753 v22 = uW - uY; | |
3754 v23 = v22; | |
3755 uYb = v22; | |
3756 if ( v22 < 0 ) | |
3757 { | |
3758 v23 = -v22; | |
3759 uYb = -v22; | |
3760 v21 = -pRenderer->uTargetSurfacePitch; | |
3761 } | |
3762 uXa = uZ - uX; | |
3763 if ((signed)(uZ - uX) >= 0) | |
3764 v24 = 1; | |
3765 else | |
3766 { | |
3767 uXa = -uXa; | |
3768 v24 = -1; | |
3769 } | |
3770 v25 = 0; | |
3771 | |
3772 v26 = (unsigned __int16 *)this->pTargetSurface; | |
3773 if ( v26 ) | |
3774 { | |
3775 if ( (signed int)uXa <= v23 )//ðèñóåì âåðòèêàëüíóþ ëèíèþ | |
3776 { | |
3777 v30 = v23 + 1; | |
3778 if ( v30 > 0 ) | |
3779 { | |
3780 v31 = 2 * v24; | |
3781 v32 = 2 * v21; | |
3782 //v12 = (int)&v26[v12]; | |
3783 int y = 0; | |
3784 int x = 0; | |
3785 for ( v30; v30; --v30 ) | |
0 | 3786 { |
2199 | 3787 v25 += uXa; |
3788 //*(short *)v12 = uColor; | |
3789 //v12 += v32; | |
3790 WritePixel16(uX + x, uY + y, uColor); | |
3791 if ( v32 >= 0 ) | |
3792 y += 1; | |
3793 else | |
3794 y -= 1; | |
3795 if ( v25 > 0 ) | |
0 | 3796 { |
2199 | 3797 v25 -= uYb; |
3798 //v12 += v31; | |
3799 if ( v31 >= 0 ) | |
2096 | 3800 x += 1; |
3801 else | |
3802 x -= 1; | |
0 | 3803 } |
3804 } | |
3805 } | |
3806 } | |
2199 | 3807 else//ðèñóåì ãîðèçîíòàëüíóþ ëèíèþ |
3808 { | |
3809 v27 = uXa + 1; | |
3810 if ( (signed int)(uXa + 1) > 0 ) | |
3811 { | |
3812 v28 = 2 * v21; | |
3813 v29 = 2 * v24; | |
3814 int y = 0; | |
3815 int x = 0; | |
3816 //v12 = (int)&v26[v12]; | |
3817 for ( v27; v27; --v27 ) | |
3818 { | |
3819 v25 += uYb; | |
3820 //*(short *)v12 = uColor; | |
3821 //v12 += v29; | |
3822 WritePixel16(uX + x, uY + y, uColor); | |
3823 if ( v29 >= 0 ) | |
3824 x += 1; | |
3825 else | |
3826 x -= 1; | |
3827 if ( v25 > (signed int)uXa ) | |
3828 { | |
3829 v25 -= uXa; | |
3830 //v12 += v28; | |
3831 if ( v28 >= 0 ) | |
3832 y += 1; | |
3833 else | |
3834 y -= 1; | |
3835 } | |
3836 } | |
3837 } | |
3838 } | |
3839 } | |
0 | 3840 } |
2102 | 3841 return; |
0 | 3842 } |
3843 | |
3844 //----- (004A0E80) -------------------------------------------------------- | |
3845 void Render::ClearZBuffer(int a2, int a3) | |
3846 { | |
2245 | 3847 memset32(this->pActiveZBuffer, -65536, 0x4B000); |
0 | 3848 } |
3849 | |
3850 //----- (004A0E97) -------------------------------------------------------- | |
709 | 3851 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
3852 { | |
3853 this->raster_clip_x = uX; | |
3854 this->raster_clip_y = uY; | |
3855 this->raster_clip_z = uZ; | |
3856 this->raster_clip_w = uW; | |
0 | 3857 } |
3858 | |
3859 //----- (004A0EB6) -------------------------------------------------------- | |
3860 void Render::ParseTargetPixelFormat() | |
3861 { | |
3862 signed int v2; // ecx@1 | |
3863 DWORD uRedMask; // edx@1 | |
3864 unsigned int uGreenMask; // esi@5 | |
3865 signed int v5; // ecx@5 | |
3866 unsigned int uBlueMask; // edx@9 | |
3867 signed int v7; // ecx@9 | |
2069 | 3868 //unsigned int v8; // ecx@13 |
0 | 3869 |
3870 v2 = 0; | |
2132 | 3871 uRedMask = this->ddpfPrimarySuface.dwRBitMask; |
3872 this->uTargetBBits = 0; | |
3873 this->uTargetGBits = 0; | |
3874 this->uTargetRBits = 0; | |
0 | 3875 do |
3876 { | |
3877 if ( (1 << v2) & uRedMask ) | |
2132 | 3878 ++this->uTargetRBits; |
0 | 3879 ++v2; |
3880 } | |
2069 | 3881 while ( v2 < 32 ); |
2132 | 3882 uGreenMask = this->ddpfPrimarySuface.dwGBitMask; |
0 | 3883 v5 = 0; |
3884 do | |
3885 { | |
3886 if ( (1 << v5) & uGreenMask ) | |
2132 | 3887 ++this->uTargetGBits; |
0 | 3888 ++v5; |
3889 } | |
2069 | 3890 while ( v5 < 32 ); |
2132 | 3891 uBlueMask = this->ddpfPrimarySuface.dwBBitMask; |
0 | 3892 v7 = 0; |
3893 do | |
3894 { | |
3895 if ( (1 << v7) & uBlueMask ) | |
2132 | 3896 ++this->uTargetBBits; |
0 | 3897 ++v7; |
3898 } | |
2069 | 3899 while ( v7 < 32 ); |
2132 | 3900 this->uTargetGMask = uGreenMask; |
3901 this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask; | |
3902 this->uTargetBMask = uBlueMask; | |
0 | 3903 } |
3904 | |
3905 //----- (004A0F40) -------------------------------------------------------- | |
3906 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
3907 { | |
2132 | 3908 //IDirectDrawSurface4 *v4; // esi@1 |
168 | 3909 HRESULT result; // eax@1 |
0 | 3910 HRESULT v6; // eax@4 |
3911 int v7; // [sp-8h] [bp-14h]@10 | |
3912 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
3913 char v9; // [sp+Bh] [bp-1h]@1 | |
3914 | |
2132 | 3915 //v4 = pSurface; |
0 | 3916 v9 = 1; |
3917 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
3918 if ( result == DDERR_SURFACELOST ) | |
3919 { | |
2132 | 3920 v6 = pSurface->Restore(); |
0 | 3921 if ( v6 ) |
3922 { | |
3923 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
3924 { | |
3925 LABEL_20: | |
3926 v9 = 0; | |
3927 result = (bool)memset(pDesc, 0, 4u); | |
3928 goto LABEL_21; | |
3929 } | |
3930 pRenderer->pFrontBuffer4->Restore(); | |
2132 | 3931 pSurface->Restore(); |
3932 } | |
3933 result = pSurface->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
0 | 3934 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) |
3935 goto LABEL_20; | |
3936 ErrD3D(result); | |
3937 if ( result ) | |
3938 { | |
3939 //v8 = 0; | |
3940 //v7 = 2161; | |
3941 LABEL_19: | |
3942 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
3943 goto LABEL_20; | |
3944 } | |
3945 if ( pRenderer->pRenderD3D ) | |
3946 pRenderD3D->HandleLostResources(); | |
3947 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
3948 } | |
3949 else | |
3950 { | |
3951 if ( result ) | |
3952 { | |
3953 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3954 goto LABEL_20; | |
3955 ErrD3D(result); | |
3956 //v8 = 0; | |
3957 //v7 = 2199; | |
3958 //goto LABEL_19; | |
3959 } | |
3960 } | |
3961 LABEL_21: | |
3962 LOBYTE(result) = v9; | |
3963 return result; | |
3964 } | |
3965 | |
3966 | |
3967 //----- (004A10E4) -------------------------------------------------------- | |
3968 void Render::CreateDirectDraw() | |
3969 { | |
3970 Render *v1; // edi@1 | |
3971 HRESULT v2; // eax@1 | |
3972 HRESULT v3; // eax@5 | |
3973 int v6; // [sp-Ch] [bp-20h]@3 | |
3974 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
3975 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
3976 | |
3977 v1 = this; | |
3978 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
3979 | |
3980 pDirectDraw4 = nullptr; | |
3981 | |
2152 | 3982 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); |
0 | 3983 |
3984 lpDD->Release(); | |
3985 lpDD = nullptr; | |
3986 } | |
3987 | |
3988 //----- (004A1169) -------------------------------------------------------- | |
3989 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
3990 { | |
3991 DWORD flags; // eax@1 | |
3992 IDirectDraw *v4; // ecx@3 | |
3993 HRESULT v5; // eax@5 | |
3994 int v6; // [sp-8h] [bp-8h]@3 | |
3995 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
3996 | |
3997 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
3998 DDSCL_NORMAL; | |
3999 | |
2152 | 4000 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); |
0 | 4001 } |
4002 | |
4003 //----- (004A11C6) -------------------------------------------------------- | |
4004 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
4005 { | |
2152 | 4006 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); |
0 | 4007 } |
4008 | |
4009 //----- (004A121C) -------------------------------------------------------- | |
4010 void Render::CreateFrontBuffer() | |
4011 { | |
4012 Render *v1; // esi@1 | |
4013 IDirectDraw *pDD; // eax@3 | |
4014 IDirectDrawSurface **pOutSurf; // esi@3 | |
4015 struct _DDSURFACEDESC *v4; // edx@3 | |
4016 HRESULT v5; // eax@5 | |
4017 int v6; // [sp-8h] [bp-8Ch]@3 | |
4018 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4019 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4020 | |
4021 v1 = this; | |
2152 | 4022 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4023 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4024 { |
4025 memset(&a2, 0, 0x7Cu); | |
4026 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
4027 a2.dwSize = 124; | |
4028 a2.dwFlags = 1; | |
4029 v7 = 0; | |
4030 a2.ddsCaps.dwCaps = 512; | |
4031 v6 = 2357; | |
4032 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
4033 v4 = (struct _DDSURFACEDESC *)&a2; | |
4034 } | |
2152 | 4035 /*else |
0 | 4036 { |
4037 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
4038 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
4039 a2.lPitch = 108; | |
4040 a2.dwBackBufferCount = 1; | |
4041 v7 = 0; | |
4042 a2.dwTextureStage = 512; | |
4043 v6 = 2346; | |
4044 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
4045 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
2152 | 4046 }*/ |
0 | 4047 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); |
4048 } | |
4049 | |
4050 //----- (004A12CD) -------------------------------------------------------- | |
4051 void Render::CreateBackBuffer() | |
4052 { | |
4053 Render *v1; // esi@1 | |
4054 IDirectDraw *v2; // eax@3 | |
4055 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
4056 struct _DDSURFACEDESC *v4; // edx@3 | |
4057 HRESULT v5; // eax@5 | |
4058 int v6; // [sp-8h] [bp-8Ch]@3 | |
4059 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4060 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4061 | |
4062 v1 = this; | |
2152 | 4063 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4064 // pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4065 { |
4066 memset(&a2, 0, 0x7Cu); | |
4067 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
4068 a2.dwSize = 124; | |
4069 a2.dwFlags = 7; | |
4070 v7 = 0; | |
4071 a2.ddsCaps.dwCaps = 2112; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
4072 a2.dwWidth = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
4073 a2.dwHeight = window->GetHeight(); |
0 | 4074 v6 = 2387; |
4075 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4076 v4 = (struct _DDSURFACEDESC *)&a2; | |
4077 } | |
2152 | 4078 /*else |
0 | 4079 { |
4080 memset(&a2.lPitch, 0, 0x6Cu); | |
4081 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4082 a2.lPitch = 108; | |
4083 a2.dwBackBufferCount = 7; | |
4084 v7 = 0; | |
4085 a2.dwTextureStage = 2112; | |
4086 a2.dwAlphaBitDepth = 640; | |
4087 a2.dwMipMapCount = 480; | |
4088 v6 = 2374; | |
4089 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4090 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
2152 | 4091 }*/ |
0 | 4092 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); |
4093 } | |
4094 | |
4095 //----- (004A139A) -------------------------------------------------------- | |
4096 void Render::CreateDirectDrawPrimarySurface() | |
4097 { | |
4098 Render *v1; // esi@1 | |
2154 | 4099 //int v2; // ebx@3 |
0 | 4100 IDirectDraw2 *v3; // eax@3 |
4101 HRESULT v4; // eax@3 | |
4102 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
4103 DDSCAPS2 *v6; // edx@3 | |
4104 IDirectDraw4 *v7; // eax@4 | |
4105 HRESULT v8; // eax@4 | |
4106 int v9; // ST14_4@5 | |
4107 IDirectDrawSurface *v10; // ST10_4@5 | |
4108 HRESULT v11; // eax@5 | |
4109 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
4110 const char *v13; // [sp+0h] [bp-A0h]@0 | |
4111 int v14; // [sp+4h] [bp-9Ch]@0 | |
4112 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
4113 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
4114 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
4115 int a4; // [sp+98h] [bp-8h]@3 | |
4116 | |
4117 v1 = this; | |
2152 | 4118 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4119 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4120 { |
2154 | 4121 //v2 = 0; |
4122 //this->field_4004C = 1; | |
0 | 4123 memset(&ddsd2, 0, 0x7Cu); |
4124 v7 = v1->pDirectDraw4; | |
4125 ddsd2.dwBackBufferCount = 1; | |
4126 ddsd2.dwSize = 0x7Cu; | |
4127 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4128 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4129 ErrD3D(v7->CreateSurface( | |
4130 &ddsd2, | |
4131 &pFrontBuffer4, | |
4132 0)); | |
4133 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
4134 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4135 } | |
2152 | 4136 /*else |
0 | 4137 { |
4138 v2 = 0; | |
4139 this->field_4004C = 1; | |
4140 | |
4141 DDSURFACEDESC ddsd; | |
4142 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4143 | |
4144 ddsd.lpSurface = (LPVOID)1; | |
4145 ddsd.lPitch = 108; | |
4146 ddsd.dwBackBufferCount = 33; | |
4147 ddsd.ddsCaps.dwCaps = 8728; | |
4148 ErrD3D(pDirectDraw2->CreateSurface( | |
4149 &ddsd, | |
4150 (IDirectDrawSurface **)&pFrontBuffer2, | |
4151 0)); | |
4152 | |
4153 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4154 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
2152 | 4155 }*/ |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4156 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used |
0 | 4157 v9 = (int)v6; |
4158 v10 = pFrontBuffer; // BUG | |
4159 | |
4160 v17.dwCaps = 4; | |
4161 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4162 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
2154 | 4163 //v1->field_40030 = v2; |
4164 //v1->field_18_locked_pitch = v2; | |
0 | 4165 } |
4166 | |
4167 //----- (004A14F4) -------------------------------------------------------- | |
4168 void Render::CreateClipper(HWND a2) | |
4169 { | |
2152 | 4170 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); |
4171 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4172 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
0 | 4173 } |
4174 | |
4175 //----- (004A15D8) -------------------------------------------------------- | |
4176 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4177 { | |
2152 | 4178 pFrontBuffer4->GetPixelFormat(pOut); |
0 | 4179 } |
4180 | |
4181 //----- (004A1605) -------------------------------------------------------- | |
4182 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4183 { | |
4184 signed int v4; // eax@3 | |
4185 | |
2152 | 4186 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4187 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4188 { |
4189 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4190 memset(&pDesc, 0, 0x7Cu); | |
4191 pDesc.dwSize = 124; | |
2132 | 4192 LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4193 *pOutSurfacePtr = pDesc.lpSurface; |
4194 v4 = pDesc.lPitch; | |
4195 } | |
2152 | 4196 /*else |
0 | 4197 { |
4198 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4199 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4200 pDesc.lPitch = 108; | |
2132 | 4201 LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1); |
0 | 4202 *pOutSurfacePtr = (void *)pDesc.lpSurface; |
4203 v4 = pDesc.dwReserved; | |
2152 | 4204 }*/ |
0 | 4205 *pOutPixelsPerRow = v4 >> 1; |
4206 } | |
4207 | |
4208 //----- (004A16E1) -------------------------------------------------------- | |
4209 void Render::UnlockBackBuffer() | |
4210 { | |
2152 | 4211 ErrD3D(pBackBuffer4->Unlock(0)); |
0 | 4212 } |
4213 | |
4214 //----- (004A172E) -------------------------------------------------------- | |
4215 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4216 { | |
4217 signed int v4; // eax@3 | |
4218 | |
2152 | 4219 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4220 { |
4221 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4222 memset(&pDesc, 0, 0x7Cu); | |
4223 pDesc.dwSize = 124; | |
2132 | 4224 LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4225 *pOutSurface = pDesc.lpSurface; |
4226 v4 = pDesc.lPitch; | |
4227 } | |
2152 | 4228 /*else |
0 | 4229 { |
4230 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4231 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4232 pDesc.lPitch = 108; | |
2132 | 4233 LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1); |
0 | 4234 *pOutSurface = (void *)pDesc.lpSurface; |
4235 v4 = pDesc.dwReserved; | |
2152 | 4236 }*/ |
0 | 4237 *pOutPixelsPerRow = v4 >> 1; |
4238 } | |
4239 | |
4240 //----- (004A17C7) -------------------------------------------------------- | |
4241 void Render::UnlockFrontBuffer() | |
4242 { | |
2152 | 4243 ErrD3D(pFrontBuffer4->Unlock(0)); |
0 | 4244 } |
4245 | |
4246 //----- (004A1814) -------------------------------------------------------- | |
4247 void Render::RestoreFrontBuffer() | |
4248 { | |
2152 | 4249 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST ) |
4250 pFrontBuffer4->Restore(); | |
0 | 4251 } |
4252 | |
4253 //----- (004A184C) -------------------------------------------------------- | |
2152 | 4254 void Render::RestoreBackBuffer() |
4255 { | |
4256 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST ) | |
4257 pBackBuffer4->Restore(); | |
0 | 4258 } |
4259 | |
4260 //----- (004A18F5) -------------------------------------------------------- | |
4261 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4262 { | |
2152 | 4263 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); |
0 | 4264 } |
4265 | |
4266 //----- (004A194A) -------------------------------------------------------- | |
4267 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
4268 { | |
4269 IDirectDrawSurface *pFront; // eax@3 | |
4270 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
4271 | |
2152 | 4272 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4273 { |
4274 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4275 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4276 } | |
2152 | 4277 /*else |
0 | 4278 { |
4279 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4280 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
2152 | 4281 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4282 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 4283 } |
4284 | |
4285 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4286 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4287 { |
0 | 4288 unsigned int v7; // edx@6 |
2166 | 4289 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4290 if (uNumBillboardsToDraw >= 999 ) |
0 | 4291 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4292 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4293 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4294 uNumBillboardsToDraw = 1; |
0 | 4295 return 0; |
4296 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4297 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4298 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4299 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4300 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4301 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4302 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4303 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4304 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4305 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4306 |
2166 | 4307 if (z > pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4308 { |
4309 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
4310 v7 = pRenderer->uNumBillboardsToDraw; | |
4311 else | |
4312 { | |
4313 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4314 { | |
2166 | 4315 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
0 | 4316 { |
2166 | 4317 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], |
4318 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - (i + 1)], | |
4319 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
0 | 4320 } |
4321 } | |
4322 ++v7; | |
4323 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4324 uNumBillboardsToDraw++; |
0 | 4325 return v7; |
4326 } | |
2166 | 4327 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4328 { |
4329 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4330 { | |
2166 | 4331 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
4332 { | |
4333 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], | |
4334 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw -(i + 1)], | |
4335 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
4336 } | |
4337 } | |
717 | 4338 uNumBillboardsToDraw++; |
4339 return v7; | |
0 | 4340 } |
4341 return v7; | |
4342 } | |
4343 | |
4344 //----- (004A1E9D) -------------------------------------------------------- | |
4345 unsigned int Render::GetBillboardDrawListSize() | |
4346 { | |
4347 return pRenderer->uNumBillboardsToDraw; | |
4348 } | |
4349 | |
4350 //----- (004A1EA3) -------------------------------------------------------- | |
4351 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
4352 { | |
2002 | 4353 return pRenderer->pBillboardRenderListD3D[uBillboardID].sParentBillboardID; |
0 | 4354 } |
4355 | |
4356 //----- (004A1EB6) -------------------------------------------------------- | |
4357 void Render::BeginSceneD3D() | |
4358 { | |
4359 if (!uNumD3DSceneBegins++) | |
4360 { | |
2154 | 4361 //if (pRenderD3D) |
0 | 4362 { |
4363 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
4364 pRenderer->uNumBillboardsToDraw = 0; | |
4365 pRenderD3D->pDevice->BeginScene(); | |
1390 | 4366 |
0 | 4367 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
4368 uFogColor = GetLevelFogColor(); | |
4369 else | |
4370 uFogColor = 0; | |
4371 | |
4372 if ( uFogColor & 0xFF000000 ) | |
4373 { | |
4374 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
4375 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
4376 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4377 bUsingSpecular = true; | |
4378 } | |
4379 else | |
4380 { | |
4381 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
4382 bUsingSpecular = 0; | |
4383 } | |
4384 } | |
2154 | 4385 /*else |
0 | 4386 { |
4387 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
4388 if (pTargetSurface) | |
4389 field_18_locked_pitch = uTargetSurfacePitch; | |
4390 else | |
4391 --uNumD3DSceneBegins; | |
2154 | 4392 }*/ |
0 | 4393 } |
4394 } | |
4395 | |
4396 //----- (004A1FE1) -------------------------------------------------------- | |
4397 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
4398 { | |
4399 --uNumD3DSceneBegins; | |
4400 if (uNumD3DSceneBegins) | |
4401 return; | |
4402 | |
4403 if (pRenderD3D) | |
4404 { | |
4405 pGame->draw_debug_outlines(); | |
161 | 4406 DoRenderBillboards_D3D(); |
0 | 4407 pGame->pStru6Instance->RenderSpecialEffects(); |
4408 pRenderD3D->pDevice->EndScene(); | |
4409 } | |
4410 else | |
4411 pGame->pStru6Instance->RenderSpecialEffects(); | |
4412 } | |
4413 | |
4414 //----- (004A2031) -------------------------------------------------------- | |
349 | 4415 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
4416 { | |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4417 // __debugbreak(); // should not fire outside decal builder |
349 | 4418 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 4419 } |
4420 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4421 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 4422 { |
4423 int v5; // ebx@1 | |
4424 int v6; // edi@1 | |
4425 int v8; // eax@7 | |
4426 float v9; // eax@12 | |
4427 float *v10; // esi@12 | |
4428 float v11; // ecx@14 | |
4429 double v12; // st7@14 | |
4430 double v13; // st7@14 | |
4431 double v14; // st7@14 | |
4432 signed int v15; // eax@14 | |
4433 int v16; // eax@15 | |
4434 float v17; // ST48_4@15 | |
4435 char v18; // zf@17 | |
4436 int v19; // eax@18 | |
4437 int v20; // eax@18 | |
4438 int v21; // edx@20 | |
4439 signed int v22; // ecx@20 | |
4440 int v23; // eax@20 | |
4441 const char *v24; // ST4C_4@20 | |
4442 unsigned int v25; // ST50_4@20 | |
4443 int v26; // ST54_4@20 | |
4444 int v27; // eax@20 | |
4445 _UNKNOWN *v28; // eax@21 | |
4446 int v29; // ecx@23 | |
4447 int v30; // eax@23 | |
4448 int v31; // eax@23 | |
4449 int v32; // eax@24 | |
4450 int v33; // eax@25 | |
4451 int v34; // eax@25 | |
4452 int v35; // eax@25 | |
4453 int v36; // eax@25 | |
4454 signed int v37; // ecx@26 | |
4455 int v38; // eax@26 | |
4456 _UNKNOWN *v39; // eax@27 | |
4457 int v40; // edx@28 | |
4458 int v41; // eax@29 | |
4459 int v42; // eax@29 | |
4460 int v43; // eax@29 | |
4461 int v44; // eax@29 | |
4462 unsigned int v46; // eax@29 | |
4463 int v47; // eax@30 | |
4464 int v48; // eax@30 | |
4465 int v49; // eax@30 | |
4466 double v52; // st6@35 | |
4467 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
4468 int v57; // [sp+5Ch] [bp-Ch]@3 | |
4469 signed int v59; // [sp+60h] [bp-8h]@12 | |
4470 int v61; // [sp+64h] [bp-4h]@4 | |
4471 int i; | |
4472 | |
4473 v6 = (int)this; | |
4474 v5 = 0; | |
4475 if (!this->uNumD3DSceneBegins) | |
4476 return; | |
4477 | |
4478 | |
4479 | |
4480 | |
186 | 4481 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 4482 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
4483 if (this->bUsingSpecular) | |
4484 { | |
186 | 4485 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4486 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4487 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 4488 } |
4489 | |
4490 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
4491 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
1637 | 4492 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4493 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); |
4494 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
4495 pVertices[0].specular = 0; | |
4496 pVertices[0].texcoord.x = array_50AC10[0].u; | |
4497 pVertices[0].texcoord.y = array_50AC10[0].v; | |
4498 | |
4499 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
4500 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
1637 | 4501 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4502 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); |
4503 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
4504 pVertices[1].specular = 0; | |
4505 pVertices[1].texcoord.x = array_50AC10[3].u; | |
4506 pVertices[1].texcoord.y = array_50AC10[3].v; | |
4507 | |
4508 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
4509 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
1637 | 4510 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4511 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); |
4512 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
4513 pVertices[2].specular = 0; | |
4514 pVertices[2].texcoord.x = array_50AC10[1].u; | |
4515 pVertices[2].texcoord.y = array_50AC10[1].v; | |
4516 | |
4517 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
4518 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
4519 | |
4520 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
4521 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
1637 | 4522 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4523 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); |
4524 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
4525 pVertices[5].specular = 0; | |
4526 pVertices[5].texcoord.x = array_50AC10[2].u; | |
4527 pVertices[5].texcoord.y = array_50AC10[2].v; | |
4528 | |
4529 | |
4530 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4531 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
4532 | |
186 | 4533 }*/ |
4534 | |
0 | 4535 //----- (004A26BC) -------------------------------------------------------- |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4536 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
186 | 4537 { |
4538 //RenderVertexSoft *pVertices; // esi@0 | |
4539 //int v7; // edi@1 | |
0 | 4540 unsigned int v8; // ebx@1 |
4541 LightmapBuilder *v9; // esi@3 | |
4542 unsigned int v10; // edx@3 | |
4543 int v11; // eax@5 | |
4544 int v12; // eax@11 | |
4545 char *v13; // esi@11 | |
4546 double v14; // st7@13 | |
4547 double v15; // st7@13 | |
4548 signed int v16; // eax@13 | |
4549 int v17; // ecx@13 | |
4550 double v18; // st7@13 | |
4551 float v19; // ST78_4@14 | |
4552 int v20; // eax@14 | |
4553 char v21; // zf@16 | |
4554 HRESULT v22; // eax@17 | |
4555 HRESULT v23; // eax@17 | |
4556 HRESULT v24; // eax@19 | |
4557 HRESULT v25; // eax@19 | |
4558 unsigned int v26; // ecx@19 | |
4559 char *v27; // eax@20 | |
4560 HRESULT v28; // eax@22 | |
4561 HRESULT v29; // eax@22 | |
4562 HRESULT v30; // eax@23 | |
4563 HRESULT v31; // eax@24 | |
4564 HRESULT v32; // eax@24 | |
4565 HRESULT v33; // eax@24 | |
4566 HRESULT v34; // eax@24 | |
4567 HRESULT v35; // eax@25 | |
4568 HRESULT v36; // eax@25 | |
4569 unsigned int v37; // ecx@25 | |
4570 char *v38; // eax@26 | |
4571 int v39; // edx@27 | |
4572 HRESULT v40; // eax@28 | |
4573 HRESULT v41; // eax@28 | |
4574 HRESULT v42; // eax@28 | |
4575 HRESULT v43; // eax@28 | |
4576 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
4577 unsigned int v45; // eax@28 | |
4578 HRESULT v46; // eax@29 | |
4579 HRESULT v47; // eax@29 | |
4580 HRESULT v48; // eax@29 | |
186 | 4581 //IDirect3DDevice3 *v49; // eax@35 |
0 | 4582 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
4583 int v51; // eax@40 | |
4584 char *v52; // esi@40 | |
4585 double v53; // st7@42 | |
4586 double v54; // st7@42 | |
4587 signed int v55; // eax@42 | |
4588 int v56; // ecx@42 | |
4589 double v57; // st7@42 | |
4590 float v58; // ST7C_4@43 | |
4591 int v59; // eax@43 | |
186 | 4592 //signed int v60; // [sp+78h] [bp-14h]@31 |
4593 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 4594 const char *v62; // [sp+80h] [bp-Ch]@0 |
4595 const char *v63; // [sp+80h] [bp-Ch]@19 | |
4596 int v64; // [sp+84h] [bp-8h]@0 | |
4597 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
4598 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
4599 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 4600 int a7; |
4601 | |
4602 //v7 = (int)this; | |
0 | 4603 v8 = 0; |
186 | 4604 if (!this->uNumD3DSceneBegins) |
75 | 4605 return; |
4606 if ( uNumVertices < 3) | |
4607 return; | |
4608 | |
186 | 4609 //v61 = pVertices; |
4610 | |
75 | 4611 /* v9 = pGame->pLightmapBuilder; |
0 | 4612 v65 = v9; |
75 | 4613 v10 = v9->std__vector_000004_size;*/ |
2155 | 4614 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 4615 { |
638 | 4616 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 4617 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); |
0 | 4618 } |
4619 else | |
4620 { | |
186 | 4621 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 4622 byte_4D864C && pGame->uFlags & 2 ) |
4623 { | |
186 | 4624 if (clampAtTextureBorders) |
4625 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 4626 else |
186 | 4627 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
4628 | |
4629 if (transparent || this->bUsingSpecular) | |
4630 { | |
4631 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4632 if (transparent) | |
0 | 4633 { |
186 | 4634 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
4635 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
4636 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
4637 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 4638 } |
4639 else | |
4640 { | |
186 | 4641 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
4642 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 4643 } |
186 | 4644 } |
1073 | 4645 |
4646 for (uint i = 0; i < uNumVertices; ++i) | |
4647 { | |
4648 | |
4649 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4650 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4651 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4652 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4653 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4654 if ( this->bUsingSpecular ) | |
0 | 4655 { |
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
|
4656 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4657 } |
1073 | 4658 else |
4659 { | |
4660 d3d_vertex_buffer[i].specular = 0; | |
4661 } | |
4662 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4663 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4664 } | |
4665 | |
4666 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4667 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
186 | 4668 if (transparent) |
4669 { | |
4670 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
4671 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4672 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4673 } |
4674 } | |
4675 else | |
4676 { | |
1073 | 4677 for (uint i = 0; i < uNumVertices; ++i) |
4678 { | |
4679 | |
4680 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4681 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4682 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4683 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4684 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4685 if ( this->bUsingSpecular ) | |
0 | 4686 { |
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
|
4687 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4688 } |
1073 | 4689 else |
4690 { | |
4691 d3d_vertex_buffer[i].specular = 0; | |
4692 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4693 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
1073 | 4694 d3d_vertex_buffer[i].specular = v20; |
4695 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4696 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4697 } | |
186 | 4698 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4699 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4700 if (pRenderer->bUsingSpecular) | |
4701 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 4702 |
4703 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 4704 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 4705 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4706 d3d_vertex_buffer, |
0 | 4707 uNumVertices, |
4708 16)); | |
4709 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 4710 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 4711 //(*(void (**)(void))(*(int *)v63 + 88))(); |
1394 | 4712 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
1073 | 4713 for (uint i = 0; i < uNumVertices; ++i) |
4714 { | |
4715 d3d_vertex_buffer[i].diffuse = -1; | |
4716 } | |
0 | 4717 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 4718 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4719 if ( !pRenderer->bUsingSpecular ) |
4720 { | |
186 | 4721 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4722 } | |
4723 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4724 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4725 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
4726 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4727 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4728 d3d_vertex_buffer, |
0 | 4729 uNumVertices, |
4730 16)); | |
4731 if ( pRenderer->bUsingSpecular ) | |
4732 { | |
186 | 4733 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4734 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 4735 for (uint i = 0; i < uNumVertices; ++i) |
4736 { | |
4737 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4738 d3d_vertex_buffer[i].specular = 0; | |
4739 } | |
4740 | |
75 | 4741 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 4742 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4743 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
4744 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4745 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4746 d3d_vertex_buffer, |
0 | 4747 uNumVertices, |
4748 16)); | |
186 | 4749 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4750 //v44 = pRenderer->pRenderD3D->pDevice; |
4751 v45 = GetLevelFogColor(); | |
4752 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
4753 v8 = 0; | |
4754 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
4755 } | |
186 | 4756 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4757 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4758 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
4759 } | |
4760 } | |
186 | 4761 |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
4762 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
1642 | 4763 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
|
4764 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 4765 } |
4766 // 4A26BC: could not find valid save-restore pair for esi | |
4767 // 4D864C: using guessed type char byte_4D864C; | |
4768 | |
4769 //----- (004A2DA3) -------------------------------------------------------- | |
1923 | 4770 void Render::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
852 | 4771 { |
67 | 4772 int v7; // eax@7 |
4773 | |
4774 if ( !this->uNumD3DSceneBegins ) | |
4775 return; | |
4776 if ( uNumVertices >= 3 ) | |
4777 { | |
186 | 4778 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 4779 if ( this->bUsingSpecular ) |
4780 { | |
186 | 4781 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4782 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4783 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 4784 } |
1427 | 4785 for ( uint i = 0; i < uNumVertices; ++i ) |
67 | 4786 { |
4787 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4788 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4789 pVertices[i].pos.z = 0.99989998; | |
168 | 4790 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 4791 |
840 | 4792 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 4793 v7 = 0; |
4794 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
|
4795 v7 = sub_47C3D7_get_fog_specular(0, 1, array_50AC10[i].vWorldViewPosition.x); |
67 | 4796 pVertices[i].specular = v7; |
4797 pVertices[i].texcoord.x = array_50AC10[i].u; | |
4798 pVertices[i].texcoord.y = array_50AC10[i].v; | |
4799 } | |
4800 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4801 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 4802 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 4803 } |
4804 } | |
4805 | |
4806 //----- (004A2ED5) -------------------------------------------------------- | |
1923 | 4807 void Render::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
0 | 4808 { |
4809 int v5; // eax@3 | |
4810 | |
4811 if ( this->uNumD3DSceneBegins ) | |
4812 { | |
1923 | 4813 if ( uNumVertices >= 3 ) |
0 | 4814 { |
186 | 4815 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1923 | 4816 v5 = 31 - (pSkyPolygon->dimming_level & 0x1F); |
638 | 4817 if ( v5 < pOutdoor->max_terrain_dimming_level ) |
4818 v5 = pOutdoor->max_terrain_dimming_level; | |
1937 | 4819 for (uint i = 0; i < uNumVertices; ++i) |
4820 { | |
4821 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
4822 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
1999 | 4823 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); |
1937 | 4824 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; |
4825 d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); | |
4826 d3d_vertex_buffer[i].specular = 0; | |
4827 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
4828 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
4829 } | |
1923 | 4830 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
1936 | 4831 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
4832 d3d_vertex_buffer, uNumVertices, 28)); | |
0 | 4833 } |
4834 } | |
4835 } | |
4836 | |
1390 | 4837 //----- (00479A53) -------------------------------------------------------- |
1923 | 4838 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID) |
1390 | 4839 { |
4840 BLVFace *pFace; // esi@1 | |
4841 double v5; // st7@3 | |
4842 signed __int64 v6; // qax@3 | |
4843 int v12; // edx@7 | |
4844 int v13; // eax@7 | |
4845 void *v15; // ecx@9 | |
4846 int v17; // edi@9 | |
4847 double v18; // st7@9 | |
4848 signed int v19; // ebx@9 | |
4849 void *v20; // ecx@9 | |
4850 int v21; // ebx@11 | |
4851 int v22; // eax@14 | |
4852 signed __int64 v23; // qtt@16 | |
4853 double v24; // st7@16 | |
4854 unsigned __int8 v25; // sf@16 | |
4855 unsigned __int8 v26; // of@16 | |
4856 double v28; // st7@20 | |
4857 char *v29; // ebx@20 | |
4858 char *v30; // edx@20 | |
4859 unsigned __int8 v31; // c0@21 | |
4860 unsigned __int8 v32; // c3@21 | |
4861 double v33; // st6@23 | |
4862 char *v34; // esi@30 | |
4863 const void *v35; // ecx@31 | |
4864 int v36; // eax@31 | |
4865 const void *v37; // edi@31 | |
4866 signed __int64 v38; // qax@31 | |
4867 int v39; // ecx@31 | |
4868 int v40; // ebx@33 | |
4869 int v41; // eax@36 | |
4870 signed __int64 v42; // qtt@39 | |
4871 int v43; // eax@39 | |
4872 char v44; // zf@39 | |
4873 double v45; // st7@39 | |
4874 double v46; // st7@39 | |
4875 unsigned int v47; // edx@40 | |
4876 double v48; // st7@41 | |
4877 RenderVertexSoft *v49; // ebx@41 | |
4878 void *v50; // edi@43 | |
4879 double v51; // st7@46 | |
4880 RenderVertexSoft *v52; // edx@46 | |
4881 void *v53; // edi@48 | |
4882 signed int v59; // [sp-4h] [bp-178h]@17 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4883 struct Polygon *v60; // [sp+0h] [bp-174h]@17 |
1390 | 4884 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 |
1981 | 4885 struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6 |
1390 | 4886 unsigned int v63; // [sp+120h] [bp-54h]@7 |
4887 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
4888 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4889 //float v67; // [sp+130h] [bp-44h]@7 |
1390 | 4890 __int64 v69; // [sp+13Ch] [bp-38h]@3 |
4891 int v70; // [sp+144h] [bp-30h]@3 | |
4892 int X; // [sp+148h] [bp-2Ch]@9 | |
4893 int v72; // [sp+14Ch] [bp-28h]@7 | |
4894 float v73; // [sp+150h] [bp-24h]@16 | |
4895 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
1999 | 4896 unsigned int v74_; // [sp+154h] [bp-20h]@3 |
1390 | 4897 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 |
4898 float v76; // [sp+15Ch] [bp-18h]@9 | |
4899 int v77; // [sp+160h] [bp-14h]@9 | |
4900 int v78; // [sp+164h] [bp-10h]@7 | |
4901 void *v79; // [sp+168h] [bp-Ch]@9 | |
4902 float v80; // [sp+16Ch] [bp-8h]@3 | |
4903 const void *v81; // [sp+170h] [bp-4h]@7 | |
4904 | |
4905 pFace = &pIndoor->pFaces[uFaceID]; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4906 //for floor and wall(for example Selesta)------------------- |
1644 | 4907 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor) |
4908 { | |
4909 int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x; | |
4910 int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y; | |
4911 for (uint i = 0; i < uNumVertices; ++i) | |
4912 { | |
4913 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f; | |
4914 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f; | |
4915 } | |
4916 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0); | |
1390 | 4917 return; |
4918 } | |
1981 | 4919 //--------------------------------------- |
4920 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179 | |
1641 | 4921 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) |
1390 | 4922 * 65536.0) |
1922 | 4923 + (double)pBLVRenderParams->uViewportCenterY); |
1981 | 4924 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0 |
4925 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183 | |
1641 | 4926 - (double)pBLVRenderParams->fov_rad_fixpoint |
1644 | 4927 / ((cos(v5) * 16192.0 + 0.0000001) |
1390 | 4928 * 65535.0) |
1922 | 4929 * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); |
1644 | 4930 |
1999 | 4931 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); |
1981 | 4932 pSkyPolygon.Create_48607B(&stru_8019C8); |
4933 pSkyPolygon.uTileBitmapID = pFace->uBitmapID; | |
4934 | |
4935 pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID); | |
4936 if ( !pSkyPolygon.pTexture ) | |
1390 | 4937 return; |
1644 | 4938 |
1981 | 4939 pSkyPolygon.dimming_level = 0; |
4940 pSkyPolygon.uNumVertices = uNumVertices; | |
4941 | |
4942 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4943 pSkyPolygon.v_18.y = 0; | |
4944 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4945 | |
1644 | 4946 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices])); |
1981 | 4947 pSkyPolygon.field_24 = 0x2000000; |
1644 | 4948 |
4949 extern float _calc_fov(int viewport_width, int angle_degree); | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4950 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4951 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); |
1644 | 4952 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74); |
1981 | 4953 v12 = pSkyPolygon.pTexture->uWidthMinus1; |
4954 v13 = pSkyPolygon.pTexture->uHeightMinus1; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4955 //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth; |
1390 | 4956 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; |
4957 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
4958 v78 = 0; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4959 //v81 = 0; |
1981 | 4960 float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight; |
4961 if ( (signed int)pSkyPolygon.uNumVertices <= 0 ) | |
4962 return; | |
1644 | 4963 |
4964 int _507D30_idx = 0; | |
1999 | 4965 for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ ) |
1390 | 4966 { |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4967 //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)); |
2207 | 4968 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1981 | 4969 v74 = v77 + pSkyPolygon.ptr_38->angle_from_north; |
4970 | |
2207 | 4971 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1999 | 4972 v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east; |
1981 | 4973 |
2207 | 4974 v79 = (void *)(fixpoint_mul(pSkyPolygon.v_18.z, v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))); |
1644 | 4975 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX); |
4976 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0; | |
1981 | 4977 v19 = -pSkyPolygon.field_24; |
4978 v77 = -pSkyPolygon.field_24; | |
4979 X = (int)((char *)v79 + pSkyPolygon.v_18.x); | |
1390 | 4980 LODWORD(v76) = (signed __int64)v18; |
4981 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
4982 while ( 1 ) | |
4983 { | |
4984 v79 = v20; | |
4985 if ( !X ) | |
4986 goto LABEL_14; | |
4987 v21 = abs(v19 >> 14); | |
1999 | 4988 if ( v21 <= abs(X) )//0x800 <= 0x28652 |
1390 | 4989 break; |
4990 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
4991 break; | |
4992 v19 = v77; | |
4993 v20 = v79; | |
4994 LABEL_14: | |
2207 | 4995 v79 = (void *)fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); |
4996 v22 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); | |
1390 | 4997 --LODWORD(v76); |
4998 v20 = (char *)v20 + v72; | |
1981 | 4999 X = v22 + pSkyPolygon.v_18.x; |
1390 | 5000 v78 = 1; |
5001 } | |
5002 if ( !v78 ) | |
5003 { | |
5004 LODWORD(v23) = v77 << 16; | |
1981 | 5005 HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000 |
1997 | 5006 v79 = (void *)(v23 / X);//X = FFFF9014(-28652) |
1390 | 5007 v77 = v17; |
2207 | 5008 signed __int64 s = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v17);// s = 0xFFFFFFFF FFFF3EE6 |
5009 LODWORD(v80) = v66 + ((signed int)fixpoint_mul(SLODWORD(s), v23 / X) >> 4); | |
1981 | 5010 array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); |
5011 | |
2207 | 5012 signed __int64 s2 = v74_ + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v17); |
5013 LODWORD(v80) = v63 + ((signed int)fixpoint_mul(SLODWORD(s2), v23 / X) >> 4); | |
1981 | 5014 array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68; |
5015 | |
2207 | 5016 v77 = fixpoint_mul(SLODWORD(s), v23 / X); |
5017 LODWORD(v73) = fixpoint_mul(SLODWORD(s2), v23 / X); | |
1644 | 5018 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5019 |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5020 //if ( (int)v81 >= pSkyPolygon.uNumVertices ) |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5021 //{ |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5022 // pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5023 // pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5024 // return; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5025 //} |
1390 | 5026 continue; |
5027 } | |
5028 break; | |
5029 } | |
1999 | 5030 if ( _507D30_idx >= pSkyPolygon.uNumVertices ) |
5031 { | |
5032 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, | |
5033 pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5034 return; | |
5035 } | |
1390 | 5036 LODWORD(v73) = 0; |
5037 v80 = v76; | |
1981 | 5038 if ( (signed int)pSkyPolygon.uNumVertices > 0 ) |
1390 | 5039 { |
5040 v28 = (double)SLODWORD(v76); | |
5041 LODWORD(v76) = (int)(char *)array_50AC10 + 28; | |
1997 | 5042 uint i = 0; |
5043 for ( v78 = pSkyPolygon.uNumVertices; v78; --v78 ) | |
5044 { | |
1390 | 5045 ++LODWORD(v73); |
1997 | 5046 memcpy(&array_50AC10[i], &array_507D30[i], 0x30u); |
1390 | 5047 LODWORD(v76) += 48; |
1997 | 5048 if ( v28 < array_507D30[i].vWorldViewProjY | v28 == array_507D30[i].vWorldViewProjY |
5049 || v28 >= array_507D30[i + 1].vWorldViewProjY ) | |
5050 { | |
5051 if ( v28 >= array_507D30[i].vWorldViewProjY || v28 <= array_507D30[i + 1].vWorldViewProjY ) | |
5052 { | |
5053 i++; | |
5054 continue; | |
5055 } | |
5056 v33 = (array_507D30[i + 1].vWorldViewProjX - array_507D30[i].vWorldViewProjX) * v28 / (array_507D30[i + 1].vWorldViewProjY - array_507D30[i].vWorldViewProjY) | |
5057 + array_507D30[i + 1].vWorldViewProjX; | |
1390 | 5058 } |
5059 else | |
5060 { | |
1997 | 5061 v33 = (array_507D30[i].vWorldViewProjX - array_507D30[i + 1].vWorldViewProjX) * v28 / (array_507D30[i].vWorldViewProjY - array_507D30[i + 1].vWorldViewProjY) |
5062 + array_507D30[i].vWorldViewProjX; | |
5063 } | |
5064 array_50AC10[i + 1].vWorldViewProjX = v33; | |
1390 | 5065 ++LODWORD(v73); |
5066 *(unsigned int *)LODWORD(v76) = v28; | |
5067 LODWORD(v76) += 48; | |
1997 | 5068 i++; |
5069 } | |
1390 | 5070 } |
5071 if ( SLODWORD(v73) <= 0 ) | |
5072 goto LABEL_40; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5073 //v34 = (char *)&array_50AC10[0].vWorldViewProjY; |
1997 | 5074 uint j = 0; |
1390 | 5075 v65 = v77 >> 14; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5076 //HIDWORD(v69) = LODWORD(v73); |
1997 | 5077 for ( int t = (int)LODWORD(v73); t > 1; t-- ) |
5078 { | |
5079 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjY)); | |
5080 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5081 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east; |
2207 | 5082 //v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v35); |
5083 v36 = (int)(fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, (int)v35) + pSkyPolygon.ptr_38->angle_from_north); | |
1997 | 5084 |
1390 | 5085 v81 = v35; |
5086 v74 = v36; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5087 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south; |
2207 | 5088 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, (int)v35); |
1390 | 5089 v78 = (int)v35; |
1981 | 5090 v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east); |
2207 | 5091 //v81 = (const void *)pSkyPolygon.v_18.z; |
5092 v78 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v35); | |
5093 v37 = (const void *)(v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX)); | |
1997 | 5094 v38 = (signed __int64)(array_50AC10[j].vWorldViewProjY - 1.0); |
1390 | 5095 v81 = 0; |
5096 LODWORD(v76) = v38; | |
5097 v39 = v72 * (v70 - v38); | |
5098 while ( 1 ) | |
5099 { | |
5100 v78 = v39; | |
5101 if ( !X ) | |
5102 goto LABEL_36; | |
5103 v40 = abs(X); | |
5104 if ( abs((signed __int64)v65) <= v40 ) | |
5105 break; | |
5106 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5107 break; | |
5108 v39 = v78; | |
5109 LABEL_36: | |
1981 | 5110 v78 = pSkyPolygon.v_18.z; |
2207 | 5111 v41 = fixpoint_mul(pSkyPolygon.v_18.z, v39); |
1390 | 5112 --LODWORD(v76); |
5113 v39 += v72; | |
1981 | 5114 X = v41 + pSkyPolygon.v_18.x; |
1390 | 5115 v81 = (const void *)1; |
5116 } | |
5117 if ( v81 ) | |
5118 { | |
1981 | 5119 v79 = (void *)pSkyPolygon.v_18.z; |
1390 | 5120 v78 = 2 * LODWORD(v76); |
2207 | 5121 v81 = (const void *)fixpoint_mul(pSkyPolygon.v_18.z, (((double)v70 - ((double)(2 * LODWORD(v76)) - array_50AC10[j].vWorldViewProjY)) |
5122 * (double)v72)); | |
1981 | 5123 X = (int)((char *)v81 + pSkyPolygon.v_18.x); |
1390 | 5124 } |
5125 LODWORD(v42) = v77 << 16; | |
5126 HIDWORD(v42) = v77 >> 16; | |
5127 v79 = (void *)(v42 / X); | |
5128 v81 = v37; | |
1997 | 5129 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5130 //v78 = pSkyPolygon.ptr_38->angle_from_west; |
2207 | 5131 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); |
5132 v43 = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); | |
1390 | 5133 v74 = (unsigned int)v37; |
5134 LODWORD(v76) = v43; | |
1997 | 5135 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5136 //v78 = pSkyPolygon.ptr_38->angle_from_south; |
2207 | 5137 v75 = (RenderVertexSoft *)((char *)v75 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, (int)v37)); |
5138 //v74 = fixpoint_mul(v43, v42 / X); | |
5139 v81 = (const void *)fixpoint_mul((int)v75, v42 / X); | |
1997 | 5140 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5141 //v34 += 48; |
2207 | 5142 //v78 = v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4); |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5143 //v44 = HIDWORD(v69)-- == 1; |
2207 | 5144 //v45 = (double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022; |
5145 //v78 = v63 + ((signed int)fixpoint_mul((int)v75, v42 / X) >> 4); | |
5146 array_50AC10[j].u = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); | |
5147 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
|
5148 //v46 = (double)(signed int)v79; |
1997 | 5149 array_50AC10[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79; |
5150 array_50AC10[j]._rhw = 65536.0 / (double)(signed int)v79; | |
5151 ++j; | |
5152 } | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5153 //while ( !v44 ); |
1390 | 5154 LABEL_40: |
1997 | 5155 uint i = 0; |
1390 | 5156 if ( SLODWORD(v73) > 0 ) |
5157 { | |
5158 v48 = (double)SLODWORD(v80); | |
1997 | 5159 for ( HIDWORD(v69) = LODWORD(v73); HIDWORD(v69); --HIDWORD(v69) ) |
5160 { | |
5161 if ( v48 >= array_50AC10[i].vWorldViewProjY ) | |
5162 { | |
5163 ++i; | |
5164 memcpy(&array_507D30[i], &array_50AC10[i], 0x30u); | |
5165 } | |
5166 } | |
5167 } | |
5168 pSkyPolygon.uNumVertices = i; | |
5169 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5170 int pNumVertices = 0; | |
1390 | 5171 if ( SLODWORD(v73) > 0 ) |
5172 { | |
5173 v51 = (double)SLODWORD(v80); | |
1997 | 5174 for ( v80 = v73; v80 != 0.0; --LODWORD(v80) ) |
5175 { | |
5176 if ( v51 <= array_50AC10[pNumVertices].vWorldViewProjY ) | |
5177 { | |
5178 ++pNumVertices; | |
5179 memcpy(&array_507D30[pNumVertices], &array_50AC10[pNumVertices], 0x30u); | |
5180 } | |
5181 } | |
5182 } | |
5183 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
1390 | 5184 } |
5185 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5186 |
0 | 5187 //----- (004A2FC0) -------------------------------------------------------- |
5188 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
5189 { | |
5190 //Render *v8; // edi@1 | |
5191 //unsigned int v9; // esi@3 | |
1072 | 5192 RenderVertexSoft *v12; // ecx@9 |
5193 RenderVertexD3D3 *v13; // eax@9 | |
0 | 5194 double v14; // st6@10 |
5195 int v15; // edx@10 | |
5196 Texture *v16; // edx@10 | |
5197 double v17; // st6@10 | |
5198 //char v18; // zf@10 | |
5199 Texture *v19; // edx@10 | |
595 | 5200 //Texture *v23; // edx@16 |
5201 //char *v24; // ecx@16 | |
5202 //char *v25; // eax@16 | |
5203 //double v26; // st6@17 | |
5204 //int v27; // esi@17 | |
5205 //double v28; // st6@17 | |
5206 //unsigned int v33; // ecx@18 | |
5207 //char *v34; // eax@19 | |
0 | 5208 //Texture *v45; // edx@23 |
5209 //char *v46; // ecx@23 | |
5210 //char *v47; // eax@23 | |
5211 //double v48; // st6@24 | |
5212 //int v49; // esi@24 | |
5213 //double v50; // st6@24 | |
5214 const char *v53; // [sp-Ch] [bp-20h]@21 | |
5215 //int v54; // [sp-8h] [bp-1Ch]@21 | |
5216 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
5217 const char *v56; // [sp+0h] [bp-14h]@0 | |
5218 int v57; // [sp+4h] [bp-10h]@0 | |
5219 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
5220 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
5221 //int a3a; // [sp+10h] [bp-4h]@4 | |
5222 | |
5223 //v8 = this; | |
5224 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
5225 return; | |
5226 | |
5227 //auto a3 = pFace; | |
5228 //auto a6 = uPackedID; | |
5229 //v59 = pGame->pLightmapBuilder; | |
5230 //v9 = v59->std__vector_000004_size; | |
5231 | |
2006 | 5232 int sCorrectedColor = uColor; |
0 | 5233 if (pGame->pLightmapBuilder->std__vector_000004_size) |
2006 | 5234 sCorrectedColor = -1; |
5235 pGame->AlterGamma_BLV(pFace, &sCorrectedColor); | |
0 | 5236 |
792 | 5237 |
5238 if (pFace->uAttributes & FACE_OUTLINED) | |
5239 { | |
5240 int color; | |
5241 if (GetTickCount() % 300 >= 150) | |
2006 | 5242 uColor = sCorrectedColor = 0xFF20FF20; |
5243 else uColor = sCorrectedColor = 0xFF109010; | |
792 | 5244 } |
5245 | |
2155 | 5246 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 5247 { |
5248 __debugbreak(); | |
5249 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 5250 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 5251 for (uint i = 0; i < uNumVertices; ++i) |
5252 { | |
5253 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5254 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5255 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5256 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5257 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
1072 | 5258 d3d_vertex_buffer[i].specular = 0; |
5259 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5260 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5261 } | |
5262 | |
186 | 5263 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5264 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
5265 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
5266 D3DPT_TRIANGLEFAN, | |
5267 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5268 d3d_vertex_buffer, |
0 | 5269 uNumVertices, |
5270 28)); | |
1394 | 5271 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
0 | 5272 } |
5273 else | |
5274 { | |
5275 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
5276 byte_4D864C && pGame->uFlags & 2) | |
5277 { | |
5278 for (uint i = 0; i < uNumVertices; ++i) | |
5279 { | |
186 | 5280 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
5281 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5282 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5283 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5284 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
186 | 5285 d3d_vertex_buffer[i].specular = 0; |
5286 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5287 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5288 } | |
5289 | |
5290 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 5291 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
5292 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5293 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5294 d3d_vertex_buffer, |
0 | 5295 uNumVertices, |
5296 28)); | |
5297 } | |
5298 else | |
5299 { | |
595 | 5300 for (uint i = 0; i < uNumVertices; ++i) |
5301 { | |
5302 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5303 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5304 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5305 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5306 d3d_vertex_buffer[i].diffuse = uColor; | |
5307 d3d_vertex_buffer[i].specular = 0; | |
5308 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5309 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5310 } | |
5311 //__debugbreak(); | |
5312 //if ( (signed int)uNumVertices > 0 ) | |
5313 //{ | |
5314 //v23 = pTex; | |
5315 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
5316 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
5317 //pTex = (Texture *)uNumVertices; | |
5318 //uint v18; | |
5319 //do | |
5320 //{ | |
5321 //v26 = *(float *)v24 * 0.061758894; | |
5322 //v27 = *((int *)v24 + 3); | |
5323 //*((int *)v25 + 4) = 0; | |
5324 //*((int *)v25 - 1) = v27; | |
5325 //*(int *)v25 = *((int *)v24 + 4); | |
5326 //*((int *)v25 + 3) = uColor; | |
5327 //v25 += 32; | |
5328 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
5329 //v28 = 1.0 / *(float *)v24; | |
5330 //v24 += 48; | |
5331 //v18 = pTex == (Texture *)1; | |
5332 //pTex = (Texture *)((char *)pTex - 1); | |
5333 //*((float *)v25 - 6) = v28; | |
0 | 5334 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 5335 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 5336 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 5337 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
5338 //} | |
5339 //while ( !v18 ); | |
5340 //} | |
0 | 5341 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 5342 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5343 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 5344 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5345 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5346 d3d_vertex_buffer, |
0 | 5347 uNumVertices, |
5348 28)); | |
595 | 5349 |
5350 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1394 | 5351 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
595 | 5352 |
5353 for (uint i = 0; i < uNumVertices; ++i) | |
2006 | 5354 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
595 | 5355 /*v33 = uNumVertices; |
0 | 5356 if ( (signed int)uNumVertices > 0 ) |
5357 { | |
186 | 5358 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 5359 do |
5360 { | |
5361 *(int *)v34 = uCorrectedColor; | |
5362 v34 += 32; | |
5363 --v33; | |
5364 } | |
5365 while ( v33 ); | |
595 | 5366 }*/ |
0 | 5367 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5368 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
5369 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5370 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5371 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5372 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
5373 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 5374 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5375 d3d_vertex_buffer, |
0 | 5376 uNumVertices, |
5377 28)); | |
186 | 5378 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
5379 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5380 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 5381 } |
5382 } | |
5383 } | |
5384 // 4D864C: using guessed type char byte_4D864C; | |
5385 | |
5386 //----- (004A43B1) -------------------------------------------------------- | |
717 | 5387 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
5388 { | |
5389 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
5390 //double v5; // st7@2 | |
5391 //float v6; // ST08_4@2 | |
0 | 5392 unsigned int v7; // eax@2 |
717 | 5393 //int v8; // ecx@2 |
5394 //unsigned int v9; // esi@2 | |
5395 //Sprite *v10; // edi@5 | |
0 | 5396 signed int v11; // eax@9 |
5397 signed int v12; // eax@9 | |
717 | 5398 //double v13; // st7@12 |
5399 //double v14; // st6@12 | |
0 | 5400 double v15; // st5@12 |
5401 double v16; // st4@12 | |
5402 double v17; // st3@12 | |
5403 double v18; // st2@12 | |
5404 int v19; // ecx@14 | |
5405 double v20; // st3@14 | |
5406 int v21; // ecx@16 | |
5407 double v22; // st3@16 | |
717 | 5408 //IDirect3DTexture2 *v23; // eax@18 |
5409 //signed int v24; // [sp+18h] [bp-18h]@5 | |
5410 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
5411 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 5412 float v27; // [sp+24h] [bp-Ch]@5 |
5413 int v28; // [sp+28h] [bp-8h]@2 | |
5414 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 5415 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 5416 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 5417 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 5418 float a1; // [sp+40h] [bp+10h]@5 |
5419 | |
717 | 5420 //v26 = this; |
0 | 5421 if ( this->uNumD3DSceneBegins ) |
5422 { | |
717 | 5423 //v4 = pSoftBillboard; |
5424 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
5425 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
5426 //v6 = pSoftBillboard->zbuffer_depth; | |
5427 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
5428 //v8 = dimming_level; | |
5429 //v9 = v7; | |
657 | 5430 v28 = dimming_level & 0xFF000000; |
5431 if ( dimming_level & 0xFF000000 ) | |
2155 | 5432 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3; |
0 | 5433 else |
2155 | 5434 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent; |
717 | 5435 //v10 = a3; |
5436 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
5437 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
2002 | 5438 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID; |
717 | 5439 //v25 = pSoftBillboard->uScreenSpaceX; |
5440 //v24 = pSoftBillboard->uScreenSpaceY; | |
5441 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
5442 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
5443 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5444 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
5445 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5446 v31 = v31 * -1.0; |
2006 | 5447 if ( pSoftBillboard->sTintColor && this->bTinting ) |
717 | 5448 { |
5449 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
2006 | 5450 v12 = BlendColors(pSoftBillboard->sTintColor, v11); |
0 | 5451 if ( v28 ) |
5452 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
5453 } | |
5454 else | |
5455 { | |
717 | 5456 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
5457 } | |
5458 //v13 = (double)v25; | |
1390 | 5459 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; |
5460 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
5461 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
717 | 5462 //v14 = (double)v24; |
5463 //v32 = v14; | |
1390 | 5464 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; |
717 | 5465 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); |
1390 | 5466 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; |
717 | 5467 v16 = 1.0 / pSoftBillboard->zbuffer_depth; |
1390 | 5468 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; |
5469 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
5470 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
717 | 5471 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); |
5472 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
5473 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5474 v17 = v17 * -1.0; |
1390 | 5475 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; |
5476 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
5477 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
5478 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
5479 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
5480 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
5481 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
5482 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
717 | 5483 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; |
5484 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5485 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5486 v20 = v20 * -1.0; |
1390 | 5487 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; |
5488 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
5489 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
5490 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
5491 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
5492 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
5493 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
5494 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
717 | 5495 v21 = pSprite->uBufferHeight - pSprite->uAreaY; |
5496 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5497 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5498 v22 = v22 * -1.0; |
1390 | 5499 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; |
5500 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
5501 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
5502 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
5503 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
5504 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
5505 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
5506 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
717 | 5507 //v23 = pSprite->pTexture; |
5508 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
5509 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
5510 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 5511 } |
5512 } | |
5513 | |
5514 //----- (004A354F) -------------------------------------------------------- | |
5515 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5516 { | |
743 | 5517 //double v5; // st7@3 |
5518 //float v6; // ST20_4@3 | |
5519 //float v7; // ST00_4@3 | |
0 | 5520 unsigned int v8; // esi@3 |
743 | 5521 //int v9; // eax@3 |
5522 //int v10; // ebx@3 | |
0 | 5523 float v11; // ST28_4@3 |
743 | 5524 //double v12; // st7@3 |
5525 //float v13; // ST24_4@3 | |
5526 //double v14; // st6@3 | |
5527 //float v15; // ST1C_4@3 | |
0 | 5528 float v16; // ST2C_4@3 |
5529 float v17; // ST30_4@3 | |
5530 signed int v18; // ST18_4@3 | |
5531 signed int v19; // ST14_4@3 | |
5532 signed int v20; // ST10_4@3 | |
5533 signed int v21; // eax@3 | |
5534 double v22; // st6@3 | |
5535 float v23; // ST2C_4@3 | |
5536 float v24; // ST30_4@3 | |
5537 signed int v25; // ST10_4@3 | |
5538 signed int v26; // ST14_4@3 | |
5539 signed int v27; // ST18_4@3 | |
5540 signed int v28; // eax@3 | |
5541 double v29; // st6@3 | |
5542 float v30; // ecx@3 | |
5543 float v31; // ST2C_4@3 | |
5544 float v32; // ST30_4@3 | |
5545 signed int v33; // ST10_4@3 | |
5546 signed int v34; // ST14_4@3 | |
5547 signed int v35; // ST18_4@3 | |
5548 signed int v36; // eax@3 | |
5549 float v37; // ecx@3 | |
5550 double v38; // st6@3 | |
5551 float v39; // ST2C_4@3 | |
5552 float v40; // ST30_4@3 | |
5553 signed int v41; // ST10_4@3 | |
5554 signed int v42; // ST14_4@3 | |
5555 signed int v43; // ST18_4@3 | |
5556 signed int v44; // eax@3 | |
5557 double v45; // st6@3 | |
5558 float v46; // eax@3 | |
5559 | |
5560 if ( this->uNumD3DSceneBegins ) | |
5561 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5562 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5563 { |
743 | 5564 //v5 = (double)a2->zbuffer_depth; |
5565 //v6 = v5; | |
5566 //v7 = v5; | |
5567 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
2155 | 5568 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5569 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5570 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5571 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
743 | 5572 //v9 = a2->uScreenSpaceX; |
5573 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5574 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 5575 //v12 = (double) a2->uScreenSpaceX; |
5576 //v13 = v12; | |
5577 //v14 = (double)(a2->uScreenSpaceY - 12); | |
5578 //v15 = v14; | |
5579 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5580 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5581 v18 = stru_5C6E00->Cos(angle); |
5582 v19 = stru_5C6E00->Sin(angle); | |
5583 v20 = stru_5C6E00->Sin(angle); | |
5584 v21 = stru_5C6E00->Cos(angle); | |
1390 | 5585 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5586 + (double)(v18 >> 16)) |
5587 * v16 | |
5588 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
5589 + (double)(v19 >> 16)) | |
5590 * v17) | |
743 | 5591 * v11 + (double) a2->uScreenSpaceX; |
0 | 5592 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
5593 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
5594 - 12.0) | |
5595 * v11 | |
5596 + (double)a2->uScreenSpaceY; | |
1390 | 5597 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5598 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5599 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
5600 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
5601 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5602 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5603 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
743 | 5604 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5605 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5606 v25 = stru_5C6E00->Cos(angle); |
5607 v26 = stru_5C6E00->Sin(angle); | |
5608 v27 = stru_5C6E00->Sin(angle); | |
5609 v28 = stru_5C6E00->Cos(angle); | |
1390 | 5610 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
0 | 5611 + (double)(v25 >> 16)) |
740 | 5612 * v31 |
0 | 5613 - ((double)(unsigned __int16)v26 * 0.000015259022 |
5614 + (double)(v26 >> 16)) | |
740 | 5615 * v32) |
743 | 5616 * v11 + (double) a2->uScreenSpaceX; |
740 | 5617 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
5618 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 5619 - 12.0) |
5620 * v11 | |
5621 + (double)a2->uScreenSpaceY; | |
1390 | 5622 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5623 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5624 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
5625 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5626 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
5627 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5628 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5629 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
743 | 5630 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
5631 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5632 v33 = stru_5C6E00->Cos(angle); |
5633 v34 = stru_5C6E00->Sin(angle); | |
5634 v35 = stru_5C6E00->Sin(angle); | |
5635 v36 = stru_5C6E00->Cos(angle); | |
1390 | 5636 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
0 | 5637 + (double)(v33 >> 16)) |
740 | 5638 * v23 |
0 | 5639 - ((double)(unsigned __int16)v34 * 0.000015259022 |
5640 + (double)(v34 >> 16)) | |
740 | 5641 * v24) |
743 | 5642 * v11 + (double) a2->uScreenSpaceX; |
1390 | 5643 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
740 | 5644 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
5645 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 5646 - 12.0) |
5647 * v11 | |
5648 + (double)a2->uScreenSpaceY; | |
1390 | 5649 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5650 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
5651 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5652 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5653 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
5654 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5655 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
743 | 5656 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5657 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5658 v41 = stru_5C6E00->Cos(angle); |
5659 v42 = stru_5C6E00->Sin(angle); | |
5660 v43 = stru_5C6E00->Sin(angle); | |
5661 v44 = stru_5C6E00->Cos(angle); | |
1390 | 5662 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
0 | 5663 + (double)(v41 >> 16)) |
5664 * v39 | |
5665 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
5666 + (double)(v42 >> 16)) | |
5667 * v40) | |
743 | 5668 * v11 + (double) a2->uScreenSpaceX; |
0 | 5669 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
5670 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
5671 - 12.0) | |
5672 * v11 | |
5673 + (double)a2->uScreenSpaceY; | |
1390 | 5674 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5675 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5676 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
5677 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5678 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5679 pBillboardRenderListD3D[v8].pTexture = a3; |
743 | 5680 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 5681 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5682 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; |
5683 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5684 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5685 } |
5686 } | |
5687 } | |
5688 | |
5689 //----- (004A3AD9) -------------------------------------------------------- | |
5690 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5691 { | |
5692 double v5; // st7@2 | |
5693 float v6; // ST28_4@2 | |
5694 float v7; // ST00_4@2 | |
5695 unsigned int v8; // esi@2 | |
5696 int v9; // eax@2 | |
5697 int v10; // ebx@2 | |
5698 float v11; // ST34_4@2 | |
5699 double v12; // st7@2 | |
5700 float v13; // ST2C_4@2 | |
5701 double v14; // st6@2 | |
5702 float v15; // ST24_4@2 | |
5703 float v16; // ST38_4@2 | |
5704 float v17; // ST3C_4@2 | |
5705 signed int v18; // ST1C_4@2 | |
5706 int v19; // ST30_4@2 | |
5707 signed int v20; // ST20_4@2 | |
5708 signed int v21; // ST18_4@2 | |
5709 signed int v22; // eax@2 | |
5710 double v23; // st6@2 | |
5711 float v24; // ST20_4@2 | |
5712 float v25; // ST1C_4@2 | |
5713 float v26; // ST38_4@2 | |
5714 float v27; // ST3C_4@2 | |
5715 signed int v28; // ST18_4@2 | |
5716 signed int v29; // ST14_4@2 | |
5717 signed int v30; // ST10_4@2 | |
5718 signed int v31; // eax@2 | |
5719 double v32; // st6@2 | |
5720 float v33; // ST38_4@2 | |
5721 float v34; // ST3C_4@2 | |
5722 signed int v35; // ST10_4@2 | |
5723 signed int v36; // ST14_4@2 | |
5724 signed int v37; // ST18_4@2 | |
5725 signed int v38; // eax@2 | |
5726 double v39; // st6@2 | |
5727 float v40; // ST38_4@2 | |
5728 float v41; // ST3C_4@2 | |
5729 signed int v42; // ST10_4@2 | |
5730 signed int v43; // ST14_4@2 | |
5731 signed int v44; // ST18_4@2 | |
5732 signed int v45; // eax@2 | |
5733 double v46; // st6@2 | |
5734 | |
5735 if ( this->uNumD3DSceneBegins ) | |
5736 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5737 v5 = (double)a2->zbuffer_depth; |
0 | 5738 v6 = v5; |
5739 v7 = v5; | |
5740 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
2155 | 5741 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5742 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5743 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5744 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
0 | 5745 v9 = a2->uScreenSpaceX; |
5746 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5747 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 5748 v12 = (double)v9; |
5749 v13 = v12; | |
5750 v14 = (double)(v10 - 12); | |
5751 v15 = v14; | |
5752 v16 = (double)(v9 - 12) - v12; | |
5753 v17 = (double)(v10 - 25) - v14; | |
323 | 5754 v18 = stru_5C6E00->Cos(angle); |
0 | 5755 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 5756 v20 = stru_5C6E00->Sin(angle); |
5757 v21 = stru_5C6E00->Sin(angle); | |
5758 v22 = stru_5C6E00->Cos(angle); | |
1390 | 5759 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5760 + (double)(v18 >> 16)) |
5761 * v16 | |
5762 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
5763 + (double)(v20 >> 16)) | |
5764 * v17) | |
5765 * v11 + v13; | |
5766 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
5767 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
5768 - 12.0) | |
5769 * v11 | |
5770 + (double)a2->uScreenSpaceY; | |
1390 | 5771 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5772 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5773 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
1637 | 5774 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5775 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; |
0 | 5776 v25 = 1.0 / v6; |
1390 | 5777 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; |
5778 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5779 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
0 | 5780 v26 = (double)(a2->uScreenSpaceX - 12) - v13; |
5781 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 5782 v28 = stru_5C6E00->Cos(angle); |
5783 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5784 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5785 v31 = stru_5C6E00->Cos(angle); | |
1390 | 5786 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
0 | 5787 + (double)(v28 >> 16)) |
5788 * v26 | |
5789 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
5790 + (double)(v29 >> 16)) | |
5791 * v27) | |
5792 * v11 + v13; | |
5793 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
5794 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
5795 - 12.0) | |
5796 * v11 | |
5797 + (double)a2->uScreenSpaceY; | |
1390 | 5798 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; |
5799 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
5800 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5801 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
5802 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5803 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5804 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
0 | 5805 v33 = (double)(a2->uScreenSpaceX + 12) - v13; |
5806 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 5807 v35 = stru_5C6E00->Cos(angle); |
5808 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5809 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5810 v38 = stru_5C6E00->Cos(angle); | |
1390 | 5811 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
0 | 5812 + (double)(v35 >> 16)) |
5813 * v33 | |
5814 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
5815 + (double)(v36 >> 16)) | |
5816 * v34) | |
5817 * v11 + v13; | |
5818 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
5819 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
5820 - 12.0) | |
5821 * v11 | |
5822 + (double)a2->uScreenSpaceY; | |
1390 | 5823 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5824 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
5825 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
5826 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5827 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
5828 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5829 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
0 | 5830 v40 = (double)(a2->uScreenSpaceX + 12) - v13; |
5831 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 5832 v42 = stru_5C6E00->Cos(angle); |
5833 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5834 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5835 v45 = stru_5C6E00->Cos(angle); | |
1390 | 5836 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
0 | 5837 + (double)(v42 >> 16)) |
5838 * v40 | |
5839 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
5840 + (double)(v43 >> 16)) | |
5841 * v41) | |
5842 * v11 + v13; | |
5843 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
5844 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
5845 - 12.0) | |
5846 * v11 | |
5847 + (double)a2->uScreenSpaceY; | |
1390 | 5848 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; |
5849 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
5850 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
5851 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5852 pBillboardRenderListD3D[v8].pTexture = a3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5853 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 5854 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5855 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; |
5856 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5857 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5858 } |
5859 } | |
5860 | |
5861 //----- (004A4023) -------------------------------------------------------- | |
657 | 5862 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
|
5863 { |
0 | 5864 unsigned int v8; // esi@2 |
5865 double v14; // st6@14 | |
5866 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5867 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5868 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5869 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5870 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5871 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5872 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5873 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5874 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5875 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5876 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 5877 float v29; // [sp+28h] [bp-8h]@5 |
5878 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5879 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5880 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5881 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5882 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5883 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5884 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5885 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5886 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
|
5887 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
|
5888 |
657 | 5889 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); |
2006 | 5890 if (a2->sTintColor & 0x00FFFFFF && bTinting) |
5891 { | |
5892 diffuse = BlendColors(a2->sTintColor, diffuse); | |
5893 if (a2->sTintColor & 0xFF000000) | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5894 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5895 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5896 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5897 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5898 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
|
5899 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
|
5900 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5901 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5902 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5903 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5904 v14 *= -1.0; |
1390 | 5905 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; |
5906 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5907 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5908 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5909 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; |
5910 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
5911 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5912 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5913 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5914 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5915 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5916 if ( a2->uFlags & 4 ) |
0 | 5917 v14 = v14 * -1.0; |
1390 | 5918 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; |
5919 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
5920 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5921 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5922 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5923 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; |
5924 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5925 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5926 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5927 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
|
5928 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5929 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5930 v14 *= -1.0; |
1390 | 5931 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; |
5932 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
5933 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5934 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5935 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5936 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; |
5937 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5938 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5939 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5940 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
|
5941 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5942 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5943 v14 *= -1.0; |
1390 | 5944 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; |
5945 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
5946 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5947 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5948 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5949 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; |
5950 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5951 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5952 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5953 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5954 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5955 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5956 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5957 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
2002 | 5958 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5959 |
2006 | 5960 if (a2->sTintColor & 0xFF000000) |
2155 | 5961 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5962 else |
2155 | 5963 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent; |
0 | 5964 } |
5965 | |
5966 | |
5967 //----- (004A49D0) -------------------------------------------------------- | |
5968 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
5969 { | |
1159 | 5970 int absXDifference; // eax@1 |
5971 int absYDifference; // eax@1 | |
5972 unsigned int smallerabsdiff; // ebx@1 | |
5973 unsigned int largerabsdiff; | |
0 | 5974 double v16; // st7@7 |
5975 double v17; // st7@7 | |
5976 double v18; // st6@7 | |
5977 double v20; // st4@8 | |
5978 double v21; // st4@10 | |
5979 double v22; // st4@10 | |
5980 double v23; // st4@10 | |
5981 double v25; // st4@11 | |
5982 double v26; // st4@13 | |
5983 double v28; // st4@13 | |
5984 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
1159 | 5985 int xDifference; // [sp+88h] [bp-Ch]@1 |
0 | 5986 signed int v32; // [sp+8Ch] [bp-8h]@1 |
1159 | 5987 int yDifference; // [sp+90h] [bp-4h]@1 |
5988 | |
5989 xDifference = bankersRounding(dstX - srcX); | |
5990 yDifference = bankersRounding(dstY - srcY); | |
5991 absYDifference = abs(yDifference); | |
5992 absXDifference = abs(xDifference); | |
5993 smallerabsdiff = min(absXDifference, absYDifference); | |
5994 largerabsdiff = max(absXDifference, absYDifference); | |
5995 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
0 | 5996 v16 = 1.0 / (double)v32; |
1159 | 5997 v17 = (double)yDifference * v16 * a4; |
5998 v18 = (double)xDifference * v16 * a4; | |
5999 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
6000 { | |
1637 | 6001 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
6002 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
1159 | 6003 } |
6004 else | |
6005 { | |
6006 v20 = a3 * 0.061758894; | |
6007 v25 = a7 * 0.061758894; | |
6008 } | |
6009 v21 = 1.0 / a3; | |
6010 v22 = (double)yDifference * v16 * a8; | |
6011 v23 = (double)xDifference * v16 * a8; | |
6012 v26 = 1.0 - 1.0 / v25; | |
6013 v28 = 1.0 / a7; | |
0 | 6014 v29[0].pos.x = srcX + v17; |
6015 v29[0].pos.y = srcY - v18; | |
1159 | 6016 v29[0].pos.z = 1.0 - 1.0 / v20; |
6017 v29[0].rhw = v21; | |
0 | 6018 v29[0].diffuse = -1; |
6019 v29[0].specular = 0; | |
6020 v29[0].texcoord.x = 1.0; | |
6021 v29[0].texcoord.y = 0.0; | |
1159 | 6022 |
0 | 6023 v29[1].pos.x = v22 + dstX; |
6024 v29[1].pos.y = dstY - v23; | |
1159 | 6025 v29[1].pos.z = v26; |
6026 v29[1].rhw = v28; | |
0 | 6027 v29[1].diffuse = -16711936; |
6028 v29[1].specular = 0; | |
6029 v29[1].texcoord.x = 1.0; | |
6030 v29[1].texcoord.y = 1.0; | |
1159 | 6031 |
6032 v29[2].pos.x = dstX - v22; | |
6033 v29[2].pos.y = v23 + dstY; | |
6034 v29[2].pos.z = v26; | |
0 | 6035 v29[2].rhw = v28; |
1159 | 6036 v29[2].diffuse = -1; |
6037 v29[2].specular = 0; | |
0 | 6038 v29[2].texcoord.x = 0.0; |
6039 v29[2].texcoord.y = 1.0; | |
1159 | 6040 |
0 | 6041 v29[3].pos.x = srcX - v17; |
6042 v29[3].pos.y = v18 + srcY; | |
1159 | 6043 v29[3].pos.z = v29[0].pos.z; |
6044 v29[3].rhw = v21; | |
6045 v29[3].diffuse = -1; | |
6046 v29[3].specular = 0; | |
0 | 6047 v29[3].texcoord.x = 0.0; |
6048 v29[3].texcoord.y = 0.0; | |
186 | 6049 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
6050 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6051 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
6052 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6053 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6054 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 6055 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
6056 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
6057 D3DPT_TRIANGLEFAN, | |
6058 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6059 v29, | |
6060 4, | |
6061 24)); | |
186 | 6062 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
6063 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6064 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6065 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6066 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6067 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 6068 } |
6069 | |
6070 //----- (004A4CC9) -------------------------------------------------------- | |
1390 | 6071 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) |
6072 { | |
0 | 6073 unsigned int v5; // eax@7 |
6074 char *v7; // edx@8 | |
6075 double v10; // st6@9 | |
6076 double v11; // st6@10 | |
6077 int v12; // ebx@13 | |
1390 | 6078 |
6079 if (a1->uNumVertices < 3) | |
6080 return; | |
6081 | |
6082 float depth = 1000000.0; | |
6083 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6084 { | |
6085 if (a1->field_104[i].z < depth) | |
6086 depth = a1->field_104[i * 4].z; | |
6087 } | |
6088 | |
6089 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
6090 pBillboardRenderListD3D[v5].field_90 = 0; | |
2002 | 6091 pBillboardRenderListD3D[v5].sParentBillboardID = -1; |
2155 | 6092 pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2; |
1390 | 6093 pBillboardRenderListD3D[v5].pTexture = 0; |
6094 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
6095 pBillboardRenderListD3D[v5].z_order = depth; | |
6096 | |
6097 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6098 { | |
6099 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
6100 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
6101 | |
6102 v10 = a1->field_104[i].z; | |
6103 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
6104 v11 = v10 * 0.061758894; | |
6105 else | |
1637 | 6106 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
1390 | 6107 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; |
6108 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
6109 | |
6110 if (diffuse & 0xFF000000) | |
6111 v12 = a1->field_104[i].diffuse; | |
6112 else | |
6113 v12 = diffuse; | |
6114 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
6115 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
6116 | |
6117 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
6118 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
0 | 6119 } |
6120 } | |
6121 | |
6122 //----- (004A4DE1) -------------------------------------------------------- | |
6123 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
6124 { | |
6125 HRESULT v12; // eax@14 | |
6126 unsigned __int16 *v13; // ecx@19 | |
6127 unsigned __int16 *v14; // eax@19 | |
6128 DWORD v15; // edx@20 | |
6129 HRESULT v16; // eax@23 | |
6130 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
6131 | |
1980 | 6132 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); |
0 | 6133 if ( pHWLTexture ) |
6134 { | |
6135 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
6136 if ( !pRenderD3D->CreateTexture( | |
6137 pHWLTexture->uWidth, | |
6138 pHWLTexture->uHeight, | |
6139 pOutSurface, | |
6140 pOutTexture, | |
6141 true, | |
6142 bMipMaps, | |
6143 uMinDeviceTextureDim) ) | |
1545 | 6144 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6145 //v10 = *pOutSurface; |
6146 //v11 = 0; | |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1574
diff
changeset
|
6147 if (bMipMaps) |
0 | 6148 { |
6149 Dst._450DDE(); | |
6150 //v20 = 0; | |
6151 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
6152 | |
6153 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
6154 while ( 1 ) | |
6155 { | |
6156 DDSCAPS2 v19; | |
6157 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6158 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6159 | |
6160 DDSURFACEDESC2 desc; | |
6161 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6162 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6163 | |
168 | 6164 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6165 { |
1831 | 6166 Dst.sub_451007_scale_image_bicubic( |
0 | 6167 pHWLTexture->pPixels, |
6168 pHWLTexture->uWidth, | |
6169 pHWLTexture->uHeight, | |
6170 pHWLTexture->uWidth, | |
6171 (unsigned short *)desc.lpSurface, | |
6172 desc.dwWidth, | |
6173 desc.dwHeight, | |
6174 desc.lPitch >> 1, | |
6175 0, | |
1831 | 6176 0); |
0 | 6177 ErrD3D(pNextSurf->Unlock(0)); |
6178 //bMipMaps = 0x4D86ACu; | |
6179 } | |
6180 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
6181 break; | |
6182 //v10 = (IDirectDrawSurface4 *)pName; | |
6183 //v11 = 0; | |
6184 } | |
6185 //v20 = -1; | |
6186 //nullsub_1(); | |
6187 } | |
6188 else | |
6189 { | |
6190 DDSCAPS2 v19; | |
6191 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6192 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6193 | |
6194 DDSURFACEDESC2 desc; | |
6195 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6196 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6197 | |
168 | 6198 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6199 { |
6200 bMipMaps = 0; | |
6201 v13 = pHWLTexture->pPixels; | |
6202 v14 = (unsigned __int16 *)desc.lpSurface; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6203 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
|
6204 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6205 for (v15 = 0; v15 < desc.dwWidth; v15++) |
0 | 6206 { |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6207 *v14 = *v13; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6208 ++v14; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6209 ++v13; |
0 | 6210 } |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6211 v14 += (desc.lPitch >> 1) - desc.dwWidth; |
0 | 6212 } |
6213 ErrD3D((*pOutSurface)->Unlock(0)); | |
6214 } | |
6215 } | |
6216 delete [] pHWLTexture->pPixels; | |
6217 delete pHWLTexture; | |
6218 return true; | |
6219 } | |
6220 return false; | |
6221 } | |
6222 | |
6223 //----- (004A5048) -------------------------------------------------------- | |
670 | 6224 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
6225 { | |
6226 | |
6227 HWLTexture *sprite_texture; // eax@1 | |
0 | 6228 unsigned __int16 *v9; // edx@5 |
6229 LPVOID v10; // eax@5 | |
6230 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6231 | |
670 | 6232 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
6233 if ( sprite_texture ) | |
6234 { | |
6235 pSprite->uAreaX = sprite_texture->uAreaX; | |
6236 pSprite->uAreaY = sprite_texture->uAreaY; | |
6237 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
6238 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
6239 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
6240 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6241 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6242 //v7 = v3->pRenderD3D; |
670 | 6243 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
1545 | 6244 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6245 //pSprite = v2->pTextureSurface; |
6246 //pSprite = (Sprite *)pSprite->pName; | |
6247 //v8 = pSprite; | |
670 | 6248 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 6249 Dst.dwSize = 124; |
670 | 6250 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
6251 { | |
6252 v9 = sprite_texture->pPixels; | |
6253 v10 = Dst.lpSurface; | |
6254 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 6255 { |
670 | 6256 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
6257 { | |
0 | 6258 *(int *)v10 = *(int *)v9; |
6259 v9 += 2; | |
6260 v10 = (char *)v10 + 4; | |
670 | 6261 } |
6262 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 6263 } |
670 | 6264 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
6265 } | |
6266 free(sprite_texture->pPixels); | |
6267 free(sprite_texture); | |
6268 return true; | |
6269 } | |
6270 return false; | |
0 | 6271 } |
6272 | |
6273 //----- (004A51CB) -------------------------------------------------------- | |
6274 void Render::BeginScene() | |
6275 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6276 //Render *v1; // esi@1 |
0 | 6277 unsigned int v2; // eax@1 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6278 /*int v3; // eax@5 |
0 | 6279 unsigned __int16 **v4; // edi@6 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6280 char *v5; // ebx@7*/ |
0 | 6281 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 |
6282 | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6283 //v1 = this; |
0 | 6284 v2 = this->uNumSceneBegins; |
6285 this->uNumSceneBegins = v2 + 1; | |
6286 if ( !v2 ) | |
6287 { | |
6288 if ( this->pRenderD3D ) | |
6289 { | |
2069 | 6290 /*if ( this->bColorKeySupported ) |
0 | 6291 { |
6292 memset(&Dst, 0, 0x7Cu); | |
6293 Dst.dwSize = 124; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6294 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
|
6295 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6296 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6297 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6298 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
|
6299 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6300 --this->uNumSceneBegins; |
2069 | 6301 }*/ |
0 | 6302 } |
6303 else | |
6304 { | |
6305 if ( !this->pTargetSurface ) | |
6306 { | |
6307 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
2154 | 6308 /*if ( this->pTargetSurface ) |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6309 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6310 this->field_18_locked_pitch = this->uTargetSurfacePitch; |
2154 | 6311 }*/ |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6312 --this->uNumSceneBegins; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6313 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6314 } |
0 | 6315 RestoreFrontBuffer(); |
6316 } | |
6317 } | |
6318 | |
6319 //----- (004A527D) -------------------------------------------------------- | |
6320 void Render::EndScene() | |
6321 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6322 if ( this->uNumSceneBegins ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6323 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6324 this->uNumSceneBegins--; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6325 if ( !this->uNumSceneBegins ) |
0 | 6326 { |
6327 if ( this->pRenderD3D ) | |
6328 { | |
2069 | 6329 /*if ( this->bColorKeySupported ) |
0 | 6330 { |
6331 this->pTargetSurface = 0; | |
6332 this->uTargetSurfacePitch = 0; | |
6333 this->field_18_locked_pitch = 0; | |
6334 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
2069 | 6335 }*/ |
0 | 6336 } |
6337 else | |
6338 { | |
6339 this->pTargetSurface = 0; | |
6340 this->uTargetSurfacePitch = 0; | |
2154 | 6341 //this->field_18_locked_pitch = 0; |
0 | 6342 UnlockBackBuffer(); |
6343 } | |
6344 } | |
6345 } | |
6346 } | |
6347 | |
2155 | 6348 //----- (004A52F1) -------------------------------------------------------- |
6349 void Render::ScreenFade(unsigned int color, float t) | |
0 | 6350 { |
6351 unsigned int v3; // esi@1 | |
2155 | 6352 //double v4; // st7@2 |
6353 //double v5; // st7@6 | |
0 | 6354 double v6; // st6@6 |
6355 unsigned int v7; // eax@6 | |
6356 double v8; // st5@6 | |
6357 double v9; // st4@6 | |
6358 HRESULT v10; // eax@6 | |
6359 HRESULT v11; // eax@6 | |
6360 unsigned int result; // eax@6 | |
6361 unsigned int v13; // eax@7 | |
6362 unsigned __int16 *v14; // ecx@7 | |
6363 int *v15; // eax@7 | |
6364 unsigned int v16; // ecx@8 | |
6365 __int16 v17; // ax@10 | |
6366 int v18; // esi@10 | |
6367 float v19; // edi@10 | |
6368 void *v20; // esi@10 | |
6369 int v21; // edx@10 | |
6370 int v22; // ecx@11 | |
6371 int v23; // edx@12 | |
6372 __int16 v24; // ax@15 | |
6373 int v25; // esi@15 | |
6374 float v26; // edi@15 | |
6375 char *v27; // esi@15 | |
6376 int v28; // edx@15 | |
6377 int v29; // ecx@16 | |
6378 int v30; // edx@17 | |
6379 int v31; // [sp-Ch] [bp-ACh]@11 | |
6380 int v32; // [sp-Ch] [bp-ACh]@16 | |
6381 const char *v33; // [sp+0h] [bp-A0h]@0 | |
6382 int v34; // [sp+4h] [bp-9Ch]@0 | |
6383 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
6384 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
6385 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
6386 int v38; // [sp+90h] [bp-10h]@7 | |
6387 double v39; // [sp+94h] [bp-Ch]@6 | |
2155 | 6388 int v40; // [sp+9Ch] [bp-4h]@6 |
6389 | |
0 | 6390 v3 = 0; |
1574 | 6391 |
6392 //{ | |
2155 | 6393 if (t > 1.0f) |
6394 t = 1.0f; | |
6395 else if (t < 0.0f) | |
6396 t = 0.0f; | |
6397 | |
6398 v40 = (char)floorf(t * 255.0f + 0.5f); | |
6399 //v5 = (double)(signed int)pViewport->uViewportTL_X; | |
6400 v36[0].pos.x = pViewport->uViewportTL_X; | |
693 | 6401 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
2155 | 6402 v7 = color | (v40 << 24); |
6403 //this_ = pViewport->uViewportBR_Y + 1; | |
0 | 6404 v36[0].specular = 0; |
6405 v36[0].pos.y = v6; | |
6406 v36[0].diffuse = v7; | |
6407 v36[1].diffuse = v7; | |
6408 v36[0].pos.z = 0.0; | |
6409 v36[2].diffuse = v7; | |
6410 v36[3].diffuse = v7; | |
6411 v36[0].rhw = 1.0; | |
6412 v36[1].specular = 0; | |
6413 v36[0].texcoord.x = 0.0; | |
6414 v36[2].specular = 0; | |
6415 v36[3].specular = 0; | |
6416 v36[0].texcoord.y = 0.0; | |
2155 | 6417 v36[1].pos.x = pViewport->uViewportTL_X; |
693 | 6418 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 6419 v36[1].pos.y = v8; |
6420 v36[1].pos.z = 0.0; | |
6421 v36[1].rhw = 1.0; | |
6422 v36[1].texcoord.x = 0.0; | |
6423 v36[1].texcoord.y = 0.0; | |
693 | 6424 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 6425 v36[2].pos.x = v9; |
6426 v36[2].pos.y = v8; | |
6427 v36[2].pos.z = 0.0; | |
6428 v36[2].rhw = 1.0; | |
6429 v36[2].texcoord.x = 0.0; | |
6430 v36[2].texcoord.y = 0.0; | |
6431 v36[3].pos.x = v9; | |
6432 v36[3].pos.y = v6; | |
6433 v36[3].pos.z = 0.0; | |
6434 v36[3].rhw = 1.0; | |
6435 v36[3].texcoord.x = 0.0; | |
6436 v36[3].texcoord.y = 0.0; | |
6437 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 6438 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
6439 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6440 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6441 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
6442 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
6443 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6444 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 6445 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
6446 D3DPT_TRIANGLEFAN, | |
6447 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6448 v36, | |
6449 4, | |
6450 28)); | |
186 | 6451 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
6452 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6453 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
6454 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6455 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6456 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
1574 | 6457 /*} |
0 | 6458 else |
6459 { | |
6460 v40 = (1.0 - a3) * 65536.0; | |
6461 v39 = v40 + 6.7553994e15; | |
6462 LODWORD(a3) = LODWORD(v39); | |
693 | 6463 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
6464 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
6465 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
6466 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 6467 v37 = 2 * v13; |
6468 LODWORD(v40) = (int)v14; | |
6469 | |
6470 int __i = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
6471 v15 = dword_F1B430.data(); |
0 | 6472 do |
6473 { | |
6474 v16 = v3; | |
6475 v3 += LODWORD(a3); | |
6476 dword_F1B430[__i++] = v16 >> 16; | |
6477 } | |
6478 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
6479 while (__i < 32); | |
6480 | |
6481 if ( pRenderer->uTargetGBits == 6 ) | |
6482 { | |
1574 | 6483 v17 = sr_42690D_colors_cvt(this_); |
0 | 6484 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); |
6485 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); | |
6486 v19 = v40; | |
6487 v20 = off_4EFDB0; | |
6488 v21 = HIDWORD(v39); | |
6489 do | |
6490 { | |
6491 v22 = v38; | |
6492 v31 = v21; | |
6493 do | |
6494 { | |
6495 v23 = (*(int *)((char *)v20 | |
6496 + ((((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; | |
6497 result = this_ | |
6498 + (*((int *)v20 | |
6499 + (((unsigned __int8)(*((char *)v20 | |
6500 + ((((unsigned __int16)(*(short *)((char *)v20 | |
6501 + ((*(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); | |
6502 *(unsigned int *)LODWORD(v19) = result; | |
6503 LODWORD(v19) += 4; | |
6504 --v22; | |
6505 } | |
6506 while ( v22 ); | |
6507 LODWORD(v19) += v37; | |
6508 v21 = v31 - 1; | |
6509 } | |
6510 while ( v31 != 1 ); | |
6511 } | |
6512 else | |
6513 { | |
1574 | 6514 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_); |
0 | 6515 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); |
6516 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
6517 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
6518 v26 = v40; | |
6519 v27 = (char *)off_4EFDB0; | |
6520 v28 = HIDWORD(v39); | |
6521 do | |
6522 { | |
6523 v29 = v38; | |
6524 v32 = v28; | |
6525 do | |
6526 { | |
6527 v30 = 32 | |
6528 * *(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; | |
6529 result = this_ | |
6530 + (*(int *)&v27[4 | |
6531 * (((unsigned __int8)(32 | |
6532 * 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); | |
6533 *(unsigned int *)LODWORD(v26) = result; | |
6534 LODWORD(v26) += 4; | |
6535 --v29; | |
6536 } | |
6537 while ( v29 ); | |
6538 LODWORD(v26) += v37; | |
6539 v28 = v32 - 1; | |
6540 } | |
6541 while ( v32 != 1 ); | |
6542 } | |
1574 | 6543 }*/ |
0 | 6544 } |
6545 | |
6546 //----- (004A5B81) -------------------------------------------------------- | |
727 | 6547 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 6548 { |
6549 this->bClip = 1; | |
6550 this->uClipY = uY; | |
6551 this->uClipX = uX; | |
6552 this->uClipW = uW; | |
6553 this->uClipZ = uZ; | |
6554 } | |
6555 | |
6556 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 6557 void Render::ResetTextureClipRect() |
0 | 6558 { |
6559 this->uClipY = 0; | |
6560 this->uClipX = 0; | |
6561 this->bClip = 1; | |
6562 this->uClipW = 480; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
6563 this->uClipZ = window->GetWidth(); |
0 | 6564 } |
6565 | |
2069 | 6566 unsigned __int32 Color32(unsigned __int16 color16) |
6567 { | |
6568 unsigned __int32 c = color16; | |
6569 unsigned int b = (c & 31) * 8; | |
6570 unsigned int g = ((c >> 5) & 63) * 4; | |
6571 unsigned int r = ((c >> 11) & 31) * 8; | |
6572 | |
2078 | 6573 return (r << 16) | (g << 8) | b;// |
2069 | 6574 } |
6575 | |
6576 //----- (0040DEF3) -------------------------------------------------------- | |
6577 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b) | |
6578 { | |
6579 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + | |
6580 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + | |
6581 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
6582 return (b >> (8 - 5)) | | |
6583 0x7E0 & (g << (6 + 5 - 8)) | | |
6584 0xF800 & (r << (6 + 5 + 5 - 8)); | |
6585 } | |
6586 | |
6587 | |
0 | 6588 //----- (004A5BE3) -------------------------------------------------------- |
6589 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
6590 { | |
6591 int v4; // edi@3 | |
2069 | 6592 //unsigned __int16 *v5; // edx@3 |
0 | 6593 unsigned __int16 *v6; // esi@3 |
6594 unsigned int v8; // eax@5 | |
6595 unsigned int v9; // ebx@5 | |
6596 unsigned int v11; // eax@7 | |
6597 unsigned int v12; // ebx@8 | |
6598 unsigned int v15; // eax@14 | |
6599 int v19; // [sp+10h] [bp-8h]@3 | |
6600 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
6601 int v23; // [sp+28h] [bp+10h]@3 | |
6602 | |
6603 if ( this->uNumSceneBegins && a4 ) | |
6604 { | |
6605 v4 = a4->uWidth; | |
2069 | 6606 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6607 v6 = a4->pPixels; |
6608 v23 = a4->uHeight; | |
6609 v19 = v4; | |
6610 if ( this->bClip ) | |
6611 { | |
1152 | 6612 if ( (signed int)uOutX < (signed int)this->uClipX ) |
6613 { | |
6614 v8 = this->uClipX - uOutX; | |
6615 v9 = uOutX - this->uClipX; | |
0 | 6616 v8 *= 2; |
6617 v4 += v9; | |
6618 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
2069 | 6619 //v5 = (unsigned __int16 *)((char *)v5 + v8); |
0 | 6620 } |
1152 | 6621 if ( (signed int)uOutY < (signed int)this->uClipY ) |
6622 { | |
6623 v11 = this->uClipY - uOutY; | |
0 | 6624 v6 += v19 * v11; |
6625 v23 += uOutY - this->uClipY; | |
2069 | 6626 //v5 += this->uTargetSurfacePitch * v11; |
0 | 6627 } |
1152 | 6628 v12 = max(this->uClipX, uOutX); |
6629 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | |
6630 { | |
6631 v4 = this->uClipZ - max(this->uClipX, uOutX); | |
6632 } | |
6633 v15 = max(this->uClipY, uOutY); | |
6634 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) | |
6635 { | |
6636 v23 = this->uClipW - max(this->uClipY, uOutY); | |
6637 } | |
6638 } | |
6639 | |
2069 | 6640 for (int y = 0; y < v23; y++) |
6641 { | |
6642 for (int x = 0; x < v4; x++) | |
6643 { | |
6644 WritePixel16(uOutX + x, uOutY + y, *v6); | |
6645 //*v5 = *v6; | |
6646 //++v5; | |
1152 | 6647 ++v6; |
6648 } | |
6649 v6 += v19 - v4; | |
2069 | 6650 //v5 += this->uTargetSurfacePitch - v4; |
0 | 6651 } |
6652 } | |
6653 } | |
6654 | |
6655 //----- (004A5D33) -------------------------------------------------------- | |
1675 | 6656 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) |
0 | 6657 { |
2069 | 6658 //unsigned __int16 *v7; // ebx@3 |
1675 | 6659 int full_width; // ecx@3 |
6660 int full_height; // edi@3 | |
2069 | 6661 //int v23; // edi@23 |
0 | 6662 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 |
6663 | |
6664 if ( this->uNumSceneBegins && pTexture ) | |
6665 { | |
2069 | 6666 /*auto v7 = this->pTargetSurface; |
6667 if (FORCE_16_BITS) | |
6668 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2); | |
6669 else | |
6670 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/ | |
1675 | 6671 full_width = pTexture->uWidth - move_X; |
6672 full_height = pTexture->uHeight - move_Y; | |
6673 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth]; | |
6674 if ( this->bClip ) | |
6675 { | |
6676 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó | |
6677 { | |
6678 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX))); | |
6679 full_width += pX - this->uClipX; | |
2069 | 6680 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX))); |
1675 | 6681 } |
6682 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó | |
6683 { | |
6684 pTexturea += pTexture->uWidth * (this->uClipY - pY); | |
6685 full_height += pY - this->uClipY; | |
2069 | 6686 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY)); |
1675 | 6687 } |
6688 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà | |
6689 this->uClipX = pX; | |
6690 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà | |
6691 this->uClipY = pY; | |
6692 if ( (full_width + this->uClipX) > this->uClipZ )//åñëè øèðèíà êàäðà âûõîäèò çà ïðàâóþ ãðàíèöó | |
6693 { | |
6694 if ( this->uClipX < pX ) | |
6695 this->uClipX = pX; | |
6696 full_width = this->uClipZ - this->uClipX; | |
6697 } | |
6698 if ( (full_height + this->uClipY) > this->uClipW )//åñëè âûñîòà êàäðà âûõîäèò çà íèæíþþ ãðàíèöó | |
6699 { | |
6700 if ( this->uClipY < pY ) | |
6701 this->uClipY = pY; | |
6702 full_height = this->uClipW - this->uClipY; | |
6703 } | |
6704 } | |
2069 | 6705 |
6706 for (int y = 0; y < full_height; ++y) | |
6707 { | |
6708 for (int x = 0; x < full_width; ++x) | |
6709 { | |
6710 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) ) | |
6711 { | |
6712 WritePixel16(pX + x, pY + y, *pTexturea); | |
6713 /*if (FORCE_16_BITS) | |
6714 *(unsigned __int16 *)v7 = *pTexturea; | |
6715 else | |
6716 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/ | |
6717 } | |
0 | 6718 ++pTexturea; |
2069 | 6719 //++v7; |
0 | 6720 } |
2069 | 6721 //v7 += this->uTargetSurfacePitch - full_width; |
1675 | 6722 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width)); |
2069 | 6723 } |
0 | 6724 } |
6725 } | |
6726 | |
6727 //----- (004A6E7E) -------------------------------------------------------- | |
2155 | 6728 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 6729 { |
2069 | 6730 //unsigned __int16 *v4; // eax@4 |
0 | 6731 int v5; // edx@4 |
6732 unsigned int v6; // edi@4 | |
6733 unsigned int v7; // edx@5 | |
6734 unsigned int v8; // edx@6 | |
6735 unsigned int v9; // edx@7 | |
6736 unsigned int v10; // edx@8 | |
6737 unsigned int v11; // ebx@9 | |
6738 unsigned int v12; // esi@11 | |
6739 unsigned int v13; // edx@12 | |
6740 unsigned int v14; // ebx@15 | |
6741 unsigned int v15; // esi@17 | |
6742 unsigned int v16; // edi@18 | |
6743 char v17; // zf@29 | |
6744 int v18; // [sp+14h] [bp-Ch]@4 | |
6745 int v19; // [sp+18h] [bp-8h]@4 | |
6746 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
6747 int v21; // [sp+28h] [bp+8h]@25 | |
6748 int v22; // [sp+28h] [bp+8h]@34 | |
6749 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
6750 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
6751 | |
6752 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
6753 { | |
2069 | 6754 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
710 | 6755 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 6756 v5 = a4->uTextureWidth; |
6757 v6 = a4->uTextureHeight; | |
6758 v19 = a4->uTextureWidth; | |
6759 v18 = a4->uTextureWidth; | |
2069 | 6760 int clipped_out_x = a2; |
6761 int clipped_out_y = a3; | |
0 | 6762 if ( this->bClip ) |
6763 { | |
6764 v7 = this->uClipX; | |
6765 if ( (signed int)a2 < (signed int)v7 ) | |
6766 { | |
6767 v8 = v7 - a2; | |
6768 v20 += v8; | |
6769 v19 += a2 - this->uClipX; | |
2069 | 6770 //v4 += v8; |
6771 clipped_out_x = uClipX; | |
0 | 6772 } |
6773 v9 = this->uClipY; | |
6774 if ( (signed int)a3 < (signed int)v9 ) | |
6775 { | |
6776 v10 = v9 - a3; | |
6777 v20 += v18 * v10; | |
6778 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
2069 | 6779 //v4 += this->uTargetSurfacePitch * v10; |
6780 clipped_out_y = uClipY; | |
0 | 6781 } |
6782 v11 = this->uClipX; | |
6783 v5 = v19; | |
6784 if ( (signed int)v11 < (signed int)a2 ) | |
6785 v11 = a2; | |
6786 v12 = this->uClipZ; | |
6787 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
6788 { | |
6789 v13 = this->uClipX; | |
6790 if ( (signed int)v13 < (signed int)a2 ) | |
6791 v13 = a2; | |
6792 v5 = v12 - v13; | |
6793 } | |
6794 v14 = this->uClipY; | |
6795 if ( (signed int)v14 < (signed int)a3 ) | |
6796 v14 = a3; | |
6797 v15 = this->uClipW; | |
6798 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
6799 { | |
6800 v16 = this->uClipY; | |
6801 if ( (signed int)v16 < (signed int)a3 ) | |
6802 v16 = a3; | |
6803 v6 = v15 - v16; | |
6804 } | |
6805 } | |
2069 | 6806 |
6807 for (int y = 0; y < v6; ++y) | |
6808 { | |
6809 for (int x = 0; x < v5; ++x) | |
6810 { | |
6811 if ( *v20 ) | |
6812 WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF); | |
6813 ++v20; | |
6814 } | |
6815 v20 += v18 - v5; | |
6816 } | |
6817 | |
6818 /*if ( pRenderer->uTargetGBits == 5 ) | |
0 | 6819 { |
6820 if ( (signed int)v6 > 0 ) | |
6821 { | |
6822 v23 = v6; | |
6823 do | |
6824 { | |
6825 if ( v5 > 0 ) | |
6826 { | |
6827 v21 = v5; | |
6828 do | |
6829 { | |
6830 if ( *v20 ) | |
6831 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
6832 ++v4; | |
6833 ++v20; | |
6834 --v21; | |
6835 } | |
6836 while ( v21 ); | |
6837 } | |
6838 v20 += v18 - v5; | |
6839 v17 = v23-- == 1; | |
6840 v4 += this->uTargetSurfacePitch - v5; | |
6841 } | |
6842 while ( !v17 ); | |
6843 } | |
6844 } | |
6845 else | |
6846 { | |
6847 if ( (signed int)v6 > 0 ) | |
6848 { | |
6849 v24 = v6; | |
6850 do | |
6851 { | |
6852 if ( v5 > 0 ) | |
6853 { | |
6854 v22 = v5; | |
6855 do | |
6856 { | |
6857 if ( *v20 ) | |
6858 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
6859 ++v4; | |
6860 ++v20; | |
6861 --v22; | |
6862 } | |
6863 while ( v22 ); | |
6864 } | |
6865 v20 += v18 - v5; | |
6866 v17 = v24-- == 1; | |
6867 v4 += this->uTargetSurfacePitch - v5; | |
6868 } | |
6869 while ( !v17 ); | |
6870 } | |
2069 | 6871 }*/ |
0 | 6872 } |
6873 } | |
6874 | |
6875 //----- (004A6DF5) -------------------------------------------------------- | |
2069 | 6876 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) |
0 | 6877 { |
2219 | 6878 int width; // ecx@3 |
6879 unsigned __int16 *pixels; // ebx@4 | |
6880 int height; // esi@4 | |
0 | 6881 |
2069 | 6882 if ( !pBitmap || !pTarget) |
6883 return; | |
6884 | |
2219 | 6885 width = a7->z - a7->x; |
6886 height = a7->w - a7->y; | |
6887 pixels = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; | |
6888 for ( int y = 0; y < height; ++y ) | |
6889 { | |
6890 for ( int x = 0; x < width; ++x ) | |
6891 { | |
6892 WritePixel16(a7->x + x, a7->y + y, *pixels); | |
6893 ++pixels; | |
6894 } | |
6895 pixels += uTargetPitch - width; | |
2093 | 6896 } |
0 | 6897 } |
6898 | |
6899 //----- (004A6D87) -------------------------------------------------------- | |
6900 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
6901 { | |
6902 if (!uNumSceneBegins) | |
6903 return; | |
6904 | |
6905 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
6906 for (uint y = 0; y < uHeight; ++y) | |
6907 { | |
2069 | 6908 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch); |
6909 | |
6910 memset32(pDst, | |
2098 | 6911 FORCE_16_BITS ? twoColors : 0xFF000000 | Color32(uColor16), // two colors per int (16bit) or 1 (32bit) |
2069 | 6912 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit) |
6913 | |
6914 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit | |
6915 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16; | |
0 | 6916 } |
6917 } | |
6918 | |
6919 //----- (004A6C4F) -------------------------------------------------------- | |
2073 | 6920 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, |
6921 unsigned int uCharHeight, unsigned __int16 *pFontPalette, | |
6922 unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
0 | 6923 { |
6924 unsigned int v9; // edi@2 | |
6925 unsigned int v10; // esi@2 | |
2069 | 6926 //unsigned __int16 *v11; // eax@2 |
0 | 6927 unsigned int v12; // ebx@3 |
6928 signed int v13; // edx@5 | |
6929 int v14; // edx@6 | |
6930 signed int v15; // ebx@7 | |
6931 unsigned int v16; // edx@9 | |
6932 signed int v17; // edi@10 | |
6933 signed int v18; // ebx@13 | |
6934 unsigned int v19; // edx@15 | |
6935 signed int v20; // esi@16 | |
2069 | 6936 //unsigned int v21; // esi@22 |
0 | 6937 unsigned __int16 v22; // dx@24 |
2069 | 6938 //char v23; // zf@28 |
0 | 6939 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 |
2069 | 6940 //unsigned int uOutXa; // [sp+18h] [bp+8h]@20 |
6941 | |
6942 if (!this->uNumSceneBegins) | |
6943 return; | |
6944 | |
0 | 6945 v9 = uCharWidth; |
6946 v10 = uCharHeight; | |
2069 | 6947 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6948 v24 = pFontPixels; |
2069 | 6949 |
6950 int clipped_out_x = uOutX, clipped_out_y = uOutY; | |
0 | 6951 if ( this->bClip ) |
6952 { | |
6953 v12 = this->uClipX; | |
6954 if ( uOutX < (signed int)v12 ) | |
6955 { | |
6956 v24 = &pFontPixels[v12 - uOutX]; | |
2069 | 6957 //v11 += v12 - uOutX; |
6958 clipped_out_x = uClipX; | |
0 | 6959 v9 = uCharWidth + uOutX - v12; |
6960 } | |
6961 v13 = this->uClipY; | |
6962 if ( uOutY < v13 ) | |
6963 { | |
6964 v14 = v13 - uOutY; | |
6965 v24 += uCharWidth * v14; | |
6966 v10 = uCharHeight + uOutY - this->uClipY; | |
2069 | 6967 //v11 += this->uTargetSurfacePitch * v14; |
6968 clipped_out_y = uClipY; | |
0 | 6969 } |
6970 v15 = this->uClipX; | |
6971 if ( v15 < uOutX ) | |
6972 v15 = uOutX; | |
6973 v16 = this->uClipZ; | |
6974 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
6975 { | |
6976 v17 = this->uClipX; | |
6977 if ( v17 < uOutX ) | |
6978 v17 = uOutX; | |
6979 v9 = v16 - v17; | |
6980 } | |
6981 v18 = this->uClipY; | |
6982 if ( v18 < uOutY ) | |
6983 v18 = uOutY; | |
6984 v19 = this->uClipW; | |
6985 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
6986 { | |
6987 v20 = this->uClipY; | |
6988 if ( v20 < uOutY ) | |
6989 v20 = uOutY; | |
6990 v10 = v19 - v20; | |
6991 } | |
6992 } | |
2069 | 6993 |
6994 for (int y = 0; y < v10; ++y) | |
6995 { | |
6996 for (int x = 0; x < v9; ++x) | |
6997 { | |
6998 if (*v24) | |
0 | 6999 { |
2069 | 7000 v22 = uShadowColor; |
7001 if ( *v24 != 1 ) | |
7002 v22 = uFaceColor; | |
2073 | 7003 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22); |
0 | 7004 } |
2073 | 7005 ++v24; |
7006 } | |
7007 v24 += uCharWidth - v9; | |
2069 | 7008 //v23 = uOutXa-- == 1; |
7009 //v11 += this->uTargetSurfacePitch - v9; | |
7010 } | |
0 | 7011 } |
7012 | |
7013 //----- (004A6A68) -------------------------------------------------------- | |
1496 | 7014 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) |
7015 { | |
0 | 7016 Texture tex; // [sp+Ch] [bp-48h]@1 |
1496 | 7017 |
0 | 7018 memcpy(&tex, a4, sizeof(tex)); |
1496 | 7019 tex.uTextureHeight = a4->uTextureHeight - height; |
7020 if ( (signed __int16)tex.uTextureHeight > 0 ) | |
0 | 7021 DrawTextureIndexed(a2, a3, &tex); |
7022 } | |
7023 | |
7024 //----- (004A6AB1) -------------------------------------------------------- | |
1268 | 7025 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
7026 { | |
0 | 7027 int v8; // edi@2 |
7028 unsigned int v9; // esi@2 | |
2069 | 7029 //unsigned __int16 *v10; // eax@2 |
0 | 7030 unsigned char *v11; // edx@2 |
7031 unsigned int v12; // ebx@3 | |
7032 signed int v13; // edx@5 | |
7033 int v14; // edx@6 | |
7034 signed int v15; // ebx@7 | |
7035 unsigned int v16; // edx@9 | |
7036 signed int v17; // edi@10 | |
7037 signed int v18; // ebx@13 | |
7038 unsigned int v19; // edx@15 | |
7039 signed int v20; // esi@16 | |
7040 int v21; // ebx@22 | |
7041 char v22; // zf@28 | |
7042 int v23; // ebx@31 | |
7043 unsigned __int16 v24; // si@35 | |
7044 int v25; // [sp+Ch] [bp-4h]@2 | |
7045 int v26; // [sp+1Ch] [bp+Ch]@24 | |
7046 int v27; // [sp+1Ch] [bp+Ch]@33 | |
7047 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
7048 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
7049 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
7050 | |
1980 | 7051 int a2 = x; |
7052 int a3 = y; | |
7053 uint a6 = uFontHeight; | |
2069 | 7054 if (!this->uNumSceneBegins) |
7055 return; | |
7056 | |
0 | 7057 v8 = a5; |
7058 v9 = a6; | |
2069 | 7059 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; |
1268 | 7060 v11 = (unsigned char *)font_pixels; |
7061 v25 = (int)font_pixels; | |
2069 | 7062 int clipped_out_x = x; |
7063 int clipped_out_y = y; | |
0 | 7064 if ( this->bClip ) |
7065 { | |
7066 v12 = this->uClipX; | |
7067 if ( a2 < (signed int)v12 ) | |
7068 { | |
1268 | 7069 v25 = v12 - a2 + (int)font_pixels; |
2069 | 7070 //v10 += v12 - a2; |
0 | 7071 v8 = a5 + a2 - v12; |
2069 | 7072 clipped_out_x = uClipX; |
0 | 7073 } |
7074 v13 = this->uClipY; | |
7075 if ( a3 < v13 ) | |
7076 { | |
7077 v14 = v13 - a3; | |
7078 v25 += a5 * v14; | |
7079 v9 = a6 + a3 - this->uClipY; | |
2069 | 7080 //v10 += this->uTargetSurfacePitch * v14; |
7081 clipped_out_y = uClipY; | |
0 | 7082 } |
7083 v15 = this->uClipX; | |
7084 if ( v15 < a2 ) | |
7085 v15 = a2; | |
7086 v16 = this->uClipZ; | |
7087 if ( v8 + v15 > (signed int)v16 ) | |
7088 { | |
7089 v17 = this->uClipX; | |
7090 if ( v17 < a2 ) | |
7091 v17 = a2; | |
7092 v8 = v16 - v17; | |
7093 } | |
7094 v18 = this->uClipY; | |
7095 if ( v18 < a3 ) | |
7096 v18 = a3; | |
7097 v19 = this->uClipW; | |
7098 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
7099 { | |
7100 v20 = this->uClipY; | |
7101 if ( v20 < a3 ) | |
7102 v20 = a3; | |
7103 v9 = v19 - v20; | |
7104 } | |
7105 v11 = (unsigned char *)v25; | |
7106 } | |
2069 | 7107 |
0 | 7108 if ( a8 ) |
7109 { | |
2069 | 7110 v28 = 0x7FF; // 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask; |
7111 for (int dy = 0; dy < v9; ++dy) | |
7112 { | |
7113 for (int dx = 0; dx < v8; ++dx) | |
7114 { | |
7115 if ( *v11 ) | |
7116 v24 = pPalette[*v11]; | |
7117 else | |
7118 v24 = v28; | |
7119 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24); | |
7120 //*v10 = v24; | |
7121 //++v10; | |
2074 | 7122 ++v11; |
2069 | 7123 //--v27; |
2074 | 7124 |
2069 | 7125 } |
7126 v11 += a5 - v8; | |
7127 } | |
7128 /*if ( (signed int)v9 > 0 ) | |
0 | 7129 { |
7130 v23 = a5; | |
7131 v30 = v9; | |
7132 do | |
7133 { | |
7134 if ( v8 > 0 ) | |
7135 { | |
7136 v27 = v8; | |
7137 do | |
7138 { | |
7139 if ( *v11 ) | |
7140 v24 = pPalette[*v11]; | |
7141 else | |
7142 v24 = v28; | |
7143 *v10 = v24; | |
7144 ++v10; | |
7145 ++v11; | |
7146 --v27; | |
7147 } | |
7148 while ( v27 ); | |
7149 } | |
7150 v11 += v23 - v8; | |
7151 v22 = v30-- == 1; | |
7152 v10 += this->uTargetSurfacePitch - v8; | |
7153 } | |
7154 while ( !v22 ); | |
2069 | 7155 }*/ |
0 | 7156 } |
7157 else | |
7158 { | |
2069 | 7159 for (int dy = 0; dy < v9; ++dy) |
7160 { | |
7161 for (int dx = 0; dx < v8; ++dx) | |
7162 { | |
2074 | 7163 if ( *v11 ) |
2069 | 7164 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]); |
7165 //*v10 = v24; | |
7166 //++v10; | |
2074 | 7167 ++v11; |
2069 | 7168 //--v27; |
7169 } | |
7170 v11 += a5 - v8; | |
7171 } | |
7172 | |
7173 /*if ( (signed int)v9 > 0 ) | |
0 | 7174 { |
7175 v21 = a5; | |
7176 v29 = v9; | |
7177 do | |
7178 { | |
7179 if ( v8 > 0 ) | |
7180 { | |
7181 v26 = v8; | |
7182 do | |
7183 { | |
7184 if ( *v11 ) | |
7185 *v10 = pPalette[*v11]; | |
7186 ++v10; | |
7187 ++v11; | |
7188 --v26; | |
7189 } | |
7190 while ( v26 ); | |
7191 } | |
7192 v11 += v21 - v8; | |
7193 v22 = v29-- == 1; | |
7194 v10 += this->uTargetSurfacePitch - v8; | |
7195 } | |
7196 while ( !v22 ); | |
2069 | 7197 }*/ |
7198 } | |
0 | 7199 } |
7200 | |
7201 //----- (004A68EF) -------------------------------------------------------- | |
7202 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
7203 { | |
2069 | 7204 DrawMasked(a2, a3, pTexture, 0x07E0); |
7205 } | |
7206 | |
0 | 7207 |
7208 //----- (004A6776) -------------------------------------------------------- | |
315 | 7209 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 7210 { |
2069 | 7211 DrawMasked(a2, a3, a4, 0xF800); |
7212 /*Texture *v4; // edi@2 | |
0 | 7213 unsigned int v5; // ebx@4 |
7214 unsigned __int16 *v6; // eax@4 | |
7215 unsigned int v7; // edx@5 | |
7216 unsigned int v8; // edx@6 | |
7217 unsigned int v9; // edx@7 | |
7218 unsigned int v10; // edx@8 | |
7219 unsigned int v11; // edx@9 | |
7220 unsigned int v12; // esi@12 | |
7221 unsigned int v13; // esi@15 | |
7222 unsigned int v14; // edx@17 | |
7223 unsigned int v15; // esi@18 | |
7224 unsigned __int8 *v16; // ebx@22 | |
7225 char v17; // zf@28 | |
7226 int v18; // [sp+10h] [bp-10h]@4 | |
7227 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7228 int v20; // [sp+1Ch] [bp-4h]@4 | |
7229 int a2a; // [sp+28h] [bp+8h]@24 | |
7230 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
7231 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
7232 | |
7233 if ( this->uNumSceneBegins ) | |
7234 { | |
7235 v4 = a4; | |
7236 if ( a4 ) | |
7237 { | |
7238 if ( a4->pPalette16 ) | |
7239 { | |
7240 v5 = a4->uTextureHeight; | |
7241 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7242 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7243 v20 = a4->uTextureWidth; |
7244 v18 = a4->uTextureWidth; | |
7245 if ( this->bClip ) | |
7246 { | |
7247 v7 = this->uClipX; | |
7248 if ( (signed int)a2 < (signed int)v7 ) | |
7249 { | |
7250 v8 = v7 - a2; | |
7251 v19 += v8; | |
7252 v20 += a2 - this->uClipX; | |
7253 v6 += v8; | |
7254 } | |
7255 v9 = this->uClipY; | |
7256 v5 = a4->uTextureHeight; | |
7257 if ( (signed int)a3 < (signed int)v9 ) | |
7258 { | |
7259 v10 = v9 - a3; | |
7260 v19 += v18 * v10; | |
7261 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
7262 v4 = a4; | |
7263 v6 += this->uTargetSurfacePitch * v10; | |
7264 } | |
7265 v11 = this->uClipX; | |
7266 if ( (signed int)v11 < (signed int)a2 ) | |
7267 v11 = a2; | |
7268 a4a = this->uClipZ; | |
7269 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
7270 { | |
7271 v12 = this->uClipX; | |
7272 if ( (signed int)v12 < (signed int)a2 ) | |
7273 v12 = a2; | |
7274 v20 = a4a - v12; | |
7275 } | |
7276 v13 = this->uClipY; | |
7277 if ( (signed int)v13 < (signed int)a3 ) | |
7278 v13 = a3; | |
7279 v14 = this->uClipW; | |
7280 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7281 { | |
7282 v15 = this->uClipY; | |
7283 if ( (signed int)v15 < (signed int)a3 ) | |
7284 v15 = a3; | |
7285 v5 = v14 - v15; | |
7286 } | |
7287 } | |
7288 if ( (signed int)v5 > 0 ) | |
7289 { | |
7290 a3a = v5; | |
7291 v16 = v19; | |
7292 do | |
7293 { | |
7294 if ( v20 > 0 ) | |
7295 { | |
7296 a2a = v20; | |
7297 do | |
7298 { | |
7299 if ( *v16 ) | |
7300 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
7301 ++v6; | |
7302 ++v16; | |
7303 --a2a; | |
7304 } | |
7305 while ( a2a ); | |
7306 } | |
7307 v16 += v18 - v20; | |
7308 v17 = a3a-- == 1; | |
7309 v6 += this->uTargetSurfacePitch - v20; | |
7310 } | |
7311 while ( !v17 ); | |
7312 } | |
7313 } | |
7314 } | |
2069 | 7315 }*/ |
7316 } | |
7317 | |
7318 //----- (004A68EF) -------------------------------------------------------- | |
7319 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask) | |
7320 { | |
7321 Texture *v4; // edi@2 | |
7322 unsigned int v5; // ebx@4 | |
7323 //unsigned __int16 *v6; // eax@4 | |
7324 signed int v7; // edx@5 | |
7325 int v8; // edx@6 | |
7326 signed int v9; // edx@7 | |
7327 int v10; // edx@8 | |
7328 signed int v11; // edx@9 | |
7329 signed int v12; // esi@12 | |
7330 signed int v13; // esi@15 | |
7331 unsigned int v14; // edx@17 | |
7332 signed int v15; // esi@18 | |
7333 unsigned __int8 *v16; // ebx@22 | |
7334 char v17; // zf@28 | |
7335 int v18; // [sp+10h] [bp-10h]@4 | |
7336 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7337 int v20; // [sp+1Ch] [bp-4h]@4 | |
7338 int v21; // [sp+28h] [bp+8h]@24 | |
7339 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
7340 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7341 | |
7342 if (!uNumSceneBegins || !pTexture) | |
7343 return; | |
7344 | |
7345 v4 = pTexture; | |
7346 | |
7347 if ( pTexture->pPalette16 ) | |
7348 { | |
7349 v5 = pTexture->uTextureHeight; | |
7350 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
7351 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; | |
7352 v20 = pTexture->uTextureWidth; | |
7353 v18 = pTexture->uTextureWidth; | |
7354 int clipped_out_x = a2; | |
7355 int clipped_out_y = a3; | |
7356 if ( this->bClip ) | |
7357 { | |
7358 v7 = this->uClipX; | |
7359 if ( a2 < v7 ) | |
7360 { | |
7361 v8 = v7 - a2; | |
7362 v19 += v8; | |
7363 v20 += a2 - this->uClipX; | |
7364 //v6 += v8; | |
7365 clipped_out_x = uClipX; | |
7366 } | |
7367 v9 = this->uClipY; | |
7368 v5 = pTexture->uTextureHeight; | |
7369 if ( a3 < v9 ) | |
7370 { | |
7371 v10 = v9 - a3; | |
7372 v19 += v18 * v10; | |
7373 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7374 v4 = pTexture; | |
7375 //v6 += this->uTargetSurfacePitch * v10; | |
7376 clipped_out_y = uClipY; | |
7377 } | |
7378 v11 = this->uClipX; | |
7379 if ( v11 < a2 ) | |
7380 v11 = a2; | |
7381 pTexturea = this->uClipZ; | |
7382 if ( v11 + v20 > (signed int)pTexturea ) | |
7383 { | |
7384 v12 = this->uClipX; | |
7385 if ( v12 < a2 ) | |
7386 v12 = a2; | |
7387 v20 = pTexturea - v12; | |
7388 } | |
7389 v13 = this->uClipY; | |
7390 if ( v13 < a3 ) | |
7391 v13 = a3; | |
7392 v14 = this->uClipW; | |
7393 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7394 { | |
7395 v15 = this->uClipY; | |
7396 if ( v15 < a3 ) | |
7397 v15 = a3; | |
7398 v5 = v14 - v15; | |
7399 } | |
7400 } | |
7401 | |
7402 v16 = v19; | |
7403 for (int y = 0; y < v5; ++y) | |
7404 { | |
7405 for (int x = 0; x < v20; ++x) | |
7406 { | |
7407 if ( *v16 ) | |
7408 WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16] & mask); | |
7409 ++v16; | |
7410 } | |
7411 v16 += v18 - v20; | |
7412 } | |
7413 | |
7414 /*if ( (signed int)v5 > 0 ) | |
7415 { | |
7416 v22 = v5; | |
7417 v16 = v19; | |
7418 do | |
7419 { | |
7420 if ( v20 > 0 ) | |
7421 { | |
7422 v21 = v20; | |
7423 do | |
7424 { | |
7425 if ( *v16 ) | |
7426 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7427 ++v6; | |
7428 ++v16; | |
7429 --v21; | |
7430 } | |
7431 while ( v21 ); | |
7432 } | |
7433 v16 += v18 - v20; | |
7434 v17 = v22-- == 1; | |
7435 v6 += this->uTargetSurfacePitch - v20; | |
7436 } | |
7437 while ( !v17 ); | |
7438 }*/ | |
7439 } | |
7440 } | |
7441 | |
0 | 7442 |
7443 //----- (004A65CC) -------------------------------------------------------- | |
7444 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
7445 { | |
2198 | 7446 unsigned int uHeight; // edi@6 |
0 | 7447 unsigned int v14; // edx@11 |
7448 unsigned int v16; // edx@14 | |
7449 unsigned int v17; // edx@17 | |
7450 unsigned int v19; // edx@20 | |
7451 int v20; // eax@27 | |
7452 int v21; // edx@29 | |
7453 int v23; // [sp+Ch] [bp-Ch]@24 | |
7454 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
7455 int xa; // [sp+20h] [bp+8h]@26 | |
7456 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
2198 | 7457 int Width; // [sp+2Ch] [bp+14h]@6 |
0 | 7458 |
7459 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
7460 { | |
710 | 7461 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7462 Width = a4->uTextureWidth; |
7463 uHeight = a4->uTextureHeight; | |
2069 | 7464 int clipped_out_x = x; |
7465 int clipped_out_y = y; | |
0 | 7466 if ( this->bClip ) |
7467 { | |
2198 | 7468 if ( (signed int)x < (signed int)this->uClipX ) |
7469 { | |
7470 v24 += this->uClipX - x; | |
7471 Width += x - this->uClipX; | |
2069 | 7472 clipped_out_x = uClipX; |
0 | 7473 } |
2198 | 7474 if ( (signed int)y < (signed int)this->uClipY ) |
7475 { | |
7476 v24 += a4->uTextureWidth * (this->uClipY - y); | |
7477 uHeight = y - this->uClipY + a4->uTextureHeight; | |
2069 | 7478 clipped_out_y = uClipY; |
0 | 7479 } |
7480 v14 = this->uClipX; | |
2198 | 7481 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7482 v14 = x; |
2198 | 7483 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7484 { |
7485 v16 = this->uClipX; | |
2198 | 7486 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7487 v16 = x; |
2198 | 7488 Width = this->uClipZ - v16; |
0 | 7489 } |
7490 v17 = this->uClipY; | |
2198 | 7491 if ( (signed int)this->uClipY < (signed int)y ) |
0 | 7492 v17 = y; |
2198 | 7493 if ( (signed int)(uHeight + v17) > (signed int)this->uClipW ) |
0 | 7494 { |
7495 v19 = this->uClipY; | |
7496 if ( (signed int)v19 < (signed int)y ) | |
7497 v19 = y; | |
2198 | 7498 uHeight = this->uClipW - v19; |
7499 } | |
7500 } | |
7501 | |
7502 for (int dy = 0; dy < uHeight; ++dy) | |
7503 { | |
7504 for (int dx = 0; dx < Width; ++dx) | |
7505 { | |
7506 v20 = *v24; | |
7507 if ( v20 >= a7 && v20 <= a8 ) | |
7508 { | |
7509 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7510 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7511 v21 = 2 * a8 - v21 - a7; | |
7512 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]); | |
7513 } | |
7514 ++v24; | |
7515 } | |
7516 v24 += a4->uTextureWidth - Width; | |
2069 | 7517 } |
7518 /*if ( (signed int)v9 > 0 ) | |
0 | 7519 { |
7520 ya = v9; | |
7521 v23 = v22 - v27; | |
7522 do | |
7523 { | |
7524 if ( v27 > 0 ) | |
7525 { | |
7526 xa = v27; | |
7527 do | |
7528 { | |
7529 v20 = *v24; | |
7530 if ( v20 >= a7 && v20 <= a8 ) | |
7531 { | |
7532 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7533 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7534 v21 = 2 * a8 - v21 - a7; | |
7535 *v8 = a4->pPalette16[v21]; | |
7536 } | |
7537 ++v8; | |
7538 ++v24; | |
7539 --xa; | |
7540 } | |
7541 while ( xa ); | |
7542 } | |
7543 v8 += this->uTargetSurfacePitch - v27; | |
7544 v24 += v23; | |
7545 --ya; | |
7546 } | |
7547 while ( ya ); | |
2069 | 7548 }*/ |
0 | 7549 } |
7550 } | |
7551 | |
7552 //----- (004A63E6) -------------------------------------------------------- | |
1455 | 7553 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) |
0 | 7554 { |
7555 unsigned int v14; // edx@11 | |
7556 unsigned int v16; // edx@14 | |
7557 unsigned int v17; // edx@17 | |
7558 unsigned int v19; // edx@20 | |
7559 int v20; // eax@27 | |
7560 int v21; // edx@29 | |
7561 int v23; // [sp+Ch] [bp-Ch]@24 | |
2198 | 7562 int Height; // [sp+10h] [bp-8h]@6 |
7563 int Width; // [sp+14h] [bp-4h]@6 | |
0 | 7564 int v27; // [sp+24h] [bp+Ch]@23 |
7565 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
7566 | |
7567 if ( this->uNumSceneBegins ) | |
7568 { | |
7569 if ( a4 ) | |
7570 { | |
7571 if ( a4->pPalette16 ) | |
7572 { | |
7573 if ( a5 ) | |
7574 { | |
7575 if ( a5->pPalette16 ) | |
7576 { | |
710 | 7577 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7578 Width = a4->uTextureWidth; |
7579 Height = a4->uTextureHeight; | |
2069 | 7580 int clipped_out_x = a2; |
7581 int clipped_out_y = a3; | |
0 | 7582 if ( this->bClip ) |
7583 { | |
2198 | 7584 if ( (signed int)a2 < (signed int)this->uClipX ) |
0 | 7585 { |
2198 | 7586 v28 += this->uClipX - a2; |
7587 Width += a2 - this->uClipX; | |
2069 | 7588 clipped_out_x = uClipX; |
0 | 7589 } |
2198 | 7590 |
7591 if ( (signed int)a3 < (signed int)this->uClipY ) | |
0 | 7592 { |
2198 | 7593 v28 += a4->uTextureWidth * (this->uClipY - a3); |
7594 Height += a3 - this->uClipY; | |
2069 | 7595 clipped_out_y = uClipY; |
0 | 7596 } |
2198 | 7597 |
0 | 7598 v14 = this->uClipX; |
2198 | 7599 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7600 v14 = a2; |
2198 | 7601 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7602 { |
7603 v16 = this->uClipX; | |
2198 | 7604 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7605 v16 = a2; |
2198 | 7606 Width = this->uClipZ - v16; |
0 | 7607 } |
2198 | 7608 |
0 | 7609 v17 = this->uClipY; |
2198 | 7610 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7611 v17 = a3; |
2198 | 7612 if ( (signed int)(Height + v17) > (signed int)this->uClipW ) |
0 | 7613 { |
7614 v19 = this->uClipY; | |
2198 | 7615 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7616 v19 = a3; |
2198 | 7617 Height = this->uClipW - v19; |
0 | 7618 } |
7619 } | |
2069 | 7620 |
0 | 7621 v27 = 0; |
2198 | 7622 for (int y = 0; y < Height; ++y) |
2069 | 7623 { |
2198 | 7624 for (int x = 0; x < Width; ++x) |
2069 | 7625 { |
7626 if ( *v28 ) | |
7627 { | |
2101 | 7628 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); |
2069 | 7629 if ( v20 >= a7 ) |
7630 { | |
7631 if ( v20 <= a8 ) | |
7632 { | |
7633 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7634 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7635 v21 = 2 * a8 - v21 - a7; | |
7636 //v9 = a5; | |
7637 //*v10 = a5->pPalette16[v21]; | |
7638 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]); | |
7639 } | |
7640 } | |
7641 } | |
7642 v28++; | |
7643 } | |
2198 | 7644 v28 += a4->uTextureWidth - Width; |
2069 | 7645 } |
7646 | |
7647 /*if ( v24 > 0 ) | |
0 | 7648 { |
7649 v23 = v22 - v25; | |
7650 do | |
7651 { | |
7652 for ( i = 0; i < v25; ++v28 ) | |
7653 { | |
7654 if ( *v28 ) | |
7655 { | |
710 | 7656 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 7657 if ( v20 >= a7 ) |
7658 { | |
7659 if ( v20 <= a8 ) | |
7660 { | |
7661 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7662 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7663 v21 = 2 * a8 - v21 - a7; | |
7664 v9 = a5; | |
7665 *v10 = a5->pPalette16[v21]; | |
7666 } | |
7667 } | |
7668 } | |
7669 ++i; | |
7670 ++v10; | |
7671 } | |
7672 ++v27; | |
7673 v10 += this->uTargetSurfacePitch - v25; | |
7674 v28 += v23; | |
7675 } | |
7676 while ( v27 < v24 ); | |
2069 | 7677 }*/ |
7678 | |
0 | 7679 } |
7680 } | |
7681 } | |
7682 } | |
7683 } | |
7684 } | |
7685 | |
7686 //----- (004A6274) -------------------------------------------------------- | |
7687 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
7688 { | |
7689 int uHeight; // ebx@4 | |
7690 unsigned int v11; // edx@9 | |
7691 unsigned int v12; // esi@12 | |
7692 unsigned int v13; // esi@15 | |
7693 unsigned int v15; // esi@18 | |
7694 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7695 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
7696 | |
7697 if ( this->uNumSceneBegins ) | |
7698 { | |
7699 if ( pTexture ) | |
7700 { | |
7701 if ( pTexture->pPalette16 ) | |
7702 { | |
7703 uHeight = pTexture->uTextureHeight; | |
710 | 7704 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7705 uWidth = pTexture->uTextureWidth; |
2069 | 7706 |
7707 int clipped_out_x = uX; | |
7708 int clipped_out_y = uY; | |
0 | 7709 if ( this->bClip ) |
7710 { | |
2198 | 7711 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 7712 { |
2198 | 7713 v19 += this->uClipX - uX; |
0 | 7714 uWidth += uX - this->uClipX; |
2069 | 7715 clipped_out_x = uClipX; |
0 | 7716 } |
2198 | 7717 |
0 | 7718 uHeight = pTexture->uTextureHeight; |
2198 | 7719 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 7720 { |
2198 | 7721 v19 += pTexture->uTextureWidth * (this->uClipY - uY); |
0 | 7722 uHeight = uY - this->uClipY + pTexture->uTextureHeight; |
2069 | 7723 clipped_out_y = uClipY; |
0 | 7724 } |
7725 v11 = this->uClipX; | |
2198 | 7726 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7727 v11 = uX; |
2198 | 7728 |
7729 if ( (signed int)(v11 + uWidth) > (signed int)this->uClipZ ) | |
0 | 7730 { |
7731 v12 = this->uClipX; | |
2198 | 7732 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7733 v12 = uX; |
2198 | 7734 uWidth = this->uClipZ - v12; |
0 | 7735 } |
7736 v13 = this->uClipY; | |
2198 | 7737 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7738 v13 = uY; |
2198 | 7739 |
7740 if ( (signed int)(uHeight + v13) > (signed int)this->uClipW ) | |
0 | 7741 { |
7742 v15 = this->uClipY; | |
2198 | 7743 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7744 v15 = uY; |
2198 | 7745 uHeight = this->uClipW - v15; |
0 | 7746 } |
7747 } | |
2198 | 7748 |
2069 | 7749 for (int y = 0; y < uHeight; ++y) |
7750 { | |
7751 for (int x = 0; x < uWidth; ++x) | |
7752 { | |
2198 | 7753 if ( *v19 ) |
7754 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); | |
7755 ++v19; | |
2069 | 7756 } |
2198 | 7757 v19 += pTexture->uTextureWidth - uWidth; |
2069 | 7758 } |
7759 /*if ( (signed int)uHeight > 0 ) | |
0 | 7760 { |
7761 uYa = uHeight; | |
7762 v16 = v19; | |
7763 do | |
7764 { | |
7765 if ( uWidth > 0 ) | |
7766 { | |
7767 uXa = uWidth; | |
7768 do | |
7769 { | |
7770 if ( *v16 ) | |
7771 *v6 = pCurrentTexture->pPalette16[*v16]; | |
7772 ++v6; | |
7773 ++v16; | |
7774 } | |
7775 while ( uXa-- !=1 ); | |
7776 } | |
7777 v16 += v18 - uWidth; | |
7778 uFlag = uYa-- == 1; | |
7779 v6 += this->uTargetSurfacePitch - uWidth; | |
7780 } | |
7781 while ( !uFlag ); | |
2069 | 7782 }*/ |
0 | 7783 } |
7784 } | |
7785 } | |
7786 } | |
7787 | |
7788 //----- (004A612A) -------------------------------------------------------- | |
710 | 7789 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 7790 { |
7791 Texture *v5; // eax@2 | |
7792 unsigned int v6; // edx@3 | |
7793 int v7; // ebx@3 | |
7794 int v8; // edi@3 | |
7795 signed int v9; // eax@4 | |
7796 int v10; // eax@5 | |
7797 unsigned int v11; // esi@6 | |
7798 signed int v12; // esi@8 | |
7799 unsigned int v13; // eax@10 | |
7800 signed int v14; // esi@11 | |
7801 unsigned int v15; // esi@14 | |
7802 unsigned int v16; // eax@16 | |
7803 unsigned int v17; // ecx@17 | |
7804 int v18; // edx@23 | |
7805 int v19; // [sp+Ch] [bp-Ch]@3 | |
7806 int v20; // [sp+10h] [bp-8h]@3 | |
7807 int uOutXa; // [sp+20h] [bp+8h]@21 | |
7808 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
7809 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
7810 | |
7811 if ( this->uNumSceneBegins ) | |
7812 { | |
7813 v5 = pTexture; | |
7814 if ( pTexture ) | |
7815 { | |
7816 v6 = uOutY; | |
7817 v7 = pTexture->uTextureHeight; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7818 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; |
710 | 7819 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7820 v8 = v5->uTextureWidth; |
7821 v20 = v5->uTextureWidth; | |
7822 v19 = v5->uTextureWidth; | |
7823 if ( this->bClip ) | |
7824 { | |
7825 v9 = this->uClipX; | |
7826 if ( uOutX < v9 ) | |
7827 { | |
7828 v10 = v9 - uOutX; | |
7829 uOutYa += v10; | |
7830 v8 += uOutX - this->uClipX; | |
7831 v20 = v8; | |
7832 pZBuffer += v10; | |
7833 } | |
7834 v11 = this->uClipY; | |
7835 if ( (signed int)v6 < (signed int)v11 ) | |
7836 { | |
7837 uOutYa += v19 * (v11 - v6); | |
7838 v7 += v6 - v11; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7839 pZBuffer += window->GetWidth() * (v11 - v6); |
0 | 7840 v8 = v20; |
7841 } | |
7842 v12 = this->uClipX; | |
7843 if ( v12 < uOutX ) | |
7844 v12 = uOutX; | |
7845 v13 = this->uClipZ; | |
7846 if ( v8 + v12 > (signed int)v13 ) | |
7847 { | |
7848 v14 = this->uClipX; | |
7849 if ( v14 < uOutX ) | |
7850 v14 = uOutX; | |
7851 v8 = v13 - v14; | |
7852 } | |
7853 v15 = this->uClipY; | |
7854 if ( (signed int)v15 < (signed int)v6 ) | |
7855 v15 = v6; | |
7856 v16 = this->uClipW; | |
7857 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
7858 { | |
7859 v17 = this->uClipY; | |
7860 if ( (signed int)v17 >= (signed int)v6 ) | |
7861 v6 = v17; | |
7862 v7 = v16 - v6; | |
7863 } | |
7864 } | |
7865 if ( v7 > 0 ) | |
7866 { | |
7867 uOutXa = v7; | |
7868 do | |
7869 { | |
7870 if ( v8 > 0 ) | |
7871 { | |
7872 v18 = v8; | |
7873 do | |
7874 { | |
7875 if ( *uOutYa ) | |
7876 *pZBuffer = zVal; | |
7877 ++pZBuffer; | |
7878 ++uOutYa; | |
7879 --v18; | |
7880 } | |
7881 while ( v18 ); | |
7882 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7883 pZBuffer += window->GetWidth() - v8; |
0 | 7884 uOutYa += v19 - v8; |
7885 --uOutXa; | |
7886 } | |
7887 while ( uOutXa ); | |
7888 } | |
7889 } | |
7890 } | |
7891 } | |
7892 | |
7893 //----- (004A601E) -------------------------------------------------------- | |
991 | 7894 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 7895 { |
7896 signed int v5; // edx@3 | |
7897 int v6; // ebx@3 | |
7898 int v7; // esi@3 | |
7899 void *v8; // esi@3 | |
7900 unsigned int v9; // eax@4 | |
7901 unsigned int v10; // eax@6 | |
7902 signed int v11; // edi@8 | |
7903 unsigned int v12; // eax@10 | |
7904 signed int v13; // edi@11 | |
7905 unsigned int v14; // edi@14 | |
7906 unsigned int v15; // eax@16 | |
7907 unsigned int v16; // ecx@17 | |
7908 int v17; // [sp+18h] [bp+Ch]@3 | |
7909 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
7910 | |
7911 if ( this->uNumSceneBegins && pTexture ) | |
7912 { | |
7913 v5 = a3; | |
7914 v6 = pTexture->uTextureHeight; | |
7915 v7 = 5 * a3; | |
7916 v17 = pTexture->uTextureHeight; | |
7917 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
7918 pTexturea = pTexture->uTextureWidth; | |
7919 if ( this->bClip ) | |
7920 { | |
7921 v9 = this->uClipX; | |
7922 if ( a2 < (signed int)v9 ) | |
7923 { | |
7924 pTexturea += a2 - v9; | |
7925 v8 = (char *)v8 + 4 * (v9 - a2); | |
7926 } | |
7927 v10 = this->uClipY; | |
7928 if ( v5 < (signed int)v10 ) | |
7929 { | |
7930 v17 += v5 - v10; | |
7931 v8 = (char *)v8 + 2560 * (v10 - v5); | |
7932 } | |
7933 v11 = this->uClipX; | |
7934 if ( v11 < a2 ) | |
7935 v11 = a2; | |
7936 v12 = this->uClipZ; | |
7937 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
7938 { | |
7939 v13 = this->uClipX; | |
7940 if ( v13 < a2 ) | |
7941 v13 = a2; | |
7942 pTexturea = v12 - v13; | |
7943 } | |
7944 v14 = this->uClipY; | |
7945 if ( (signed int)v14 < v5 ) | |
7946 v14 = v5; | |
7947 v6 = v17; | |
7948 v15 = this->uClipW; | |
7949 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
7950 { | |
7951 v16 = this->uClipY; | |
7952 if ( (signed int)v16 < v5 ) | |
7953 v16 = v5; | |
7954 v6 = v15 - v16; | |
7955 } | |
7956 } | |
7957 if ( v6 > 0 ) | |
7958 { | |
7959 do | |
7960 { | |
7961 if ( (signed int)pTexturea > 0 ) | |
7962 { | |
7963 memset32(v8, a5, pTexturea); | |
7964 v8 = (char *)v8 + 4 * pTexturea; | |
7965 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7966 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea); |
0 | 7967 --v6; |
7968 } | |
7969 while ( v6 ); | |
7970 } | |
7971 } | |
7972 } | |
7973 | |
7974 //----- (004A5EB2) -------------------------------------------------------- | |
7975 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
7976 { | |
2069 | 7977 int v5; // ebx@4 |
0 | 7978 unsigned int v8; // edx@6 |
7979 unsigned int v10; // edx@8 | |
7980 unsigned int v11; // edx@9 | |
7981 unsigned int v12; // esi@12 | |
7982 unsigned int v13; // esi@15 | |
7983 unsigned int v15; // esi@18 | |
7984 char v17; // zf@26 | |
7985 int v18; // [sp+10h] [bp-10h]@4 | |
7986 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7987 int v20; // [sp+1Ch] [bp-4h]@4 | |
7988 int uXa; // [sp+28h] [bp+8h]@24 | |
7989 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
7990 | |
7991 if ( this->uNumSceneBegins ) | |
7992 { | |
7993 if ( a4 ) | |
7994 { | |
7995 if ( a4->pPalette16 ) | |
7996 { | |
7997 v5 = a4->uTextureHeight; | |
2069 | 7998 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
710 | 7999 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8000 v20 = a4->uTextureWidth; |
8001 v18 = a4->uTextureWidth; | |
2069 | 8002 |
8003 int clipped_out_x = uX; | |
8004 int clipped_out_y = uY; | |
0 | 8005 if ( this->bClip ) |
8006 { | |
2198 | 8007 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 8008 { |
2198 | 8009 v8 = this->uClipX - uX; |
0 | 8010 v19 += v8; |
8011 v20 += uX - this->uClipX; | |
2069 | 8012 clipped_out_x = uClipX; |
0 | 8013 } |
2198 | 8014 |
0 | 8015 v5 = a4->uTextureHeight; |
2198 | 8016 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 8017 { |
2198 | 8018 v10 = this->uClipY - uY; |
0 | 8019 v19 += v18 * v10; |
8020 v5 = uY - this->uClipY + a4->uTextureHeight; | |
2198 | 8021 //v4 = a4; |
2069 | 8022 clipped_out_y = uClipY; |
0 | 8023 } |
2198 | 8024 |
0 | 8025 v11 = this->uClipX; |
8026 if ( (signed int)v11 < (signed int)uX ) | |
8027 v11 = uX; | |
2198 | 8028 |
8029 if ( (signed int)(v11 + v20) > (signed int)this->uClipZ ) | |
0 | 8030 { |
8031 v12 = this->uClipX; | |
8032 if ( (signed int)v12 < (signed int)uX ) | |
8033 v12 = uX; | |
2198 | 8034 v20 = this->uClipZ - v12; |
0 | 8035 } |
2198 | 8036 |
0 | 8037 v13 = this->uClipY; |
8038 if ( (signed int)v13 < (signed int)uY ) | |
8039 v13 = uY; | |
2069 | 8040 |
8041 if ( (signed int)(v5 + v13) > (signed int)uClipW ) | |
0 | 8042 { |
8043 v15 = this->uClipY; | |
8044 if ( (signed int)v15 < (signed int)uY ) | |
8045 v15 = uY; | |
2069 | 8046 v5 = uClipW - v15; |
0 | 8047 } |
8048 } | |
2198 | 8049 |
2069 | 8050 for (int y = 0; y < v5; ++y) |
8051 { | |
8052 for (int x = 0; x < v20; ++x) | |
8053 { | |
2198 | 8054 if ( a4->pPalette16[*v19] != 0x7FF )// 2047 |
8055 WritePixel16(clipped_out_x + x, clipped_out_y + y, a4->pPalette16[*v19]); | |
8056 ++v19; | |
2069 | 8057 } |
2198 | 8058 v19 += v18 - v20; |
2069 | 8059 } |
8060 /*if ( (signed int)v5 > 0 ) | |
0 | 8061 { |
8062 uYa = v5; | |
8063 v16 = v19; | |
8064 do | |
8065 { | |
8066 if ( v20 > 0 ) | |
8067 { | |
8068 uXa = v20; | |
8069 do | |
8070 { | |
8071 *pTarget = v4->pPalette16[*v16]; | |
8072 ++pTarget; | |
8073 ++v16; | |
8074 --uXa; | |
8075 } | |
8076 while ( uXa ); | |
8077 } | |
8078 v16 += v18 - v20; | |
8079 v17 = uYa-- == 1; | |
8080 pTarget += this->uTargetSurfacePitch - v20; | |
8081 } | |
8082 while ( !v17 ); | |
2069 | 8083 }*/ |
0 | 8084 } |
8085 } | |
8086 } | |
8087 } | |
8088 | |
8089 //----- (004667E9) -------------------------------------------------------- | |
8090 void Render::ChangeBetweenWinFullscreenModes() | |
8091 { | |
8092 float v0; // ST14_4@17 | |
8093 int v4; // edx@26 | |
8094 ObjectDesc *v5; // eax@26 | |
8095 RGBTexture *v6; // esi@33 | |
8096 const char *v8; // [sp-4h] [bp-28h]@33 | |
8097 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
8098 | |
2061 | 8099 /*if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) |
0 | 8100 { |
1458 | 8101 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 | 8102 return; |
2061 | 8103 }*/ |
2154 | 8104 if ( pRenderer->bWindowMode || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8105 { |
0 | 8106 if ( pEventTimer->bPaused ) |
2061 | 8107 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0800; |
0 | 8108 else |
8109 pEventTimer->Pause(); | |
8110 if ( pMiscTimer->bPaused ) | |
2061 | 8111 dword_6BE364_game_settings_1 |= GAME_SETTINGS_1000; |
0 | 8112 else |
8113 pMiscTimer->Pause(); | |
8114 pMouse->bActive = 0; | |
8115 if ( pRenderer->pRenderD3D ) | |
8116 { | |
8117 pBitmaps_LOD->ReleaseHardwareTextures(); | |
8118 pSprites_LOD->ReleaseAll(); | |
8119 } | |
8120 if ( pRenderer->bWindowMode ) | |
8121 { | |
1802 | 8122 //SetMenu(hWnd, 0); |
8123 //SetWindowLongA(hWnd, -20, 0); | |
8124 //SetWindowLongA(hWnd, -16, 0x10000000u); | |
8125 window->SetFullscreenMode(); | |
8126 pRenderer->InitializeFullscreen(); | |
0 | 8127 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; |
8128 pGame->pGammaController->Initialize(v0); | |
8129 } | |
8130 else | |
8131 { | |
1802 | 8132 //ClipCursor(0); |
8133 window->SetWindowedMode(window->GetWidth(), window->GetHeight()); | |
8134 pRenderer->SwitchToWindow(); | |
0 | 8135 } |
8136 if ( pRenderer->pRenderD3D ) | |
8137 { | |
8138 pBitmaps_LOD->_410423_move_textures_to_device(); | |
8139 pSprites_LOD->MoveSpritesToVideoMemory(); | |
8140 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8141 if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits |
0 | 8142 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8143 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8144 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8145 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8146 pPaletteManager->RecalculateAll(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8147 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8148 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8149 for (int i = 0; i < pObjectList->uNumObjects; i++) |
0 | 8150 { |
8151 BYTE3(v4) = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8152 v5 = &pObjectList->pObjects[i]; |
0 | 8153 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; |
8154 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
8155 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8156 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8157 SetUserInterface(pParty->alignment, true); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8158 if ( pVideoPlayer->pVideoFrame.pPixels ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8159 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); |
2006 | 8160 if ( sCurrentMenuID != MENU_CREATEPARTY ) |
8161 { | |
8162 if ( sCurrentMenuID == MENU_CREDITSPROC ) | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8163 dword_A74C88 = 1; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8164 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8165 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8166 { |
2006 | 8167 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8168 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8169 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8170 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8171 v8 = "makeme.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8172 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8173 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8174 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8175 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8176 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8177 v8 = "title.pcx"; |
2006 | 8178 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8179 v8 = "lsave640.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8180 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8181 v6->Load(v8, 0); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8182 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8183 } |
0 | 8184 viewparams->bRedrawGameUI = 1; |
688 | 8185 viewparams->InitGrayPalette(); |
0 | 8186 pMouse->SetCurrentCursorBitmap(); |
1802 | 8187 /*if ( pRenderer->bWindowMode ) |
0 | 8188 { |
1655 | 8189 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); |
8190 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); | |
1586 | 8191 ShowWindow(hWnd, SW_SHOWNORMAL); |
1802 | 8192 }*/ |
8193 pMouse->bActive = true; | |
0 | 8194 if ( pVideoPlayer->AnyMovieLoaded() ) |
898 | 8195 pVideoPlayer->SelectMovieType(); |
2061 | 8196 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0800) |
8197 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0800; | |
0 | 8198 else |
8199 pEventTimer->Resume(); | |
2061 | 8200 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_1000) |
8201 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_1000; | |
0 | 8202 else |
8203 pMiscTimer->Resume(); | |
8204 } | |
8205 } | |
8206 | |
8207 | |
8208 //----- (004524D8) -------------------------------------------------------- | |
8209 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
8210 { | |
1583 | 8211 //int v11; // eax@13 |
8212 //int v12; // ecx@13 | |
0 | 8213 void *v13; // eax@13 |
1583 | 8214 //unsigned __int8 v14; // zf@13 |
8215 //unsigned __int8 v15; // sf@13 | |
0 | 8216 int v16; // esi@14 |
8217 int v17; // ecx@16 | |
8218 int v18; // esi@16 | |
8219 unsigned __int16 *v19; // eax@16 | |
8220 int v20; // edx@16 | |
8221 int v21; // ecx@16 | |
8222 int v22; // eax@16 | |
8223 int v23; // esi@16 | |
8224 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
8225 int v27; // [sp+28h] [bp-Ch]@14 | |
8226 int v28; // [sp+2Ch] [bp-8h]@13 | |
8227 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
8228 | |
8229 //v3 = this; | |
8230 //sprintf(Str1, "%s", pName); | |
8231 //v4 = uNumItems; | |
8232 if (!uNumItems) | |
8233 return nullptr; | |
8234 | |
8235 //{ | |
8236 //v5 = 0, pDesta = uNumItems; | |
8237 uint idx1 = 0, | |
8238 idx2 = uNumItems; | |
8239 while (true) | |
8240 { | |
1980 | 8241 uint i = idx1 + (idx2 - idx1) / 2; |
8242 | |
8243 int res = _stricmp(pName, pSpriteNames[i]); | |
0 | 8244 if (!res) |
8245 { | |
8246 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
8247 break; | |
8248 } | |
8249 else if (res < 0) | |
8250 idx2 = idx1 + (idx2 - idx1) / 2; | |
8251 else | |
8252 idx1 = i + 1; | |
8253 | |
8254 if ( idx1 >= idx2 ) | |
8255 return false; | |
8256 } | |
8257 | |
8258 | |
8259 uint uCompressedSize = 0; | |
8260 fread(&uCompressedSize, 4, 1, pFile); | |
8261 | |
1980 | 8262 HWLTexture* pTex = new HWLTexture; |
670 | 8263 fread(&pTex->uBufferWidth, 4, 1, pFile); |
8264 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
8265 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
8266 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 8267 fread(&pTex->uWidth, 4, 1, pFile); |
8268 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 8269 fread(&pTex->uAreaX, 4, 1, pFile); |
8270 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 8271 |
8272 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
8273 if (uCompressedSize) | |
8274 { | |
1980 | 8275 char* pCompressedData = new char[uCompressedSize]; |
0 | 8276 { |
8277 fread(pCompressedData, 1, uCompressedSize, pFile); | |
1980 | 8278 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); |
0 | 8279 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); |
8280 } | |
8281 delete [] pCompressedData; | |
8282 } | |
8283 else | |
8284 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
8285 | |
1583 | 8286 if ( scale_hwls_to_half ) |
8287 { | |
8288 pTex->uHeight /= 2; | |
8289 pTex->uWidth /= 2; | |
8290 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
0 | 8291 v28 = 0; |
8292 v26 = (unsigned __int16 *)v13; | |
1583 | 8293 if ( pTex->uHeight > 0 ) |
0 | 8294 { |
8295 v16 = pTex->uWidth; | |
8296 v27 = 1; | |
8297 do | |
8298 { | |
8299 pDestb = 0; | |
8300 if ( v16 > 0 ) | |
8301 { | |
8302 do | |
8303 { | |
8304 v17 = v16 * v27; | |
8305 v18 = v28 * v16; | |
8306 v19 = pTex->pPixels; | |
8307 v20 = pDestb + 2 * v18; | |
8308 v21 = (int)&v19[2 * (pDestb + v17)]; | |
8309 v22 = (int)&v19[2 * v20]; | |
8310 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
8311 LOWORD(v21) = *(unsigned short *)v21; | |
8312 v23 = pDestb++ + v18; | |
1583 | 8313 extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); |
8314 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
0 | 8315 v16 = pTex->uWidth; |
8316 } | |
8317 while (pDestb < pTex->uWidth); | |
8318 } | |
8319 ++v28; | |
8320 v27 += 2; | |
8321 } | |
8322 while ( v28 < (signed int)pTex->uHeight ); | |
8323 } | |
8324 delete [] pTex->pPixels; | |
8325 pTex->pPixels = v26; | |
8326 } | |
8327 return pTex; | |
8328 } | |
8329 | |
8330 //----- (0045271F) -------------------------------------------------------- | |
8331 bool RenderHWLContainer::Release() | |
8332 { | |
8333 __int32 v4; // eax@6 | |
8334 FILE *v5; // ST24_4@6 | |
8335 FILE *File; // [sp+4h] [bp-4h]@6 | |
8336 | |
1162 | 8337 if ( this->bDumpDebug) |
0 | 8338 { |
8339 File = fopen("logd3d.txt", "w"); | |
1162 | 8340 v4 = ftell(this->pFile); |
8341 v5 = this->pFile; | |
8342 this->uDataOffset = v4; | |
8343 fwrite(&this->uNumItems, 4u, 1u, v5); | |
8344 for (int i = 0; i < this->uNumItems; i++) | |
8345 { | |
8346 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
8347 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
8348 } | |
8349 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
8350 fseek(this->pFile, 4, 0); | |
8351 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
8352 fclose(this->pFile); | |
0 | 8353 fclose(File); |
8354 } | |
8355 else | |
8356 { | |
8357 fclose(this->pFile); | |
1162 | 8358 for (int i = 0; i < this->uNumItems; i++) |
8359 { | |
8360 free(this->pSpriteNames[i]); | |
0 | 8361 } |
8362 } | |
1093 | 8363 return true; |
0 | 8364 } |
8365 | |
8366 //----- (00452347) -------------------------------------------------------- | |
8367 RenderHWLContainer::RenderHWLContainer(): | |
8368 bDumpDebug(false) | |
8369 { | |
8370 this->pFile = 0; | |
8371 uSignature = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8372 this->uDataOffset = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8373 memset(&this->uNumItems, 0, 0x61A84u); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8374 this->uNumItems = 0; |
1583 | 8375 this->scale_hwls_to_half = false; |
0 | 8376 } |
8377 | |
8378 //----- (0045237F) -------------------------------------------------------- | |
8379 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
8380 { | |
8381 pFile = _wfopen(pFilename, L"rb"); | |
8382 if (!pFile) | |
8383 { | |
8384 Log::Warning(L"Failed to open file: %s", pFilename); | |
8385 return false; | |
8386 } | |
8387 | |
8388 fread(&uSignature, 1, 4, pFile); | |
8389 if (uSignature != 'TD3D') | |
8390 { | |
8391 Log::Warning(L"Invalid format: %s", pFilename); | |
8392 return false; | |
8393 } | |
8394 | |
8395 fread(&uDataOffset, 4, 1, pFile); | |
8396 fseek(pFile, uDataOffset, SEEK_SET); | |
8397 fread(&uNumItems, 4, 1, pFile); | |
8398 | |
8399 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
8400 for (uint i = 0; i < uNumItems; ++i) | |
8401 { | |
8402 pSpriteNames[i] = new char[20]; | |
8403 fread(pSpriteNames[i], 1, 20, pFile); | |
8404 } | |
8405 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
8406 | |
8407 return true; | |
8408 } | |
8409 | |
8410 //----- (004A1C1E) -------------------------------------------------------- | |
2153 | 8411 void Render::DoRenderBillboards_D3D() |
8412 { | |
8413 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
8414 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8415 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8416 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8417 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8418 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8419 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8420 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8421 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8422 { |
1390 | 8423 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; |
8424 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
8425 } | |
8426 p->pQuads[0].pos.x = 10; | |
8427 p->pQuads[0].pos.y = 10; | |
8428 | |
8429 p->pQuads[1].pos.x = 10; | |
8430 p->pQuads[1].pos.y = 200; | |
8431 | |
8432 p->pQuads[2].pos.x = 100; | |
8433 p->pQuads[2].pos.y = 200; | |
8434 | |
8435 p->pQuads[3].pos.x = 100; | |
8436 p->pQuads[3].pos.y = 10; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8437 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8438 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8439 SetBillboardBlendOptions(p->uOpacity); |
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 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8442 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8443 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8444 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8445 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8446 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8447 }*/ |
0 | 8448 |
2153 | 8449 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) |
8450 { | |
2155 | 8451 if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend) |
8452 SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity); | |
2114 | 8453 |
2153 | 8454 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture); |
8455 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
8456 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8457 pBillboardRenderListD3D[i].pQuads, pBillboardRenderListD3D[i].uNumVertices, | |
8458 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); | |
8459 } | |
8460 | |
8461 if (bFogEnabled) | |
8462 { | |
8463 bFogEnabled = false; | |
8464 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8465 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8466 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8467 } | |
8468 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
8469 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8470 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8471 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8472 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8473 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8474 } |
8475 | |
8476 //----- (004A1DA8) -------------------------------------------------------- | |
2153 | 8477 void Render::SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) |
0 | 8478 { |
8479 switch (a1) | |
8480 { | |
8481 case RenderBillboardD3D::Transparent: | |
8482 { | |
2153 | 8483 if (bFogEnabled) |
8484 { | |
8485 bFogEnabled = false; | |
8486 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8487 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8488 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8489 } | |
8490 | |
8491 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
8492 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
8493 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8494 } |
8495 break; | |
8496 | |
8497 case RenderBillboardD3D::Opaque_1: | |
8498 case RenderBillboardD3D::Opaque_2: | |
8499 case RenderBillboardD3D::Opaque_3: | |
8500 { | |
2153 | 8501 if (bUsingSpecular) |
8502 { | |
8503 if (!bFogEnabled) | |
0 | 8504 { |
2153 | 8505 bFogEnabled = true; |
8506 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
186 | 8507 } |
8508 } | |
8509 | |
2153 | 8510 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
8511 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8512 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 8513 } |
8514 break; | |
8515 | |
8516 default: | |
8517 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8518 assert(false); |
0 | 8519 break; |
8520 } | |
1787 | 8521 } |
1903 | 8522 //----- (00424CD7) -------------------------------------------------------- |
8523 int ODM_NearClip(unsigned int num_vertices) | |
8524 { | |
8525 bool current_vertices_flag; // edi@1 | |
8526 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 | |
8527 double t; // st6@10 | |
2320 | 8528 bool bFound; |
8529 | |
8530 bFound = false; | |
1903 | 8531 |
8532 if (!num_vertices) | |
8533 return 0; | |
2320 | 8534 for (uint i = 0; i < num_vertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû |
8535 { | |
8536 if ( array_50AC10[i].vWorldViewPosition.x > 8.0 ) | |
8537 { | |
8538 bFound = true; | |
8539 break; | |
8540 } | |
8541 } | |
8542 if ( !bFound ) | |
8543 return 0; | |
1903 | 8544 |
2318 | 8545 memcpy(&array_50AC10[num_vertices], &array_50AC10[0], sizeof(array_50AC10[0])); |
8546 current_vertices_flag = false; | |
8547 next_vertices_flag = false; | |
8548 if ( array_50AC10[0].vWorldViewPosition.x <= 8.0 ) | |
8549 current_vertices_flag = true; | |
2320 | 8550 //check for near clip plane(ïðîâåðêà ïî áëèæíåé ãðàíèöå) |
8551 // | |
8552 // v3.__________________. v0 | |
8553 // | | | |
8554 // | | | |
8555 // | | | |
8556 // ----------------------- 8.0(near_clip - 8.0) | |
8557 // | | | |
8558 // .__________________. | |
8559 // v2 v1 | |
1903 | 8560 |
8561 int out_num_vertices = 0; | |
8562 for (int i = 0; i < num_vertices; ++i) | |
8563 { | |
2318 | 8564 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x <= 8.0;// |
8565 if ( current_vertices_flag ^ next_vertices_flag ) | |
8566 { | |
8567 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé | |
1903 | 8568 { |
2191 | 8569 //t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) |
1903 | 8570 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
2318 | 8571 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; |
8572 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t; | |
8573 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t; | |
8574 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t; | |
8575 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t; | |
8576 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
8577 } | |
8578 else// òåêóùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé | |
8579 { | |
8580 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); | |
8581 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; | |
8582 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t; | |
8583 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t; | |
8584 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t; | |
8585 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t; | |
8586 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
8587 } | |
1904 | 8588 //array_507D30[out_num_vertices]._rhw = 0x3E000000u; |
1903 | 8589 ++out_num_vertices; |
8590 } | |
2318 | 8591 if ( !next_vertices_flag ) |
8592 { | |
8593 memcpy(&array_507D30[out_num_vertices], &array_50AC10[i + 1], sizeof(array_50AC10[i + 1])); | |
8594 out_num_vertices++; | |
1903 | 8595 } |
8596 current_vertices_flag = next_vertices_flag; | |
8597 } | |
8598 return out_num_vertices >= 3 ? out_num_vertices : 0; | |
8599 } | |
1787 | 8600 //----- (00424EE0) -------------------------------------------------------- |
1903 | 8601 int ODM_FarClip(unsigned int uNumVertices) |
1787 | 8602 { |
2318 | 8603 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 |
8604 bool next_vertices_flag; // edi@1 | |
1787 | 8605 double t; // st6@10 |
8606 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 | |
2318 | 8607 bool bFound; |
1787 | 8608 //Äîï èíôî "Ïðîãðàììèðîâàíèå òð¸õìåðíûõ èãð äëÿ windows" Ëàìîò ñòð 910 |
8609 | |
2318 | 8610 bFound = false; |
8611 | |
8612 memcpy(&array_50AC10[uNumVertices], &array_50AC10[0], sizeof(array_50AC10[uNumVertices])); | |
1787 | 8613 depth_num_vertices = 0; |
2318 | 8614 current_vertices_flag = false; |
8615 if ( array_50AC10[0].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist ) | |
8616 current_vertices_flag = true;//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè | |
1787 | 8617 if ( (signed int)uNumVertices <= 0 ) |
8618 return 0; | |
2318 | 8619 for (uint i = 0; i < uNumVertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû |
8620 { | |
8621 if ( array_50AC10[i].vWorldViewPosition.x < pODMRenderParams->shading_dist_mist ) | |
8622 { | |
8623 bFound = true; | |
8624 break; | |
8625 } | |
8626 } | |
8627 if ( !bFound ) | |
8628 return 0; | |
8629 //check for far clip plane(ïðîâåðêà ïî äàëüíåé ãðàíèöå) | |
8630 // | |
8631 // v3.__________________. v0 | |
8632 // | | | |
8633 // | | | |
8634 // | | | |
8635 // ----------------------- 8192.0(far_clip - 0x2000) | |
8636 // | | | |
8637 // .__________________. | |
8638 // v2 v1 | |
8639 | |
8640 for ( uint i = 0; i < uNumVertices; ++i ) | |
8641 { | |
8642 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist; | |
8643 if ( current_vertices_flag ^ next_vertices_flag )//îäíà èç ãðàíåé çà ãðàíèöåé âèäèìîñòè | |
8644 { | |
8645 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(íàñòîÿùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v3 | |
8646 { | |
8647 //t = far_clip - v2.x / v3.x - v2.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
2320 | 8648 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); |
2318 | 8649 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; |
8650 //New_y = v2.y + (v3.y - v2.y)*t | |
2320 | 8651 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 | 8652 //New_z = v2.z + (v3.z - v2.z)*t |
2320 | 8653 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t; |
8654 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t; | |
8655 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t; | |
2318 | 8656 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; |
8657 } | |
8658 else//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(ñëåäóþùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v0 | |
1787 | 8659 { |
8660 //t = far_clip - v1.x / v0.x - v1.x | |
2318 | 8661 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
8662 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; | |
8663 //New_y = (v0.y - v1.y)*t + v1.y | |
2320 | 8664 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 | 8665 //New_z = (v0.z - v1.z)*t + v1.z |
2320 | 8666 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t; |
8667 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t; | |
8668 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t; | |
2318 | 8669 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; |
8670 } | |
1787 | 8671 ++depth_num_vertices; |
8672 } | |
2318 | 8673 if ( !next_vertices_flag )//îáà â ãðàíèöå âèäèìîñòè |
8674 { | |
8675 memcpy(&array_507D30[depth_num_vertices], &array_50AC10[i + 1], sizeof(array_507D30[depth_num_vertices])); | |
8676 depth_num_vertices++; | |
8677 } | |
8678 current_vertices_flag = next_vertices_flag; | |
8679 } | |
8680 return depth_num_vertices >= 3 ? depth_num_vertices : 0; | |
1787 | 8681 } |
8682 | |
8683 //----- (0047840D) -------------------------------------------------------- | |
8684 void Render::DrawBuildingsD3D() | |
8685 { | |
8686 int v9; // ecx@8 | |
8687 Texture *pFaceTexture; // eax@10 | |
8688 unsigned int v16; // edi@22 | |
8689 int v27; // eax@57 | |
8690 int vertex_id; // eax@58 | |
8691 unsigned int v34; // eax@80 | |
8692 int v40; // [sp-4h] [bp-5Ch]@2 | |
8693 int v49; // [sp+2Ch] [bp-2Ch]@10 | |
8694 int v50; // [sp+30h] [bp-28h]@34 | |
8695 int v51; // [sp+34h] [bp-24h]@35 | |
8696 int v52; // [sp+38h] [bp-20h]@36 | |
8697 int v53; // [sp+3Ch] [bp-1Ch]@8 | |
8698 int uNumVertices; // [sp+4Ch] [bp-Ch]@34 | |
8699 int unused; // [sp+50h] [bp-8h]@3 | |
8700 | |
8701 if ( !pRenderer->pRenderD3D ) | |
8702 { | |
8703 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); | |
8704 } | |
8705 | |
8706 unused = 0; | |
8707 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
8708 { | |
8709 for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++ ) | |
8710 { | |
8711 if ( IsBModelVisible(model_id, &unused) ) | |
8712 { | |
8713 pOutdoor->pBModels[model_id].field_40 |= 1; | |
8714 if ( pOutdoor->pBModels[model_id].uNumFaces > 0 ) | |
8715 { | |
8716 for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ ) | |
8717 { | |
8718 if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible()) | |
8719 { | |
8720 v53 = 0; | |
8721 array_77EC08[pODMRenderParams->uNumPolygons].flags = 0; | |
8722 array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0; | |
8723 v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID; | |
8724 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME) | |
8725 v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); | |
8726 pFaceTexture = pBitmaps_LOD->GetTexture(v9); | |
8727 array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture; | |
8728 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID) | |
8729 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2; | |
1922 | 8730 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_INDOOR_SKY ) |
1787 | 8731 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
2166 | 8732 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW8 ) |
1787 | 8733 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
8734 else | |
8735 { | |
2166 | 8736 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW9 ) |
1787 | 8737 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8; |
8738 } | |
2166 | 8739 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW10) |
1787 | 8740 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000; |
8741 else | |
8742 { | |
8743 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE) | |
8744 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10u; | |
8745 } | |
8746 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU; | |
8747 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV; | |
8748 v16 = GetTickCount() >> 4; | |
8749 if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 ) | |
8750 { | |
8751 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8752 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8753 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8754 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8755 } | |
8756 else | |
8757 { | |
8758 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8759 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8760 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8761 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8762 } | |
8763 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 ) | |
8764 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8765 else | |
8766 { | |
8767 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 ) | |
8768 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8769 } | |
8770 v50 = 0; | |
8771 v49 = 0; | |
8772 uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8773 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 ) | |
8774 { | |
8775 for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ ) | |
8776 { | |
8777 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; | |
8778 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; | |
8779 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; | |
8780 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); | |
8781 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); | |
8782 } | |
8783 for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ ) | |
8784 { | |
8785 if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z ) | |
8786 ++v53; | |
8787 pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); | |
8788 if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) | |
8789 { | |
8790 if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 ) | |
8791 v49 = 1; | |
8792 else | |
8793 v50 = 1; | |
8794 } | |
8795 else | |
8796 pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); | |
8797 } | |
8798 } | |
8799 if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices ) | |
8800 LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1; | |
8801 array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8802 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8803 array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5; | |
2207 | 8804 v51 = fixpoint_mul(-pOutdoor->vSunlight.x, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x); |
8805 v53 = fixpoint_mul(-pOutdoor->vSunlight.y, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y); | |
8806 v52 = fixpoint_mul(-pOutdoor->vSunlight.z, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z); | |
8807 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - fixpoint_mul(20, v51 + v53 + v52); | |
1787 | 8808 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 ) |
8809 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0; | |
8810 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 ) | |
8811 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31; | |
8812 if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) | |
8813 return; | |
2169 | 8814 if ( ODMFace::IsBackfaceCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) |
1787 | 8815 { |
8816 pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1; | |
8817 array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id; | |
8818 array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id; | |
8819 v27 = 8 * (face_id | (model_id << 6)); | |
8820 LOBYTE(v27) = v27 | 6; | |
8821 array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27; | |
8822 for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id) | |
8823 { | |
8824 memcpy(&array_50AC10[vertex_id], &array_73D150[vertex_id], sizeof(array_50AC10[vertex_id])); | |
8825 array_50AC10[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001); | |
8826 } | |
8827 static stru154 static_RenderBuildingsD3D_stru_73C834; | |
8828 /*static bool __init_flag = false; | |
8829 if (!__init_flag) | |
8830 { | |
8831 __init_flag = true; | |
8832 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; | |
8833 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); | |
8834 atexit(loc_4789D4); | |
8835 }*/ | |
8836 | |
8837 v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8838 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8839 pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8840 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
8841 int v31 = 0; | |
8842 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
8843 { | |
8844 v31 = v50 ? 3 : v49 != 0 ? 5 : 0; | |
8845 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices); | |
8846 if ( pDecalBuilder->uNumDecals > 0 ) | |
8847 { | |
8848 v40 = -1; | |
8849 pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834, | |
8850 pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, array_50AC10, 0, (char)v31, -1); | |
8851 } | |
8852 } | |
8853 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
8854 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); | |
8855 if ( v50 ) | |
8856 { | |
1903 | 8857 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8858 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8859 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8860 } | |
8861 if ( v49 ) | |
8862 { | |
1903 | 8863 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8864 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8865 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8866 } | |
8867 if ( uNumVertices ) | |
8868 { | |
8869 if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 ) | |
8870 { | |
8871 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C ) | |
8872 v34 = pRenderer->pHDWaterBitmapIDs[0]; | |
8873 else | |
8874 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
8875 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; | |
8876 } | |
8877 else | |
8878 v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; | |
8879 pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40); | |
8880 } | |
8881 } | |
8882 } | |
8883 } | |
8884 } | |
8885 } | |
8886 } | |
8887 } | |
8888 return; | |
1911 | 8889 } |
8890 //----- (00479543) -------------------------------------------------------- | |
1923 | 8891 void Render::DrawOutdoorSkyD3D() |
1911 | 8892 { |
8893 int v9; // eax@4 | |
8894 int v10; // ebx@4 | |
8895 int v13; // edi@6 | |
8896 int v14; // ecx@6 | |
8897 int v15; // eax@8 | |
8898 int v16; // eax@12 | |
8899 signed __int64 v17; // qtt@13 | |
8900 signed int v18; // ecx@13 | |
8901 struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1 | |
8902 int v30; // [sp+134h] [bp-30h]@1 | |
8903 int v32; // [sp+13Ch] [bp-28h]@6 | |
8904 int v33; // [sp+140h] [bp-24h]@2 | |
8905 signed __int64 v34; // [sp+144h] [bp-20h]@1 | |
8906 int v35; // [sp+148h] [bp-1Ch]@4 | |
8907 int v36; // [sp+14Ch] [bp-18h]@2 | |
8908 int v37; // [sp+154h] [bp-10h]@8 | |
8909 int v38; // [sp+158h] [bp-Ch]@1 | |
8910 int v39; // [sp+15Ch] [bp-8h]@4 | |
2120 | 8911 |
8912 v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z) | |
1911 | 8913 / ((double)pODMRenderParams->int_fov_rad + 8192.0) |
2119 | 8914 + (double)(pViewport->uScreenCenterY)); |
8915 v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192 | |
2120 | 8916 v38 = (signed __int64)((double)(pViewport->uScreenCenterY) |
1911 | 8917 - (double)pODMRenderParams->int_fov_rad |
8918 / (v34 + 0.0000001) | |
8919 * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) | |
8920 * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist | |
8921 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); | |
8922 pSkyPolygon.Create_48607B(&stru_8019C8);//çàïîëíÿåòñÿ ptr_38 | |
8923 pSkyPolygon.ptr_38->_48694B_frustum_sky(); | |
2006 | 8924 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166) |
8925 pSkyPolygon.pTexture = (Texture *)(SLOWORD(pOutdoor->sSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->sSky_TextureID)] : 0); | |
1911 | 8926 if ( pSkyPolygon.pTexture ) |
8927 { | |
8928 pSkyPolygon.dimming_level = 0; | |
8929 pSkyPolygon.uNumVertices = 4; | |
2119 | 8930 //centering(öåíòðóåì)----------------------------------------------------------------- |
2120 | 8931 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8932 pSkyPolygon.v_18.y = 0; |
2120 | 8933 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8934 |
8935 //sky wiew position(ïîëîæåíèå íåáà íà ýêðàíå)------------------------------------------ | |
8936 // X | |
8937 // 0._____________________________.3 | |
8938 // |8,8 468,8 | | |
8939 // | | | |
8940 // | | | |
8941 // Y| | | |
8942 // | | | |
8943 // |8,351 468,351 | | |
8944 // 1._____________________________.2 | |
8945 // | |
2119 | 8946 array_50AC10[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 |
8947 array_50AC10[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8948 | |
8949 array_50AC10[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 | |
8950 array_50AC10[1].vWorldViewProjY = (double)v38;//247 | |
8951 | |
8952 array_50AC10[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8953 array_50AC10[2].vWorldViewProjY = (double)v38;//247 | |
8954 | |
8955 array_50AC10[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8956 array_50AC10[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8957 | |
8958 pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8959 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8960 | |
8961 pSkyPolygon.field_24 = 0x2000000u;//maybe attributes | |
2120 | 8962 v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2) / tan(0.6457717418670654) + 0.5); |
1911 | 8963 for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i ) |
8964 { | |
8965 //rotate skydome(âðàùåíèå êóïîëà íåáà)-------------------------------------- | |
8966 //  èãðå ïðèíÿòà ñâîÿ ñèñòåìà èçìåðåíèÿ óãëîâ. Ïîëíûé óãîë (180). Çíà÷åíèþ óãëà 0 ñîîòâåòñòâóåò | |
8967 // íàïðàâëåíèå íà ñåâåð è/èëè þã (ëèáî íà âîñòîê è/èëè çàïàä), çíà÷åíèþ 65536 åäåíèöàì(0õ10000) ñîîòâåòñòâóåò óãîë 90. | |
2119 | 8968 // äâå ïåðåìåííûå õðàíÿò äàííûå ïî óãëó îáçîðà. field_14 ïî çàïàäó è âîñòîêó. field_20 ïî þãó è ñåâåðó |
1911 | 8969 // îò -25080 äî 25080 |
2207 | 8970 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8971 v35 = v39 + pSkyPolygon.ptr_38->angle_from_north; |
8972 | |
2207 | 8973 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f))); |
2120 | 8974 v36 = v39 + pSkyPolygon.ptr_38->angle_from_east; |
8975 | |
2207 | 8976 v9 = fixpoint_mul(pSkyPolygon.v_18.z, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8977 v10 = pSkyPolygon.v_18.x + v9; |
2119 | 8978 if ( v10 > 0 ) |
1911 | 8979 v10 = 0; |
2120 | 8980 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX); |
8981 v34 = -pSkyPolygon.field_24; | |
8982 v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0; | |
8983 v14 = v33 * (v30 - v32); | |
1911 | 8984 while ( 1 ) |
8985 { | |
2120 | 8986 if ( v10 ) |
1911 | 8987 { |
2120 | 8988 v37 = abs((int)v34 >> 14); |
8989 v15 = abs(v10); | |
8990 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportTL_Y ) | |
8991 { | |
8992 if ( v10 <= 0 ) | |
8993 break; | |
8994 } | |
1911 | 8995 } |
2207 | 8996 v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14); |
1911 | 8997 --v32; |
8998 v14 += v33; | |
8999 v10 = pSkyPolygon.v_18.x + v16; | |
9000 } | |
9001 LODWORD(v17) = LODWORD(v34) << 16; | |
2120 | 9002 HIDWORD(v17) = v34 >> 16; |
9003 v18 = v17 / v10; | |
1911 | 9004 if ( v18 < 0 ) |
9005 v18 = pODMRenderParams->shading_dist_mist; | |
2207 | 9006 v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v13); |
9007 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v37, v18) >> 3); | |
2120 | 9008 array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0); |
9009 | |
2207 | 9010 v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v13); |
9011 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v36, v18) >> 3); | |
2120 | 9012 array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0); |
2119 | 9013 |
9014 array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192 | |
2120 | 9015 array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16); |
1911 | 9016 } |
1923 | 9017 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
2120 | 9018 array_50AC10[0].vWorldViewProjY = (double)v10; |
1911 | 9019 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; |
9020 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; | |
2120 | 9021 array_50AC10[3].vWorldViewProjY = (double)v10; |
1923 | 9022 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
1911 | 9023 return; |
9024 } | |
1913 | 9025 } |
9026 //----- (004226C2) -------------------------------------------------------- | |
9027 bool PauseGameDrawing() | |
9028 { | |
9029 if ( pCurrentScreen != SCREEN_GAME | |
9030 && pCurrentScreen != SCREEN_NPC_DIALOGUE | |
9031 && pCurrentScreen != SCREEN_CHANGE_LOCATION ) | |
9032 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2135
diff
changeset
|
9033 if (pCurrentScreen == SCREEN_INPUT_BLV) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2135
diff
changeset
|
9034 return pVideoPlayer->pMovie;//pSmackerMovie != 0; |
1913 | 9035 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) |
9036 return true; | |
9037 } | |
9038 return false; | |
2154 | 9039 } |
9040 | |
9041 | |
9042 //----- (0045E03A) -------------------------------------------------------- | |
9043 unsigned short *Render::MakeScreenshot(signed int width, signed int height) | |
9044 { | |
9045 unsigned __int16 *v3; // ebx@1 | |
9046 int v4; // edx@7 | |
9047 unsigned __int8 v5; // cf@9 | |
9048 unsigned int v6; // ecx@9 | |
9049 unsigned __int16 *v7; // edi@9 | |
9050 int j; // ecx@9 | |
9051 unsigned int screen_x; // qax@18 | |
9052 HRESULT v14; // eax@21 | |
9053 int v15; // edi@29 | |
9054 signed __int64 v16; // qax@30 | |
9055 signed int v17; // edx@34 | |
9056 unsigned __int16 *v18; // edi@36 | |
9057 int k; // ecx@36 | |
9058 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 | |
9059 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 | |
9060 float interval_x; // [sp+84h] [bp-20h]@1 | |
9061 unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 | |
9062 float interval_y; // [sp+8Ch] [bp-18h]@1 | |
9063 unsigned int screen_y; // [sp+90h] [bp-14h]@17 | |
9064 int v28; // [sp+98h] [bp-Ch]@16 | |
9065 int v29; // [sp+9Ch] [bp-8h]@15 | |
9066 | |
9067 interval_x = game_viewport_width / (double)width; | |
9068 interval_y = game_viewport_height / (double)height; | |
9069 | |
9070 pPixels = (unsigned __int16 *)malloc(2 * height * width); | |
9071 memset(pPixels, 0 , 2 * height * width); | |
9072 | |
9073 v3 = pPixels; | |
9074 | |
2182 | 9075 BeginSceneD3D(); |
9076 | |
9077 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9078 pIndoor->Draw(); | |
9079 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
9080 pOutdoor->Draw(); | |
9081 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
9082 memset(&Dst, 0, 0x7C); | |
9083 Dst.dwSize = sizeof(Dst); | |
9084 | |
9085 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
9086 { | |
9087 for (uint y = 0; y < height; ++y) | |
9088 { | |
9089 for (uint x = 0; x < width; ++x) | |
9090 { | |
9091 //*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 | 9092 /* |
9093 if (ddpfPrimarySuface.dwRGBBitCount == 32) | |
9094 { | |
9095 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
9096 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
9097 } | |
9098 else if (ddpfPrimarySuface.dwRGBBitCount == 16) | |
9099 { | |
9100 auto p = (unsigned __int16 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
9101 *v3 = *p; | |
9102 } | |
9103 */ | |
9104 pRenderer->pTargetSurface; | |
2182 | 9105 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) |
2154 | 9106 { |
2182 | 9107 auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch; |
9108 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
9109 } | |
9110 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) | |
9111 { | |
9112 auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; | |
9113 *v3 = *p; | |
2154 | 9114 } |
2182 | 9115 else __debugbreak(); |
9116 ++v3; | |
9117 } | |
9118 } | |
9119 ErrD3D(pBackBuffer4->Unlock(0)); | |
9120 } | |
9121 else | |
9122 { | |
9123 __debugbreak(); // unrefactored - black screenshot | |
9124 v4 = height; | |
9125 if ( height > 0 ) | |
9126 { | |
9127 do | |
9128 { | |
9129 if ( width > 0 ) | |
2154 | 9130 { |
2182 | 9131 v5 = width & 1; |
9132 v6 = (unsigned int)width / 2; | |
9133 memset(v3, 0, 4 * ((unsigned int)width / 2)); | |
9134 v7 = &v3[2 * v6]; | |
9135 for ( j = v5; j; --j ) | |
2154 | 9136 { |
2182 | 9137 *v7 = 0; |
9138 ++v7; | |
2154 | 9139 } |
2182 | 9140 v3 += width; |
2154 | 9141 } |
2182 | 9142 --v4; |
9143 } | |
9144 while ( v4 ); | |
9145 } | |
9146 } | |
9147 | |
2154 | 9148 /*if (!pRenderer->pRenderD3D) |
9149 { | |
9150 pRenderer->BeginScene(); | |
9151 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
9152 { | |
9153 pIndoor->Draw(); | |
9154 } | |
9155 else | |
9156 { | |
9157 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
9158 pOutdoor->Draw(); | |
9159 } | |
9160 _this = pRenderer->pTargetSurface; | |
9161 v26 = pRenderer->uTargetSurfacePitch; | |
9162 if ( pRenderer->pTargetSurface ) | |
9163 { | |
9164 if ( height > 0 ) | |
9165 { | |
9166 for ( v29 = 0; v29 < height; ++v29 ) | |
9167 { | |
9168 if ( width > 0 ) | |
9169 { | |
9170 v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); | |
9171 for ( v28 = 0; v28 < width; v28++ ) | |
9172 { | |
9173 *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)]; | |
9174 ++v3; | |
9175 } | |
9176 } | |
9177 } | |
9178 } | |
9179 } | |
9180 else | |
9181 { | |
9182 if ( height > 0 ) | |
9183 { | |
9184 for ( v17 = height; v17; --v17 ) | |
9185 { | |
9186 if ( width > 0 ) | |
9187 { | |
9188 memset(v3, 0, 4 * ((unsigned int)width >> 1)); | |
9189 v18 = &v3[2 * ((unsigned int)width >> 1)]; | |
9190 for ( k = width & 1; k; --k ) | |
9191 { | |
9192 *v18 = 0; | |
9193 ++v18; | |
9194 } | |
9195 v3 += width; | |
9196 } | |
9197 } | |
9198 } | |
9199 } | |
9200 pRenderer->EndScene(); | |
9201 }*/ | |
9202 return pPixels; | |
9203 } | |
9204 //----- (0045E26C) -------------------------------------------------------- | |
9205 void Render::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height) | |
9206 { | |
9207 auto pixels = pRenderer->MakeScreenshot(width, height); | |
9208 pRenderer->SavePCXImage(pFilename, pixels, width, height); | |
9209 free(pixels); | |
9210 } | |
9211 | |
9212 void Render::PackScreenshot(unsigned int width, unsigned int height, void *data, unsigned int data_size, unsigned int *out_screenshot_size) | |
9213 { | |
9214 auto pixels = pRenderer->MakeScreenshot(150, 112); | |
9215 pRenderer->PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size); | |
9216 free(pixels); | |
9217 } | |
2155 | 9218 |
9219 | |
9220 //----- (0046A7C8) -------------------------------------------------------- | |
2182 | 9221 int Render::_46À6ÀÑ_GetActorsInViewport(int pDepth) |
9222 { | |
9223 unsigned int v3; // eax@2 ïðèìåíÿåòñÿ â çàêëå Æàð ïå÷è äëÿ ïîäñ÷¸òà êîë-âà ìîíñòðîâ âèäèìûõ ãðóïïå è çàïîëíåíèÿ ìàññèâà id âèäèìûõ ìîíñòðîâ | |
2155 | 9224 unsigned int v5; // eax@2 |
9225 unsigned int v6; // eax@4 | |
9226 unsigned int v12; // [sp+10h] [bp-14h]@1 | |
2182 | 9227 int mon_num; // [sp+1Ch] [bp-8h]@1 |
2155 | 9228 unsigned int a1a; // [sp+20h] [bp-4h]@1 |
9229 | |
2182 | 9230 mon_num = 0; |
2155 | 9231 v12 = GetBillboardDrawListSize(); |
9232 if ( (signed int)GetBillboardDrawListSize() > 0 ) | |
9233 { | |
9234 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) | |
9235 { | |
9236 v3 = GetParentBillboardID(a1a); | |
9237 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; | |
9238 if ( PID_TYPE(v5) == OBJECT_Actor) | |
9239 { | |
2182 | 9240 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) ) |
2155 | 9241 { |
9242 v6 = PID_ID(v5); | |
9243 if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed | |
9244 && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) | |
9245 { | |
2182 | 9246 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) ) |
2155 | 9247 { |
2182 | 9248 if ( mon_num < 100 ) |
2155 | 9249 { |
2182 | 9250 _50BF30_actors_in_viewport_ids[mon_num] = v6; |
9251 mon_num++; | |
2155 | 9252 } |
9253 } | |
9254 } | |
9255 } | |
9256 } | |
9257 } | |
9258 } | |
2182 | 9259 return mon_num; |
2155 | 9260 } |
9261 | |
9262 | |
9263 | |
9264 | |
9265 void Render::BeginLightmaps() | |
9266 { | |
9267 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9268 | |
9269 if (bUsingSpecular) | |
9270 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); | |
9271 | |
9272 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9273 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9274 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9275 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9276 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9277 } | |
9278 | |
9279 void Render::EndLightmaps() | |
9280 { | |
9281 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9282 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9283 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9284 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9285 | |
9286 if (bUsingSpecular) | |
9287 { | |
9288 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9289 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor)); | |
9290 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
9291 } | |
9292 } | |
9293 | |
9294 | |
9295 void Render::BeginLightmaps2() | |
9296 { | |
9297 if (bUsingSpecular) | |
9298 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9299 | |
9300 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9301 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9302 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9303 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9304 | |
9305 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9306 | |
9307 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9308 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9309 } | |
9310 | |
9311 | |
9312 void Render::EndLightmaps2() | |
9313 { | |
9314 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9315 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9316 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9317 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9318 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9319 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9320 | |
9321 if (bUsingSpecular) | |
9322 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9323 } | |
9324 | |
9325 | |
9326 | |
9327 //----- (00437C96) -------------------------------------------------------- | |
9328 void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) | |
9329 { | |
9330 double v6; // st7@2 | |
9331 //IDirect3DDevice3 *v7; // eax@2 | |
9332 HRESULT v8; // eax@2 | |
9333 std::string v9; // [sp-18h] [bp-60h]@3 | |
9334 const char *v10; // [sp-Ch] [bp-54h]@2 | |
9335 const char *v11; // [sp-8h] [bp-50h]@2 | |
9336 int v12; // [sp-4h] [bp-4Ch]@2 | |
9337 RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2 | |
9338 | |
9339 //if ( pRenderer->pRenderD3D ) | |
9340 { | |
9341 v6 = 0.001 - z_stuff; | |
9342 memcpy(v13, pLineBegin, 0x20u); | |
9343 memcpy(&v13[1], pLineEnd, sizeof(v13[1])); | |
9344 v13[0].pos.z = v6; | |
9345 v13[1].pos.z = v6; | |
9346 v13[0].diffuse = sDiffuseBegin; | |
9347 v13[1].diffuse = sDiffuseEnd; | |
9348 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9349 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
9350 D3DPT_LINELIST, | |
9351 452, | |
9352 v13, | |
9353 2, | |
9354 16)); | |
9355 } | |
9356 } | |
9357 | |
9358 | |
9359 void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9360 { | |
9361 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9362 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, | |
9363 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9364 (void *)vertices, | |
9365 num_vertices, | |
9366 D3DDP_DONOTLIGHT)); | |
9367 } | |
9368 | |
9369 | |
9370 void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9371 { | |
9372 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
9373 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); | |
9374 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9375 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9376 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9377 | |
9378 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9379 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9380 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9381 (void *)vertices, | |
9382 num_vertices, | |
9383 28)); | |
9384 | |
9385 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9386 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9387 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9388 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); | |
9389 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9390 } | |
9391 | |
9392 | |
9393 void Render::BeginDecals() | |
9394 { | |
9395 // code chunk from 0049C304 | |
9396 if (bUsingSpecular) | |
9397 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9398 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9399 | |
9400 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9401 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9402 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9403 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9404 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9405 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9406 | |
9407 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); | |
9408 } | |
9409 | |
9410 | |
9411 void Render::EndDecals() | |
9412 { | |
9413 // code chunk from 0049C304 | |
9414 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9415 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9416 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9417 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9418 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9419 | |
9420 if (bUsingSpecular) | |
9421 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9422 } | |
9423 | |
9424 | |
9425 | |
9426 //----- (0049C095) -------------------------------------------------------- | |
9427 void Render::DrawDecal(Decal *pDecal, float z_bias) | |
9428 { | |
9429 signed int v21; // [sp+Ch] [bp-864h]@15 | |
9430 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6 | |
9431 | |
9432 if (pDecal->uNumVertices < 3) | |
9433 { | |
9434 Log::Warning(L"Decal has < 3 vertices"); | |
9435 return; | |
9436 } | |
9437 | |
9438 float color_mult; | |
9439 if ( pDecal->field_C1C & 1 ) | |
9440 color_mult = 1.0; | |
9441 else | |
9442 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time(); | |
9443 | |
9444 for (uint i = 0; i < pDecal->uNumVertices; ++i) | |
9445 { | |
9446 uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr); | |
9447 | |
9448 uint uTintR = (uTint >> 16) & 0xFF, | |
9449 uTintG = (uTint >> 8) & 0xFF, | |
9450 uTintB = uTint & 0xFF; | |
9451 | |
9452 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF, | |
9453 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF, | |
9454 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF; | |
9455 | |
9456 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f), | |
9457 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f), | |
9458 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f); | |
9459 | |
9460 | |
9461 float v15; | |
9462 if (fabs(z_bias) < 1e-5) | |
9463 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); | |
9464 else | |
9465 { | |
9466 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; | |
9467 if (v15 < 0.000099999997) | |
9468 v15 = 0.000099999997; | |
9469 } | |
9470 | |
9471 pVerticesD3D[i].pos.z = v15; | |
9472 | |
9473 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX; | |
9474 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY; | |
9475 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u; | |
9476 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v; | |
9477 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB; | |
9478 pVerticesD3D[i].specular = 0; | |
9479 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x; | |
9480 } | |
9481 | |
9482 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9483 v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; | |
9484 else | |
9485 v21 = D3DDP_DONOTLIGHT; | |
9486 | |
9487 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9488 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9489 pVerticesD3D, | |
9490 pDecal->uNumVertices, | |
9491 v21)); | |
9492 } | |
9493 | |
9494 | |
9495 void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) | |
9496 { | |
9497 ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture)); | |
9498 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9499 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9500 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9501 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9502 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9503 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9504 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
9505 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9506 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9507 (void *)vertices, 4, 28)); | |
9508 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9509 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9510 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9511 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9512 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9513 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
9514 } |