Mercurial > mm7
annotate Render.cpp @ 2370:bbf8a522dcec
removing non-nullptr conditions before deletes
author | Grumpy7 |
---|---|
date | Mon, 12 May 2014 01:55:23 +0200 |
parents | bddcaf5d5db2 |
children | 2fe8feb3dcd1 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2245
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
2336 | 2 #include "mm7_unsorted_subs.h" |
2352 | 3 #include "ZlibWrapper.h" |
2336 | 4 #include "ErrorHandling.h" |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2245
diff
changeset
|
5 |
2153 | 6 #include "Render.h" |
1277 | 7 #include "Outdoor_stuff.h" |
1016 | 8 #include "VideoPlayer.h" |
9 #include "Sprites.h" | |
10 #include "Mouse.h" | |
11 #include "GammaControl.h" | |
12 #include "stru6.h" | |
1183 | 13 #include "GUIWindow.h" |
1016 | 14 #include "DecalBuilder.h" |
15 #include "ParticleEngine.h" | |
0 | 16 #include "Outdoor.h" |
17 #include "Party.h" | |
18 #include "LOD.h" | |
19 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2016
diff
changeset
|
20 #include "OurMath.h" |
0 | 21 #include "PaletteManager.h" |
2044 | 22 #include "Timer.h" |
0 | 23 #include "Game.h" |
24 #include "LightmapBuilder.h" | |
25 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
26 #include "SpriteObject.h" |
0 | 27 #include "DecorationList.h" |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
28 #include "Actor.h" |
0 | 29 #include "Log.h" |
179 | 30 #include "TileFrameTable.h" |
189 | 31 #include "texts.h" |
0 | 32 #include "mm7_data.h" |
860 | 33 #include "MM7.h" |
1262 | 34 #include "Lights.h" |
1828
35c1e4ff6ba7
party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents:
1814
diff
changeset
|
35 #include "Level/Decoration.h" |
2155 | 36 #include "Vis.h" |
2341 | 37 #include "Registry.h" |
0 | 38 |
1924
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
39 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") |
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1913
diff
changeset
|
40 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") |
0 | 41 |
42 struct IDirectDrawClipper *pDDrawClipper; | |
43 struct Render *pRenderer; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
44 struct RenderVertexD3D3 pVertices[50]; |
0 | 45 int uNumDecorationsDrawnThisFrame; // weak |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
46 RenderBillboard pBillboardRenderList[500]; |
0 | 47 unsigned int uNumBillboardsToDraw; |
48 int uNumSpritesDrawnThisFrame; // weak | |
49 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
50 RenderVertexSoft array_507D30[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
51 RenderVertexSoft array_50AC10[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
52 RenderVertexSoft array_73D150[20]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
53 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
54 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 55 |
56 /* 384 */ | |
57 #pragma pack(push, 1) | |
58 struct PCXHeader_1 | |
59 { | |
60 char manufacturer; | |
61 char version; | |
62 char encoding; | |
63 char bpp; | |
64 __int16 left; | |
65 __int16 up; | |
66 __int16 right; | |
67 __int16 bottom; | |
68 __int16 hdpi; | |
69 __int16 vdpi; | |
70 }; | |
71 #pragma pack(pop) | |
72 | |
73 /* 385 */ | |
74 #pragma pack(push, 1) | |
75 struct PCXHeader_2 | |
76 { | |
77 char reserved; | |
78 char planes; | |
79 __int16 pitch; | |
80 __int16 palette_info; | |
81 }; | |
82 #pragma pack(pop) | |
83 | |
84 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
85 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
86 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
87 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
88 | |
89 //----- (0049E79F) -------------------------------------------------------- | |
2154 | 90 bool Render::CheckTextureStages() |
0 | 91 { |
92 bool v0; // edi@1 | |
93 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
94 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
95 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
96 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
97 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
98 | |
99 v0 = false; | |
2154 | 100 pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); |
101 pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
102 | |
103 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
104 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
105 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2)); | |
106 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
107 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
108 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
109 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1)); | |
110 | |
111 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
112 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
113 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1)); | |
114 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7)); | |
115 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2)); | |
116 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1)); | |
117 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2)); | |
118 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2)); | |
119 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1)); | |
120 | |
121 if ( !pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
0 | 122 v0 = true; |
2154 | 123 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); |
0 | 124 pTexture1->Release(); |
125 pTexture2->Release(); | |
126 pSurface1->Release(); | |
127 pSurface2->Release(); | |
128 return v0; | |
129 } | |
130 | |
2002 | 131 |
0 | 132 //----- (00440CB8) -------------------------------------------------------- |
133 void Render::DrawBillboardList_BLV() | |
134 { | |
135 __int16 v2; // ax@3 | |
136 int v5; // eax@11 | |
137 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
138 | |
2002 | 139 soft_billboard.sParentBillboardID = -1; |
0 | 140 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; |
141 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
142 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
143 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
144 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
145 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
146 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
147 | |
1637 | 148 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw; |
617 | 149 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 150 { |
1980 | 151 RenderBillboard* p = &pBillboardRenderList[i]; |
0 | 152 |
153 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
2002 | 154 soft_billboard.sParentBillboardID = i; |
0 | 155 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
156 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
|
157 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 158 soft_billboard.sZValue = p->sZValue; |
159 soft_billboard.uFlags = p->field_1E; | |
2006 | 160 soft_billboard.sTintColor = p->sTintColor; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
161 v2 = p->HwSpriteID; |
0 | 162 if ( v2 != -1 ) |
163 { | |
164 if ( pRenderer->pRenderD3D ) | |
657 | 165 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 166 else |
167 { | |
657 | 168 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 169 if (p->field_1E & 0x0100) |
170 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
171 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
172 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
|
173 v5 = p->HwSpriteID; |
0 | 174 if ( v5 >= 0 ) |
733 | 175 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 176 } |
177 } | |
178 } | |
179 } | |
180 | |
181 //----- (004A16A5) -------------------------------------------------------- | |
2154 | 182 bool Render::AreRenderSurfacesOk() |
183 { | |
184 return pFrontBuffer4 && pBackBuffer4; | |
0 | 185 } |
186 | |
2152 | 187 |
188 //----- (004A19D8) -------------------------------------------------------- | |
189 unsigned int BlendColors(unsigned int a1, unsigned int a2) | |
190 { | |
191 /*signed __int64 v2; // ST10_8@1 | |
192 double v3; // st7@1 | |
193 float v4; // ST24_4@1 | |
194 double v5; // ST10_8@1 | |
195 int v6; // ST1C_4@1 | |
196 float v7; // ST24_4@1 | |
197 double v8; // ST10_8@1 | |
198 unsigned __int8 v9; // ST20_1@1 | |
199 float v10; // ST24_4@1 | |
200 double v11; // ST10_8@1 | |
201 float v12; // ST24_4@1 | |
202 double v13; // ST08_8@1*/ | |
203 | |
204 uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f * | |
205 (a2 >> 24) / 255.0f * 255.0f), | |
206 red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f * | |
207 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f), | |
208 green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f * | |
209 ((a2 >> 8) & 0xFF) / 255.0f * 255.0f), | |
210 blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f * | |
211 ((a2 >> 0) & 0xFF) / 255.0f * 255.0f); | |
212 return (alpha << 24) | (red << 16) | (green << 8) | blue; | |
213 /*v2 = a1 >> 24; | |
214 v3 = (double)v2 / 255.0f; | |
215 HIDWORD(v2) = 0; | |
216 LODWORD(v2) = a2 >> 24; | |
217 v4 = v3 * (double)v2 / 255.0f * 255.0; | |
218 v5 = v4 + 6.7553994e15; | |
219 v6 = LODWORD(v5); | |
220 v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0; | |
221 v8 = v7 + 6.7553994e15; | |
222 v9 = LOBYTE(v8); | |
223 v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0; | |
224 v11 = v10 + 6.7553994e15; | |
225 v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0; | |
226 v13 = v12 + 6.7553994e15; | |
227 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ | |
228 } | |
229 | |
230 | |
1338 | 231 void Render::RenderTerrainD3D() // New function |
86 | 232 { |
233 int v6; // ecx@8 | |
1427 | 234 struct Polygon *pTilePolygon; // ebx@8 |
2334 | 235 // float Light_tile_dist; |
186 | 236 |
237 //warning: the game uses CW culling by default, ccw is incosistent | |
238 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
239 | |
1338 | 240 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ |
241 | |
242 //Ãåíåðàöèÿ ìåñòîïîëîæåíèÿ âåðøèí------------------------------------------------------------------------- | |
243 //ðåø¸òêà âåðøèí äåëèòñÿ íà äâå ÷àñòè îò -64 äî 0 è îò 0 äî 64 | |
244 // | |
245 // -64 X 0 64 | |
246 // --------------- 64 | |
247 // | | | | |
248 // | | | | |
249 // | | | | |
250 // 0|------+------| Z | |
251 // | | | | |
252 // | | | | |
253 // | | | | |
254 // --------------- | |
255 // -64 | |
256 | |
257 int blockScale = 512; | |
258 int heightScale = 32; | |
259 for (unsigned int z = 0; z < 128; ++z) | |
260 { | |
261 for (unsigned int x = 0; x < 128; ++x) | |
262 { | |
263 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
264 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
265 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 266 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
267 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 268 } |
269 } | |
2318 | 270 //-------(Îòñå÷åíèå íåâèäèìîé ÷àñòè êàðòû)------------------------------------------------------------------------------------------ |
271 float direction = pGame->pIndoorCameraD3D->sRotationY / 256;//direction of the camera(íàïðâëåíèå êàìåðû) | |
2316 | 272 //0-East(B) |
273 //1-NorthEast(CB) | |
274 //2-North(C) | |
275 //3-WestNorth(CÇ) | |
276 //4-West(Ç) | |
277 //5-SouthWest(ÞÇ) | |
278 //6-South(Þ) | |
279 //7-SouthEast(ÞÂ) | |
280 int Start_X, End_X, Start_Z, End_Z; | |
2318 | 281 if ( direction >= 0 && direction < 1.0 )//East(B) - NorthEast(CB) |
282 { | |
2321 | 283 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127; |
2318 | 284 Start_Z = 0, End_Z = 127; |
285 } | |
286 else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CÇ) | |
287 { | |
2316 | 288 Start_X = 0, End_X = 127; |
2321 | 289 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ + 1; |
2318 | 290 } |
291 else if (direction >= 3.0 && direction < 5.0)//WestNorth(CÇ) - SouthWest(ÞÇ) | |
292 { | |
2322 | 293 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 2; |
2318 | 294 Start_Z = 0, End_Z = 127; |
295 } | |
296 else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ÞÇ) - //SouthEast(ÞÂ) | |
297 { | |
298 Start_X = 0, End_X = 127; | |
2321 | 299 Start_Z = pODMRenderParams->uMapGridCellZ - 2, End_Z = 127; |
2318 | 300 } |
301 else//SouthEast(ÞÂ) - East(B) | |
302 { | |
2321 | 303 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127; |
2318 | 304 Start_Z = 0, End_Z = 127; |
2316 | 305 } |
306 for (unsigned int z = Start_Z; z < End_Z; ++z) | |
307 { | |
308 for (unsigned int x = Start_X; x < End_X; ++x) | |
1338 | 309 { |
1637 | 310 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; |
1427 | 311 pTilePolygon->flags = 0; |
312 pTilePolygon->field_32 = 0; | |
313 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
314 pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; | |
315 if (pTilePolygon->uTileBitmapID == 0xFFFF) | |
106 | 316 continue; |
186 | 317 |
1338 | 318 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1427 | 319 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); |
320 pTilePolygon->field_32 = 0; | |
321 pTilePolygon->field_59 = 1; | |
322 pTilePolygon->sTextureDeltaU = 0; | |
323 pTilePolygon->sTextureDeltaV = 0; | |
1338 | 324 // x,z x+1,z |
325 // .____________. | |
326 // | | | |
327 // | | | |
328 // | | | |
329 // | | | |
330 // | | | |
331 // .____________. | |
332 // x,z+1 x+1,z+1 | |
333 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
106 | 334 array_73D150[0].u = 0; |
335 array_73D150[0].v = 0; | |
1338 | 336 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z |
106 | 337 array_73D150[1].u = 1; |
338 array_73D150[1].v = 0; | |
1338 | 339 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 |
106 | 340 array_73D150[2].u = 1; |
341 array_73D150[2].v = 1; | |
1338 | 342 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 |
106 | 343 array_73D150[3].u = 0; |
344 array_73D150[3].v = 1; | |
1338 | 345 //v58 = 0; |
346 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
347 //pTile->field_32 |= 0x0001; | |
1427 | 348 pTilePolygon->pODMFace = nullptr; |
349 pTilePolygon->uNumVertices = 4; | |
350 pTilePolygon->field_59 = 5; | |
1338 | 351 |
352 //shading (çàòåíåíèå)---------------------------------------------------------------------------- | |
353 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
1424 | 354 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; |
638 | 355 assert(norm_idx < uNumTerrainNormals); |
356 | |
1980 | 357 Vec3_float_* norm = &pTerrainNormals[norm_idx]; |
1338 | 358 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
359 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
360 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
1427 | 361 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); |
2274 | 362 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 ) |
363 norm = 0; | |
364 else | |
365 norm = &pTerrainNormals[norm_idx]; | |
2322 | 366 //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows |
367 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1); | |
368 //unsigned int a5 = 4; | |
369 //---------------------------------------------------------------------------- | |
638 | 370 |
1637 | 371 ++pODMRenderParams->uNumPolygons; |
372 ++pODMRenderParams->field_44; | |
373 assert(pODMRenderParams->uNumPolygons < 20000); | |
265 | 374 |
1427 | 375 pTilePolygon->uBModelID = 0; |
376 pTilePolygon->uBModelFaceID = 0; | |
377 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
378 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
106 | 379 { |
380 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 381 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 382 } |
2318 | 383 //---------Draw distance(Äàëüíîñòü îòðèñîâêè)------------------------------- |
2320 | 384 int temp = pODMRenderParams->shading_dist_mist; |
385 if ( draw_terrain_dist_mist ) | |
386 pODMRenderParams->shading_dist_mist = 0x5000; | |
2318 | 387 bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0 |
388 || array_73D150[1].vWorldViewPosition.x < 8.0 | |
389 || array_73D150[2].vWorldViewPosition.x < 8.0 | |
390 || array_73D150[3].vWorldViewPosition.x < 8.0; | |
391 bool far_clip = (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x | |
392 || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x | |
393 || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x | |
394 || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x; | |
2322 | 395 |
396 /* int v33 = 0; | |
397 static stru154 static_sub_0048034E_stru_154; | |
398 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
399 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
400 { | |
401 if ( neer_clip ) | |
402 v33 = 3; | |
403 else | |
404 v33 = far_clip != 0 ? 5 : 0; | |
405 static_sub_0048034E_stru_154.ClassifyPolygon(norm, Light_tile_dist); | |
406 if ( pDecalBuilder->uNumDecals > 0 ) | |
407 pDecalBuilder->ApplyDecals(31 - pTilePolygon->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); | |
408 } | |
409 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
410 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);*/ | |
411 | |
2318 | 412 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) |
413 { | |
2321 | 414 //if ( neer_clip ) //Ritor1: Äà¸ò èñêàæåíèÿ íà ïîäú¸ìå, âîçìîæíî òðåáóåòñÿ ô-öèÿ Áåçüå |
415 //{ | |
416 // pTilePolygon->uNumVertices = ODM_NearClip(pTilePolygon->uNumVertices); | |
417 // ODM_Project(pTilePolygon->uNumVertices); | |
418 //} | |
2318 | 419 if ( far_clip ) |
420 { | |
421 pTilePolygon->uNumVertices = ODM_FarClip(pTilePolygon->uNumVertices); | |
2320 | 422 ODM_Project(pTilePolygon->uNumVertices); |
2318 | 423 } |
424 } | |
2320 | 425 pODMRenderParams->shading_dist_mist = temp; |
140 | 426 |
1338 | 427 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))---------------------- |
186 | 428 bool transparent = false; |
1427 | 429 if ( !( pTilePolygon->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable |
430 { | |
431 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id) | |
1338 | 432 { |
433 //transparent = false; | |
434 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
435 } | |
436 else | |
437 { | |
1427 | 438 v6 = pTilePolygon->uTileBitmapID; |
439 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) ) | |
1338 | 440 transparent = true; |
441 } | |
179 | 442 |
140 | 443 assert(v6 < 1000); // many random crashes here |
186 | 444 |
445 // for all shore tiles - draw a tile water under them since they're half-empty | |
1427 | 446 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX |
2153 | 447 DrawBorderTiles(pTilePolygon); |
1427 | 448 |
449 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1338 | 450 } |
451 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû | |
452 //pTile->DrawBorderTiles(); | |
453 //-------------------------------------------------------------------------------------------------------------------------------- | |
186 | 454 |
1637 | 455 --pODMRenderParams->uNumPolygons; |
456 --pODMRenderParams->field_44; | |
106 | 457 } |
458 } | |
459 } | |
0 | 460 |
2153 | 461 //----- (004811A3) -------------------------------------------------------- |
462 void Render::DrawBorderTiles(struct Polygon *poly) | |
463 { | |
464 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); | |
465 DrawTerrainPolygon(poly->uNumVertices, poly, | |
466 pBitmaps_LOD->pHardwareTextures[pHDWaterBitmapIDs[hd_water_current_frame]], false, true); | |
467 | |
468 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); | |
469 //DrawTerrainPolygon(poly->uNumVertices, poly, pBitmaps_LOD->pHardwareTextures[poly->uTileBitmapID], true, true); | |
470 } | |
471 | |
0 | 472 |
473 //----- (0047BACF) -------------------------------------------------------- | |
474 void Render::TransformBillboardsAndSetPalettesODM() | |
475 { | |
142 | 476 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
477 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
478 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
479 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
480 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
481 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
482 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
483 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
484 //int v8; // ebx@4 |
2334 | 485 // unsigned __int16 *v9; // eax@7 |
486 // char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
487 //DWORD v11; // eax@13 |
2334 | 488 // int v12; // eax@13 |
489 // int v13; // eax@14 | |
0 | 490 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 |
2334 | 491 // int v15; // [sp+54h] [bp-10h]@13 |
142 | 492 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
493 //int v17; // [sp+5Ch] [bp-8h]@2 |
2334 | 494 // int v18; // [sp+60h] [bp-4h]@13 |
0 | 495 |
2002 | 496 billboard.sParentBillboardID = -1; |
0 | 497 billboard.pTarget = pRenderer->pTargetSurface; |
498 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
499 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 500 billboard.uViewportX = pViewport->uViewportTL_X; |
501 billboard.uViewportY = pViewport->uViewportTL_Y; | |
502 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
503 billboard.uViewportW = pViewport->uViewportBR_Y; | |
1637 | 504 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw; |
142 | 505 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
506 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 507 { |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
508 billboard.uScreenSpaceX = pBillboardRenderList[i].uScreenSpaceX; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
509 billboard.uScreenSpaceY = pBillboardRenderList[i].uScreenSpaceY; |
2002 | 510 billboard.sParentBillboardID = i; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
511 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
|
512 billboard.sTintColor = pBillboardRenderList[i].sTintColor; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
513 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
|
514 billboard.sZValue = pBillboardRenderList[i].sZValue; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
515 billboard.uFlags = pBillboardRenderList[i].field_1E; |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
516 if (pBillboardRenderList[i].HwSpriteID != -1) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
517 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
518 if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
519 //if (pRenderer->pRenderD3D) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
520 pRenderer->TransformBillboard(&billboard, |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
521 &pSprites_LOD->pHardwareSprites[pBillboardRenderList[i].HwSpriteID], |
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
522 pBillboardRenderList[i].dimming_level, &pBillboardRenderList[i]); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
523 /*else |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
524 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
525 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
526 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
527 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 528 if ( *(v1 - 10) & 2 ) |
529 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
530 else | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
531 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 532 v10 = (*(v1 - 9) & 1) == 0; |
533 billboard.pPalette = v9; | |
534 if ( !v10 ) | |
535 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
536 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
537 { | |
323 | 538 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 539 v15 = abs(v12); |
540 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
541 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
542 } | |
543 v13 = *((short *)v1 - 8); | |
544 if ( v13 >= 0 ) | |
733 | 545 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
546 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
547 } |
0 | 548 } |
549 } | |
550 | |
551 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
552 void Render::DrawSpriteObjects_ODM() |
0 | 553 { |
2206 | 554 SpriteFrame *frame; // eax@10 |
0 | 555 unsigned int v6; // eax@10 |
556 int v9; // ecx@10 | |
557 int v17; // ecx@25 | |
558 int v18; // eax@25 | |
2334 | 559 // int v22; // ST3C_4@29 |
0 | 560 signed __int64 v23; // qtt@30 |
561 int v26; // eax@31 | |
2334 | 562 // char v27; // zf@31 |
0 | 563 int v30; // [sp+14h] [bp-2Ch]@23 |
564 int v37; // [sp+1Ch] [bp-24h]@23 | |
565 int a6; // [sp+20h] [bp-20h]@10 | |
566 int v42; // [sp+2Ch] [bp-14h]@23 | |
567 int y; // [sp+30h] [bp-10h]@10 | |
568 int x; // [sp+34h] [bp-Ch]@10 | |
569 int z; // [sp+38h] [bp-8h]@10 | |
570 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
571 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
572 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
573 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
|
574 { |
1980 | 575 SpriteObject* object = &pSpriteObjects[i]; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
576 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
577 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
578 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
579 //{ |
430 | 580 if (!object->uObjectDescID) // item probably pciked up |
581 continue; | |
582 | |
583 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
1980 | 584 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID]; |
430 | 585 if (object_desc->NoSprite()) |
586 continue; | |
587 | |
588 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
589 //if ( !(v1->uFlags & 1) ) | |
590 //{ | |
591 //v2 = *((short *)v0 - 14) | |
2206 | 592 //v2 = object->uType; |
593 if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600) | |
594 || pGame->pStru6Instance->_4A81CA(object) ) | |
430 | 595 { |
596 //a5 = *(short *)v0; | |
597 x = object->vPosition.x; | |
598 y = object->vPosition.y; | |
599 z = object->vPosition.z; | |
2206 | 600 frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); |
601 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
|
602 v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); |
430 | 603 //LOWORD(v7) = object->uFacing; |
604 //v8 = v36; | |
2206 | 605 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
|
606 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[v9]; |
2206 | 607 if ( frame->uFlags & 0x20 ) |
608 { | |
609 //v8 = v36; | |
610 z -= fixpoint_mul(frame->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)frame->pHwSpriteIDs[v9]].uHeight) / 2; | |
611 } | |
612 v46 = 0; | |
613 if ( frame->uFlags & 2 ) | |
614 v46 = 2; | |
615 //v11 = (int *)(256 << v9); | |
616 if ( (256 << v9) & frame->uFlags ) | |
617 v46 |= 4u; | |
618 if ( frame->uFlags & 0x40000 ) | |
619 v46 |= 0x40u; | |
620 if ( frame->uFlags & 0x20000 ) | |
621 LOBYTE(v46) = v46 | 0x80; | |
622 if ( a6 ) | |
623 { | |
624 //LOBYTE(v11) = _4E94D3_light_type; | |
625 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type); | |
626 } | |
627 if (pGame->pIndoorCameraD3D->sRotationX) | |
628 { | |
629 v30 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
630 + fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
631 v37 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_sine_y); | |
632 v42 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x) | |
633 + fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_cosine_x); | |
634 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
635 { | |
636 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - v37; | |
637 v18 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) | |
638 - fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_sine_x); | |
639 if ( abs(v42) >= abs(v17) ) | |
640 { | |
641 LODWORD(v23) = 0; | |
642 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
643 | |
644 object->uAttributes |= 1; | |
645 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
646 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
647 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
648 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
649 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
650 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
651 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
652 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
653 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
654 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
655 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
656 HIWORD(v26) = HIWORD(v42); | |
657 LOWORD(v26) = 0; | |
658 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
659 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
660 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
661 if ( !(object->uAttributes & 0x20) ) | |
0 | 662 { |
2206 | 663 if ( !pRenderer->pRenderD3D ) |
664 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
0 | 665 } |
2206 | 666 //if (::uNumBillboardsToDraw >= 500) |
667 // return; | |
668 assert(::uNumBillboardsToDraw < 500); | |
669 ++::uNumBillboardsToDraw; | |
670 ++uNumSpritesDrawnThisFrame; | |
0 | 671 } |
2206 | 672 } |
673 } | |
674 else | |
675 { | |
676 v42 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y) | |
677 + fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y); | |
678 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) | |
679 { | |
680 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) | |
681 - fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y); | |
682 v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; | |
683 if ( abs(v42) >= abs(v17) ) | |
684 { | |
685 LODWORD(v23) = 0; | |
686 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
687 | |
688 object->uAttributes |= 1; | |
689 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
690 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
691 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
692 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
693 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
694 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
695 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
696 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
697 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
698 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
699 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
700 HIWORD(v26) = HIWORD(v42); | |
701 LOWORD(v26) = 0; | |
702 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
703 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
704 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
705 if ( !(object->uAttributes & 0x20) ) | |
706 { | |
707 if ( !pRenderer->pRenderD3D ) | |
708 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
709 } | |
710 //if (::uNumBillboardsToDraw >= 500) | |
711 // return; | |
712 assert(::uNumBillboardsToDraw < 500); | |
713 ++::uNumBillboardsToDraw; | |
714 ++uNumSpritesDrawnThisFrame; | |
715 } | |
716 } | |
717 } | |
718 } | |
0 | 719 } |
720 } | |
721 | |
722 //----- (0049D9BC) -------------------------------------------------------- | |
723 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
724 { | |
725 size_t v4; // eax@1 | |
726 size_t v5; // eax@1 | |
727 IUnknown *v6; // eax@10 | |
728 size_t v7; // eax@13 | |
729 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
730 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
731 int v11; // [sp+430h] [bp-CCh]@16 | |
732 int v12; // [sp+434h] [bp-C8h]@16 | |
733 int v13; // [sp+438h] [bp-C4h]@16 | |
734 int v14; // [sp+474h] [bp-88h]@16*/ | |
735 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
736 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
737 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
738 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
739 int v19; // [sp+4C8h] [bp-34h]@16 | |
740 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
741 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
742 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
743 | |
744 v4 = strlen(lpDriverName); | |
745 v20.pDriverName = new char[v4 + 1]; | |
746 v5 = strlen(lpDevDesc); | |
747 v20.pDeviceDesc = new char[v5 + 1]; | |
748 strcpy(v20.pDriverName, lpDriverName); | |
749 strcpy(v20.pDeviceDesc, lpDevDesc); | |
750 if ( lpGUID ) | |
751 { | |
752 v20.pGUID = new GUID; | |
753 memcpy(v20.pGUID, lpGUID, 0x10u); | |
754 } | |
755 else | |
756 v20.pGUID = 0; | |
757 | |
758 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
759 { | |
760 delete [] v20.pDriverName; | |
761 delete [] v20.pDeviceDesc; | |
2370 | 762 delete v20.pGUID; |
0 | 763 } |
764 else | |
765 { | |
766 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
767 { | |
768 delete [] v20.pDriverName; | |
769 delete [] v20.pDeviceDesc; | |
2370 | 770 delete v20.pGUID; |
0 | 771 v6 = (IUnknown *)pDirectDraw; |
772 } | |
773 else | |
774 { | |
775 pDirectDraw->Release(); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
776 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1))) |
0 | 777 v20.pDDraw4DevDesc = 0; |
778 else | |
779 { | |
780 v7 = strlen(ddDevId.szDescription); | |
781 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
782 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
783 } | |
784 memset(&ddsCaps, 0, 0x10u); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
785 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem))) |
0 | 786 v20.uVideoMem = 0; |
787 memset(&v10, 0, 0x7Cu); | |
788 v10.dwSize = 124; | |
789 v10.dwFlags = 6; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
790 v10.dwHeight = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
791 v10.dwWidth = window->GetHeight(); |
0 | 792 v10.ddpfPixelFormat.dwSize = 32; |
793 | |
794 v19 = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
795 if ( FAILED(pDirectDraw4->EnumDisplayModes(0, 0, &v19, (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) |
0 | 796 || !v19 |
797 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
798 { | |
799 delete [] v20.pDriverName; | |
800 delete [] v20.pDeviceDesc; | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
801 free(v20.pDDraw4DevDesc); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
802 delete v20.pGUID; |
0 | 803 v6 = (IUnknown *)pDirectDraw4; |
804 } | |
805 else | |
806 { | |
807 aux.pInfo = pOut; | |
808 aux.ptr_4 = &v20; | |
809 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
810 delete [] v20.pDriverName; | |
811 delete [] v20.pDeviceDesc; | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
812 free(v20.pDDraw4DevDesc); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
813 delete v20.pGUID; |
0 | 814 pDirectDraw4->Release(); |
815 v6 = (IUnknown *)pDirect3D3; | |
816 pDirectDraw4 = 0; | |
817 } | |
818 } | |
819 v6->Release(); | |
820 } | |
821 return 1; | |
822 } | |
823 | |
824 //----- (0049D784) -------------------------------------------------------- | |
825 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
826 { | |
827 int v6; // eax@1 | |
828 signed int v7; // edi@1 | |
829 signed int v8; // edi@14 | |
830 size_t v9; // eax@30 | |
831 size_t v10; // eax@30 | |
832 size_t v11; // eax@30 | |
833 size_t v12; // eax@30 | |
834 size_t v13; // eax@30 | |
835 | |
836 v6 = pHWDesc->dwFlags; | |
837 v7 = -1; | |
838 if ( v6 ) | |
839 { | |
840 if ( !a6->ptr_4->pGUID ) | |
841 v7 = 0; | |
842 if ( v6 && a6->ptr_4->pGUID ) | |
843 v7 = 1; | |
844 } | |
845 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
846 v7 = 2; | |
847 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
848 v7 = 3; | |
849 if ( v7 != -1 ) | |
850 { | |
851 v8 = v7; | |
852 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
853 a6->pInfo[v8].uCaps = 0; | |
854 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
855 a6->pInfo[v8].uCaps |= 2u; | |
856 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
857 a6->pInfo[v8].uCaps |= 4u; | |
858 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
859 a6->pInfo[v8].uCaps |= 8u; | |
860 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
861 a6->pInfo[v8].uCaps |= 0x10u; | |
862 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
863 a6->pInfo[v8].uCaps |= 0x20u; | |
864 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
865 a6->pInfo[v8].uCaps |= 0x40u; | |
866 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
867 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
868 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
869 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
870 v9 = strlen(lpDeviceName); | |
871 a6->pInfo[v8].pName = new char[v9 + 1]; | |
872 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
873 v10 = strlen(lpDeviceDesc); | |
874 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
875 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
1631 | 876 a6->pInfo[v8].pGUID = new GUID; |
0 | 877 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); |
878 v11 = strlen(a6->ptr_4->pDriverName); | |
879 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
880 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
881 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
882 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
883 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
884 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
885 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
886 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
887 if ( a6->ptr_4->pGUID ) | |
888 { | |
889 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
890 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
891 } | |
892 else | |
893 { | |
894 a6->pInfo[v8].pDirectDrawGUID = 0; | |
895 } | |
896 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
897 } | |
898 return 1; | |
899 } | |
900 | |
901 //----- (0049D75C) -------------------------------------------------------- | |
902 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
903 { | |
904 HRESULT result; // eax@3 | |
905 | |
906 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
907 { | |
908 *a2 = 1; | |
909 result = 0; | |
910 } | |
911 else | |
912 result = 1; | |
913 return result; | |
914 } | |
915 | |
916 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
917 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
918 { |
0 | 919 unsigned int v6; // edi@9 |
920 int v7; // eax@9 | |
921 SpriteFrame *v8; // eax@9 | |
922 unsigned __int16 *v10; // eax@9 | |
923 int v13; // ecx@9 | |
924 int v14; // ecx@20 | |
925 char v15; // dl@20 | |
926 signed int v16; // eax@20 | |
927 int v17; // eax@23 | |
928 int v18; // ecx@24 | |
929 int v19; // eax@24 | |
930 int v20; // ecx@24 | |
931 int v21; // ebx@26 | |
932 int v22; // eax@26 | |
933 signed __int64 v24; // qtt@31 | |
934 int v25; // ebx@31 | |
935 __int16 v29; // cx@37 | |
936 int v30; // ecx@37 | |
937 int v31; // ebx@37 | |
619 | 938 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
0 | 939 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
940 int v38; // [sp+88h] [bp-1Ch]@9 | |
941 int v40; // [sp+90h] [bp-14h]@24 | |
942 int v41; // [sp+94h] [bp-10h]@24 | |
943 int v42; // [sp+98h] [bp-Ch]@9 | |
944 int b; // [sp+A0h] [bp-4h]@22 | |
945 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
946 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
947 { |
2274 | 948 //LevelDecoration* decor = &pLevelDecorations[i]; |
949 if ((!(pLevelDecorations[i].uFlags & LEVEL_DECORATION_OBELISK_CHEST) | |
950 || pLevelDecorations[i].IsObeliskChestActive()) && !(pLevelDecorations[i].uFlags & LEVEL_DECORATION_INVISIBLE)) | |
951 { | |
952 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
|
953 if ( (char)decor_desc->uFlags >= 0 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
954 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
955 if ( !(decor_desc->uFlags & 0x22) ) |
0 | 956 { |
1490 | 957 v6 = pMiscTimer->uTotalGameTimeElapsed; |
2274 | 958 v7 = abs(pLevelDecorations[i].vPosition.x + pLevelDecorations[i].vPosition.y); |
1490 | 959 |
960 #pragma region "New: seasons change" | |
961 extern bool change_seasons; | |
962 if (change_seasons) | |
963 switch (pParty->uCurrentMonth) | |
964 { | |
965 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
966 case 11: case 0: case 1: // winter | |
967 switch (decor_desc->uSpriteID) | |
968 { | |
969 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
970 case 548: // flower10 | |
971 case 547: // flower09 | |
972 case 541: // flower03 | |
973 case 539: continue; // flower01 | |
974 | |
975 case 483: // tree01 | |
976 case 486: // tree04 | |
977 case 492: // tree10 | |
978 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); | |
979 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
980 break; | |
981 | |
982 default: | |
983 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
984 } | |
985 break; | |
986 | |
987 case 2: case 3: case 4: // spring | |
988 switch (decor_desc->uSpriteID) | |
989 { | |
990 } | |
991 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
992 break; | |
993 | |
994 case 8: case 9: case 10: // autumn | |
995 switch (decor_desc->uSpriteID) | |
996 { | |
997 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
998 case 548: // flower10 | |
999 case 547: // flower09 | |
1000 case 541: // flower03 | |
1001 case 539: continue; // flower01 | |
1002 | |
1003 case 483: // tree01 | |
1004 case 486: // tree04 | |
1005 case 492: // tree10 | |
1006 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); | |
1007 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
1008 break; | |
1009 | |
1010 default: | |
1011 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1012 } | |
1013 break; | |
1014 | |
1015 case 5: case 6: case 7: // summer | |
1016 //all green by default | |
1017 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1018 break; | |
1019 | |
1020 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
1021 } | |
1022 else | |
1023 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1024 #pragma endregion | |
1025 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1026 | |
2274 | 1027 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, |
1028 pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); | |
1490 | 1029 v38 = 0; |
2274 | 1030 v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + pLevelDecorations[i].field_10_y_rot - (signed int)v10) >> 8) & 7; |
1490 | 1031 v37 = (unsigned __int16 *)v13; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1032 if ( v8->uFlags & 2 ) |
1490 | 1033 v38 = 2; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1034 if ( (256 << v13) & v8->uFlags ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1035 v38 |= 4; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1036 if ( v8->uFlags & 0x40000 ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1037 v38 |= 0x40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1038 if ( v8->uFlags & 0x20000 ) |
1490 | 1039 LOBYTE(v38) = v38 | 0x80; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1040 if ( v8->uGlowRadius ) |
0 | 1041 { |
1490 | 1042 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) |
0 | 1043 { |
2322 | 1044 v14 = 255;//decor_desc->uColoredLightRed; |
1045 v15 = 255;//decor_desc->uColoredLightGreen; | |
1046 v16 = 255;//decor_desc->uColoredLightBlue; | |
0 | 1047 } |
1048 else | |
1049 { | |
1490 | 1050 v16 = 255; |
1051 v14 = 255; | |
1052 v15 = 255; | |
1053 } | |
2274 | 1054 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
|
1055 v8->uGlowRadius, v14, v15, v16, _4E94D0_light_type); |
1490 | 1056 } |
2274 | 1057 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
|
1058 if (pGame->pIndoorCameraD3D->sRotationX) |
1490 | 1059 { |
2274 | 1060 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; |
2207 | 1061 v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1062 v41 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 1063 v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x); |
2274 | 1064 v20 = v19 + fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); |
2207 | 1065 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1066 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1067 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1068 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
|
1069 if ( 2 * abs(v20) >= abs(v21) ) |
0 | 1070 { |
1490 | 1071 LODWORD(v24) = 0; |
1637 | 1072 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1073 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
|
1074 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
|
1075 v41 = fixpoint_mul(v8->scale, v24 / v20); |
1490 | 1076 if ( pRenderer->pRenderD3D ) |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1077 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41); |
1490 | 1078 else |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1079 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41); |
1490 | 1080 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
1081 { | |
1082 if (::uNumBillboardsToDraw >= 500) | |
1083 return; | |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1084 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1085 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1086 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
1490 | 1087 v29 = v38; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1088 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1089 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1090 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1091 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
2274 | 1092 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; |
1093 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1094 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
|
1095 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1096 HIWORD(v30) = HIWORD(v20); |
1490 | 1097 v31 = PID(OBJECT_Decoration,i); |
1098 LOWORD(v30) = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1099 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1100 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1101 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1102 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1103 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1104 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1105 ++uNumDecorationsDrawnThisFrame; |
1490 | 1106 } |
0 | 1107 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1108 continue; |
1490 | 1109 } |
1110 } | |
1111 else | |
1112 { | |
2274 | 1113 v42 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; |
1114 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
|
1115 v20 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); |
2207 | 1116 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1490 | 1117 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1118 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y); |
2274 | 1119 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
|
1120 v42 = v22; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1121 if ( 2 * abs(v20) >= abs(v21) ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1122 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1123 LODWORD(v24) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1124 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1125 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
|
1126 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
|
1127 v41 = fixpoint_mul(v8->scale, v24 / v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1128 if ( pRenderer->pRenderD3D ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1129 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
|
1130 else |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1131 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
|
1132 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
|
1133 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1134 if (::uNumBillboardsToDraw >= 500) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1135 return; |
2226
5944810e88e2
occasionally pRenderer->pBillboardRenderListD3D array elements are not correct (0xcdcdcdcd) fix
Ritor1
parents:
2221
diff
changeset
|
1136 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37]; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1137 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1138 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1139 v29 = v38; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1140 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1141 HIBYTE(v29) |= 2; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1142 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1143 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
2274 | 1144 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; |
1145 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1146 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
|
1147 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1148 HIWORD(v30) = HIWORD(v20); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1149 v31 = PID(OBJECT_Decoration,i); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1150 LOWORD(v30) = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1151 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1152 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1153 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1154 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1155 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1156 ::uNumBillboardsToDraw++; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1157 ++uNumDecorationsDrawnThisFrame; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1158 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1159 } |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1160 continue; |
0 | 1161 } |
1162 } | |
1163 } | |
1490 | 1164 } |
1165 else | |
1166 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1167 memset(&local_0, 0, 0x68); |
1490 | 1168 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
1169 local_0.uDiffuse = 0xFF3C1E; | |
2274 | 1170 local_0.x = (double)pLevelDecorations[i].vPosition.x; |
1171 local_0.y = (double)pLevelDecorations[i].vPosition.y; | |
1172 local_0.z = (double)pLevelDecorations[i].vPosition.z; | |
1490 | 1173 local_0.r = 0.0; |
1174 local_0.g = 0.0; | |
1175 local_0.b = 0.0; | |
1176 local_0.flt_28 = 1.0; | |
1177 local_0.timeToLive = (rand() & 0x80) + 128; | |
1178 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
1179 pGame->pParticleEngine->AddParticle(&local_0); | |
1180 } | |
1181 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1182 } |
0 | 1183 } |
1184 | |
1185 //----- (0049D717) -------------------------------------------------------- | |
1186 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1187 { | |
2069 | 1188 if ( Src->dwFlags & (0x400 | 0x2000)) |
0 | 1189 { |
1190 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1191 { |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1192 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1193 return 0; |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1194 } |
0 | 1195 if ( !Dst->dwSize ) |
1196 { | |
2078 | 1197 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1198 return 1; |
0 | 1199 } |
1200 } | |
1201 return 1; | |
1202 } | |
1203 | |
1204 //----- (0049DC28) -------------------------------------------------------- | |
1205 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1206 { | |
1207 RenderD3D__DevInfo *v2; // eax@1 | |
1208 | |
1209 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1210 *pOutDevices = v2; | |
1211 memset(v2, 0, 0xA0u); | |
1985 | 1212 DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)RenderD3D__DeviceEnumerator, *pOutDevices, DDENUM_ATTACHEDSECONDARYDEVICES); |
0 | 1213 } |
1214 | |
1215 //----- (0049DC58) -------------------------------------------------------- | |
1216 RenderD3D::RenderD3D() | |
1217 { | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1218 this->pHost = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1219 this->pDirect3D = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1220 this->pUnk = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1221 this->pBackBuffer = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1222 this->pFrontBuffer = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1223 this->pZBuffer = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1224 this->pDevice = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1225 this->pViewport = nullptr; |
0 | 1226 this->field_40 = 1; |
1227 this->field_44 = 10; | |
1228 GetAvailableDevices(&this->pAvailableDevices); | |
1229 } | |
1230 | |
1231 //----- (0049DC90) -------------------------------------------------------- | |
1232 void RenderD3D::Release() | |
1233 { | |
1234 RenderD3D *v1; // esi@1 | |
1235 IDirectDraw4 *v2; // eax@2 | |
1236 signed int v3; // edi@4 | |
1237 IDirect3DViewport3 *v4; // eax@22 | |
1238 IUnknown *v5; // eax@24 | |
1239 IDirectDrawSurface4 *v6; // eax@26 | |
1240 IDirect3DDevice3 *v7; // eax@28 | |
1241 IDirect3D3 *v8; // eax@30 | |
1242 IDirectDrawSurface4 *v9; // eax@32 | |
1243 IDirectDrawSurface4 *v10; // eax@34 | |
1244 IDirectDraw4 *v11; // eax@36 | |
1245 | |
1246 v1 = this; | |
1247 if ( !this->bWindowed ) | |
1248 { | |
1249 v2 = this->pHost; | |
1250 if ( v2 ) | |
1251 { | |
1252 v2->RestoreDisplayMode(); | |
1253 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
1254 v1->pHost->FlipToGDISurface(); | |
1255 } | |
1256 } | |
1257 v3 = 0; | |
1258 do | |
1259 { | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1260 free(v1->pAvailableDevices[v3].pDriverName); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1261 v1->pAvailableDevices[v3].pDriverName = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1262 free(v1->pAvailableDevices[v3].pDeviceDesc); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1263 v1->pAvailableDevices[v3].pDeviceDesc = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1264 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1265 v1->pAvailableDevices[v3].pDDraw4DevDesc = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1266 free(v1->pAvailableDevices[v3].pDirectDrawGUID); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1267 v1->pAvailableDevices[v3].pDirectDrawGUID = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1268 free(v1->pAvailableDevices[v3].pName); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1269 v1->pAvailableDevices[v3].pName = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1270 free(v1->pAvailableDevices[v3].pDescription); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1271 v1->pAvailableDevices[v3].pDescription = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1272 free(v1->pAvailableDevices[v3].pGUID); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1273 v1->pAvailableDevices[v3].pGUID = nullptr; |
0 | 1274 ++v3; |
1275 } | |
1276 while ( v3 < 4 ); | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1277 free(v1->pAvailableDevices); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
1278 v1->pAvailableDevices = 0; |
0 | 1279 v4 = v1->pViewport; |
1280 if ( v4 ) | |
1281 { | |
1282 v4->Release(); | |
1283 v1->pViewport = 0; | |
1284 } | |
1285 v5 = v1->pUnk; | |
1286 if ( v5 ) | |
1287 { | |
1288 v5->Release(); | |
1289 v1->pUnk = 0; | |
1290 } | |
1291 v6 = v1->pZBuffer; | |
1292 if ( v6 ) | |
1293 { | |
1294 v6->Release(); | |
1295 v1->pZBuffer = 0; | |
1296 } | |
1297 v7 = v1->pDevice; | |
1298 if ( v7 ) | |
1299 { | |
1300 v7->Release(); | |
1301 v1->pDevice = 0; | |
1302 } | |
1303 v8 = v1->pDirect3D; | |
1304 if ( v8 ) | |
1305 { | |
1306 v8->Release(); | |
1307 v1->pDirect3D = 0; | |
1308 } | |
1309 v9 = v1->pBackBuffer; | |
1310 if ( v9 ) | |
1311 { | |
1312 v9->Release(); | |
1313 v1->pBackBuffer = 0; | |
1314 } | |
1315 v10 = v1->pFrontBuffer; | |
1316 if ( v10 ) | |
1317 { | |
1318 v10->Release(); | |
1319 v1->pFrontBuffer = 0; | |
1320 } | |
1321 v11 = v1->pHost; | |
1322 if ( v11 ) | |
1323 { | |
1324 v11->Release(); | |
1325 v1->pHost = 0; | |
1326 } | |
1327 } | |
1328 | |
1329 //----- (0049DE14) -------------------------------------------------------- | |
2069 | 1330 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window) |
0 | 1331 { |
1332 //IDirectDraw4 *v8; // eax@12 | |
1333 //IDirectDraw4 *v9; // eax@16 | |
1334 //IDirectDraw4 *v10; // eax@20 | |
1335 //IDirectDraw4 *v13; // eax@35 | |
1336 const char *v23; // [sp-4h] [bp-DCh]@9 | |
1337 const char *v24; // [sp-4h] [bp-DCh]@13 | |
1338 const char *v25; // [sp-4h] [bp-DCh]@19 | |
1339 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1340 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1341 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1342 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1343 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
1344 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1345 | |
2069 | 1346 auto hWnd = window->GetApiHandle(); |
1347 int game_width = window->GetWidth(); | |
1348 int game_height = window->GetHeight(); | |
1349 | |
0 | 1350 this->bWindowed = bWindowed; |
1351 this->hWindow = hWnd; | |
1352 | |
1353 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
1354 { | |
1355 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1356 return 0; | |
1357 } | |
1358 | |
1359 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1360 { | |
1361 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1362 if (lpDD) | |
1363 lpDD->Release(); | |
1364 return 0; | |
1365 } | |
1366 lpDD->Release(); | |
1367 lpDD = 0; | |
1368 | |
1369 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1370 { | |
1371 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
1372 { | |
1373 v23 = "Init - Failed to set cooperative level.\n"; | |
1374 sprintf(pErrorMessage, v23); | |
1375 LABEL_65: | |
1376 if (pHost) | |
1377 { | |
1378 pHost->Release(); | |
1379 pHost = 0; | |
1380 } | |
1381 return 0; | |
1382 } | |
1383 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1384 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1385 ddsd2.dwFlags = DDSD_CAPS; | |
1386 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
1387 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1388 { | |
1389 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1390 pHost->GetDisplayMode(&ddsd2); | |
2069 | 1391 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) |
0 | 1392 { |
1393 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
1394 goto LABEL_14; | |
1395 } | |
1396 | |
1397 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
1398 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
2069 | 1399 ddsd2.dwWidth = game_width; |
1400 ddsd2.dwHeight = game_height; | |
0 | 1401 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) |
1402 { | |
1403 v24 = "Init - Failed to create back buffer.\n"; | |
1404 LABEL_14: | |
1405 sprintf(pErrorMessage, v24); | |
1406 if (pFrontBuffer) | |
1407 { | |
1408 pFrontBuffer->Release(); | |
1409 pFrontBuffer = 0; | |
1410 } | |
1411 goto LABEL_65; | |
1412 } | |
1413 if ( pHost->CreateClipper(0, &v30, 0) ) | |
1414 { | |
1415 v25 = "Init - Failed to create clipper.\n"; | |
1416 goto LABEL_45; | |
1417 } | |
1418 v30->SetHWnd(0, hWnd); | |
1419 pFrontBuffer->SetClipper(v30); | |
1420 | |
1421 v30->Release(); | |
1422 v30 = 0; | |
1423 | |
1424 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1425 | |
1426 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1427 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
2069 | 1428 ddsd2.dwWidth = game_width; |
1429 ddsd2.dwHeight = game_height; | |
0 | 1430 |
1431 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1432 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1433 &ddsd2.ddpfPixelFormat) ) | |
1434 goto LABEL_21; | |
1435 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1436 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
1437 | |
1438 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1439 { | |
1440 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
1441 { | |
1442 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1443 pBackBuffer, | |
1444 &pDevice, | |
1445 0) ) | |
1446 { | |
1447 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1448 d3dvp2.dvClipWidth = 2.0; | |
1449 d3dvp2.dvClipY = 1.0; | |
1450 d3dvp2.dvClipHeight = 2.0; | |
1451 d3dvp2.dvMaxZ = 1.0; | |
1452 d3dvp2.dvMinZ = 0.0; | |
1453 goto LABEL_54; | |
1454 } | |
1455 LABEL_51: | |
1456 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1457 if (pDirect3D) | |
1458 { | |
1459 pDirect3D->Release(); | |
1460 pDirect3D = 0; | |
1461 } | |
1462 goto LABEL_59; | |
1463 } | |
1464 LABEL_48: | |
1465 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1466 if (pZBuffer) | |
1467 { | |
1468 pZBuffer->Release(); | |
1469 pZBuffer = 0; | |
1470 } | |
1471 goto LABEL_61; | |
1472 } | |
1473 goto LABEL_44; | |
1474 } | |
1475 LABEL_36: | |
1476 v23 = "Init - Failed to create front buffer.\n"; | |
1477 sprintf(pErrorMessage, v23); | |
1478 goto LABEL_65; | |
1479 } | |
1480 if ( uDeviceID == 1 ) | |
1481 v26 = 1045; | |
1482 else | |
1483 v26 = 1041; | |
1484 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
1485 { | |
1486 v23 = "Init - Failed to set cooperative level.\n"; | |
1487 sprintf(pErrorMessage, v23); | |
1488 goto LABEL_65; | |
1489 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1490 if (pHost->SetDisplayMode(window->GetWidth(), window->GetHeight(), 16, 0, 0) ) |
0 | 1491 { |
1492 v23 = "Init - Failed to set display mode.\n"; | |
1493 sprintf(pErrorMessage, v23); | |
1494 goto LABEL_65; | |
1495 } | |
1496 | |
1497 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1498 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1499 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
1500 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
1501 ddsd2.dwBackBufferCount = 1; | |
1502 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
1503 goto LABEL_36; | |
1504 //a3a = &pBackBuffer; | |
1505 //v14 = *v34; | |
1506 memset(&v27, 0, sizeof(DDSCAPS2)); | |
1507 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
1508 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
1509 //hWnda = &pDirect3D; | |
1510 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1511 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
1512 { | |
1513 v25 = "Init - Failed to get D3D interface.\n"; | |
1514 goto LABEL_45; | |
1515 } | |
1516 | |
1517 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1518 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1519 ddsd2.dwWidth = 640; | |
1520 ddsd2.dwHeight = 480; | |
1521 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1522 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1523 &ddsd2.ddpfPixelFormat) ) | |
1524 { | |
1525 LABEL_21: | |
1526 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
1527 goto LABEL_45; | |
1528 } | |
1529 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1530 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
1531 //uDeviceIDa = &pZBuffer; | |
1532 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
1533 { | |
1534 LABEL_44: | |
1535 v25 = "Init - Failed to create z-buffer.\n"; | |
1536 LABEL_45: | |
1537 sprintf(pErrorMessage, v25); | |
1538 if (pBackBuffer) | |
1539 { | |
1540 pBackBuffer->Release(); | |
1541 pBackBuffer = 0; | |
1542 } | |
1543 LABEL_63: | |
1544 //v19 = &pFrontBuffer; | |
1545 if (pFrontBuffer) | |
1546 { | |
1547 pFrontBuffer->Release(); | |
1548 pFrontBuffer= 0; | |
1549 } | |
1550 goto LABEL_65; | |
1551 } | |
1552 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
1553 goto LABEL_48; | |
1554 //v33 = &pDevice; | |
1555 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
1556 pBackBuffer, | |
1557 &pDevice, | |
1558 0) ) | |
1559 goto LABEL_51; | |
1560 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1561 d3dvp2.dvClipWidth = 2.0; | |
1562 d3dvp2.dvClipY = 1.0; | |
1563 d3dvp2.dvClipHeight = 2.0; | |
1564 d3dvp2.dvMaxZ = 1.0; | |
1565 | |
1566 LABEL_54: | |
1567 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
1568 //v17 = *hWnda; | |
2069 | 1569 d3dvp2.dwWidth = game_width; |
1570 d3dvp2.dwHeight = game_height; | |
0 | 1571 d3dvp2.dvClipX = -1.0; |
1572 //v18 = v17->lpVtbl; | |
1573 //v32 = &v4->pViewport; | |
1574 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
1575 { | |
1576 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
1577 if (pDevice) | |
1578 { | |
1579 pDevice->Release(); | |
1580 pDevice = 0; | |
1581 } | |
1582 if (pDirect3D) | |
1583 { | |
1584 pDirect3D->Release(); | |
1585 pDirect3D = 0; | |
1586 } | |
1587 LABEL_59: | |
1588 if (pZBuffer) | |
1589 { | |
1590 pZBuffer->Release(); | |
1591 pZBuffer = 0; | |
1592 } | |
1593 LABEL_61: | |
1594 if (pBackBuffer) | |
1595 { | |
1596 pBackBuffer->Release(); | |
1597 pBackBuffer = 0; | |
1598 } | |
1599 goto LABEL_63; | |
1600 } | |
1601 | |
1602 pDevice->AddViewport(pViewport); | |
1603 pViewport->SetViewport2(&d3dvp2); | |
1604 pDevice->SetCurrentViewport(pViewport); | |
1605 return 1; | |
1606 } | |
1607 | |
1608 //----- (0049E444) -------------------------------------------------------- | |
1609 unsigned int RenderD3D::GetDeviceCaps() | |
1610 { | |
1611 unsigned int v1; // ebx@1 | |
1612 RenderD3D *v2; // edi@1 | |
1613 IDirect3DDevice3 *v3; // eax@1 | |
1614 unsigned int result; // eax@2 | |
1615 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
1616 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
1617 | |
1618 v1 = 0; | |
1619 v2 = this; | |
1620 memset(&halCaps, 0, 0xFCu); | |
1621 halCaps.dwSize = 252; | |
1622 memset(&refCaps, 0, 0xFCu); | |
1623 v3 = v2->pDevice; | |
1624 refCaps.dwSize = 252; | |
1625 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
1626 { | |
1627 result = 1; | |
1628 } | |
1629 else | |
1630 { | |
2154 | 1631 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) ) |
0 | 1632 v1 = 2; |
2154 | 1633 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1634 v1 |= 4u; |
2154 | 1635 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) ) |
0 | 1636 v1 |= 8u; |
2154 | 1637 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) ) |
0 | 1638 v1 |= 0x10u; |
2154 | 1639 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) ) |
0 | 1640 v1 |= 0x20u; |
2154 | 1641 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) ) |
0 | 1642 v1 |= 0x40u; |
2154 | 1643 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ) |
1644 v1 |= 0x80; | |
0 | 1645 result = v1; |
1646 } | |
1647 return result; | |
1648 } | |
1649 | |
1650 //----- (0049E4FC) -------------------------------------------------------- | |
1651 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
1652 { | |
1653 uint uClearFlags = 0; | |
1654 | |
1655 if (bClearColor) | |
1656 uClearFlags |= D3DCLEAR_TARGET; | |
1657 if (bClearDepth) | |
1658 uClearFlags |= D3DCLEAR_ZBUFFER; | |
1659 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
1660 D3DRECT rects[] = {{0, 0, window->GetWidth(), window->GetHeight()}}; |
0 | 1661 if (uClearFlags) |
1662 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
1663 } | |
1664 | |
1665 //----- (0049E54D) -------------------------------------------------------- | |
1666 void RenderD3D::Present(bool bForceBlit) | |
1667 { | |
1668 RECT v5; // [sp+18h] [bp-18h]@1 | |
1669 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
1670 | |
1671 v5.left = 0; | |
1672 v5.top = 0; | |
2217 | 1673 v5.bottom = 480;//window->GetHeight(); //Ritor1: ïðîáëåìà ñ êíîïêîé "ðàçâåðíóòü" |
1674 v5.right = 640; //window->GetWidth(); | |
0 | 1675 |
1676 if (bWindowed || bForceBlit) | |
1677 { | |
1678 RECT rc; | |
1679 GetClientRect(hWindow, &rc); | |
1680 Point.y = 0; | |
1681 Point.x = 0; | |
1682 ClientToScreen(hWindow, &Point); | |
1683 OffsetRect(&rc, Point.x, Point.y); | |
1684 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
1685 } | |
1686 else | |
1687 pFrontBuffer->Flip(0, 1); | |
1688 } | |
1689 | |
1690 //----- (0049E5D4) -------------------------------------------------------- | |
1691 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
1692 { | |
1693 unsigned int v8; // edx@4 | |
1694 unsigned int v9; // ebx@5 | |
1695 unsigned int v10; // eax@5 | |
1696 DWORD v11; // edx@5 | |
1697 //int v12; // edx@7 | |
1698 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
1699 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
1700 | |
1701 //v15 = this; | |
1702 memset(&ddsd2, 0, 0x7Cu); | |
1703 ddsd2.dwSize = 0x7Cu; | |
1704 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1705 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
1706 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
1707 ddsd2.dwHeight = uTextureHeight; | |
1708 ddsd2.dwWidth = uTextureWidth; | |
1709 if ( bMipmaps ) | |
1710 { | |
1711 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
1712 { | |
1713 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
1714 LABEL_8: | |
1715 ddsd2.dwMipMapCount = v8; | |
1716 if ( !v8 ) | |
1717 goto LABEL_12; | |
1718 goto LABEL_11; | |
1719 } | |
1720 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
1721 { | |
1722 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
1723 goto LABEL_8; | |
1724 } | |
1725 v9 = GetMaxMipLevels(uTextureWidth); | |
1726 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
1727 ddsd2.dwMipMapCount = v9 - v10; | |
1728 if ( v9 == v10 ) | |
1729 { | |
1730 ddsd2.dwFlags = 0x1007u; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
1731 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used |
0 | 1732 ddsd2.ddsCaps.dwCaps = v11; |
1733 goto LABEL_12; | |
1734 } | |
1735 } | |
1736 else | |
1737 { | |
1738 ddsd2.dwMipMapCount = 1; | |
1739 } | |
1740 LABEL_11: | |
1741 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1742 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1743 LABEL_12: | |
1744 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
1745 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
1746 if (bAlphaChannel) | |
1747 { | |
1748 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
1749 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
1750 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
1751 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1752 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
1753 } | |
1754 else | |
1755 { | |
1756 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
1757 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
1758 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
1759 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1760 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
1761 } | |
1762 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
1763 return false; | |
1764 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
1765 { | |
1766 (*pOutSurface)->Release(); | |
1767 *pOutSurface = 0; | |
1768 return false; | |
1769 } | |
1770 return true; | |
1771 } | |
1772 | |
1773 //----- (004A5190) -------------------------------------------------------- | |
1774 void RenderD3D::HandleLostResources() | |
1775 { | |
1776 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
1777 pBitmaps_LOD->_410423_move_textures_to_device(); | |
1778 pSprites_LOD->ReleaseLostHardwareSprites(); | |
1779 } | |
1780 | |
1781 //----- (004A2050) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
1782 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) |
0 | 1783 { |
1784 Render *v5; // edi@1 | |
1785 unsigned int v6; // ebx@1 | |
1786 LightmapBuilder *v7; // esi@3 | |
1787 int v8; // eax@7 | |
2334 | 1788 // ODMFace *v9; // eax@12 |
1789 // char *v10; // esi@12 | |
1790 // double v11; // st7@14 | |
1791 // double v12; // st7@14 | |
1792 // int v13; // eax@14 | |
1793 // ODMFace *v14; // ecx@14 | |
1794 // double v15; // st7@14 | |
1795 // float v16; // ST48_4@15 | |
1796 // int v17; // eax@15 | |
1797 // char v18; // zf@17 | |
1798 // HRESULT v19; // eax@18 | |
1799 // HRESULT v20; // eax@18 | |
1800 // HRESULT v21; // eax@20 | |
1801 // HRESULT v22; // eax@20 | |
1802 // unsigned int v23; // ecx@20 | |
1803 // char *v24; // eax@21 | |
1804 // HRESULT v25; // eax@23 | |
1805 // HRESULT v26; // eax@23 | |
1806 // HRESULT v27; // eax@24 | |
1807 // HRESULT v28; // eax@25 | |
1808 // HRESULT v29; // eax@25 | |
1809 // HRESULT v30; // eax@25 | |
1810 // HRESULT v31; // eax@25 | |
1811 // HRESULT v32; // eax@26 | |
1812 // unsigned int v33; // ecx@26 | |
1813 // char *v34; // eax@27 | |
1814 // int v35; // edx@28 | |
1815 // HRESULT v36; // eax@29 | |
1816 // HRESULT v37; // eax@29 | |
1817 // HRESULT v38; // eax@29 | |
1818 // HRESULT v39; // eax@29 | |
0 | 1819 //IDirect3DDevice3Vtbl *v40; // ebx@29 |
1820 unsigned int v41; // eax@29 | |
2334 | 1821 // HRESULT v42; // eax@30 |
1822 // HRESULT v43; // eax@30 | |
1823 // HRESULT v44; // eax@30 | |
1824 // char *v45; // esi@34 | |
1825 // int v46; // ecx@35 | |
1826 // double v47; // st6@35 | |
1827 // int v48; // eax@36 | |
1828 // const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
1829 // const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
1830 // int v51; // [sp+50h] [bp-18h]@0 | |
1831 // unsigned int v52; // [sp+54h] [bp-14h]@0 | |
0 | 1832 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 |
1833 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
2334 | 1834 // unsigned int v55; // [sp+5Ch] [bp-Ch]@34 |
1835 // unsigned int v56; // [sp+60h] [bp-8h]@12 | |
1836 // int v57; // [sp+60h] [bp-8h]@34 | |
2006 | 1837 signed int a2; // [sp+64h] [bp-4h]@4 |
0 | 1838 |
1839 v5 = this; | |
1840 v6 = 0; | |
1841 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
1842 { | |
1843 v7 = pGame->pLightmapBuilder; | |
1844 v53 = v7; | |
1845 v54 = v7->std__vector_000004_size; | |
1846 if ( v7->std__vector_000004_size) | |
2006 | 1847 a2 = -1; |
638 | 1848 pGame->AlterGamma_ODM(a4, &a2); |
2155 | 1849 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 1850 { |
638 | 1851 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 1852 v7->DrawLightmaps(/*v8, 0*/); |
0 | 1853 } |
1854 else | |
1855 { | |
1856 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
1857 { | |
323 | 1858 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1859 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
1860 if (bUsingSpecular) | |
1861 { | |
186 | 1862 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
1863 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1864 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1865 } |
1073 | 1866 for (uint i = 0; i < uNumVertices; ++i) |
1867 { | |
1868 | |
1869 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1870 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1871 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1872 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1873 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1874 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
1875 | |
1876 if ( this->bUsingSpecular ) | |
0 | 1877 { |
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
|
1878 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1879 } |
1073 | 1880 else |
1881 { | |
1882 d3d_vertex_buffer[i].specular = 0; | |
1883 } | |
1884 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1885 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1886 | |
1887 } | |
323 | 1888 |
1889 if (a4->uAttributes & FACE_OUTLINED) | |
1890 { | |
1891 int color; | |
1892 if (GetTickCount() % 300 >= 150) | |
1893 color = 0xFFFF2020; | |
1894 else color = 0xFF901010; | |
1895 | |
1896 for (uint i = 0; i < uNumVertices; ++i) | |
1897 d3d_vertex_buffer[i].diffuse = color; | |
1898 } | |
1899 | |
0 | 1900 pRenderD3D->pDevice->SetTexture(0, pTexture); |
1901 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1902 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1903 d3d_vertex_buffer, |
0 | 1904 uNumVertices, |
1905 D3DDP_DONOTLIGHT); | |
1906 } | |
1907 else | |
1908 { | |
1073 | 1909 for (uint i = 0; i < uNumVertices; ++i) |
1910 { | |
1911 | |
1912 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
1913 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 1914 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 1915 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
1916 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
1917 if ( this->bUsingSpecular ) | |
0 | 1918 { |
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
|
1919 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 1920 } |
1073 | 1921 else |
1922 { | |
1923 d3d_vertex_buffer[i].specular = 0; | |
1924 } | |
1925 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
1926 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
1927 | |
1928 } | |
1929 | |
186 | 1930 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
1931 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 1932 if (bUsingSpecular) |
186 | 1933 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 1934 |
1935 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
1936 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1937 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1938 d3d_vertex_buffer, |
0 | 1939 uNumVertices, |
1940 D3DDP_DONOTLIGHT)); | |
1941 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
1942 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1943 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
1394 | 1944 v53->DrawLightmaps(/*-1, 0*/); |
1073 | 1945 for (uint i = 0; i < uNumVertices; ++i) |
1946 { | |
1947 d3d_vertex_buffer[i].diffuse = a2; | |
1948 } | |
0 | 1949 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 1950 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 1951 if ( !pRenderer->bUsingSpecular ) |
186 | 1952 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
1953 | |
1954 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
1955 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
1956 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 1957 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1958 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1959 d3d_vertex_buffer, |
0 | 1960 uNumVertices, |
1961 D3DDP_DONOTLIGHT)); | |
1962 if (bUsingSpecular) | |
1963 { | |
186 | 1964 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 1965 |
1073 | 1966 for (uint i = 0; i < uNumVertices; ++i) |
1967 { | |
1968 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
1969 d3d_vertex_buffer[i].specular = 0; | |
1970 } | |
1971 | |
0 | 1972 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 1973 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
1974 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 1975 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
1976 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1977 d3d_vertex_buffer, |
0 | 1978 uNumVertices, |
1979 D3DDP_DONOTLIGHT)); | |
186 | 1980 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 1981 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
1982 v41 = GetLevelFogColor(); | |
1983 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
1984 v6 = 0; | |
1985 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
1986 } | |
186 | 1987 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
1988 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 1989 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
1990 } | |
1991 } | |
1992 } | |
1993 } | |
1994 // 4D864C: using guessed type char byte_4D864C; | |
1995 | |
1996 //----- (0049EB79) -------------------------------------------------------- | |
1997 Render::~Render() | |
1998 { | |
1999 Render *v1; // esi@1 | |
2000 | |
2001 v1 = this; | |
1583 | 2002 free(this->pDefaultZBuffer); |
0 | 2003 v1->pD3DBitmaps.Release(); |
2004 v1->pD3DSprites.Release(); | |
2005 Release(); | |
2006 v1->bWindowMode = 1; | |
2007 //nullsub_1(); | |
2008 //nullsub_1(); | |
2009 } | |
2010 | |
2011 | |
2012 //----- (0049E992) -------------------------------------------------------- | |
2013 Render::Render() | |
2014 { | |
2216 | 2015 //Render *v1; // esi@1 |
2334 | 2016 // int v2; // eax@1 |
2017 // char v3; // zf@1 | |
0 | 2018 |
2216 | 2019 //v1 = this; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2020 this->pDirectDraw4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2021 this->pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2022 this->pBackBuffer4 = nullptr; |
2154 | 2023 //this->pColorKeySurface4 = 0; |
2152 | 2024 //this->pDirectDraw2 = 0; |
2025 //this->pFrontBuffer2 = 0; | |
2026 //this->pBackBuffer2 = 0; | |
2027 //this->pSomeSurface2 = 0; | |
0 | 2028 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); |
2029 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2216 | 2030 this->bWindowMode = 1; |
2031 //this->field_40054 = 0; | |
2032 //this->field_10 = 640; | |
2033 //this->field_14 = 480; | |
2034 //this->field_40030 = 0; | |
2035 //this->field_4002C = 0; | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2036 this->pActiveZBuffer = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2037 this->pDefaultZBuffer = nullptr; |
2216 | 2038 this->raster_clip_y = 0; |
2039 this->raster_clip_x = 0; | |
2040 this->raster_clip_z = 639; | |
2041 this->raster_clip_w = 479; | |
2042 //this->field_4003C = 0x004EED80; | |
2043 //this->field_40040 = dword_4EED78; | |
2044 this->uClipZ = 640; | |
2045 //this->field_40044 = 2; | |
2046 //this->field_40048 = 6; | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2047 this->pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2048 this->pBackBuffer4 = nullptr; |
2216 | 2049 //this->pColorKeySurface4 = 0; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2050 this->pDirectDraw4 = nullptr; |
2216 | 2051 this->pRenderD3D = 0; |
2052 this->uNumSceneBegins = 0; | |
2053 this->uNumD3DSceneBegins = 0; | |
2054 this->using_software_screen_buffer = 0; | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2055 this->pTargetSurface = nullptr; |
2216 | 2056 this->uTargetSurfacePitch = 0; |
2057 this->uClipY = 0; | |
2058 this->uClipX = 0; | |
2059 this->uClipW = 480; | |
2060 this->bClip = 1; | |
2061 //this->bColorKeySupported = 0; | |
2062 this->bRequiredTextureStagesAvailable = 0; | |
2063 this->bTinting = 1; | |
2064 //LOBYTE(this->field_103668) = 0; | |
0 | 2065 uNumBillboardsToDraw = 0; |
2066 bFogEnabled = false; | |
265 | 2067 |
2068 hd_water_tile_id = -1; | |
2069 hd_water_current_frame = 0; | |
0 | 2070 } |
2071 | |
2069 | 2072 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
0 | 2073 { |
1802 | 2074 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); |
2075 | |
2076 this->window = window; | |
2069 | 2077 //bStartInWindow = true; |
1802 | 2078 //windowed_mode_width = windowed_width; |
2079 //windowed_mode_height = windowed_height; | |
2080 | |
1985 | 2081 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0); |
0 | 2082 |
2083 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
2084 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
2085 | |
2086 this->bTinting = bTinting; | |
2087 | |
1980 | 2088 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); |
2089 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
0 | 2090 |
2091 return r1 && r2; | |
2092 } | |
2093 | |
2094 | |
2095 //----- (0049ECC4) -------------------------------------------------------- | |
2096 void Render::ClearBlack() | |
2097 { | |
2154 | 2098 //if (pRenderD3D) |
0 | 2099 { |
2069 | 2100 if (using_software_screen_buffer) |
0 | 2101 pRenderD3D->ClearTarget(true, 0, false, 0.0); |
2102 } | |
2154 | 2103 //else |
2104 //memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
0 | 2105 } |
2106 | |
2107 //----- (0049ED18) -------------------------------------------------------- | |
2108 void Render::PresentBlackScreen() | |
2109 { | |
2110 IDirectDrawSurface *v2; // eax@3 | |
2111 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
2112 RECT x; // [sp+68h] [bp-10h]@3 | |
2113 | |
2114 memset(&v3, 0, sizeof(DDBLTFX)); | |
1802 | 2115 GetWindowRect(window->GetApiHandle(), &x); |
2152 | 2116 |
0 | 2117 { |
2118 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
2119 } | |
2152 | 2120 |
0 | 2121 v3.dwFillColor = 0; |
2122 v3.dwSize = 100; | |
2123 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
2124 pRenderer->Present(); | |
2125 } | |
2126 | |
2127 //----- (0049EDB6) -------------------------------------------------------- | |
2128 void Render::SavePCXScreenshot() | |
2129 { | |
2130 int v5; // eax@8 | |
2132 | 2131 FILE *pOutFile; // edi@10 |
2133 | 2132 unsigned short *v8; // eax@11 |
2334 | 2133 // int v9; // eax@13 |
2134 // int v10; // ecx@15 | |
0 | 2135 signed int v12; // eax@18 |
2334 | 2136 // HRESULT v14; // eax@29 |
0 | 2137 char v15[56]; // [sp+Ch] [bp-158h]@10 |
2138 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2139 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2140 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2132 | 2141 char *lineB; // [sp+11Ch] [bp-48h]@14 |
2142 char *lineG; // [sp+120h] [bp-44h]@14 | |
2143 //int v24; // [sp+124h] [bp-40h]@11 | |
0 | 2144 FILE *File; // [sp+128h] [bp-3Ch]@3 |
2145 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2146 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2132 | 2147 char *lineRGB; // [sp+148h] [bp-1Ch]@10 |
2148 void *surface; // [sp+14Ch] [bp-18h]@8 | |
2149 int image_width; // [sp+150h] [bp-14h]@4 | |
2150 int pitch; // [sp+154h] [bp-10h]@4 | |
0 | 2151 char v31; // [sp+15Ah] [bp-Ah]@25 |
2132 | 2152 unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17 |
2153 unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10 | |
2154 byte test_byte; // [sp+163h] [bp-1h]@17 | |
2155 | |
2156 int num_r_bits = 5; | |
2157 int num_g_bits = 6; | |
2158 int num_b_bits = 5; | |
2159 | |
2160 int r_mask = 0xF800; | |
2161 int g_mask = 0x7E0; | |
2162 int b_mask = 0x1F; | |
2163 | |
2069 | 2164 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2165 { |
2132 | 2166 sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100); |
0 | 2167 File = fopen(Filename, "wb"); |
2168 if ( File ) | |
2169 { | |
2154 | 2170 pitch = this->GetRenderWidth(); |
2171 if ( pitch & 1 ) | |
2172 pitch = pitch + 1; | |
2132 | 2173 if ( this->pRenderD3D ) |
2174 { | |
2175 memset(&Dst, 0, 0x7C); | |
0 | 2176 Dst.dwSize = 124; |
168 | 2177 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 2178 return; |
2132 | 2179 surface = Dst.lpSurface; |
2180 v5 = Dst.lPitch / 2; | |
0 | 2181 } |
2182 else | |
2183 { | |
2184 pRenderer->BeginScene(); | |
2132 | 2185 surface = pRenderer->pTargetSurface; |
0 | 2186 v5 = pRenderer->uTargetSurfacePitch; |
2187 } | |
2154 | 2188 header1.right = GetRenderWidth() - 1; |
2132 | 2189 header1.left = 0; |
2154 | 2190 header1.bottom = this->GetRenderHeight() - 1; |
2132 | 2191 header1.up = 0; |
2192 header2.pitch = pitch; | |
0 | 2193 memset(color_map, 0, sizeof(color_map)); |
2194 memset(v15, 0, sizeof(v15)); | |
2195 header2.reserved = 0; | |
2196 header1.manufacturer = 10; | |
2132 | 2197 pOutFile = File; |
0 | 2198 header1.version = 5; |
2199 header1.encoding = 1; | |
2200 header1.bpp = 8; | |
2201 header1.hdpi = 75; | |
2202 header1.vdpi = 75; | |
2203 header2.planes = 3; | |
2204 header2.palette_info = 1; | |
2132 | 2205 fwrite(&header1, 1, 1, File); |
2206 fwrite(&header1.version, 1, 1, pOutFile); | |
2207 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2208 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2209 fwrite(&header1.left, 2, 1, pOutFile); | |
2210 fwrite(&header1.up, 2, 1, pOutFile); | |
2211 fwrite(&header1.right, 2, 1, pOutFile); | |
2212 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2213 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2214 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2215 fwrite(color_map, 0x30u, 1, pOutFile); | |
2216 fwrite(&header2, 1, 1, pOutFile); | |
2217 fwrite(&header2.planes, 1, 1, pOutFile); | |
2218 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2219 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2220 fwrite(v15, 0x3Au, 1, pOutFile); | |
2154 | 2221 lineRGB = (char *)malloc(3 * GetRenderWidth() + 6); |
2222 if ( this->GetRenderHeight() > 0 ) | |
2132 | 2223 { |
2224 image_width = 3 * pitch; | |
2225 //v24 = 2 * v5; | |
2226 v8 = (unsigned short *)surface; | |
2154 | 2227 for ( int y = 0; y < this->GetRenderHeight(); y++ ) |
0 | 2228 { |
2132 | 2229 line_picture_data = v8; |
2154 | 2230 if ( GetRenderWidth() > 0 ) |
0 | 2231 { |
2132 | 2232 lineG = (char *)lineRGB + pitch; |
2233 lineB = (char *)lineRGB + 2 * pitch; | |
2154 | 2234 for ( uint x = 0; x < this->GetRenderWidth(); x++ ) |
0 | 2235 { |
2221 | 2236 //int p = *line_picture_data; //0x2818 |
2237 //int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits );//16 = 8 + 8 | |
2238 //int value = (pRenderer->uTargetRMask & *line_picture_data);//0 = 0xFF0000 & 0x2818 | |
2239 //int result = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits ); | |
2133 | 2240 lineRGB[x] = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits );// + pRenderer->uTargetRBits - 8); |
2241 lineG[x] = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits);// + pRenderer->uTargetGBits - 8); | |
2221 | 2242 //int value2 = (pRenderer->uTargetGMask & *line_picture_data); //10240 = 0xFF00 & 0x2818 |
2243 //int result2 = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits); | |
2133 | 2244 lineB[x] = (pRenderer->uTargetBMask & *line_picture_data);// << (8 - pRenderer->uTargetBBits); |
2221 | 2245 //int value3 = (pRenderer->uTargetBMask & *line_picture_data);//24 = 0xFF & 0x2818 |
2132 | 2246 line_picture_data += 2; |
0 | 2247 } |
2248 } | |
2132 | 2249 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2250 { |
2132 | 2251 pict_byte = lineRGB[i]; |
2252 for ( test_byte = 1; test_byte < 0x3F; ++test_byte ) | |
0 | 2253 { |
2132 | 2254 v12 = i + test_byte; |
2255 if ( lineRGB[v12] != pict_byte ) | |
0 | 2256 break; |
2132 | 2257 if ( !(v12 % pitch) ) |
0 | 2258 break; |
2259 } | |
2132 | 2260 if ( i + test_byte > image_width ) |
2261 test_byte = 3 * pitch - i; | |
2262 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
2263 { | |
2264 v31 = test_byte | 0xC0; | |
2265 fwrite(&v31, 1, 1, pOutFile); | |
2266 } | |
2267 fwrite(&pict_byte, 1, 1, pOutFile); | |
0 | 2268 } |
2132 | 2269 v8 += v5; |
0 | 2270 } |
2271 } | |
2132 | 2272 if ( this->pRenderD3D ) |
0 | 2273 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2274 else | |
2275 pRenderer->EndScene(); | |
2132 | 2276 |
2277 free(lineRGB); | |
2278 fclose(pOutFile); | |
0 | 2279 } |
2280 } | |
2281 } | |
2282 | |
2283 //----- (0049F1BC) -------------------------------------------------------- | |
2069 | 2284 void Render::SaveWinnersCertificate(const char *a1) |
0 | 2285 { |
2286 unsigned int v6; // eax@8 | |
2133 | 2287 //FILE *v7; // edi@10 |
2334 | 2288 // int v8; // ecx@11 |
2133 | 2289 unsigned short *v9; // eax@11 |
0 | 2290 int v10; // eax@13 |
2291 signed int v13; // eax@18 | |
2334 | 2292 // char v14; // zf@27 |
2293 // HRESULT v15; // eax@29 | |
2133 | 2294 char v16[56]; // [sp+Ch] [bp-12Ch]@10 |
0 | 2295 __int16 v17; // [sp+44h] [bp-F4h]@10 |
2133 | 2296 DDSURFACEDESC2 Dst; // [sp+48h] [bp-F0h]@7 |
2334 | 2297 // int v19; // [sp+58h] [bp-E0h]@8 |
2298 // unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
2133 | 2299 char color_map[48]; // [sp+C4h] [bp-74h]@10 |
2334 | 2300 // unsigned int v22; // [sp+F4h] [bp-44h]@11 |
2133 | 2301 char *lineB; // [sp+F8h] [bp-40h]@14 |
2302 int image_width; // [sp+FCh] [bp-3Ch]@11 | |
0 | 2303 int v25; // [sp+100h] [bp-38h]@4 |
2304 FILE *File; // [sp+104h] [bp-34h]@3 | |
2305 char Str; // [sp+108h] [bp-30h]@10 | |
2306 char v28; // [sp+109h] [bp-2Fh]@10 | |
2307 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
2308 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
2309 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
2310 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
2311 __int16 v33; // [sp+110h] [bp-28h]@10 | |
2312 __int16 v34; // [sp+112h] [bp-26h]@10 | |
2313 __int16 v35; // [sp+114h] [bp-24h]@10 | |
2314 __int16 v36; // [sp+116h] [bp-22h]@10 | |
2315 char v37; // [sp+118h] [bp-20h]@10 | |
2316 char v38; // [sp+119h] [bp-1Fh]@10 | |
2317 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
2318 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
2133 | 2319 char *lineRGB; // [sp+120h] [bp-18h]@10 |
2320 void *surface; // [sp+124h] [bp-14h]@8 | |
2321 int pitch; // [sp+128h] [bp-10h]@4 | |
0 | 2322 char v44; // [sp+12Fh] [bp-9h]@25 |
2133 | 2323 char *lineG; // [sp+130h] [bp-8h]@10 |
2324 unsigned char pict_byte; // [sp+137h] [bp-1h]@17 | |
2325 byte test_byte; | |
2326 | |
2327 int num_r_bits = 5; | |
2328 int num_g_bits = 6; | |
2329 int num_b_bits = 5; | |
2330 | |
2331 int r_mask = 0xF800; | |
2332 int g_mask = 0x7E0; | |
2333 int b_mask = 0x1F; | |
2334 | |
2069 | 2335 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2336 { |
2154 | 2337 static int _4EFA84_num_winners_certificates = 0; |
2338 ++_4EFA84_num_winners_certificates; | |
2339 | |
0 | 2340 File = fopen(a1, "wb"); |
2341 if ( File ) | |
2342 { | |
2154 | 2343 v25 = this->GetRenderWidth(); |
2344 pitch = v25; | |
2345 if ( pitch & 1 ) | |
2346 pitch = pitch + 1; | |
2133 | 2347 if ( this->pRenderD3D ) |
2348 { | |
2349 memset(&Dst, 0, 0x7C); | |
2350 Dst.dwSize = 124; | |
168 | 2351 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 2352 return; |
2133 | 2353 surface = Dst.lpSurface; |
2354 v6 = Dst.lPitch / 2; | |
0 | 2355 } |
2356 else | |
2357 { | |
2358 pRenderer->BeginScene(); | |
2133 | 2359 surface = pRenderer->pTargetSurface; |
0 | 2360 v6 = pRenderer->uTargetSurfacePitch; |
2361 } | |
2154 | 2362 v33 = this->GetRenderWidth() - 1; |
2133 | 2363 v31 = 0; |
2154 | 2364 v34 = (short)this->GetRenderHeight() - 1; |
2133 | 2365 v32 = 0; |
2366 v39 = pitch; | |
2367 memset(&color_map, 0, sizeof(color_map)); | |
2368 memset(&v16, 0, sizeof(v16)); | |
0 | 2369 v37 = 0; |
2370 Str = 10; | |
2371 v17 = 0; | |
2372 v28 = 5; | |
2373 v29 = 1; | |
2374 v30 = 8; | |
2375 v35 = 75; | |
2376 v36 = 75; | |
2377 v38 = 3; | |
2378 v40 = 1; | |
2133 | 2379 fwrite(&Str, 1, 1, File); |
2380 fwrite(&v28, 1, 1, File); | |
2381 fwrite(&v29, 1, 1, File); | |
2382 fwrite(&v30, 1, 1, File); | |
2383 fwrite(&v31, 2, 1, File); | |
2384 fwrite(&v32, 2, 1, File); | |
2385 fwrite(&v33, 2, 1, File); | |
2386 fwrite(&v34, 2, 1, File); | |
2387 fwrite(&v35, 2, 1, File); | |
2388 fwrite(&v36, 2, 1, File); | |
2389 fwrite(&color_map, 0x30, 1, File); | |
2390 fwrite(&v37, 1, 1, File); | |
2391 fwrite(&v38, 1, 1, File); | |
2392 fwrite(&v39, 2, 1, File); | |
2393 fwrite(&v40, 2, 1, File); | |
2394 fwrite(&v16, 0x3A, 1, File); | |
2395 lineRGB = (char *)malloc(3 * (v25 + 2)); | |
2154 | 2396 if ( (signed int)this->GetRenderHeight() > 0 ) |
2133 | 2397 { |
2398 image_width = 3 * pitch; | |
2399 v9 = (unsigned short *)surface; | |
2154 | 2400 for ( uint j = 0; j < this->GetRenderHeight(); j++) |
0 | 2401 { |
2402 a1 = (const char *)v9; | |
2403 if ( v25 > 0 ) | |
2404 { | |
2133 | 2405 lineG = (char *)lineRGB + pitch; |
2406 lineB = (char *)lineRGB + 2 * pitch; | |
2407 for ( v10 = 0; v10 < v25; v10++ ) | |
0 | 2408 { |
2133 | 2409 lineRGB[v10] = (signed int)(r_mask & *(short *)a1) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2410 lineG[v10] = (signed int)(g_mask & *(short *)a1) >> (num_b_bits + num_g_bits - 8); | |
2411 lineB[v10] = (b_mask & *(short *)a1) << (8 - num_b_bits); | |
0 | 2412 a1 += 2; |
2413 } | |
2414 } | |
2133 | 2415 for ( uint i = 0; i < image_width; i += test_byte ) |
0 | 2416 { |
2133 | 2417 pict_byte = lineRGB[i]; |
2418 for ( test_byte = 1; test_byte < 0x3F; test_byte ) | |
0 | 2419 { |
2133 | 2420 v13 = i + test_byte; |
2421 if ( lineRGB[v13] != pict_byte ) | |
0 | 2422 break; |
2133 | 2423 if ( !(v13 % pitch) ) |
0 | 2424 break; |
2425 } | |
2133 | 2426 if ( i + test_byte > image_width ) |
2427 test_byte = 3 * pitch - i; | |
2428 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
0 | 2429 { |
2133 | 2430 v44 = test_byte | 0xC0; |
2431 fwrite(&v44, 1, 1, File); | |
0 | 2432 } |
2133 | 2433 fwrite(&pict_byte, 1, 1, File); |
0 | 2434 } |
2133 | 2435 v9 += pitch; |
0 | 2436 } |
2437 } | |
2133 | 2438 if ( this->pRenderD3D ) |
0 | 2439 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2440 else | |
2441 pRenderer->EndScene(); | |
2133 | 2442 free(lineRGB); |
2443 fclose(File); | |
0 | 2444 } |
2445 } | |
2446 } | |
2447 | |
2448 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 2449 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
2127 | 2450 { |
0 | 2451 void *v8; // esi@3 |
2452 void *v9; // esi@3 | |
810 | 2453 unsigned short* v11; // eax@4 |
2334 | 2454 // int v13; // eax@8 |
2455 // int v14; // ecx@8 | |
0 | 2456 signed int v15; // eax@11 |
2334 | 2457 // char v16; // zf@20 |
2458 // int result; // eax@21 | |
0 | 2459 char v18[58]; // [sp+Ch] [bp-ACh]@3 |
2460 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 2461 char *lineG; // [sp+78h] [bp-40h]@7 |
2462 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 2463 int v23; // [sp+80h] [bp-38h]@4 |
2464 int v24; // [sp+84h] [bp-34h]@4 | |
2465 int v25; // [sp+88h] [bp-30h]@4 | |
2466 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 2467 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
2468 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
2469 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
2470 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 2471 char v43; // [sp+B3h] [bp-5h]@18 |
2472 int i; // [sp+B4h] [bp-4h]@6 | |
2132 | 2473 unsigned short* line_picture_data; |
810 | 2474 byte test_byte; |
2475 unsigned char pict_byte; | |
0 | 2476 |
2131 | 2477 int num_r_bits = 5; |
2478 int num_g_bits = 6; | |
2479 int num_b_bits = 5; | |
2480 | |
2481 int r_mask = 0xF800; | |
2482 int g_mask = 0x7E0; | |
2483 int b_mask = 0x1F; | |
2484 | |
810 | 2485 pitch = wight; |
2486 if ( wight & 1 ) | |
2487 pitch = wight + 1; | |
2488 Src.left = 0; | |
2489 Src.up = 0; | |
2490 Src.right = wight - 1; | |
2491 Src.bottom = heidth - 1; | |
2492 v27.pitch = pitch; | |
0 | 2493 memset(&v20, 0, 0x30u); |
2494 memset(&v18, 0, 0x38u); | |
810 | 2495 v8 = data_buff; |
2496 v27.reserved = 0; | |
0 | 2497 *(_WORD *)&v18[56] = 0; |
810 | 2498 Src.manufacturer = 10; |
2499 Src.version = 5; | |
2500 Src.encoding = 1; | |
2501 Src.bpp = 8; | |
2502 Src.hdpi = 75; | |
2503 Src.vdpi = 75; | |
2504 v27.planes = 3; | |
2505 v27.palette_info = 1; | |
2128 | 2506 memcpy(data_buff, &Src, 1); |
0 | 2507 v8 = (char *)v8 + 1; |
2128 | 2508 memcpy(v8, &Src.version, 1); |
0 | 2509 v8 = (char *)v8 + 1; |
2128 | 2510 memcpy(v8, &Src.encoding, 1); |
0 | 2511 v8 = (char *)v8 + 1; |
2128 | 2512 memcpy(v8, &Src.bpp, 1); |
0 | 2513 v8 = (char *)v8 + 1; |
2128 | 2514 memcpy(v8, &Src.left, 2); |
0 | 2515 v8 = (char *)v8 + 2; |
2128 | 2516 memcpy(v8, &Src.up, 2); |
0 | 2517 v8 = (char *)v8 + 2; |
2128 | 2518 memcpy(v8, &Src.right, 2); |
0 | 2519 v8 = (char *)v8 + 2; |
2128 | 2520 memcpy(v8, &Src.bottom, 2); |
0 | 2521 v8 = (char *)v8 + 2; |
2127 | 2522 memcpy(v8, &Src.hdpi, 2); |
0 | 2523 v8 = (char *)v8 + 2; |
2127 | 2524 memcpy(v8, &Src.vdpi, 2); |
0 | 2525 v8 = (char *)v8 + 2; |
2526 memcpy(v8, &v20, 0x30u); | |
2527 v8 = (char *)v8 + 48; | |
810 | 2528 memcpy(v8, &v27, 1u); |
0 | 2529 v8 = (char *)v8 + 1; |
2127 | 2530 memcpy(v8, &v27.planes, 1); |
0 | 2531 v8 = (char *)v8 + 1; |
2127 | 2532 memcpy(v8, &v27.pitch, 2); |
0 | 2533 v8 = (char *)v8 + 2; |
2127 | 2534 memcpy(v8, &v27.palette_info, 2); |
0 | 2535 v8 = (char *)v8 + 2; |
2536 memcpy(v8, &v18, 0x3Au); | |
2537 v9 = (char *)v8 + 58; | |
810 | 2538 |
1583 | 2539 lineRGB = (char*)malloc(3 * (wight + 2)); |
810 | 2540 if ( heidth > 0 ) |
2541 { | |
2542 v26 = 3 * pitch; | |
2543 v23 = 2 * wight; | |
2544 v11 = picture_data; | |
2545 v24 = (int)picture_data; | |
2127 | 2546 for ( v25 = heidth; v25; v25-- ) |
0 | 2547 { |
2132 | 2548 line_picture_data = v11; |
810 | 2549 if ( wight > 0 ) |
2550 { | |
2551 lineG = (char *)lineRGB + pitch; | |
2552 lineB = (char *)lineRGB + 2 * pitch; | |
2127 | 2553 for ( uint i = 0; i < wight; i++ ) |
0 | 2554 { |
2132 | 2555 lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); |
2556 lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8); | |
2557 lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits); | |
2558 line_picture_data += 1; | |
810 | 2559 } |
0 | 2560 } |
2561 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
2562 { | |
2128 | 2563 pict_byte = lineRGB[i]; |
2127 | 2564 for ( test_byte = 1; test_byte < 63; ++test_byte ) |
0 | 2565 { |
810 | 2566 v15 = i + test_byte; |
2128 | 2567 if ( lineRGB[v15] != pict_byte ) |
0 | 2568 break; |
810 | 2569 if ( !(v15 % pitch) ) |
0 | 2570 break; |
810 | 2571 } |
2572 if ( i + test_byte > v26 ) | |
2573 test_byte = 3 * pitch - i; | |
2127 | 2574 if ( test_byte > 1 || pict_byte >= 192 ) |
810 | 2575 { |
2576 v43 = test_byte | 0xC0; | |
2127 | 2577 memcpy(v9, &v43, 1); |
0 | 2578 v9 = (char *)v9 + 1; |
2579 } | |
2127 | 2580 memcpy(v9, &pict_byte, 1); |
810 | 2581 i += test_byte; |
2582 } | |
2128 | 2583 v11 += wight; |
810 | 2584 } |
2585 } | |
1583 | 2586 free(lineRGB); |
810 | 2587 *(int *)packed_size = (char *)v9 - data_buff; |
0 | 2588 } |
2589 | |
2590 //----- (0049F8B5) -------------------------------------------------------- | |
2155 | 2591 void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) |
0 | 2592 { |
2593 FILE *result; // eax@1 | |
2127 | 2594 FILE *pOutFile; // edi@4 |
2128 | 2595 unsigned short* v9; // eax@5 |
2334 | 2596 // int v10; // eax@7 |
0 | 2597 signed int v12; // eax@12 |
2334 | 2598 // char v13; // zf@21 |
0 | 2599 char v14[56]; // [sp+4h] [bp-A0h]@4 |
2600 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
2601 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
2602 int v18; // [sp+74h] [bp-30h]@5 | |
2334 | 2603 // char *v19; // [sp+78h] [bp-2Ch]@5 |
2127 | 2604 int image_width; // [sp+7Ch] [bp-28h]@5 |
0 | 2605 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 |
2606 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
2128 | 2607 char *lineRGB; // [sp+98h] [bp-Ch]@4 |
2608 int pitch; // [sp+9Ch] [bp-8h]@2 | |
2609 char *lineB; // [sp+A0h] [bp-4h]@8 | |
2610 char *lineG; | |
2611 unsigned short* line_pictute_data; | |
2612 byte test_byte; | |
2613 char v43; | |
2127 | 2614 |
2615 int num_r_bits = 5; | |
2616 int num_g_bits = 6; | |
2617 int num_b_bits = 5; | |
2618 | |
2619 int r_mask = 0xF800; | |
2620 int g_mask = 0x7E0; | |
2621 int b_mask = 0x1F; | |
0 | 2622 |
2623 result = fopen(Filename, "wb"); | |
2624 Filename = (const char *)result; | |
2625 if ( result ) | |
2626 { | |
2128 | 2627 pitch = width; |
2127 | 2628 if ( width & 1 ) |
2128 | 2629 pitch = width + 1; |
0 | 2630 header1.left = 0; |
2631 header1.up = 0; | |
2127 | 2632 header1.right = width - 1; |
2633 header1.bottom = height - 1; | |
2128 | 2634 header2.pitch = pitch; |
0 | 2635 memset(color_map, 0, sizeof(color_map)); |
2636 header2.reserved = 0; | |
2637 memset(v14, 0, sizeof(v14)); | |
2638 v15 = 0; | |
2639 header1.manufacturer = 10; | |
2640 header1.version = 5; | |
2641 header1.encoding = 1; | |
2642 header1.bpp = 8; | |
2643 header1.hdpi = 75; | |
2644 header1.vdpi = 75; | |
2645 header2.planes = 3; | |
2646 header2.palette_info = 1; | |
2127 | 2647 fwrite(&header1, 1, 1, (FILE *)Filename); |
2648 pOutFile = (FILE *)Filename; | |
2649 fwrite(&header1.version, 1, 1, (FILE *)Filename); | |
2650 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2651 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2652 fwrite(&header1.left, 2, 1, pOutFile); | |
2653 fwrite(&header1.up, 2, 1, pOutFile); | |
2654 fwrite(&header1.right, 2, 1, pOutFile); | |
2655 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2656 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2657 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2658 fwrite(color_map, 0x30u, 1, pOutFile); | |
2659 fwrite(&header2, 1, 1, pOutFile); | |
2660 fwrite(&header2.planes, 1, 1, pOutFile); | |
2661 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2662 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2663 fwrite(v14, 0x3Au, 1, pOutFile); | |
2128 | 2664 |
2665 lineRGB = (char *)malloc(3 * (width + 2)); | |
2131 | 2666 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ |
2667 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî. | |
2128 | 2668 image_width = 3 * pitch; |
2669 v9 = picture_data; | |
2127 | 2670 for ( v18 = 0; v18 < height; v18++ )//ñòîëáåö |
2671 { | |
2128 | 2672 line_pictute_data = v9; |
2673 lineG = (char *)lineRGB + pitch; | |
2674 lineB = (char *)lineRGB + 2 * pitch; | |
2675 | |
2676 for ( int i = 0; i < width; i++ )//ñòðîêà | |
2677 { | |
2678 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); | |
2679 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); | |
2680 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); | |
2131 | 2681 line_pictute_data += 1; |
2128 | 2682 } |
2683 test_byte = 1; | |
2131 | 2684 for ( int i = 0; (signed int)i < image_width; i += test_byte ) |
2128 | 2685 { |
2686 unsigned char pic_byte = lineRGB[i]; | |
2687 for ( test_byte; test_byte < 63; ++test_byte )// ðàñ÷¸ò êîëè÷åñòâà îäèíàêîâûõ öâåòîâ | |
0 | 2688 { |
2128 | 2689 v12 = i + test_byte; |
2690 if ( lineRGB[v12] != pic_byte ) | |
2127 | 2691 break; |
2128 | 2692 if ( !(v12 % pitch) ) |
2127 | 2693 break; |
0 | 2694 } |
2128 | 2695 if ( i + test_byte > image_width ) |
2696 test_byte = 3 * pitch - i; | |
2697 if ( test_byte > 1 || pic_byte >= 0xC0 ) | |
0 | 2698 { |
2128 | 2699 v43 = test_byte | 0xC0;//òåñò-áàéò îáúåäèíåíèÿ |
2700 fwrite(&v43, 1, 1, pOutFile); | |
0 | 2701 } |
2128 | 2702 fwrite(&pic_byte, 1, 1, pOutFile); |
2703 } | |
2704 v9 += width; | |
2131 | 2705 } |
2128 | 2706 free(lineRGB); |
2155 | 2707 fclose(pOutFile); |
2708 } | |
0 | 2709 } |
2710 | |
2711 //----- (0049FBCD) -------------------------------------------------------- | |
2712 void Render::ClearTarget(unsigned int uColor) | |
2713 { | |
2154 | 2714 //if (pRenderD3D) |
0 | 2715 { |
2069 | 2716 if (using_software_screen_buffer) |
0 | 2717 pRenderD3D->ClearTarget(true, uColor, false, 0.0); |
2718 } | |
2154 | 2719 //else |
2720 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
0 | 2721 } |
2722 | |
2723 | |
2724 //----- (0049FC37) -------------------------------------------------------- | |
2725 void Render::Present() | |
2726 { | |
2217 | 2727 //struct tagRECT Rect; // [sp+8h] [bp-28h]@11 |
2728 //RECT a4; // [sp+18h] [bp-18h]@11 | |
2729 //struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
2730 | |
2069 | 2731 if ( !pRenderer->pRenderD3D || this->using_software_screen_buffer ) |
0 | 2732 { |
2733 this->pBeforePresentFunction(); | |
2217 | 2734 if ( this->pRenderD3D ) |
2735 { | |
2736 if ( this->using_software_screen_buffer ) | |
0 | 2737 pRenderD3D->Present(false); |
2217 | 2738 } |
2739 else | |
2740 __debugbreak(); // no sr | |
1802 | 2741 /*{ |
2217 | 2742 if ( this->bWindowMode ) |
0 | 2743 { |
2744 RestoreFrontBuffer(); | |
2217 | 2745 GetClientRect(this->hWnd, &Rect); |
0 | 2746 Point.y = 0; |
2747 Point.x = 0; | |
2217 | 2748 ClientToScreen(this->hWnd, &Point); |
0 | 2749 OffsetRect(&Rect, Point.x, Point.y); |
2750 a4.top = 0; | |
2751 a4.bottom = 480; | |
2752 a4.left = 0; | |
2753 a4.right = 640; | |
2754 PresentRect(&Rect, &a4); | |
2755 } | |
2756 else | |
2757 { | |
2758 RestoreFrontBuffer(); | |
2759 a4.top = 0; | |
2760 a4.bottom = 480; | |
2761 a4.left = 0; | |
2762 a4.right = 640; | |
2763 BltBackToFontFast(0, 0, &a4); | |
2764 } | |
1802 | 2765 }*/ |
0 | 2766 } |
2767 } | |
2768 | |
2769 //----- (0049FD3A) -------------------------------------------------------- | |
2154 | 2770 void Render::_49FD3A_fullscreen() |
0 | 2771 { |
2772 Render *v2; // esi@1 | |
2773 IDirectDrawSurface4 *v3; // eax@6 | |
2774 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
2775 RECT v5; // [sp+8h] [bp-10h]@6 | |
2776 | |
1980 | 2777 Render* a1 = this; |
0 | 2778 v2 = a1; |
2779 if ( a1->pRenderD3D ) | |
2780 { | |
2781 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
2782 pFrontBuffer4->Restore(); | |
2783 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
2784 pBackBuffer4->Restore(); | |
2785 v3 = v2->pBackBuffer4; | |
2786 v4 = v2->pFrontBuffer4; | |
2787 v5.top = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2788 v5.bottom = window->GetHeight(); |
0 | 2789 v5.left = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
2790 v5.right = window->GetWidth(); |
0 | 2791 v3->BltFast(0, 0, v4, &v5, 16u); |
2792 } | |
2793 } | |
2794 | |
2795 //----- (0049FDBF) -------------------------------------------------------- | |
2796 void Render::CreateZBuffer() | |
2797 { | |
2798 if (!pDefaultZBuffer) | |
2799 { | |
1583 | 2800 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); |
871 | 2801 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 2802 } |
2803 } | |
2804 | |
2805 //----- (0049FE05) -------------------------------------------------------- | |
2806 void Render::Release() | |
2807 { | |
2808 Render *v1; // esi@1 | |
1802 | 2809 //RenderD3D *v2; // ecx@1 |
2810 //char v3; // zf@4 | |
2811 //void *v4; // ebx@6 | |
2334 | 2812 // IDirectDraw *v5; // eax@10 |
2813 // IDirectDrawSurface2 *v6; // eax@11 | |
2814 // IDirectDrawSurface2 *v7; // eax@13 | |
2815 // IDirectDrawSurface2 *v8; // eax@15 | |
2816 // IDirectDraw2 *v9; // eax@17 | |
2817 // IDirectDraw4 *v10; // eax@19 | |
2818 // IDirectDrawSurface4 *v11; // eax@20 | |
2819 // IDirectDrawSurface4 *v12; // eax@22 | |
2820 // IDirectDrawSurface4 *v13; // eax@24 | |
2821 // IDirectDraw4 *v14; // eax@26 | |
2822 // unsigned __int16 **v15; // ebx@28 | |
2823 // void **v16; // esi@29 | |
0 | 2824 |
2825 v1 = this; | |
1802 | 2826 if (pRenderD3D) |
0 | 2827 { |
2069 | 2828 if ( v1->using_software_screen_buffer ) |
0 | 2829 { |
1802 | 2830 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2831 pRenderD3D->Present(0); |
1802 | 2832 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
0 | 2833 } |
2154 | 2834 //v1->pColorKeySurface4 = 0; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2835 v1->pBackBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2836 v1->pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2837 v1->pDirectDraw4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2838 delete [] v1->pTargetSurface_unaligned; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2839 v1->pTargetSurface = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2840 v1->pTargetSurface_unaligned = nullptr; |
1802 | 2841 if (pRenderD3D) |
0 | 2842 { |
2843 pRenderD3D->Release(); | |
1802 | 2844 delete pRenderD3D; |
2845 } | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
2846 pRenderD3D = nullptr; |
0 | 2847 } |
2848 else | |
1802 | 2849 ;//__debugbreak(); // no sr |
2850 /*{ | |
0 | 2851 if ( bWinNT4_0 == 1 ) |
2852 { | |
2853 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
2854 if ( !v5 ) | |
2855 return; | |
2856 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
2857 v1->pDirectDraw2->FlipToGDISurface(); | |
2858 v6 = v1->pSomeSurface2; | |
2859 if ( v6 ) | |
2860 { | |
2861 v6->Release(); | |
2862 v1->pSomeSurface2 = 0; | |
2863 } | |
2864 v7 = v1->pBackBuffer2; | |
2865 if ( v7 ) | |
2866 { | |
2867 v7->Release(); | |
2868 v1->pBackBuffer2 = 0; | |
2869 } | |
2870 v8 = v1->pFrontBuffer2; | |
2871 if ( v8 ) | |
2872 { | |
2873 v8->Release(); | |
2874 v1->pFrontBuffer2 = 0; | |
2875 } | |
2876 v9 = v1->pDirectDraw2; | |
2877 if ( v9 ) | |
2878 { | |
2879 v9->Release(); | |
2880 v1->pDirectDraw2 = 0; | |
2881 } | |
2882 } | |
2883 else | |
2884 { | |
2885 v10 = v1->pDirectDraw4; | |
2886 if ( !v10 ) | |
2887 return; | |
2888 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
2889 v1->pDirectDraw4->FlipToGDISurface(); | |
2890 v11 = v1->pColorKeySurface4; | |
2891 if ( v11 ) | |
2892 { | |
2893 v11->Release(); | |
2894 v1->pColorKeySurface4 = 0; | |
2895 } | |
2896 v12 = v1->pBackBuffer4; | |
2897 if ( v12 ) | |
2898 { | |
2899 v12->Release(); | |
2900 v1->pBackBuffer4 = 0; | |
2901 } | |
2902 v13 = v1->pFrontBuffer4; | |
2903 if ( v13 ) | |
2904 { | |
2905 v13->Release(); | |
2906 v1->pFrontBuffer4 = 0; | |
2907 } | |
2908 v14 = v1->pDirectDraw4; | |
2909 if ( v14 ) | |
2910 { | |
2911 v14->Release(); | |
2912 v1->pDirectDraw4 = 0; | |
2913 } | |
2914 } | |
2915 v15 = &v1->pTargetSurface; | |
2916 if ( v1->pTargetSurface ) | |
2917 { | |
2918 v16 = (void **)&v1->ptr_400E8; | |
2919 free(*v16); | |
2920 *v15 = 0; | |
2921 *v16 = 0; | |
2922 } | |
1802 | 2923 }*/ |
0 | 2924 } |
2925 | |
2152 | 2926 |
2927 | |
2928 | |
2929 void Present32(unsigned __int32 *src, unsigned int src_pitch, | |
2930 unsigned __int32 *dst, unsigned int dst_pitch) | |
2931 { | |
2932 for (uint y = 0; y < 8; ++y) | |
2933 memcpy(dst + y * dst_pitch, | |
2934 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2935 | |
2936 for (uint y = 8; y < 352; ++y) | |
2937 { | |
2938 memcpy(dst + y * dst_pitch, | |
2939 src + y * src_pitch, 8 * sizeof(__int32)); | |
2940 memcpy(dst + 8 + game_viewport_width + y * dst_pitch, | |
2941 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32)); | |
2942 } | |
2943 | |
2944 for (uint y = 352; y < 480; ++y) | |
2945 memcpy(dst + y * dst_pitch, | |
2946 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
2947 | |
2948 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
2949 { | |
2950 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
2951 { | |
2952 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) | |
2155 | 2953 if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) |
2152 | 2954 dst[x + y * dst_pitch] = src[x + y * src_pitch]; |
2955 } | |
2956 } | |
2957 } | |
2958 | |
2959 //----- (004A597D) -------------------------------------------------------- | |
2960 void Present_NoColorKey() | |
2961 { | |
2962 //unsigned __int16 *v0; // eax@4 | |
2334 | 2963 // unsigned __int16 *v1; // esi@4 |
2152 | 2964 void *v2; // edi@4 |
2965 //signed int v4; // ebx@4 | |
2966 //signed int v5; // ebx@6 | |
2967 //void *v6; // edi@7 | |
2968 //const void *v7; // esi@7 | |
2334 | 2969 // signed int v8; // ebx@8 |
2152 | 2970 int v9; // eax@10 |
2971 unsigned int v10; // esi@10 | |
2972 unsigned __int32 v11; // edi@10 | |
2973 //int v12; // ecx@10 | |
2974 unsigned int v13; // ebx@10 | |
2334 | 2975 // int v14; // eax@11 |
2976 // int v15; // eax@13 | |
2977 // int v16; // eax@14 | |
2978 // int v17; // eax@16 | |
2979 // HRESULT v18; // eax@22 | |
2152 | 2980 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 |
2981 //int v20; // [sp+88h] [bp-1Ch]@10 | |
2982 int v21; // [sp+8Ch] [bp-18h]@10 | |
2983 __int32 v22; // [sp+90h] [bp-14h]@10 | |
2984 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10 | |
2985 unsigned int v24; // [sp+98h] [bp-Ch]@4 | |
2986 //unsigned int _this; // [sp+9Ch] [bp-8h]@10 | |
2987 //LPVOID v26; // [sp+A0h] [bp-4h]@4 | |
2988 | |
2989 int r_mask = 0xF800; | |
2990 int g_mask = 0x7E0; | |
2991 int b_mask = 0x1F; | |
2992 | |
2993 if ( !pRenderer->uNumSceneBegins ) | |
2994 { | |
2154 | 2995 //if ( pRenderer->using_software_screen_buffer ) |
2996 //{ | |
2152 | 2997 memset(&Dst, 0, 0x7Cu); |
2998 Dst.dwSize = 124; | |
2999 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
3000 { | |
3001 //v26 = Dst.lpSurface; | |
3002 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; | |
3003 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16); | |
3004 //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; | |
3005 //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; | |
3006 //v1 = pRenderer->pTargetSurface; | |
3007 v2 = Dst.lpSurface; | |
3008 | |
3009 | |
3010 /*for (uint y = 0; y < 480; ++y) | |
3011 { | |
3012 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch); | |
3013 for (uint x = 0; x < 640; ++x) | |
3014 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; | |
3015 }*/ | |
3016 | |
3017 if (!FORCE_16_BITS) | |
3018 Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4); | |
3019 else | |
3020 { | |
3021 ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface; | |
3022 short* pDst = (__int16 *)Dst.lpSurface; | |
3023 | |
3024 for (uint y = 0; y < 8; ++y) | |
3025 memcpy(pDst + y * Dst.lPitch / 2, | |
3026 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3027 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
2152 | 3028 |
3029 for (uint y = 8; y < 352; ++y) | |
3030 { | |
3031 memcpy(pDst + y * Dst.lPitch / 2, | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3032 pSrc + y * window->GetWidth(), 8 * sizeof(__int16)); |
2152 | 3033 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
|
3034 pSrc + 8 + game_viewport_width/*462*/ + y * window->GetWidth(), 174/*172*/ * sizeof(__int16)); |
2152 | 3035 } |
3036 | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3037 for (uint y = 352; y < window->GetHeight(); ++y) |
2152 | 3038 memcpy(pDst + y * Dst.lPitch / 2, |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3039 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3040 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3041 |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3042 ushort* pSrc_x1y1 = pSrc + window->GetWidth() * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; |
2152 | 3043 //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)]; |
3044 short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; | |
3045 //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY)); | |
3046 v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1); | |
3047 //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1); | |
3048 v22 = 4 * ((Dst.lPitch / 4) + v9); | |
3049 v21 = 4 * v9 + 1280; | |
3050 | |
3051 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1; | |
3052 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1); | |
3053 v10 = (int)pSrc_x1y1; | |
3054 v11 = (int)pDst_x1y1; | |
3055 int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; | |
3056 v13 = v24; | |
3057 | |
3058 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
3059 { | |
3060 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, | |
3061 // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); | |
3062 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
3063 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3064 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
|
3065 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * window->GetWidth() + x]; |
2152 | 3066 } |
3067 } | |
3068 } | |
3069 | |
3070 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3071 | |
3072 /* while ( 1 ) | |
3073 { | |
3074 while ( 1 ) | |
3075 { | |
3076 v14 = *(int *)v10; | |
3077 v10 += 4; | |
3078 if ( v14 == v13 ) | |
3079 break; | |
3080 if ( (short)v14 == (short)v13 ) | |
3081 { | |
3082 *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000; | |
3083 v11 += 4; | |
3084 --uHalfWidth; | |
3085 if ( !uHalfWidth ) | |
3086 goto LABEL_21; | |
3087 } | |
3088 else | |
3089 { | |
3090 v15 = __ROL__(v14, 16); | |
3091 if ( (short)v15 == (short)v13 ) | |
3092 { | |
3093 v17 = __ROR__(v15, 16); | |
3094 *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17; | |
3095 v11 += 4; | |
3096 --uHalfWidth; | |
3097 if ( !uHalfWidth ) | |
3098 goto LABEL_21; | |
3099 } | |
3100 else | |
3101 { | |
3102 v16 = __ROR__(v15, 16); | |
3103 *(int *)v11 = v16; | |
3104 v11 += 4; | |
3105 --uHalfWidth; | |
3106 if ( !uHalfWidth ) | |
3107 goto LABEL_21; | |
3108 } | |
3109 } | |
3110 } | |
3111 v11 += 4; | |
3112 --uHalfWidth; | |
3113 if ( !uHalfWidth ) | |
3114 { | |
3115 LABEL_21: | |
3116 v10 += v21; | |
3117 v11 += v22; | |
3118 uHalfWidth = v20; | |
3119 if ( !--uNumLines ) | |
3120 { | |
3121 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3122 return; | |
3123 } | |
3124 } | |
3125 }*/ | |
3126 } | |
2154 | 3127 //} |
3128 } | |
3129 } | |
3130 | |
0 | 3131 |
3132 //----- (0049FFFB) -------------------------------------------------------- | |
1802 | 3133 bool Render::InitializeFullscreen() |
0 | 3134 { |
3135 //Render *v2; // esi@1 | |
3136 //HWND v3; // ebx@1 | |
3137 //void *v4; // eax@2 | |
3138 //RenderD3D *v5; // eax@3 | |
3139 unsigned int v6; // edx@5 | |
3140 RenderD3D__DevInfo *v7; // ecx@5 | |
3141 bool v8; // eax@6 | |
3142 RenderD3D *v9; // ecx@13 | |
3143 unsigned int v10; // eax@13 | |
3144 RenderD3D *v11; // eax@25 | |
2334 | 3145 // HRESULT v12; // eax@25 |
0 | 3146 int v13; // ecx@25 |
3147 int v14; // eax@27 | |
3148 signed int v15; // ebx@31 | |
2069 | 3149 //bool v16; // eax@35 |
3150 //char v17; // zf@35 | |
2334 | 3151 // IDirectDraw4 *v18; // eax@38 |
3152 // HRESULT v19; // eax@38 | |
2069 | 3153 //int *v20; // eax@39 |
0 | 3154 int *v22; // eax@42 |
3155 int v23; // ecx@42 | |
3156 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3157 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3158 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
2334 | 3159 // DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 |
0 | 3160 void *v28; // [sp+2FCh] [bp-10h]@2 |
3161 int v29; // [sp+308h] [bp-4h]@2 | |
3162 | |
2069 | 3163 __debugbreak(); // Nomad |
3164 | |
0 | 3165 //v2 = this; |
2069 | 3166 this->using_software_screen_buffer = 0; |
2154 | 3167 //this->pColorKeySurface4 = 0; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3168 this->pBackBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3169 this->pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3170 this->pDirectDraw4 = nullptr; |
2069 | 3171 //this->bColorKeySupported = 0; |
0 | 3172 Release(); |
3173 //v3 = hWnd; | |
1802 | 3174 this->window = window; |
0 | 3175 CreateZBuffer(); |
1802 | 3176 |
3177 /*if (!bUserDirect3D) | |
3178 { | |
3179 CreateDirectDraw(); | |
3180 SetDirectDrawCooperationMode(hWnd, 1); | |
3181 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3182 CreateDirectDrawPrimarySurface(); | |
3183 v15 = 1; | |
3184 } | |
3185 else | |
3186 {*/ | |
0 | 3187 pRenderD3D = new RenderD3D; |
3188 v28 = pRenderD3D; | |
3189 v6 = uDesiredDirect3DDevice; | |
3190 v29 = -1; | |
3191 v7 = pRenderD3D->pAvailableDevices; | |
3192 if ( v7[v6].bIsDeviceCompatible ) | |
3193 { | |
2069 | 3194 v8 = pRenderD3D->CreateDevice(v6, /*0*/true, window); |
0 | 3195 } |
3196 else | |
3197 { | |
3198 if ( v7[1].bIsDeviceCompatible ) | |
3199 { | |
2069 | 3200 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window); |
0 | 3201 } |
3202 else | |
3203 { | |
3204 if ( !v7->bIsDeviceCompatible ) | |
1545 | 3205 Error("There aren't any D3D devices to create."); |
3206 | |
2069 | 3207 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window); |
0 | 3208 } |
3209 } | |
3210 if ( !v8 ) | |
1545 | 3211 Error("D3Drend->Init failed."); |
3212 | |
0 | 3213 v9 = pRenderD3D; |
3214 pBackBuffer4 = v9->pBackBuffer; | |
3215 pFrontBuffer4 = v9->pFrontBuffer; | |
3216 pDirectDraw4 = v9->pHost; | |
3217 v10 = pRenderD3D->GetDeviceCaps(); | |
3218 if ( v10 & 1 ) | |
3219 { | |
3220 if ( pRenderD3D ) | |
3221 { | |
3222 pRenderD3D->Release(); | |
3223 delete pRenderD3D; | |
3224 } | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3225 pRenderD3D = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3226 pBackBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3227 pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3228 pDirectDraw4 = nullptr; |
1545 | 3229 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3230 } |
3231 if ( v10 & 0x3E ) | |
3232 { | |
3233 if ( pRenderD3D ) | |
3234 { | |
3235 pRenderD3D->Release(); | |
3236 delete pRenderD3D; | |
3237 } | |
2154 | 3238 //pColorKeySurface4 = 0; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3239 pRenderD3D = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3240 pBackBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3241 pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3242 pDirectDraw4 = nullptr; |
1545 | 3243 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3244 } |
3245 if ( (v10 & 0x80u) != 0 ) | |
3246 { | |
3247 if ( pRenderD3D ) | |
3248 { | |
3249 pRenderD3D->Release(); | |
3250 delete pRenderD3D; | |
3251 } | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3252 pRenderD3D = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3253 pBackBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3254 pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3255 pDirectDraw4 = nullptr; |
1545 | 3256 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3257 } |
2154 | 3258 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; |
0 | 3259 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3260 memset(&halCaps, 0, 0xFCu); | |
3261 halCaps.dwSize = 252; | |
3262 memset(&refCaps, 0, 0xFCu); | |
3263 v11 = pRenderD3D; | |
3264 refCaps.dwSize = 252; | |
3265 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
3266 v13 = halCaps.dwMinTextureWidth; | |
3267 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3268 v13 = halCaps.dwMinTextureHeight; | |
3269 v14 = halCaps.dwMaxTextureWidth; | |
3270 uMinDeviceTextureDim = v13; | |
3271 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
3272 v14 = halCaps.dwMaxTextureHeight; | |
3273 uMaxDeviceTextureDim = v14; | |
3274 if ( (unsigned int)v13 < 4 ) | |
3275 uMinDeviceTextureDim = 4; | |
3276 v15 = 1; | |
3277 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3278 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
2154 | 3279 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2)); |
0 | 3280 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); |
3281 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3282 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
2154 | 3283 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); |
3284 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
3285 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
3286 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3)); | |
3287 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2)); | |
0 | 3288 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); |
2154 | 3289 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2)); |
3290 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
0 | 3291 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); |
2154 | 3292 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4)); |
1802 | 3293 //} |
2069 | 3294 ddpfPrimarySuface.dwSize = 32; |
3295 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3296 ParseTargetPixelFormat(); |
2069 | 3297 |
3298 if (!pRenderD3D) | |
3299 { | |
3300 __debugbreak(); | |
3301 pBeforePresentFunction = 0;//nullsub_1; | |
3302 } | |
3303 //else | |
3304 //{ | |
3305 /*v16 = IsColorKeySupported(pDirectDraw4); | |
0 | 3306 v17 = uAcquiredDirect3DDevice == v15; |
3307 bColorKeySupported = v16; | |
3308 if ( !v17 ) | |
3309 bColorKeySupported = 0; | |
3310 if ( bColorKeySupported ) | |
3311 { | |
3312 memset(&ddsd2, 0, 0x7Cu); | |
3313 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3314 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3315 v18 = pDirectDraw4; | |
3316 ddsd2.dwSize = 124; | |
3317 ddsd2.dwFlags = 65543; | |
3318 ddsd2.ddsCaps.dwCaps = 2112; | |
3319 ddsd2.dwWidth = 640; | |
3320 ddsd2.dwHeight = 480; | |
3321 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3322 pBeforePresentFunction = Present_ColorKey; | |
3323 } | |
2069 | 3324 else*/ |
0 | 3325 { |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3326 pTargetSurface = nullptr; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3327 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32); |
2069 | 3328 if ( !pTargetSurface_unaligned |
0 | 3329 || (memset(&pDesc, 0, 0x7Cu), |
3330 pDesc.dwSize = 124, | |
3331 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
3332 return 0; | |
3333 pBackBuffer4->Unlock(0); | |
2069 | 3334 v22 = (int *)pTargetSurface_unaligned + 4; |
0 | 3335 v23 = (unsigned int)pDesc.lpSurface & 7; |
3336 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
3337 uTargetSurfacePitch = window->GetWidth(); |
0 | 3338 pBeforePresentFunction = Present_NoColorKey; |
3339 v15 = 1; | |
2069 | 3340 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23); |
3341 } | |
3342 using_software_screen_buffer = v15; | |
3343 //} | |
0 | 3344 bWindowMode = 0; |
3345 pParty->uFlags |= 2u; | |
2151 | 3346 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
3347 return v15 != 0; |
0 | 3348 } |
3349 | |
3350 //----- (004A05F3) -------------------------------------------------------- | |
1802 | 3351 bool Render::SwitchToWindow() |
0 | 3352 { |
3353 //Render *v2; // esi@1 | |
3354 //void *v3; // eax@2 | |
3355 //RenderD3D *v4; // eax@3 | |
3356 //unsigned int v5; // edx@5 | |
3357 //RenderD3D__DevInfo *v6; // ecx@5 | |
3358 bool v7; // eax@7 | |
3359 //RenderD3D *v8; // ecx@12 | |
3360 unsigned int v9; // eax@12 | |
2334 | 3361 // RenderD3D *v10; // eax@24 |
3362 // HRESULT v11; // eax@24 | |
0 | 3363 int v12; // eax@24 |
3364 int v13; // eax@26 | |
2069 | 3365 //bool v14; // eax@32 |
3366 //char v15; // zf@32 | |
2334 | 3367 // IDirectDraw4 *v16; // eax@35 |
3368 // HRESULT v17; // eax@35 | |
2069 | 3369 //int *v18; // eax@36 |
2334 | 3370 // int *v19; // edx@38 |
3371 // int v20; // eax@38 | |
3372 // unsigned int v21; // ecx@38 | |
3373 // int v22; // eax@41 | |
0 | 3374 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 |
3375 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3376 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
2334 | 3377 // DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 |
0 | 3378 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 |
3379 int v29; // [sp+308h] [bp-4h]@2 | |
3380 | |
2069 | 3381 pParty->uFlags |= PARTY_FLAGS_1_0002; |
2151 | 3382 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); |
2069 | 3383 using_software_screen_buffer = 0; |
0 | 3384 Release(); |
2154 | 3385 //pColorKeySurface4 = 0; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3386 pBackBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3387 pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3388 pDirectDraw4 = nullptr; |
2069 | 3389 //bColorKeySupported = 0; |
0 | 3390 CreateZBuffer(); |
1802 | 3391 /*if (!bUserDirect3D) |
3392 { | |
3393 CreateDirectDraw(); | |
3394 SetDirectDrawCooperationMode(hWnd, 0); | |
3395 field_4004C = 1; | |
3396 CreateFrontBuffer(); | |
3397 CreateClipper(hWnd); | |
3398 CreateBackBuffer(); | |
3399 field_40030 = 0; | |
3400 field_18_locked_pitch = 0; | |
3401 } | |
3402 else | |
3403 {*/ | |
1631 | 3404 /*v3 = malloc(0x148u); |
0 | 3405 thisa = (RenderD3D *)v3; |
3406 v29 = 0; | |
3407 if ( v3 ) | |
3408 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3409 else | |
3410 v4 = 0;*/ | |
3411 pRenderD3D = new RenderD3D; | |
3412 //v4 = pRenderD3D; | |
3413 //v5 = uDesiredDirect3DDevice; | |
3414 v29 = -1; | |
3415 //v6 = pRenderD3D->pAvailableDevices; | |
3416 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
3417 uDesiredDirect3DDevice != 1 ) | |
3418 { | |
2069 | 3419 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window); |
0 | 3420 } |
3421 else | |
3422 { | |
3423 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
1545 | 3424 Error("There aren't any D3D devices to init."); |
3425 | |
2069 | 3426 v7 = pRenderD3D->CreateDevice(0, true, window); |
0 | 3427 } |
3428 if ( !v7 ) | |
1545 | 3429 Error("D3Drend->Init failed."); |
0 | 3430 |
3431 //v8 = pRenderD3D; | |
2154 | 3432 //pColorKeySurface4 = 0; |
0 | 3433 pBackBuffer4 = pRenderD3D->pBackBuffer; |
3434 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3435 pDirectDraw4 = pRenderD3D->pHost; | |
3436 v9 = pRenderD3D->GetDeviceCaps(); | |
3437 if ( v9 & 1 ) | |
3438 { | |
3439 if (pRenderD3D) | |
3440 { | |
3441 pRenderD3D->Release(); | |
3442 delete pRenderD3D; | |
3443 } | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3444 pRenderD3D = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3445 pBackBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3446 pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3447 pDirectDraw4 = nullptr; |
1545 | 3448 Error("Direct3D renderer: The device failed to return capabilities."); |
0 | 3449 } |
3450 if ( v9 & 0x3E ) | |
3451 { | |
3452 if (pRenderD3D) | |
3453 { | |
3454 pRenderD3D->Release(); | |
3455 delete pRenderD3D; | |
3456 } | |
2154 | 3457 //pColorKeySurface4 = 0; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3458 pRenderD3D = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3459 pBackBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3460 pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3461 pDirectDraw4 = nullptr; |
1545 | 3462 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); |
0 | 3463 } |
2154 | 3464 if (v9 & 0x80) |
0 | 3465 { |
3466 if (pRenderD3D) | |
3467 { | |
3468 pRenderD3D->Release(); | |
3469 delete pRenderD3D; | |
3470 } | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3471 pRenderD3D = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3472 pBackBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3473 pFrontBuffer4 = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2368
diff
changeset
|
3474 pDirectDraw4 = nullptr; |
1545 | 3475 Error("Direct3D renderer: The device doesn't support non-square textures."); |
0 | 3476 } |
2154 | 3477 //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; |
0 | 3478 bRequiredTextureStagesAvailable = CheckTextureStages(); |
3479 memset(&halCaps, 0, 0xFCu); | |
3480 halCaps.dwSize = 252; | |
3481 memset(&refCaps, 0, 0xFCu); | |
3482 //v10 = v2->pRenderD3D; | |
3483 refCaps.dwSize = 252; | |
3484 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3485 v12 = halCaps.dwMinTextureWidth; | |
2069 | 3486 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight ) |
0 | 3487 v12 = halCaps.dwMinTextureHeight; |
3488 uMinDeviceTextureDim = v12; | |
3489 v13 = halCaps.dwMaxTextureWidth; | |
3490 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3491 v13 = halCaps.dwMaxTextureHeight; | |
3492 uMaxDeviceTextureDim = v13; | |
3493 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
3494 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
3495 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3496 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
3497 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
3498 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3499 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3500 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3501 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3502 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3503 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3504 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3505 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3506 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3507 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
1802 | 3508 //} |
3509 | |
2069 | 3510 ddpfPrimarySuface.dwSize = 32; |
3511 GetTargetPixelFormat(&ddpfPrimarySuface); | |
0 | 3512 ParseTargetPixelFormat(); |
2069 | 3513 |
0 | 3514 if ( !pRenderD3D ) |
3515 { | |
2069 | 3516 __debugbreak(); |
3517 //pBeforePresentFunction = 0;//nullsub_1; | |
3518 //goto LABEL_47; | |
3519 } | |
3520 /*v14 = IsColorKeySupported(pDirectDraw4); | |
0 | 3521 v15 = uAcquiredDirect3DDevice == 1; |
3522 bColorKeySupported = v14; | |
3523 if ( !v15 ) | |
2069 | 3524 bColorKeySupported = 0;*/ |
3525 //if ( bColorKeySupported ) | |
3526 if (false) | |
3527 { | |
3528 /*memset(&ddsd2, 0, 0x7Cu); | |
0 | 3529 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; |
3530 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3531 v16 = pDirectDraw4; | |
3532 ddsd2.dwSize = 124; | |
3533 ddsd2.dwFlags = 65543; | |
3534 ddsd2.ddsCaps.dwCaps = 2112; | |
3535 ddsd2.dwWidth = 640; | |
3536 ddsd2.dwHeight = 480; | |
3537 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
2069 | 3538 pBeforePresentFunction = Present_ColorKey;*/ |
0 | 3539 LABEL_45: |
2069 | 3540 using_software_screen_buffer = 1; |
3541 //LABEL_47: | |
0 | 3542 bWindowMode = 1; |
1802 | 3543 //hWnd = hWnd; |
0 | 3544 return 0; |
3545 } | |
3546 pTargetSurface = 0; | |
2069 | 3547 pTargetSurface_unaligned = 0; |
3548 | |
3549 uint num_pixels = window->GetWidth() * window->GetHeight(); | |
3550 pTargetSurface_unaligned = new unsigned int[num_pixels]; | |
3551 | |
3552 if (!pTargetSurface_unaligned) | |
3553 return false; | |
3554 | |
3555 memset(&pDesc, 0, 0x7Cu); | |
3556 pDesc.dwSize = 124; | |
3557 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT)) | |
3558 { | |
3559 delete [] pTargetSurface_unaligned; | |
3560 return false; | |
3561 } | |
3562 | |
3563 memset32(pTargetSurface_unaligned, -1, num_pixels); | |
3564 | |
3565 | |
0 | 3566 pRenderer->pBackBuffer4->Unlock(0); |
2069 | 3567 /*v19 = pTargetSurface_unaligned; |
0 | 3568 v20 = (unsigned int)pDesc.lpSurface & 7; |
3569 v21 = (unsigned int)ptr_400E8 & 7; | |
3570 if ( v21 == v20 ) | |
3571 { | |
3572 pTargetSurface = (unsigned __int16 *)v19; | |
3573 } | |
3574 else | |
3575 { | |
3576 if ( (signed int)v21 >= v20 ) | |
3577 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
3578 else | |
3579 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
3580 pTargetSurface = (unsigned __int16 *)v22; | |
2069 | 3581 }*/ |
3582 pTargetSurface = pTargetSurface_unaligned; | |
3583 uTargetSurfacePitch = window->GetWidth(); | |
0 | 3584 pBeforePresentFunction = Present_NoColorKey; |
3585 goto LABEL_45; | |
3586 } | |
3587 | |
2154 | 3588 |
3589 //----- (0044F2B2) -------------------------------------------------------- | |
3590 bool Render::IsGammaSupported() | |
3591 { | |
2334 | 3592 // bool result; // eax@3 |
3593 // HRESULT v1; // eax@4 | |
2154 | 3594 |
3595 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
3596 { | |
3597 DDCAPS halCaps; // [sp+0h] [bp-180h]@4 | |
3598 memset(&halCaps, 0, sizeof(DDCAPS)); | |
3599 halCaps.dwSize = sizeof(DDCAPS); | |
3600 | |
3601 ErrD3D(pDirectDraw4->GetCaps(&halCaps, 0)); | |
3602 return (halCaps.dwCaps2 >> 17) & 1; | |
3603 } | |
3604 /*else | |
3605 return false;*/ | |
3606 } | |
3607 | |
0 | 3608 //----- (004A0BEE) -------------------------------------------------------- |
2102 | 3609 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) |
3610 { | |
2198 | 3611 signed int lower_bound; // eax@17 |
2334 | 3612 // signed int left_bound; |
0 | 3613 unsigned int v21; // edi@46 |
3614 int v22; // esi@47 | |
3615 int v23; // ebx@47 | |
3616 signed int v24; // edx@50 | |
3617 signed int v25; // esi@52 | |
3618 unsigned __int16 *v26; // ecx@52 | |
3619 int v27; // ebx@54 | |
3620 int v28; // edi@55 | |
3621 int v29; // edx@55 | |
3622 int v30; // ebx@60 | |
3623 int v31; // edx@61 | |
3624 int v32; // edi@61 | |
2198 | 3625 signed int upper_bound; // [sp+18h] [bp-4h]@28 |
0 | 3626 unsigned int uXa; // [sp+24h] [bp+8h]@49 |
3627 int uYb; // [sp+28h] [bp+Ch]@47 | |
2245 | 3628 bool left_border_x = false; |
3629 bool right_border_x = false; | |
3630 bool left_border_z = false; | |
3631 bool right_border_z = false; | |
3632 bool upper_border_y = false; | |
3633 bool bottom_border_y = false; | |
3634 bool upper_border_w = false; | |
3635 bool bottom_border_w = false; | |
3636 | |
2101 | 3637 if ( uX < this->raster_clip_x )// x âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2245 | 3638 left_border_x = true; |
2101 | 3639 if ( uX > this->raster_clip_z )// x âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
2245 | 3640 right_border_x = true; |
2097 | 3641 |
2101 | 3642 if ( uZ < this->raster_clip_x )// z âûõîäèò çà ðàìêè ëåâîé ãðàíèöû |
2245 | 3643 left_border_z = true; |
2101 | 3644 if ( uZ > this->raster_clip_z )// z âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû |
2245 | 3645 right_border_z = true; |
2101 | 3646 |
3647 if ( uY < this->raster_clip_y )// y âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
2245 | 3648 upper_border_y = true; |
2101 | 3649 if ( uY > this->raster_clip_w )// y âûõîäèò çà ðàìêè íèæíåé ãðàíèöû |
2245 | 3650 bottom_border_y = true; |
2101 | 3651 |
3652 if ( uW < this->raster_clip_y )// w âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
2245 | 3653 upper_border_w = true; |
2101 | 3654 if ( uW > this->raster_clip_w )// w âûõîäèò çà ðàìêè íèæíåé ãðàíèöû |
2245 | 3655 bottom_border_w = true; |
3656 | |
3657 if ( (left_border_x && left_border_z) || (right_border_x && right_border_z ) | |
3658 || (upper_border_y && upper_border_w) || (bottom_border_y && bottom_border_w)) | |
2102 | 3659 return; |
3660 | |
2245 | 3661 if ( left_border_x || left_border_z || right_border_x || right_border_z |
3662 || upper_border_y || upper_border_w || bottom_border_y || bottom_border_w) | |
3663 { | |
3664 if ( left_border_x || left_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left (ëåâàÿ ãðàíèöà) | |
3665 { | |
3666 if ( left_border_x )//left_border = true; õ ìåíüøå ëåâîé ãðàíèöû | |
3667 { | |
3668 uY += (uW - uY) * ((this->raster_clip_x - uX) / (uZ - uX));//t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
2199 | 3669 uX = this->raster_clip_x; |
3670 } | |
2245 | 3671 else if ( left_border_z )//z ìåíüøå ëåâîé ãðàíèöû |
2199 | 3672 { |
3673 uZ = this->raster_clip_x; | |
2245 | 3674 uW += (uY - uW) * ((this->raster_clip_x - uZ) / (uX - uZ)); |
3675 } | |
3676 } | |
3677 | |
3678 if ( right_border_x || right_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )//for right (ïðàâàÿ ãðàíèöà) | |
3679 { | |
3680 if ( right_border_x ) //right_border = true; õ áîëüøå ïðàâîé ãðàíèöû | |
3681 { | |
3682 uY += (uY - uW) * ((this->raster_clip_z - uX) / (uZ - uX)); | |
2199 | 3683 uX = this->raster_clip_z; |
0 | 3684 } |
2245 | 3685 else if ( right_border_z )//z áîëüøå ïðàâîé ãðàíèöû |
3686 { | |
3687 uW += (uW - uY) * ((this->raster_clip_z - uZ) / (uX - uZ)); | |
2199 | 3688 uZ = this->raster_clip_z; |
3689 } | |
3690 } | |
2245 | 3691 |
2199 | 3692 upper_bound = 0; |
3693 if ( uY < this->raster_clip_y ) | |
3694 upper_bound = 2; | |
3695 if ( uY > this->raster_clip_w ) | |
3696 upper_bound |= 1; | |
3697 | |
3698 lower_bound = 0; | |
3699 if ( uW < this->raster_clip_y ) | |
3700 lower_bound = 2; | |
3701 if ( uW > this->raster_clip_w ) | |
3702 lower_bound |= 1; | |
3703 | |
3704 if ( !(lower_bound & upper_bound) )//for up and down(äëÿ âåðõà è íèçà) | |
3705 { | |
3706 lower_bound ^= upper_bound; | |
3707 if ( lower_bound & 2 ) | |
3708 { | |
3709 if ( upper_bound & 2 ) | |
3710 { | |
2245 | 3711 uX += (uZ - uX) * ((this->raster_clip_y - uY) / (uW - uY)); |
2199 | 3712 uY = this->raster_clip_y; |
3713 } | |
3714 else | |
3715 { | |
2245 | 3716 uZ += (uX - uZ) * ((this->raster_clip_y - uW) / (uY - uW)); |
2199 | 3717 uW = this->raster_clip_y; |
3718 } | |
3719 } | |
3720 if ( lower_bound & 1 ) | |
3721 { | |
3722 if ( upper_bound & 1 ) | |
3723 { | |
2245 | 3724 uX += (uZ - uX) * ((this->raster_clip_w - uY) / (uW - uY)); |
2199 | 3725 uY = this->raster_clip_w; |
3726 } | |
3727 else | |
0 | 3728 { |
2245 | 3729 uZ += (uX - uZ) * ((this->raster_clip_w - uW) / (uY - uW)); |
2199 | 3730 uW = this->raster_clip_w; |
3731 } | |
3732 } | |
3733 } | |
3734 } | |
3735 v21 = pRenderer->uTargetSurfacePitch; | |
3736 if ( pRenderer->uTargetSurfacePitch ) | |
3737 { | |
3738 //v12 = uX + uY * pRenderer->uTargetSurfacePitch; | |
3739 v22 = uW - uY; | |
3740 v23 = v22; | |
3741 uYb = v22; | |
3742 if ( v22 < 0 ) | |
3743 { | |
3744 v23 = -v22; | |
3745 uYb = -v22; | |
3746 v21 = -pRenderer->uTargetSurfacePitch; | |
3747 } | |
3748 uXa = uZ - uX; | |
3749 if ((signed)(uZ - uX) >= 0) | |
3750 v24 = 1; | |
3751 else | |
3752 { | |
3753 uXa = -uXa; | |
3754 v24 = -1; | |
3755 } | |
3756 v25 = 0; | |
3757 | |
3758 v26 = (unsigned __int16 *)this->pTargetSurface; | |
3759 if ( v26 ) | |
3760 { | |
3761 if ( (signed int)uXa <= v23 )//ðèñóåì âåðòèêàëüíóþ ëèíèþ | |
3762 { | |
3763 v30 = v23 + 1; | |
3764 if ( v30 > 0 ) | |
3765 { | |
3766 v31 = 2 * v24; | |
3767 v32 = 2 * v21; | |
3768 //v12 = (int)&v26[v12]; | |
3769 int y = 0; | |
3770 int x = 0; | |
3771 for ( v30; v30; --v30 ) | |
0 | 3772 { |
2199 | 3773 v25 += uXa; |
3774 //*(short *)v12 = uColor; | |
3775 //v12 += v32; | |
3776 WritePixel16(uX + x, uY + y, uColor); | |
3777 if ( v32 >= 0 ) | |
3778 y += 1; | |
3779 else | |
3780 y -= 1; | |
3781 if ( v25 > 0 ) | |
0 | 3782 { |
2199 | 3783 v25 -= uYb; |
3784 //v12 += v31; | |
3785 if ( v31 >= 0 ) | |
2096 | 3786 x += 1; |
3787 else | |
3788 x -= 1; | |
0 | 3789 } |
3790 } | |
3791 } | |
3792 } | |
2199 | 3793 else//ðèñóåì ãîðèçîíòàëüíóþ ëèíèþ |
3794 { | |
3795 v27 = uXa + 1; | |
3796 if ( (signed int)(uXa + 1) > 0 ) | |
3797 { | |
3798 v28 = 2 * v21; | |
3799 v29 = 2 * v24; | |
3800 int y = 0; | |
3801 int x = 0; | |
3802 //v12 = (int)&v26[v12]; | |
3803 for ( v27; v27; --v27 ) | |
3804 { | |
3805 v25 += uYb; | |
3806 //*(short *)v12 = uColor; | |
3807 //v12 += v29; | |
3808 WritePixel16(uX + x, uY + y, uColor); | |
3809 if ( v29 >= 0 ) | |
3810 x += 1; | |
3811 else | |
3812 x -= 1; | |
3813 if ( v25 > (signed int)uXa ) | |
3814 { | |
3815 v25 -= uXa; | |
3816 //v12 += v28; | |
3817 if ( v28 >= 0 ) | |
3818 y += 1; | |
3819 else | |
3820 y -= 1; | |
3821 } | |
3822 } | |
3823 } | |
3824 } | |
3825 } | |
0 | 3826 } |
2102 | 3827 return; |
0 | 3828 } |
3829 | |
3830 //----- (004A0E80) -------------------------------------------------------- | |
3831 void Render::ClearZBuffer(int a2, int a3) | |
3832 { | |
2245 | 3833 memset32(this->pActiveZBuffer, -65536, 0x4B000); |
0 | 3834 } |
3835 | |
3836 //----- (004A0E97) -------------------------------------------------------- | |
709 | 3837 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
3838 { | |
3839 this->raster_clip_x = uX; | |
3840 this->raster_clip_y = uY; | |
3841 this->raster_clip_z = uZ; | |
3842 this->raster_clip_w = uW; | |
0 | 3843 } |
3844 | |
3845 //----- (004A0EB6) -------------------------------------------------------- | |
3846 void Render::ParseTargetPixelFormat() | |
3847 { | |
3848 signed int v2; // ecx@1 | |
3849 DWORD uRedMask; // edx@1 | |
3850 unsigned int uGreenMask; // esi@5 | |
3851 signed int v5; // ecx@5 | |
3852 unsigned int uBlueMask; // edx@9 | |
3853 signed int v7; // ecx@9 | |
2069 | 3854 //unsigned int v8; // ecx@13 |
0 | 3855 |
3856 v2 = 0; | |
2132 | 3857 uRedMask = this->ddpfPrimarySuface.dwRBitMask; |
3858 this->uTargetBBits = 0; | |
3859 this->uTargetGBits = 0; | |
3860 this->uTargetRBits = 0; | |
0 | 3861 do |
3862 { | |
3863 if ( (1 << v2) & uRedMask ) | |
2132 | 3864 ++this->uTargetRBits; |
0 | 3865 ++v2; |
3866 } | |
2069 | 3867 while ( v2 < 32 ); |
2132 | 3868 uGreenMask = this->ddpfPrimarySuface.dwGBitMask; |
0 | 3869 v5 = 0; |
3870 do | |
3871 { | |
3872 if ( (1 << v5) & uGreenMask ) | |
2132 | 3873 ++this->uTargetGBits; |
0 | 3874 ++v5; |
3875 } | |
2069 | 3876 while ( v5 < 32 ); |
2132 | 3877 uBlueMask = this->ddpfPrimarySuface.dwBBitMask; |
0 | 3878 v7 = 0; |
3879 do | |
3880 { | |
3881 if ( (1 << v7) & uBlueMask ) | |
2132 | 3882 ++this->uTargetBBits; |
0 | 3883 ++v7; |
3884 } | |
2069 | 3885 while ( v7 < 32 ); |
2132 | 3886 this->uTargetGMask = uGreenMask; |
3887 this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask; | |
3888 this->uTargetBMask = uBlueMask; | |
0 | 3889 } |
3890 | |
3891 //----- (004A0F40) -------------------------------------------------------- | |
3892 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
3893 { | |
2132 | 3894 //IDirectDrawSurface4 *v4; // esi@1 |
168 | 3895 HRESULT result; // eax@1 |
0 | 3896 HRESULT v6; // eax@4 |
2334 | 3897 // int v7; // [sp-8h] [bp-14h]@10 |
3898 // unsigned int v8; // [sp-4h] [bp-10h]@10 | |
0 | 3899 char v9; // [sp+Bh] [bp-1h]@1 |
3900 | |
2132 | 3901 //v4 = pSurface; |
0 | 3902 v9 = 1; |
3903 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
3904 if ( result == DDERR_SURFACELOST ) | |
3905 { | |
2132 | 3906 v6 = pSurface->Restore(); |
0 | 3907 if ( v6 ) |
3908 { | |
3909 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
3910 { | |
3911 LABEL_20: | |
3912 v9 = 0; | |
3913 result = (bool)memset(pDesc, 0, 4u); | |
3914 goto LABEL_21; | |
3915 } | |
3916 pRenderer->pFrontBuffer4->Restore(); | |
2132 | 3917 pSurface->Restore(); |
3918 } | |
3919 result = pSurface->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
0 | 3920 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) |
3921 goto LABEL_20; | |
3922 ErrD3D(result); | |
3923 if ( result ) | |
3924 { | |
3925 //v8 = 0; | |
3926 //v7 = 2161; | |
2334 | 3927 //LABEL_19: |
0 | 3928 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); |
3929 goto LABEL_20; | |
3930 } | |
3931 if ( pRenderer->pRenderD3D ) | |
3932 pRenderD3D->HandleLostResources(); | |
3933 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
3934 } | |
3935 else | |
3936 { | |
3937 if ( result ) | |
3938 { | |
3939 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
3940 goto LABEL_20; | |
3941 ErrD3D(result); | |
3942 //v8 = 0; | |
3943 //v7 = 2199; | |
3944 //goto LABEL_19; | |
3945 } | |
3946 } | |
3947 LABEL_21: | |
3948 LOBYTE(result) = v9; | |
3949 return result; | |
3950 } | |
3951 | |
3952 | |
3953 //----- (004A10E4) -------------------------------------------------------- | |
3954 void Render::CreateDirectDraw() | |
3955 { | |
3956 Render *v1; // edi@1 | |
2334 | 3957 // HRESULT v2; // eax@1 |
3958 // HRESULT v3; // eax@5 | |
3959 // int v6; // [sp-Ch] [bp-20h]@3 | |
3960 // unsigned int v9; // [sp+0h] [bp-14h]@0 | |
0 | 3961 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 |
3962 | |
3963 v1 = this; | |
3964 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
3965 | |
3966 pDirectDraw4 = nullptr; | |
3967 | |
2152 | 3968 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); |
0 | 3969 |
3970 lpDD->Release(); | |
3971 lpDD = nullptr; | |
3972 } | |
3973 | |
3974 //----- (004A1169) -------------------------------------------------------- | |
3975 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
3976 { | |
3977 DWORD flags; // eax@1 | |
2334 | 3978 // IDirectDraw *v4; // ecx@3 |
3979 //// HRESULT v5; // eax@5 | |
3980 // int v6; // [sp-8h] [bp-8h]@3 | |
3981 // unsigned int v7; // [sp-4h] [bp-4h]@3 | |
0 | 3982 |
3983 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
3984 DDSCL_NORMAL; | |
3985 | |
2152 | 3986 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); |
0 | 3987 } |
3988 | |
3989 //----- (004A11C6) -------------------------------------------------------- | |
3990 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
3991 { | |
2152 | 3992 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); |
0 | 3993 } |
3994 | |
3995 //----- (004A121C) -------------------------------------------------------- | |
3996 void Render::CreateFrontBuffer() | |
3997 { | |
3998 Render *v1; // esi@1 | |
3999 IDirectDraw *pDD; // eax@3 | |
4000 IDirectDrawSurface **pOutSurf; // esi@3 | |
4001 struct _DDSURFACEDESC *v4; // edx@3 | |
2334 | 4002 //// HRESULT v5; // eax@5 |
0 | 4003 int v6; // [sp-8h] [bp-8Ch]@3 |
4004 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4005 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4006 | |
4007 v1 = this; | |
2152 | 4008 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4009 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4010 { |
4011 memset(&a2, 0, 0x7Cu); | |
4012 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
4013 a2.dwSize = 124; | |
4014 a2.dwFlags = 1; | |
4015 v7 = 0; | |
4016 a2.ddsCaps.dwCaps = 512; | |
4017 v6 = 2357; | |
4018 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
4019 v4 = (struct _DDSURFACEDESC *)&a2; | |
4020 } | |
2152 | 4021 /*else |
0 | 4022 { |
4023 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
4024 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
4025 a2.lPitch = 108; | |
4026 a2.dwBackBufferCount = 1; | |
4027 v7 = 0; | |
4028 a2.dwTextureStage = 512; | |
4029 v6 = 2346; | |
4030 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
4031 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
2152 | 4032 }*/ |
0 | 4033 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); |
4034 } | |
4035 | |
4036 //----- (004A12CD) -------------------------------------------------------- | |
4037 void Render::CreateBackBuffer() | |
4038 { | |
4039 Render *v1; // esi@1 | |
4040 IDirectDraw *v2; // eax@3 | |
4041 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
4042 struct _DDSURFACEDESC *v4; // edx@3 | |
2334 | 4043 // HRESULT v5; // eax@5 |
0 | 4044 int v6; // [sp-8h] [bp-8Ch]@3 |
4045 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4046 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4047 | |
4048 v1 = this; | |
2152 | 4049 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4050 // pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4051 { |
4052 memset(&a2, 0, 0x7Cu); | |
4053 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
4054 a2.dwSize = 124; | |
4055 a2.dwFlags = 7; | |
4056 v7 = 0; | |
4057 a2.ddsCaps.dwCaps = 2112; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
4058 a2.dwWidth = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
4059 a2.dwHeight = window->GetHeight(); |
0 | 4060 v6 = 2387; |
4061 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4062 v4 = (struct _DDSURFACEDESC *)&a2; | |
4063 } | |
2152 | 4064 /*else |
0 | 4065 { |
4066 memset(&a2.lPitch, 0, 0x6Cu); | |
4067 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4068 a2.lPitch = 108; | |
4069 a2.dwBackBufferCount = 7; | |
4070 v7 = 0; | |
4071 a2.dwTextureStage = 2112; | |
4072 a2.dwAlphaBitDepth = 640; | |
4073 a2.dwMipMapCount = 480; | |
4074 v6 = 2374; | |
4075 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4076 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
2152 | 4077 }*/ |
0 | 4078 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); |
4079 } | |
4080 | |
4081 //----- (004A139A) -------------------------------------------------------- | |
4082 void Render::CreateDirectDrawPrimarySurface() | |
4083 { | |
4084 Render *v1; // esi@1 | |
2154 | 4085 //int v2; // ebx@3 |
2334 | 4086 // IDirectDraw2 *v3; // eax@3 |
4087 // HRESULT v4; // eax@3 | |
0 | 4088 IDirectDrawSurface *pFrontBuffer; // eax@3 |
4089 DDSCAPS2 *v6; // edx@3 | |
4090 IDirectDraw4 *v7; // eax@4 | |
2334 | 4091 // HRESULT v8; // eax@4 |
0 | 4092 int v9; // ST14_4@5 |
4093 IDirectDrawSurface *v10; // ST10_4@5 | |
2334 | 4094 // HRESULT v11; // eax@5 |
0 | 4095 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 |
2334 | 4096 // const char *v13; // [sp+0h] [bp-A0h]@0 |
4097 // int v14; // [sp+4h] [bp-9Ch]@0 | |
4098 // unsigned int v15; // [sp+8h] [bp-98h]@0 | |
0 | 4099 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 |
4100 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
2334 | 4101 // int a4; // [sp+98h] [bp-8h]@3 |
0 | 4102 |
4103 v1 = this; | |
2152 | 4104 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4105 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4106 { |
2154 | 4107 //v2 = 0; |
4108 //this->field_4004C = 1; | |
0 | 4109 memset(&ddsd2, 0, 0x7Cu); |
4110 v7 = v1->pDirectDraw4; | |
4111 ddsd2.dwBackBufferCount = 1; | |
4112 ddsd2.dwSize = 0x7Cu; | |
4113 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4114 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4115 ErrD3D(v7->CreateSurface( | |
4116 &ddsd2, | |
4117 &pFrontBuffer4, | |
4118 0)); | |
4119 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
4120 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4121 } | |
2152 | 4122 /*else |
0 | 4123 { |
4124 v2 = 0; | |
4125 this->field_4004C = 1; | |
4126 | |
4127 DDSURFACEDESC ddsd; | |
4128 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4129 | |
4130 ddsd.lpSurface = (LPVOID)1; | |
4131 ddsd.lPitch = 108; | |
4132 ddsd.dwBackBufferCount = 33; | |
4133 ddsd.ddsCaps.dwCaps = 8728; | |
4134 ErrD3D(pDirectDraw2->CreateSurface( | |
4135 &ddsd, | |
4136 (IDirectDrawSurface **)&pFrontBuffer2, | |
4137 0)); | |
4138 | |
4139 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4140 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
2152 | 4141 }*/ |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4142 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used |
0 | 4143 v9 = (int)v6; |
4144 v10 = pFrontBuffer; // BUG | |
4145 | |
4146 v17.dwCaps = 4; | |
4147 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4148 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
2154 | 4149 //v1->field_40030 = v2; |
4150 //v1->field_18_locked_pitch = v2; | |
0 | 4151 } |
4152 | |
4153 //----- (004A14F4) -------------------------------------------------------- | |
4154 void Render::CreateClipper(HWND a2) | |
4155 { | |
2152 | 4156 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); |
4157 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4158 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
0 | 4159 } |
4160 | |
4161 //----- (004A15D8) -------------------------------------------------------- | |
4162 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4163 { | |
2152 | 4164 pFrontBuffer4->GetPixelFormat(pOut); |
0 | 4165 } |
4166 | |
4167 //----- (004A1605) -------------------------------------------------------- | |
4168 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4169 { | |
4170 signed int v4; // eax@3 | |
4171 | |
2152 | 4172 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4173 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
0 | 4174 { |
4175 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4176 memset(&pDesc, 0, 0x7Cu); | |
4177 pDesc.dwSize = 124; | |
2132 | 4178 LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4179 *pOutSurfacePtr = pDesc.lpSurface; |
4180 v4 = pDesc.lPitch; | |
4181 } | |
2152 | 4182 /*else |
0 | 4183 { |
4184 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4185 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4186 pDesc.lPitch = 108; | |
2132 | 4187 LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1); |
0 | 4188 *pOutSurfacePtr = (void *)pDesc.lpSurface; |
4189 v4 = pDesc.dwReserved; | |
2152 | 4190 }*/ |
0 | 4191 *pOutPixelsPerRow = v4 >> 1; |
4192 } | |
4193 | |
4194 //----- (004A16E1) -------------------------------------------------------- | |
4195 void Render::UnlockBackBuffer() | |
4196 { | |
2152 | 4197 ErrD3D(pBackBuffer4->Unlock(0)); |
0 | 4198 } |
4199 | |
4200 //----- (004A172E) -------------------------------------------------------- | |
4201 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4202 { | |
4203 signed int v4; // eax@3 | |
4204 | |
2152 | 4205 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4206 { |
4207 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4208 memset(&pDesc, 0, 0x7Cu); | |
4209 pDesc.dwSize = 124; | |
2132 | 4210 LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4211 *pOutSurface = pDesc.lpSurface; |
4212 v4 = pDesc.lPitch; | |
4213 } | |
2152 | 4214 /*else |
0 | 4215 { |
4216 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4217 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4218 pDesc.lPitch = 108; | |
2132 | 4219 LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1); |
0 | 4220 *pOutSurface = (void *)pDesc.lpSurface; |
4221 v4 = pDesc.dwReserved; | |
2152 | 4222 }*/ |
0 | 4223 *pOutPixelsPerRow = v4 >> 1; |
4224 } | |
4225 | |
4226 //----- (004A17C7) -------------------------------------------------------- | |
4227 void Render::UnlockFrontBuffer() | |
4228 { | |
2152 | 4229 ErrD3D(pFrontBuffer4->Unlock(0)); |
0 | 4230 } |
4231 | |
4232 //----- (004A1814) -------------------------------------------------------- | |
4233 void Render::RestoreFrontBuffer() | |
4234 { | |
2152 | 4235 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST ) |
4236 pFrontBuffer4->Restore(); | |
0 | 4237 } |
4238 | |
4239 //----- (004A184C) -------------------------------------------------------- | |
2152 | 4240 void Render::RestoreBackBuffer() |
4241 { | |
4242 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST ) | |
4243 pBackBuffer4->Restore(); | |
0 | 4244 } |
4245 | |
4246 //----- (004A18F5) -------------------------------------------------------- | |
4247 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4248 { | |
2152 | 4249 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); |
0 | 4250 } |
4251 | |
4252 //----- (004A194A) -------------------------------------------------------- | |
4253 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
4254 { | |
4255 IDirectDrawSurface *pFront; // eax@3 | |
4256 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
4257 | |
2152 | 4258 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) |
0 | 4259 { |
4260 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4261 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4262 } | |
2152 | 4263 /*else |
0 | 4264 { |
4265 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4266 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
2152 | 4267 }*/ |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4268 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 4269 } |
4270 | |
4271 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4272 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4273 { |
0 | 4274 unsigned int v7; // edx@6 |
2166 | 4275 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4276 if (uNumBillboardsToDraw >= 999 ) |
0 | 4277 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4278 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4279 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4280 uNumBillboardsToDraw = 1; |
0 | 4281 return 0; |
4282 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4283 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4284 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4285 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4286 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4287 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4288 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4289 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4290 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4291 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4292 |
2166 | 4293 if (z > pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4294 { |
4295 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
4296 v7 = pRenderer->uNumBillboardsToDraw; | |
4297 else | |
4298 { | |
4299 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4300 { | |
2166 | 4301 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
0 | 4302 { |
2166 | 4303 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], |
4304 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - (i + 1)], | |
4305 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
0 | 4306 } |
4307 } | |
4308 ++v7; | |
4309 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
4310 uNumBillboardsToDraw++; |
0 | 4311 return v7; |
4312 } | |
2166 | 4313 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order ) |
0 | 4314 { |
4315 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4316 { | |
2166 | 4317 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) |
4318 { | |
4319 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], | |
4320 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw -(i + 1)], | |
4321 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
4322 } | |
4323 } | |
717 | 4324 uNumBillboardsToDraw++; |
4325 return v7; | |
0 | 4326 } |
4327 return v7; | |
4328 } | |
4329 | |
4330 //----- (004A1E9D) -------------------------------------------------------- | |
4331 unsigned int Render::GetBillboardDrawListSize() | |
4332 { | |
4333 return pRenderer->uNumBillboardsToDraw; | |
4334 } | |
4335 | |
4336 //----- (004A1EA3) -------------------------------------------------------- | |
4337 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
4338 { | |
2002 | 4339 return pRenderer->pBillboardRenderListD3D[uBillboardID].sParentBillboardID; |
0 | 4340 } |
4341 | |
4342 //----- (004A1EB6) -------------------------------------------------------- | |
4343 void Render::BeginSceneD3D() | |
4344 { | |
4345 if (!uNumD3DSceneBegins++) | |
4346 { | |
2154 | 4347 //if (pRenderD3D) |
0 | 4348 { |
4349 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
4350 pRenderer->uNumBillboardsToDraw = 0; | |
4351 pRenderD3D->pDevice->BeginScene(); | |
1390 | 4352 |
0 | 4353 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
4354 uFogColor = GetLevelFogColor(); | |
4355 else | |
4356 uFogColor = 0; | |
4357 | |
4358 if ( uFogColor & 0xFF000000 ) | |
4359 { | |
4360 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
4361 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
4362 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4363 bUsingSpecular = true; | |
4364 } | |
4365 else | |
4366 { | |
4367 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
4368 bUsingSpecular = 0; | |
4369 } | |
4370 } | |
2154 | 4371 /*else |
0 | 4372 { |
4373 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
4374 if (pTargetSurface) | |
4375 field_18_locked_pitch = uTargetSurfacePitch; | |
4376 else | |
4377 --uNumD3DSceneBegins; | |
2154 | 4378 }*/ |
0 | 4379 } |
4380 } | |
4381 | |
4382 //----- (004A1FE1) -------------------------------------------------------- | |
4383 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
4384 { | |
4385 --uNumD3DSceneBegins; | |
4386 if (uNumD3DSceneBegins) | |
4387 return; | |
4388 | |
4389 if (pRenderD3D) | |
4390 { | |
4391 pGame->draw_debug_outlines(); | |
161 | 4392 DoRenderBillboards_D3D(); |
0 | 4393 pGame->pStru6Instance->RenderSpecialEffects(); |
4394 pRenderD3D->pDevice->EndScene(); | |
4395 } | |
4396 else | |
4397 pGame->pStru6Instance->RenderSpecialEffects(); | |
4398 } | |
4399 | |
4400 //----- (004A2031) -------------------------------------------------------- | |
349 | 4401 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
4402 { | |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4403 // __debugbreak(); // should not fire outside decal builder |
349 | 4404 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 4405 } |
4406 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4407 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 4408 { |
4409 int v5; // ebx@1 | |
4410 int v6; // edi@1 | |
4411 int v8; // eax@7 | |
4412 float v9; // eax@12 | |
4413 float *v10; // esi@12 | |
4414 float v11; // ecx@14 | |
4415 double v12; // st7@14 | |
4416 double v13; // st7@14 | |
4417 double v14; // st7@14 | |
4418 signed int v15; // eax@14 | |
4419 int v16; // eax@15 | |
4420 float v17; // ST48_4@15 | |
4421 char v18; // zf@17 | |
4422 int v19; // eax@18 | |
4423 int v20; // eax@18 | |
4424 int v21; // edx@20 | |
4425 signed int v22; // ecx@20 | |
4426 int v23; // eax@20 | |
4427 const char *v24; // ST4C_4@20 | |
4428 unsigned int v25; // ST50_4@20 | |
4429 int v26; // ST54_4@20 | |
4430 int v27; // eax@20 | |
4431 _UNKNOWN *v28; // eax@21 | |
4432 int v29; // ecx@23 | |
4433 int v30; // eax@23 | |
4434 int v31; // eax@23 | |
4435 int v32; // eax@24 | |
4436 int v33; // eax@25 | |
4437 int v34; // eax@25 | |
4438 int v35; // eax@25 | |
4439 int v36; // eax@25 | |
4440 signed int v37; // ecx@26 | |
4441 int v38; // eax@26 | |
4442 _UNKNOWN *v39; // eax@27 | |
4443 int v40; // edx@28 | |
4444 int v41; // eax@29 | |
4445 int v42; // eax@29 | |
4446 int v43; // eax@29 | |
4447 int v44; // eax@29 | |
4448 unsigned int v46; // eax@29 | |
4449 int v47; // eax@30 | |
4450 int v48; // eax@30 | |
4451 int v49; // eax@30 | |
4452 double v52; // st6@35 | |
4453 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
4454 int v57; // [sp+5Ch] [bp-Ch]@3 | |
4455 signed int v59; // [sp+60h] [bp-8h]@12 | |
4456 int v61; // [sp+64h] [bp-4h]@4 | |
4457 int i; | |
4458 | |
4459 v6 = (int)this; | |
4460 v5 = 0; | |
4461 if (!this->uNumD3DSceneBegins) | |
4462 return; | |
4463 | |
4464 | |
4465 | |
4466 | |
186 | 4467 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 4468 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
4469 if (this->bUsingSpecular) | |
4470 { | |
186 | 4471 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4472 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4473 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 4474 } |
4475 | |
4476 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
4477 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
1637 | 4478 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4479 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); |
4480 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
4481 pVertices[0].specular = 0; | |
4482 pVertices[0].texcoord.x = array_50AC10[0].u; | |
4483 pVertices[0].texcoord.y = array_50AC10[0].v; | |
4484 | |
4485 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
4486 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
1637 | 4487 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4488 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); |
4489 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
4490 pVertices[1].specular = 0; | |
4491 pVertices[1].texcoord.x = array_50AC10[3].u; | |
4492 pVertices[1].texcoord.y = array_50AC10[3].v; | |
4493 | |
4494 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
4495 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
1637 | 4496 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4497 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); |
4498 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
4499 pVertices[2].specular = 0; | |
4500 pVertices[2].texcoord.x = array_50AC10[1].u; | |
4501 pVertices[2].texcoord.y = array_50AC10[1].v; | |
4502 | |
4503 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
4504 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
4505 | |
4506 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
4507 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
1637 | 4508 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
86 | 4509 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); |
4510 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
4511 pVertices[5].specular = 0; | |
4512 pVertices[5].texcoord.x = array_50AC10[2].u; | |
4513 pVertices[5].texcoord.y = array_50AC10[2].v; | |
4514 | |
4515 | |
4516 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4517 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
4518 | |
186 | 4519 }*/ |
4520 | |
0 | 4521 //----- (004A26BC) -------------------------------------------------------- |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4522 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
186 | 4523 { |
4524 //RenderVertexSoft *pVertices; // esi@0 | |
4525 //int v7; // edi@1 | |
0 | 4526 unsigned int v8; // ebx@1 |
2334 | 4527 // LightmapBuilder *v9; // esi@3 |
4528 // unsigned int v10; // edx@3 | |
0 | 4529 int v11; // eax@5 |
2334 | 4530 // int v12; // eax@11 |
4531 // char *v13; // esi@11 | |
4532 // double v14; // st7@13 | |
4533 // double v15; // st7@13 | |
4534 // signed int v16; // eax@13 | |
4535 // int v17; // ecx@13 | |
4536 // double v18; // st7@13 | |
4537 // float v19; // ST78_4@14 | |
0 | 4538 int v20; // eax@14 |
2334 | 4539 // char v21; // zf@16 |
4540 // HRESULT v22; // eax@17 | |
4541 // HRESULT v23; // eax@17 | |
4542 // HRESULT v24; // eax@19 | |
4543 // HRESULT v25; // eax@19 | |
4544 // unsigned int v26; // ecx@19 | |
4545 // char *v27; // eax@20 | |
4546 // HRESULT v28; // eax@22 | |
4547 // HRESULT v29; // eax@22 | |
4548 // HRESULT v30; // eax@23 | |
4549 // HRESULT v31; // eax@24 | |
4550 // HRESULT v32; // eax@24 | |
4551 // HRESULT v33; // eax@24 | |
4552 // HRESULT v34; // eax@24 | |
4553 // HRESULT v35; // eax@25 | |
4554 // HRESULT v36; // eax@25 | |
4555 // unsigned int v37; // ecx@25 | |
4556 // char *v38; // eax@26 | |
4557 // int v39; // edx@27 | |
4558 // HRESULT v40; // eax@28 | |
4559 // HRESULT v41; // eax@28 | |
4560 // HRESULT v42; // eax@28 | |
4561 // HRESULT v43; // eax@28 | |
0 | 4562 //IDirect3DDevice3Vtbl *v44; // ebx@28 |
4563 unsigned int v45; // eax@28 | |
2334 | 4564 // HRESULT v46; // eax@29 |
4565 // HRESULT v47; // eax@29 | |
4566 // HRESULT v48; // eax@29 | |
186 | 4567 //IDirect3DDevice3 *v49; // eax@35 |
0 | 4568 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
2334 | 4569 // int v51; // eax@40 |
4570 // char *v52; // esi@40 | |
4571 // double v53; // st7@42 | |
4572 // double v54; // st7@42 | |
4573 // signed int v55; // eax@42 | |
4574 // int v56; // ecx@42 | |
4575 // double v57; // st7@42 | |
4576 // float v58; // ST7C_4@43 | |
4577 // int v59; // eax@43 | |
186 | 4578 //signed int v60; // [sp+78h] [bp-14h]@31 |
4579 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
2334 | 4580 // const char *v62; // [sp+80h] [bp-Ch]@0 |
4581 // const char *v63; // [sp+80h] [bp-Ch]@19 | |
4582 // int v64; // [sp+84h] [bp-8h]@0 | |
4583 // LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
4584 // unsigned int v66; // [sp+88h] [bp-4h]@40 | |
4585 // unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
4586 // int a7; | |
186 | 4587 |
4588 //v7 = (int)this; | |
0 | 4589 v8 = 0; |
186 | 4590 if (!this->uNumD3DSceneBegins) |
75 | 4591 return; |
4592 if ( uNumVertices < 3) | |
4593 return; | |
4594 | |
186 | 4595 //v61 = pVertices; |
4596 | |
75 | 4597 /* v9 = pGame->pLightmapBuilder; |
0 | 4598 v65 = v9; |
75 | 4599 v10 = v9->std__vector_000004_size;*/ |
2155 | 4600 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 4601 { |
638 | 4602 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1394 | 4603 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); |
0 | 4604 } |
4605 else | |
4606 { | |
186 | 4607 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 4608 byte_4D864C && pGame->uFlags & 2 ) |
4609 { | |
186 | 4610 if (clampAtTextureBorders) |
4611 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 4612 else |
186 | 4613 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
4614 | |
4615 if (transparent || this->bUsingSpecular) | |
4616 { | |
4617 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4618 if (transparent) | |
0 | 4619 { |
186 | 4620 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
4621 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
4622 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
4623 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 4624 } |
4625 else | |
4626 { | |
186 | 4627 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
4628 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 4629 } |
186 | 4630 } |
1073 | 4631 |
4632 for (uint i = 0; i < uNumVertices; ++i) | |
4633 { | |
4634 | |
4635 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4636 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4637 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4638 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4639 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4640 if ( this->bUsingSpecular ) | |
0 | 4641 { |
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
|
4642 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4643 } |
1073 | 4644 else |
4645 { | |
4646 d3d_vertex_buffer[i].specular = 0; | |
4647 } | |
4648 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4649 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4650 } | |
4651 | |
4652 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4653 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
186 | 4654 if (transparent) |
4655 { | |
4656 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
4657 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4658 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4659 } |
4660 } | |
4661 else | |
4662 { | |
1073 | 4663 for (uint i = 0; i < uNumVertices; ++i) |
4664 { | |
4665 | |
4666 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4667 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
1637 | 4668 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
1073 | 4669 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); |
4670 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4671 if ( this->bUsingSpecular ) | |
0 | 4672 { |
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
|
4673 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4674 } |
1073 | 4675 else |
4676 { | |
4677 d3d_vertex_buffer[i].specular = 0; | |
4678 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
4679 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
1073 | 4680 d3d_vertex_buffer[i].specular = v20; |
4681 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4682 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4683 } | |
186 | 4684 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4685 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4686 if (pRenderer->bUsingSpecular) | |
4687 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 4688 |
4689 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 4690 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 4691 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4692 d3d_vertex_buffer, |
0 | 4693 uNumVertices, |
4694 16)); | |
4695 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 4696 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 4697 //(*(void (**)(void))(*(int *)v63 + 88))(); |
1394 | 4698 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
1073 | 4699 for (uint i = 0; i < uNumVertices; ++i) |
4700 { | |
4701 d3d_vertex_buffer[i].diffuse = -1; | |
4702 } | |
0 | 4703 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 4704 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4705 if ( !pRenderer->bUsingSpecular ) |
4706 { | |
186 | 4707 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4708 } | |
4709 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4710 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4711 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
4712 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4713 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4714 d3d_vertex_buffer, |
0 | 4715 uNumVertices, |
4716 16)); | |
4717 if ( pRenderer->bUsingSpecular ) | |
4718 { | |
186 | 4719 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4720 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 4721 for (uint i = 0; i < uNumVertices; ++i) |
4722 { | |
4723 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4724 d3d_vertex_buffer[i].specular = 0; | |
4725 } | |
4726 | |
75 | 4727 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 4728 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4729 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
4730 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 4731 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4732 d3d_vertex_buffer, |
0 | 4733 uNumVertices, |
4734 16)); | |
186 | 4735 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4736 //v44 = pRenderer->pRenderD3D->pDevice; |
4737 v45 = GetLevelFogColor(); | |
4738 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
4739 v8 = 0; | |
4740 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
4741 } | |
186 | 4742 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4743 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4744 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
4745 } | |
4746 } | |
186 | 4747 |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
4748 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
1642 | 4749 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
|
4750 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 4751 } |
4752 // 4A26BC: could not find valid save-restore pair for esi | |
4753 // 4D864C: using guessed type char byte_4D864C; | |
4754 | |
4755 //----- (004A2DA3) -------------------------------------------------------- | |
1923 | 4756 void Render::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
852 | 4757 { |
67 | 4758 int v7; // eax@7 |
4759 | |
4760 if ( !this->uNumD3DSceneBegins ) | |
4761 return; | |
4762 if ( uNumVertices >= 3 ) | |
4763 { | |
186 | 4764 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 4765 if ( this->bUsingSpecular ) |
4766 { | |
186 | 4767 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
4768 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4769 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 4770 } |
1427 | 4771 for ( uint i = 0; i < uNumVertices; ++i ) |
67 | 4772 { |
4773 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4774 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4775 pVertices[i].pos.z = 0.99989998; | |
168 | 4776 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 4777 |
840 | 4778 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 4779 v7 = 0; |
4780 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
|
4781 v7 = sub_47C3D7_get_fog_specular(0, 1, array_50AC10[i].vWorldViewPosition.x); |
67 | 4782 pVertices[i].specular = v7; |
4783 pVertices[i].texcoord.x = array_50AC10[i].u; | |
4784 pVertices[i].texcoord.y = array_50AC10[i].v; | |
4785 } | |
4786 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4787 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 4788 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 4789 } |
4790 } | |
4791 | |
4792 //----- (004A2ED5) -------------------------------------------------------- | |
1923 | 4793 void Render::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) |
0 | 4794 { |
4795 int v5; // eax@3 | |
4796 | |
4797 if ( this->uNumD3DSceneBegins ) | |
4798 { | |
1923 | 4799 if ( uNumVertices >= 3 ) |
0 | 4800 { |
186 | 4801 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1923 | 4802 v5 = 31 - (pSkyPolygon->dimming_level & 0x1F); |
638 | 4803 if ( v5 < pOutdoor->max_terrain_dimming_level ) |
4804 v5 = pOutdoor->max_terrain_dimming_level; | |
1937 | 4805 for (uint i = 0; i < uNumVertices; ++i) |
4806 { | |
4807 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
4808 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
1999 | 4809 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); |
1937 | 4810 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; |
4811 d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); | |
4812 d3d_vertex_buffer[i].specular = 0; | |
4813 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
4814 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
4815 } | |
1923 | 4816 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
1936 | 4817 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
4818 d3d_vertex_buffer, uNumVertices, 28)); | |
0 | 4819 } |
4820 } | |
4821 } | |
4822 | |
1390 | 4823 //----- (00479A53) -------------------------------------------------------- |
1923 | 4824 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID) |
1390 | 4825 { |
4826 BLVFace *pFace; // esi@1 | |
4827 double v5; // st7@3 | |
4828 signed __int64 v6; // qax@3 | |
4829 int v12; // edx@7 | |
4830 int v13; // eax@7 | |
2334 | 4831 // void *v15; // ecx@9 |
1390 | 4832 int v17; // edi@9 |
4833 double v18; // st7@9 | |
4834 signed int v19; // ebx@9 | |
4835 void *v20; // ecx@9 | |
4836 int v21; // ebx@11 | |
4837 int v22; // eax@14 | |
4838 signed __int64 v23; // qtt@16 | |
2334 | 4839 // double v24; // st7@16 |
4840 // unsigned __int8 v25; // sf@16 | |
4841 // unsigned __int8 v26; // of@16 | |
1390 | 4842 double v28; // st7@20 |
2334 | 4843 // char *v29; // ebx@20 |
4844 // char *v30; // edx@20 | |
4845 // unsigned __int8 v31; // c0@21 | |
4846 // unsigned __int8 v32; // c3@21 | |
1390 | 4847 double v33; // st6@23 |
2334 | 4848 // char *v34; // esi@30 |
1390 | 4849 const void *v35; // ecx@31 |
4850 int v36; // eax@31 | |
4851 const void *v37; // edi@31 | |
4852 signed __int64 v38; // qax@31 | |
4853 int v39; // ecx@31 | |
4854 int v40; // ebx@33 | |
4855 int v41; // eax@36 | |
4856 signed __int64 v42; // qtt@39 | |
4857 int v43; // eax@39 | |
2334 | 4858 // char v44; // zf@39 |
4859 // double v45; // st7@39 | |
4860 // double v46; // st7@39 | |
4861 // unsigned int v47; // edx@40 | |
1390 | 4862 double v48; // st7@41 |
2334 | 4863 // RenderVertexSoft *v49; // ebx@41 |
4864 // void *v50; // edi@43 | |
1390 | 4865 double v51; // st7@46 |
2334 | 4866 // RenderVertexSoft *v52; // edx@46 |
4867 // void *v53; // edi@48 | |
4868 // signed int v59; // [sp-4h] [bp-178h]@17 | |
4869 // struct Polygon *v60; // [sp+0h] [bp-174h]@17 | |
4870 // IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 | |
1981 | 4871 struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6 |
1390 | 4872 unsigned int v63; // [sp+120h] [bp-54h]@7 |
4873 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
4874 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4875 //float v67; // [sp+130h] [bp-44h]@7 |
1390 | 4876 __int64 v69; // [sp+13Ch] [bp-38h]@3 |
4877 int v70; // [sp+144h] [bp-30h]@3 | |
4878 int X; // [sp+148h] [bp-2Ch]@9 | |
4879 int v72; // [sp+14Ch] [bp-28h]@7 | |
4880 float v73; // [sp+150h] [bp-24h]@16 | |
4881 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
1999 | 4882 unsigned int v74_; // [sp+154h] [bp-20h]@3 |
1390 | 4883 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 |
4884 float v76; // [sp+15Ch] [bp-18h]@9 | |
4885 int v77; // [sp+160h] [bp-14h]@9 | |
4886 int v78; // [sp+164h] [bp-10h]@7 | |
4887 void *v79; // [sp+168h] [bp-Ch]@9 | |
4888 float v80; // [sp+16Ch] [bp-8h]@3 | |
4889 const void *v81; // [sp+170h] [bp-4h]@7 | |
4890 | |
4891 pFace = &pIndoor->pFaces[uFaceID]; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4892 //for floor and wall(for example Selesta)------------------- |
1644 | 4893 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor) |
4894 { | |
4895 int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x; | |
4896 int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y; | |
4897 for (uint i = 0; i < uNumVertices; ++i) | |
4898 { | |
4899 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f; | |
4900 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f; | |
4901 } | |
4902 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0); | |
1390 | 4903 return; |
4904 } | |
1981 | 4905 //--------------------------------------- |
4906 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179 | |
1641 | 4907 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) |
1390 | 4908 * 65536.0) |
1922 | 4909 + (double)pBLVRenderParams->uViewportCenterY); |
1981 | 4910 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0 |
4911 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183 | |
1641 | 4912 - (double)pBLVRenderParams->fov_rad_fixpoint |
1644 | 4913 / ((cos(v5) * 16192.0 + 0.0000001) |
1390 | 4914 * 65535.0) |
1922 | 4915 * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); |
1644 | 4916 |
1999 | 4917 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); |
1981 | 4918 pSkyPolygon.Create_48607B(&stru_8019C8); |
4919 pSkyPolygon.uTileBitmapID = pFace->uBitmapID; | |
4920 | |
4921 pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID); | |
4922 if ( !pSkyPolygon.pTexture ) | |
1390 | 4923 return; |
1644 | 4924 |
1981 | 4925 pSkyPolygon.dimming_level = 0; |
4926 pSkyPolygon.uNumVertices = uNumVertices; | |
4927 | |
4928 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4929 pSkyPolygon.v_18.y = 0; | |
4930 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); | |
4931 | |
1644 | 4932 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices])); |
1981 | 4933 pSkyPolygon.field_24 = 0x2000000; |
1644 | 4934 |
4935 extern float _calc_fov(int viewport_width, int angle_degree); | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4936 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4937 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); |
1644 | 4938 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74); |
1981 | 4939 v12 = pSkyPolygon.pTexture->uWidthMinus1; |
4940 v13 = pSkyPolygon.pTexture->uHeightMinus1; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4941 //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth; |
1390 | 4942 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; |
4943 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
4944 v78 = 0; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4945 //v81 = 0; |
1981 | 4946 float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight; |
4947 if ( (signed int)pSkyPolygon.uNumVertices <= 0 ) | |
4948 return; | |
1644 | 4949 |
4950 int _507D30_idx = 0; | |
1999 | 4951 for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ ) |
1390 | 4952 { |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
4953 //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)); |
2207 | 4954 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1981 | 4955 v74 = v77 + pSkyPolygon.ptr_38->angle_from_north; |
4956 | |
2207 | 4957 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); |
1999 | 4958 v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east; |
1981 | 4959 |
2207 | 4960 v79 = (void *)(fixpoint_mul(pSkyPolygon.v_18.z, v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))); |
1644 | 4961 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX); |
4962 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0; | |
1981 | 4963 v19 = -pSkyPolygon.field_24; |
4964 v77 = -pSkyPolygon.field_24; | |
4965 X = (int)((char *)v79 + pSkyPolygon.v_18.x); | |
1390 | 4966 LODWORD(v76) = (signed __int64)v18; |
4967 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
4968 while ( 1 ) | |
4969 { | |
4970 v79 = v20; | |
4971 if ( !X ) | |
4972 goto LABEL_14; | |
4973 v21 = abs(v19 >> 14); | |
1999 | 4974 if ( v21 <= abs(X) )//0x800 <= 0x28652 |
1390 | 4975 break; |
4976 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
4977 break; | |
4978 v19 = v77; | |
4979 v20 = v79; | |
4980 LABEL_14: | |
2207 | 4981 v79 = (void *)fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); |
4982 v22 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); | |
1390 | 4983 --LODWORD(v76); |
4984 v20 = (char *)v20 + v72; | |
1981 | 4985 X = v22 + pSkyPolygon.v_18.x; |
1390 | 4986 v78 = 1; |
4987 } | |
4988 if ( !v78 ) | |
4989 { | |
4990 LODWORD(v23) = v77 << 16; | |
1981 | 4991 HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000 |
1997 | 4992 v79 = (void *)(v23 / X);//X = FFFF9014(-28652) |
1390 | 4993 v77 = v17; |
2207 | 4994 signed __int64 s = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v17);// s = 0xFFFFFFFF FFFF3EE6 |
4995 LODWORD(v80) = v66 + ((signed int)fixpoint_mul(SLODWORD(s), v23 / X) >> 4); | |
1981 | 4996 array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); |
4997 | |
2207 | 4998 signed __int64 s2 = v74_ + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v17); |
4999 LODWORD(v80) = v63 + ((signed int)fixpoint_mul(SLODWORD(s2), v23 / X) >> 4); | |
1981 | 5000 array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68; |
5001 | |
2207 | 5002 v77 = fixpoint_mul(SLODWORD(s), v23 / X); |
5003 LODWORD(v73) = fixpoint_mul(SLODWORD(s2), v23 / X); | |
1644 | 5004 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5005 |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5006 //if ( (int)v81 >= pSkyPolygon.uNumVertices ) |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5007 //{ |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5008 // pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5009 // pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5010 // return; |
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5011 //} |
1390 | 5012 continue; |
5013 } | |
5014 break; | |
5015 } | |
1999 | 5016 if ( _507D30_idx >= pSkyPolygon.uNumVertices ) |
5017 { | |
5018 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, | |
5019 pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5020 return; | |
5021 } | |
1390 | 5022 LODWORD(v73) = 0; |
5023 v80 = v76; | |
1981 | 5024 if ( (signed int)pSkyPolygon.uNumVertices > 0 ) |
1390 | 5025 { |
5026 v28 = (double)SLODWORD(v76); | |
5027 LODWORD(v76) = (int)(char *)array_50AC10 + 28; | |
1997 | 5028 uint i = 0; |
5029 for ( v78 = pSkyPolygon.uNumVertices; v78; --v78 ) | |
5030 { | |
1390 | 5031 ++LODWORD(v73); |
1997 | 5032 memcpy(&array_50AC10[i], &array_507D30[i], 0x30u); |
1390 | 5033 LODWORD(v76) += 48; |
1997 | 5034 if ( v28 < array_507D30[i].vWorldViewProjY | v28 == array_507D30[i].vWorldViewProjY |
5035 || v28 >= array_507D30[i + 1].vWorldViewProjY ) | |
5036 { | |
5037 if ( v28 >= array_507D30[i].vWorldViewProjY || v28 <= array_507D30[i + 1].vWorldViewProjY ) | |
5038 { | |
5039 i++; | |
5040 continue; | |
5041 } | |
5042 v33 = (array_507D30[i + 1].vWorldViewProjX - array_507D30[i].vWorldViewProjX) * v28 / (array_507D30[i + 1].vWorldViewProjY - array_507D30[i].vWorldViewProjY) | |
5043 + array_507D30[i + 1].vWorldViewProjX; | |
1390 | 5044 } |
5045 else | |
5046 { | |
1997 | 5047 v33 = (array_507D30[i].vWorldViewProjX - array_507D30[i + 1].vWorldViewProjX) * v28 / (array_507D30[i].vWorldViewProjY - array_507D30[i + 1].vWorldViewProjY) |
5048 + array_507D30[i].vWorldViewProjX; | |
5049 } | |
5050 array_50AC10[i + 1].vWorldViewProjX = v33; | |
1390 | 5051 ++LODWORD(v73); |
5052 *(unsigned int *)LODWORD(v76) = v28; | |
5053 LODWORD(v76) += 48; | |
1997 | 5054 i++; |
5055 } | |
1390 | 5056 } |
5057 if ( SLODWORD(v73) <= 0 ) | |
5058 goto LABEL_40; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5059 //v34 = (char *)&array_50AC10[0].vWorldViewProjY; |
1997 | 5060 uint j = 0; |
1390 | 5061 v65 = v77 >> 14; |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5062 //HIDWORD(v69) = LODWORD(v73); |
1997 | 5063 for ( int t = (int)LODWORD(v73); t > 1; t-- ) |
5064 { | |
5065 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjY)); | |
5066 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5067 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east; |
2207 | 5068 //v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v35); |
5069 v36 = (int)(fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, (int)v35) + pSkyPolygon.ptr_38->angle_from_north); | |
1997 | 5070 |
1390 | 5071 v81 = v35; |
5072 v74 = v36; | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5073 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south; |
2207 | 5074 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, (int)v35); |
1390 | 5075 v78 = (int)v35; |
1981 | 5076 v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east); |
2207 | 5077 //v81 = (const void *)pSkyPolygon.v_18.z; |
5078 v78 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v35); | |
5079 v37 = (const void *)(v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX)); | |
1997 | 5080 v38 = (signed __int64)(array_50AC10[j].vWorldViewProjY - 1.0); |
1390 | 5081 v81 = 0; |
5082 LODWORD(v76) = v38; | |
5083 v39 = v72 * (v70 - v38); | |
5084 while ( 1 ) | |
5085 { | |
5086 v78 = v39; | |
5087 if ( !X ) | |
5088 goto LABEL_36; | |
5089 v40 = abs(X); | |
5090 if ( abs((signed __int64)v65) <= v40 ) | |
5091 break; | |
5092 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5093 break; | |
5094 v39 = v78; | |
5095 LABEL_36: | |
1981 | 5096 v78 = pSkyPolygon.v_18.z; |
2207 | 5097 v41 = fixpoint_mul(pSkyPolygon.v_18.z, v39); |
1390 | 5098 --LODWORD(v76); |
5099 v39 += v72; | |
1981 | 5100 X = v41 + pSkyPolygon.v_18.x; |
1390 | 5101 v81 = (const void *)1; |
5102 } | |
5103 if ( v81 ) | |
5104 { | |
1981 | 5105 v79 = (void *)pSkyPolygon.v_18.z; |
1390 | 5106 v78 = 2 * LODWORD(v76); |
2207 | 5107 v81 = (const void *)fixpoint_mul(pSkyPolygon.v_18.z, (((double)v70 - ((double)(2 * LODWORD(v76)) - array_50AC10[j].vWorldViewProjY)) |
5108 * (double)v72)); | |
1981 | 5109 X = (int)((char *)v81 + pSkyPolygon.v_18.x); |
1390 | 5110 } |
5111 LODWORD(v42) = v77 << 16; | |
5112 HIDWORD(v42) = v77 >> 16; | |
5113 v79 = (void *)(v42 / X); | |
5114 v81 = v37; | |
1997 | 5115 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5116 //v78 = pSkyPolygon.ptr_38->angle_from_west; |
2207 | 5117 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); |
5118 v43 = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); | |
1390 | 5119 v74 = (unsigned int)v37; |
5120 LODWORD(v76) = v43; | |
1997 | 5121 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5122 //v78 = pSkyPolygon.ptr_38->angle_from_south; |
2207 | 5123 v75 = (RenderVertexSoft *)((char *)v75 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, (int)v37)); |
5124 //v74 = fixpoint_mul(v43, v42 / X); | |
5125 v81 = (const void *)fixpoint_mul((int)v75, v42 / X); | |
1997 | 5126 |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5127 //v34 += 48; |
2207 | 5128 //v78 = v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4); |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5129 //v44 = HIDWORD(v69)-- == 1; |
2207 | 5130 //v45 = (double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022; |
5131 //v78 = v63 + ((signed int)fixpoint_mul((int)v75, v42 / X) >> 4); | |
5132 array_50AC10[j].u = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); | |
5133 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
|
5134 //v46 = (double)(signed int)v79; |
1997 | 5135 array_50AC10[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79; |
5136 array_50AC10[j]._rhw = 65536.0 / (double)(signed int)v79; | |
5137 ++j; | |
5138 } | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5139 //while ( !v44 ); |
1390 | 5140 LABEL_40: |
1997 | 5141 uint i = 0; |
1390 | 5142 if ( SLODWORD(v73) > 0 ) |
5143 { | |
5144 v48 = (double)SLODWORD(v80); | |
1997 | 5145 for ( HIDWORD(v69) = LODWORD(v73); HIDWORD(v69); --HIDWORD(v69) ) |
5146 { | |
5147 if ( v48 >= array_50AC10[i].vWorldViewProjY ) | |
5148 { | |
5149 ++i; | |
5150 memcpy(&array_507D30[i], &array_50AC10[i], 0x30u); | |
5151 } | |
5152 } | |
5153 } | |
5154 pSkyPolygon.uNumVertices = i; | |
5155 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5156 int pNumVertices = 0; | |
1390 | 5157 if ( SLODWORD(v73) > 0 ) |
5158 { | |
5159 v51 = (double)SLODWORD(v80); | |
1997 | 5160 for ( v80 = v73; v80 != 0.0; --LODWORD(v80) ) |
5161 { | |
5162 if ( v51 <= array_50AC10[pNumVertices].vWorldViewProjY ) | |
5163 { | |
5164 ++pNumVertices; | |
5165 memcpy(&array_507D30[pNumVertices], &array_50AC10[pNumVertices], 0x30u); | |
5166 } | |
5167 } | |
5168 } | |
5169 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
1390 | 5170 } |
5171 | |
2016
f1fd2ed4e9ba
Обращённый набор изменений ÑлиÑниÑ: 9dbc142fc8f7
Ritor1
parents:
2014
diff
changeset
|
5172 |
0 | 5173 //----- (004A2FC0) -------------------------------------------------------- |
5174 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
5175 { | |
5176 //Render *v8; // edi@1 | |
5177 //unsigned int v9; // esi@3 | |
2334 | 5178 // RenderVertexSoft *v12; // ecx@9 |
5179 // RenderVertexD3D3 *v13; // eax@9 | |
5180 // double v14; // st6@10 | |
5181 // int v15; // edx@10 | |
5182 // Texture *v16; // edx@10 | |
5183 // double v17; // st6@10 | |
0 | 5184 //char v18; // zf@10 |
2334 | 5185 // Texture *v19; // edx@10 |
595 | 5186 //Texture *v23; // edx@16 |
5187 //char *v24; // ecx@16 | |
5188 //char *v25; // eax@16 | |
5189 //double v26; // st6@17 | |
5190 //int v27; // esi@17 | |
5191 //double v28; // st6@17 | |
5192 //unsigned int v33; // ecx@18 | |
5193 //char *v34; // eax@19 | |
0 | 5194 //Texture *v45; // edx@23 |
5195 //char *v46; // ecx@23 | |
5196 //char *v47; // eax@23 | |
5197 //double v48; // st6@24 | |
5198 //int v49; // esi@24 | |
5199 //double v50; // st6@24 | |
2334 | 5200 // const char *v53; // [sp-Ch] [bp-20h]@21 |
0 | 5201 //int v54; // [sp-8h] [bp-1Ch]@21 |
5202 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
2334 | 5203 // const char *v56; // [sp+0h] [bp-14h]@0 |
5204 // int v57; // [sp+4h] [bp-10h]@0 | |
5205 // unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
0 | 5206 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 |
5207 //int a3a; // [sp+10h] [bp-4h]@4 | |
5208 | |
5209 //v8 = this; | |
5210 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
5211 return; | |
5212 | |
5213 //auto a3 = pFace; | |
5214 //auto a6 = uPackedID; | |
5215 //v59 = pGame->pLightmapBuilder; | |
5216 //v9 = v59->std__vector_000004_size; | |
5217 | |
2006 | 5218 int sCorrectedColor = uColor; |
0 | 5219 if (pGame->pLightmapBuilder->std__vector_000004_size) |
2006 | 5220 sCorrectedColor = -1; |
5221 pGame->AlterGamma_BLV(pFace, &sCorrectedColor); | |
0 | 5222 |
792 | 5223 |
5224 if (pFace->uAttributes & FACE_OUTLINED) | |
5225 { | |
2334 | 5226 // int color; |
792 | 5227 if (GetTickCount() % 300 >= 150) |
2006 | 5228 uColor = sCorrectedColor = 0xFF20FF20; |
5229 else uColor = sCorrectedColor = 0xFF109010; | |
792 | 5230 } |
5231 | |
2155 | 5232 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
0 | 5233 { |
5234 __debugbreak(); | |
5235 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 5236 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 5237 for (uint i = 0; i < uNumVertices; ++i) |
5238 { | |
5239 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5240 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5241 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5242 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5243 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
1072 | 5244 d3d_vertex_buffer[i].specular = 0; |
5245 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5246 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5247 } | |
5248 | |
186 | 5249 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5250 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
5251 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
5252 D3DPT_TRIANGLEFAN, | |
5253 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5254 d3d_vertex_buffer, |
0 | 5255 uNumVertices, |
5256 28)); | |
1394 | 5257 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
0 | 5258 } |
5259 else | |
5260 { | |
5261 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
5262 byte_4D864C && pGame->uFlags & 2) | |
5263 { | |
5264 for (uint i = 0; i < uNumVertices; ++i) | |
5265 { | |
186 | 5266 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
5267 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5268 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5269 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
2006 | 5270 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
186 | 5271 d3d_vertex_buffer[i].specular = 0; |
5272 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5273 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5274 } | |
5275 | |
5276 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 5277 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
5278 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5279 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5280 d3d_vertex_buffer, |
0 | 5281 uNumVertices, |
5282 28)); | |
5283 } | |
5284 else | |
5285 { | |
595 | 5286 for (uint i = 0; i < uNumVertices; ++i) |
5287 { | |
5288 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5289 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5290 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5291 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5292 d3d_vertex_buffer[i].diffuse = uColor; | |
5293 d3d_vertex_buffer[i].specular = 0; | |
5294 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5295 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5296 } | |
5297 //__debugbreak(); | |
5298 //if ( (signed int)uNumVertices > 0 ) | |
5299 //{ | |
5300 //v23 = pTex; | |
5301 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
5302 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
5303 //pTex = (Texture *)uNumVertices; | |
5304 //uint v18; | |
5305 //do | |
5306 //{ | |
5307 //v26 = *(float *)v24 * 0.061758894; | |
5308 //v27 = *((int *)v24 + 3); | |
5309 //*((int *)v25 + 4) = 0; | |
5310 //*((int *)v25 - 1) = v27; | |
5311 //*(int *)v25 = *((int *)v24 + 4); | |
5312 //*((int *)v25 + 3) = uColor; | |
5313 //v25 += 32; | |
5314 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
5315 //v28 = 1.0 / *(float *)v24; | |
5316 //v24 += 48; | |
5317 //v18 = pTex == (Texture *)1; | |
5318 //pTex = (Texture *)((char *)pTex - 1); | |
5319 //*((float *)v25 - 6) = v28; | |
0 | 5320 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 5321 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 5322 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 5323 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
5324 //} | |
5325 //while ( !v18 ); | |
5326 //} | |
0 | 5327 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 5328 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5329 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 5330 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5331 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5332 d3d_vertex_buffer, |
0 | 5333 uNumVertices, |
5334 28)); | |
595 | 5335 |
5336 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1394 | 5337 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); |
595 | 5338 |
5339 for (uint i = 0; i < uNumVertices; ++i) | |
2006 | 5340 d3d_vertex_buffer[i].diffuse = sCorrectedColor; |
595 | 5341 /*v33 = uNumVertices; |
0 | 5342 if ( (signed int)uNumVertices > 0 ) |
5343 { | |
186 | 5344 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 5345 do |
5346 { | |
5347 *(int *)v34 = uCorrectedColor; | |
5348 v34 += 32; | |
5349 --v33; | |
5350 } | |
5351 while ( v33 ); | |
595 | 5352 }*/ |
0 | 5353 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5354 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
5355 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5356 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5357 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5358 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
5359 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 5360 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5361 d3d_vertex_buffer, |
0 | 5362 uNumVertices, |
5363 28)); | |
186 | 5364 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
5365 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5366 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 5367 } |
5368 } | |
5369 } | |
5370 // 4D864C: using guessed type char byte_4D864C; | |
5371 | |
5372 //----- (004A43B1) -------------------------------------------------------- | |
717 | 5373 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
5374 { | |
5375 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
5376 //double v5; // st7@2 | |
5377 //float v6; // ST08_4@2 | |
0 | 5378 unsigned int v7; // eax@2 |
717 | 5379 //int v8; // ecx@2 |
5380 //unsigned int v9; // esi@2 | |
5381 //Sprite *v10; // edi@5 | |
0 | 5382 signed int v11; // eax@9 |
5383 signed int v12; // eax@9 | |
717 | 5384 //double v13; // st7@12 |
5385 //double v14; // st6@12 | |
0 | 5386 double v15; // st5@12 |
5387 double v16; // st4@12 | |
5388 double v17; // st3@12 | |
5389 double v18; // st2@12 | |
5390 int v19; // ecx@14 | |
5391 double v20; // st3@14 | |
5392 int v21; // ecx@16 | |
5393 double v22; // st3@16 | |
717 | 5394 //IDirect3DTexture2 *v23; // eax@18 |
5395 //signed int v24; // [sp+18h] [bp-18h]@5 | |
5396 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
5397 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 5398 float v27; // [sp+24h] [bp-Ch]@5 |
5399 int v28; // [sp+28h] [bp-8h]@2 | |
5400 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 5401 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 5402 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 5403 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 5404 float a1; // [sp+40h] [bp+10h]@5 |
5405 | |
717 | 5406 //v26 = this; |
0 | 5407 if ( this->uNumD3DSceneBegins ) |
5408 { | |
717 | 5409 //v4 = pSoftBillboard; |
5410 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
5411 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
5412 //v6 = pSoftBillboard->zbuffer_depth; | |
5413 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
5414 //v8 = dimming_level; | |
5415 //v9 = v7; | |
657 | 5416 v28 = dimming_level & 0xFF000000; |
5417 if ( dimming_level & 0xFF000000 ) | |
2155 | 5418 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3; |
0 | 5419 else |
2155 | 5420 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent; |
717 | 5421 //v10 = a3; |
5422 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
5423 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
2002 | 5424 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID; |
717 | 5425 //v25 = pSoftBillboard->uScreenSpaceX; |
5426 //v24 = pSoftBillboard->uScreenSpaceY; | |
5427 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
5428 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
5429 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5430 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
5431 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5432 v31 = v31 * -1.0; |
2006 | 5433 if ( pSoftBillboard->sTintColor && this->bTinting ) |
717 | 5434 { |
5435 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
2006 | 5436 v12 = BlendColors(pSoftBillboard->sTintColor, v11); |
0 | 5437 if ( v28 ) |
5438 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
5439 } | |
5440 else | |
5441 { | |
717 | 5442 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
5443 } | |
5444 //v13 = (double)v25; | |
1390 | 5445 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; |
5446 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
5447 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
717 | 5448 //v14 = (double)v24; |
5449 //v32 = v14; | |
1390 | 5450 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; |
717 | 5451 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); |
1390 | 5452 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; |
717 | 5453 v16 = 1.0 / pSoftBillboard->zbuffer_depth; |
1390 | 5454 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; |
5455 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
5456 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
717 | 5457 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); |
5458 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
5459 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5460 v17 = v17 * -1.0; |
1390 | 5461 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; |
5462 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
5463 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
5464 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
5465 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
5466 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
5467 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
5468 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
717 | 5469 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; |
5470 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5471 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5472 v20 = v20 * -1.0; |
1390 | 5473 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; |
5474 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
5475 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
5476 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
5477 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
5478 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
5479 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
5480 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
717 | 5481 v21 = pSprite->uBufferHeight - pSprite->uAreaY; |
5482 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5483 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 5484 v22 = v22 * -1.0; |
1390 | 5485 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; |
5486 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
5487 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
5488 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
5489 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
5490 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
5491 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
5492 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
717 | 5493 //v23 = pSprite->pTexture; |
5494 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
5495 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
5496 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 5497 } |
5498 } | |
5499 | |
5500 //----- (004A354F) -------------------------------------------------------- | |
5501 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5502 { | |
743 | 5503 //double v5; // st7@3 |
5504 //float v6; // ST20_4@3 | |
5505 //float v7; // ST00_4@3 | |
0 | 5506 unsigned int v8; // esi@3 |
743 | 5507 //int v9; // eax@3 |
5508 //int v10; // ebx@3 | |
0 | 5509 float v11; // ST28_4@3 |
743 | 5510 //double v12; // st7@3 |
5511 //float v13; // ST24_4@3 | |
5512 //double v14; // st6@3 | |
5513 //float v15; // ST1C_4@3 | |
0 | 5514 float v16; // ST2C_4@3 |
5515 float v17; // ST30_4@3 | |
5516 signed int v18; // ST18_4@3 | |
5517 signed int v19; // ST14_4@3 | |
5518 signed int v20; // ST10_4@3 | |
5519 signed int v21; // eax@3 | |
5520 double v22; // st6@3 | |
5521 float v23; // ST2C_4@3 | |
5522 float v24; // ST30_4@3 | |
5523 signed int v25; // ST10_4@3 | |
5524 signed int v26; // ST14_4@3 | |
5525 signed int v27; // ST18_4@3 | |
5526 signed int v28; // eax@3 | |
5527 double v29; // st6@3 | |
5528 float v30; // ecx@3 | |
5529 float v31; // ST2C_4@3 | |
5530 float v32; // ST30_4@3 | |
5531 signed int v33; // ST10_4@3 | |
5532 signed int v34; // ST14_4@3 | |
5533 signed int v35; // ST18_4@3 | |
5534 signed int v36; // eax@3 | |
5535 float v37; // ecx@3 | |
5536 double v38; // st6@3 | |
5537 float v39; // ST2C_4@3 | |
5538 float v40; // ST30_4@3 | |
5539 signed int v41; // ST10_4@3 | |
5540 signed int v42; // ST14_4@3 | |
5541 signed int v43; // ST18_4@3 | |
5542 signed int v44; // eax@3 | |
5543 double v45; // st6@3 | |
5544 float v46; // eax@3 | |
5545 | |
5546 if ( this->uNumD3DSceneBegins ) | |
5547 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5548 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5549 { |
743 | 5550 //v5 = (double)a2->zbuffer_depth; |
5551 //v6 = v5; | |
5552 //v7 = v5; | |
5553 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
2155 | 5554 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5555 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5556 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5557 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
743 | 5558 //v9 = a2->uScreenSpaceX; |
5559 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5560 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 5561 //v12 = (double) a2->uScreenSpaceX; |
5562 //v13 = v12; | |
5563 //v14 = (double)(a2->uScreenSpaceY - 12); | |
5564 //v15 = v14; | |
5565 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5566 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5567 v18 = stru_5C6E00->Cos(angle); |
5568 v19 = stru_5C6E00->Sin(angle); | |
5569 v20 = stru_5C6E00->Sin(angle); | |
5570 v21 = stru_5C6E00->Cos(angle); | |
1390 | 5571 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5572 + (double)(v18 >> 16)) |
5573 * v16 | |
5574 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
5575 + (double)(v19 >> 16)) | |
5576 * v17) | |
743 | 5577 * v11 + (double) a2->uScreenSpaceX; |
0 | 5578 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
5579 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
5580 - 12.0) | |
5581 * v11 | |
5582 + (double)a2->uScreenSpaceY; | |
1390 | 5583 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5584 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5585 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
5586 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
5587 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5588 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5589 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
743 | 5590 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5591 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5592 v25 = stru_5C6E00->Cos(angle); |
5593 v26 = stru_5C6E00->Sin(angle); | |
5594 v27 = stru_5C6E00->Sin(angle); | |
5595 v28 = stru_5C6E00->Cos(angle); | |
1390 | 5596 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
0 | 5597 + (double)(v25 >> 16)) |
740 | 5598 * v31 |
0 | 5599 - ((double)(unsigned __int16)v26 * 0.000015259022 |
5600 + (double)(v26 >> 16)) | |
740 | 5601 * v32) |
743 | 5602 * v11 + (double) a2->uScreenSpaceX; |
740 | 5603 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
5604 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 5605 - 12.0) |
5606 * v11 | |
5607 + (double)a2->uScreenSpaceY; | |
1390 | 5608 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5609 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5610 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
5611 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5612 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
5613 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5614 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5615 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
743 | 5616 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
5617 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 5618 v33 = stru_5C6E00->Cos(angle); |
5619 v34 = stru_5C6E00->Sin(angle); | |
5620 v35 = stru_5C6E00->Sin(angle); | |
5621 v36 = stru_5C6E00->Cos(angle); | |
1390 | 5622 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
0 | 5623 + (double)(v33 >> 16)) |
740 | 5624 * v23 |
0 | 5625 - ((double)(unsigned __int16)v34 * 0.000015259022 |
5626 + (double)(v34 >> 16)) | |
740 | 5627 * v24) |
743 | 5628 * v11 + (double) a2->uScreenSpaceX; |
1390 | 5629 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
740 | 5630 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
5631 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 5632 - 12.0) |
5633 * v11 | |
5634 + (double)a2->uScreenSpaceY; | |
1390 | 5635 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5636 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
5637 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5638 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5639 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
5640 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5641 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
743 | 5642 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
5643 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 5644 v41 = stru_5C6E00->Cos(angle); |
5645 v42 = stru_5C6E00->Sin(angle); | |
5646 v43 = stru_5C6E00->Sin(angle); | |
5647 v44 = stru_5C6E00->Cos(angle); | |
1390 | 5648 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
0 | 5649 + (double)(v41 >> 16)) |
5650 * v39 | |
5651 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
5652 + (double)(v42 >> 16)) | |
5653 * v40) | |
743 | 5654 * v11 + (double) a2->uScreenSpaceX; |
0 | 5655 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
5656 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
5657 - 12.0) | |
5658 * v11 | |
5659 + (double)a2->uScreenSpaceY; | |
1390 | 5660 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
5661 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5662 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
5663 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5664 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5665 pBillboardRenderListD3D[v8].pTexture = a3; |
743 | 5666 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 5667 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5668 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; |
5669 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5670 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5671 } |
5672 } | |
5673 } | |
5674 | |
5675 //----- (004A3AD9) -------------------------------------------------------- | |
5676 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5677 { | |
5678 double v5; // st7@2 | |
5679 float v6; // ST28_4@2 | |
5680 float v7; // ST00_4@2 | |
5681 unsigned int v8; // esi@2 | |
5682 int v9; // eax@2 | |
5683 int v10; // ebx@2 | |
5684 float v11; // ST34_4@2 | |
5685 double v12; // st7@2 | |
5686 float v13; // ST2C_4@2 | |
5687 double v14; // st6@2 | |
5688 float v15; // ST24_4@2 | |
5689 float v16; // ST38_4@2 | |
5690 float v17; // ST3C_4@2 | |
5691 signed int v18; // ST1C_4@2 | |
5692 int v19; // ST30_4@2 | |
5693 signed int v20; // ST20_4@2 | |
5694 signed int v21; // ST18_4@2 | |
5695 signed int v22; // eax@2 | |
5696 double v23; // st6@2 | |
5697 float v24; // ST20_4@2 | |
5698 float v25; // ST1C_4@2 | |
5699 float v26; // ST38_4@2 | |
5700 float v27; // ST3C_4@2 | |
5701 signed int v28; // ST18_4@2 | |
5702 signed int v29; // ST14_4@2 | |
5703 signed int v30; // ST10_4@2 | |
5704 signed int v31; // eax@2 | |
5705 double v32; // st6@2 | |
5706 float v33; // ST38_4@2 | |
5707 float v34; // ST3C_4@2 | |
5708 signed int v35; // ST10_4@2 | |
5709 signed int v36; // ST14_4@2 | |
5710 signed int v37; // ST18_4@2 | |
5711 signed int v38; // eax@2 | |
5712 double v39; // st6@2 | |
5713 float v40; // ST38_4@2 | |
5714 float v41; // ST3C_4@2 | |
5715 signed int v42; // ST10_4@2 | |
5716 signed int v43; // ST14_4@2 | |
5717 signed int v44; // ST18_4@2 | |
5718 signed int v45; // eax@2 | |
5719 double v46; // st6@2 | |
5720 | |
5721 if ( this->uNumD3DSceneBegins ) | |
5722 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5723 v5 = (double)a2->zbuffer_depth; |
0 | 5724 v6 = v5; |
5725 v7 = v5; | |
5726 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
2155 | 5727 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
0 | 5728 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5729 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
2002 | 5730 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
0 | 5731 v9 = a2->uScreenSpaceX; |
5732 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5733 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 5734 v12 = (double)v9; |
5735 v13 = v12; | |
5736 v14 = (double)(v10 - 12); | |
5737 v15 = v14; | |
5738 v16 = (double)(v9 - 12) - v12; | |
5739 v17 = (double)(v10 - 25) - v14; | |
323 | 5740 v18 = stru_5C6E00->Cos(angle); |
0 | 5741 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 5742 v20 = stru_5C6E00->Sin(angle); |
5743 v21 = stru_5C6E00->Sin(angle); | |
5744 v22 = stru_5C6E00->Cos(angle); | |
1390 | 5745 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 5746 + (double)(v18 >> 16)) |
5747 * v16 | |
5748 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
5749 + (double)(v20 >> 16)) | |
5750 * v17) | |
5751 * v11 + v13; | |
5752 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
5753 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
5754 - 12.0) | |
5755 * v11 | |
5756 + (double)a2->uScreenSpaceY; | |
1390 | 5757 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
5758 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5759 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
1637 | 5760 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5761 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; |
0 | 5762 v25 = 1.0 / v6; |
1390 | 5763 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; |
5764 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5765 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
0 | 5766 v26 = (double)(a2->uScreenSpaceX - 12) - v13; |
5767 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 5768 v28 = stru_5C6E00->Cos(angle); |
5769 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5770 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5771 v31 = stru_5C6E00->Cos(angle); | |
1390 | 5772 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
0 | 5773 + (double)(v28 >> 16)) |
5774 * v26 | |
5775 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
5776 + (double)(v29 >> 16)) | |
5777 * v27) | |
5778 * v11 + v13; | |
5779 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
5780 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
5781 - 12.0) | |
5782 * v11 | |
5783 + (double)a2->uScreenSpaceY; | |
1390 | 5784 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; |
5785 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
5786 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5787 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
5788 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5789 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5790 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
0 | 5791 v33 = (double)(a2->uScreenSpaceX + 12) - v13; |
5792 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 5793 v35 = stru_5C6E00->Cos(angle); |
5794 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5795 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5796 v38 = stru_5C6E00->Cos(angle); | |
1390 | 5797 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
0 | 5798 + (double)(v35 >> 16)) |
5799 * v33 | |
5800 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
5801 + (double)(v36 >> 16)) | |
5802 * v34) | |
5803 * v11 + v13; | |
5804 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
5805 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
5806 - 12.0) | |
5807 * v11 | |
5808 + (double)a2->uScreenSpaceY; | |
1390 | 5809 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
5810 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
5811 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
5812 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5813 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
5814 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5815 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
0 | 5816 v40 = (double)(a2->uScreenSpaceX + 12) - v13; |
5817 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 5818 v42 = stru_5C6E00->Cos(angle); |
5819 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5820 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5821 v45 = stru_5C6E00->Cos(angle); | |
1390 | 5822 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
0 | 5823 + (double)(v42 >> 16)) |
5824 * v40 | |
5825 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
5826 + (double)(v43 >> 16)) | |
5827 * v41) | |
5828 * v11 + v13; | |
5829 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
5830 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
5831 - 12.0) | |
5832 * v11 | |
5833 + (double)a2->uScreenSpaceY; | |
1390 | 5834 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; |
5835 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
5836 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
5837 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 5838 pBillboardRenderListD3D[v8].pTexture = a3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5839 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 5840 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 5841 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; |
5842 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5843 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 5844 } |
5845 } | |
5846 | |
5847 //----- (004A4023) -------------------------------------------------------- | |
657 | 5848 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
|
5849 { |
0 | 5850 unsigned int v8; // esi@2 |
5851 double v14; // st6@14 | |
5852 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5853 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5854 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5855 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5856 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5857 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5858 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5859 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5860 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5861 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5862 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 5863 float v29; // [sp+28h] [bp-8h]@5 |
5864 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5865 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5866 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5867 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5868 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5869 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5870 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5871 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5872 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
|
5873 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
|
5874 |
657 | 5875 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); |
2006 | 5876 if (a2->sTintColor & 0x00FFFFFF && bTinting) |
5877 { | |
5878 diffuse = BlendColors(a2->sTintColor, diffuse); | |
5879 if (a2->sTintColor & 0xFF000000) | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5880 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5881 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5882 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5883 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5884 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
|
5885 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
|
5886 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5887 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5888 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5889 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5890 v14 *= -1.0; |
1390 | 5891 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; |
5892 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5893 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5894 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5895 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; |
5896 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
5897 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5898 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5899 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5900 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5901 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5902 if ( a2->uFlags & 4 ) |
0 | 5903 v14 = v14 * -1.0; |
1390 | 5904 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; |
5905 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
5906 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5907 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5908 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5909 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; |
5910 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5911 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5912 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5913 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
|
5914 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5915 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5916 v14 *= -1.0; |
1390 | 5917 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; |
5918 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
5919 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5920 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5921 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5922 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; |
5923 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5924 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5925 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5926 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
|
5927 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5928 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5929 v14 *= -1.0; |
1390 | 5930 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; |
5931 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
5932 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5933 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
1637 | 5934 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
1390 | 5935 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; |
5936 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5937 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5938 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5939 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5940 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5941 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5942 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5943 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
2002 | 5944 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5945 |
2006 | 5946 if (a2->sTintColor & 0xFF000000) |
2155 | 5947 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5948 else |
2155 | 5949 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent; |
0 | 5950 } |
5951 | |
5952 | |
5953 //----- (004A49D0) -------------------------------------------------------- | |
5954 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
5955 { | |
1159 | 5956 int absXDifference; // eax@1 |
5957 int absYDifference; // eax@1 | |
5958 unsigned int smallerabsdiff; // ebx@1 | |
5959 unsigned int largerabsdiff; | |
0 | 5960 double v16; // st7@7 |
5961 double v17; // st7@7 | |
5962 double v18; // st6@7 | |
5963 double v20; // st4@8 | |
5964 double v21; // st4@10 | |
5965 double v22; // st4@10 | |
5966 double v23; // st4@10 | |
5967 double v25; // st4@11 | |
5968 double v26; // st4@13 | |
5969 double v28; // st4@13 | |
5970 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
1159 | 5971 int xDifference; // [sp+88h] [bp-Ch]@1 |
0 | 5972 signed int v32; // [sp+8Ch] [bp-8h]@1 |
1159 | 5973 int yDifference; // [sp+90h] [bp-4h]@1 |
5974 | |
5975 xDifference = bankersRounding(dstX - srcX); | |
5976 yDifference = bankersRounding(dstY - srcY); | |
5977 absYDifference = abs(yDifference); | |
5978 absXDifference = abs(xDifference); | |
5979 smallerabsdiff = min(absXDifference, absYDifference); | |
5980 largerabsdiff = max(absXDifference, absYDifference); | |
5981 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
0 | 5982 v16 = 1.0 / (double)v32; |
1159 | 5983 v17 = (double)yDifference * v16 * a4; |
5984 v18 = (double)xDifference * v16 * a4; | |
5985 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
5986 { | |
1637 | 5987 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
5988 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
1159 | 5989 } |
5990 else | |
5991 { | |
5992 v20 = a3 * 0.061758894; | |
5993 v25 = a7 * 0.061758894; | |
5994 } | |
5995 v21 = 1.0 / a3; | |
5996 v22 = (double)yDifference * v16 * a8; | |
5997 v23 = (double)xDifference * v16 * a8; | |
5998 v26 = 1.0 - 1.0 / v25; | |
5999 v28 = 1.0 / a7; | |
0 | 6000 v29[0].pos.x = srcX + v17; |
6001 v29[0].pos.y = srcY - v18; | |
1159 | 6002 v29[0].pos.z = 1.0 - 1.0 / v20; |
6003 v29[0].rhw = v21; | |
0 | 6004 v29[0].diffuse = -1; |
6005 v29[0].specular = 0; | |
6006 v29[0].texcoord.x = 1.0; | |
6007 v29[0].texcoord.y = 0.0; | |
1159 | 6008 |
0 | 6009 v29[1].pos.x = v22 + dstX; |
6010 v29[1].pos.y = dstY - v23; | |
1159 | 6011 v29[1].pos.z = v26; |
6012 v29[1].rhw = v28; | |
0 | 6013 v29[1].diffuse = -16711936; |
6014 v29[1].specular = 0; | |
6015 v29[1].texcoord.x = 1.0; | |
6016 v29[1].texcoord.y = 1.0; | |
1159 | 6017 |
6018 v29[2].pos.x = dstX - v22; | |
6019 v29[2].pos.y = v23 + dstY; | |
6020 v29[2].pos.z = v26; | |
0 | 6021 v29[2].rhw = v28; |
1159 | 6022 v29[2].diffuse = -1; |
6023 v29[2].specular = 0; | |
0 | 6024 v29[2].texcoord.x = 0.0; |
6025 v29[2].texcoord.y = 1.0; | |
1159 | 6026 |
0 | 6027 v29[3].pos.x = srcX - v17; |
6028 v29[3].pos.y = v18 + srcY; | |
1159 | 6029 v29[3].pos.z = v29[0].pos.z; |
6030 v29[3].rhw = v21; | |
6031 v29[3].diffuse = -1; | |
6032 v29[3].specular = 0; | |
0 | 6033 v29[3].texcoord.x = 0.0; |
6034 v29[3].texcoord.y = 0.0; | |
186 | 6035 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
6036 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6037 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
6038 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6039 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6040 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 6041 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
6042 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
6043 D3DPT_TRIANGLEFAN, | |
6044 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6045 v29, | |
6046 4, | |
6047 24)); | |
186 | 6048 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
6049 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6050 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6051 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6052 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6053 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 6054 } |
6055 | |
6056 //----- (004A4CC9) -------------------------------------------------------- | |
1390 | 6057 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) |
6058 { | |
0 | 6059 unsigned int v5; // eax@7 |
2334 | 6060 // char *v7; // edx@8 |
0 | 6061 double v10; // st6@9 |
6062 double v11; // st6@10 | |
6063 int v12; // ebx@13 | |
1390 | 6064 |
6065 if (a1->uNumVertices < 3) | |
6066 return; | |
6067 | |
6068 float depth = 1000000.0; | |
6069 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6070 { | |
6071 if (a1->field_104[i].z < depth) | |
6072 depth = a1->field_104[i * 4].z; | |
6073 } | |
6074 | |
6075 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
6076 pBillboardRenderListD3D[v5].field_90 = 0; | |
2002 | 6077 pBillboardRenderListD3D[v5].sParentBillboardID = -1; |
2155 | 6078 pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2; |
1390 | 6079 pBillboardRenderListD3D[v5].pTexture = 0; |
6080 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
6081 pBillboardRenderListD3D[v5].z_order = depth; | |
6082 | |
6083 for (uint i = 0; i < a1->uNumVertices; ++i) | |
6084 { | |
6085 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
6086 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
6087 | |
6088 v10 = a1->field_104[i].z; | |
6089 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
6090 v11 = v10 * 0.061758894; | |
6091 else | |
1637 | 6092 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; |
1390 | 6093 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; |
6094 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
6095 | |
6096 if (diffuse & 0xFF000000) | |
6097 v12 = a1->field_104[i].diffuse; | |
6098 else | |
6099 v12 = diffuse; | |
6100 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
6101 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
6102 | |
6103 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
6104 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
0 | 6105 } |
6106 } | |
6107 | |
6108 //----- (004A4DE1) -------------------------------------------------------- | |
6109 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
6110 { | |
2334 | 6111 // HRESULT v12; // eax@14 |
0 | 6112 unsigned __int16 *v13; // ecx@19 |
6113 unsigned __int16 *v14; // eax@19 | |
6114 DWORD v15; // edx@20 | |
2334 | 6115 // HRESULT v16; // eax@23 |
0 | 6116 stru350 Dst; // [sp+Ch] [bp-F8h]@12 |
6117 | |
1980 | 6118 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); |
0 | 6119 if ( pHWLTexture ) |
6120 { | |
6121 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
6122 if ( !pRenderD3D->CreateTexture( | |
6123 pHWLTexture->uWidth, | |
6124 pHWLTexture->uHeight, | |
6125 pOutSurface, | |
6126 pOutTexture, | |
6127 true, | |
6128 bMipMaps, | |
6129 uMinDeviceTextureDim) ) | |
1545 | 6130 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6131 //v10 = *pOutSurface; |
6132 //v11 = 0; | |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1574
diff
changeset
|
6133 if (bMipMaps) |
0 | 6134 { |
6135 Dst._450DDE(); | |
6136 //v20 = 0; | |
6137 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
6138 | |
6139 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
6140 while ( 1 ) | |
6141 { | |
6142 DDSCAPS2 v19; | |
6143 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6144 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6145 | |
6146 DDSURFACEDESC2 desc; | |
6147 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6148 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6149 | |
168 | 6150 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6151 { |
1831 | 6152 Dst.sub_451007_scale_image_bicubic( |
0 | 6153 pHWLTexture->pPixels, |
6154 pHWLTexture->uWidth, | |
6155 pHWLTexture->uHeight, | |
6156 pHWLTexture->uWidth, | |
6157 (unsigned short *)desc.lpSurface, | |
6158 desc.dwWidth, | |
6159 desc.dwHeight, | |
6160 desc.lPitch >> 1, | |
6161 0, | |
1831 | 6162 0); |
0 | 6163 ErrD3D(pNextSurf->Unlock(0)); |
6164 //bMipMaps = 0x4D86ACu; | |
6165 } | |
6166 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
6167 break; | |
6168 //v10 = (IDirectDrawSurface4 *)pName; | |
6169 //v11 = 0; | |
6170 } | |
6171 //v20 = -1; | |
6172 //nullsub_1(); | |
6173 } | |
6174 else | |
6175 { | |
6176 DDSCAPS2 v19; | |
6177 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6178 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6179 | |
6180 DDSURFACEDESC2 desc; | |
6181 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6182 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6183 | |
168 | 6184 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 6185 { |
6186 bMipMaps = 0; | |
6187 v13 = pHWLTexture->pPixels; | |
6188 v14 = (unsigned __int16 *)desc.lpSurface; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6189 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
|
6190 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6191 for (v15 = 0; v15 < desc.dwWidth; v15++) |
0 | 6192 { |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6193 *v14 = *v13; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6194 ++v14; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6195 ++v13; |
0 | 6196 } |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6197 v14 += (desc.lPitch >> 1) - desc.dwWidth; |
0 | 6198 } |
6199 ErrD3D((*pOutSurface)->Unlock(0)); | |
6200 } | |
6201 } | |
6202 delete [] pHWLTexture->pPixels; | |
6203 delete pHWLTexture; | |
6204 return true; | |
6205 } | |
6206 return false; | |
6207 } | |
6208 | |
6209 //----- (004A5048) -------------------------------------------------------- | |
670 | 6210 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
6211 { | |
6212 | |
6213 HWLTexture *sprite_texture; // eax@1 | |
0 | 6214 unsigned __int16 *v9; // edx@5 |
6215 LPVOID v10; // eax@5 | |
6216 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6217 | |
670 | 6218 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
6219 if ( sprite_texture ) | |
6220 { | |
6221 pSprite->uAreaX = sprite_texture->uAreaX; | |
6222 pSprite->uAreaY = sprite_texture->uAreaY; | |
6223 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
6224 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
6225 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
6226 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6227 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6228 //v7 = v3->pRenderD3D; |
670 | 6229 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
1545 | 6230 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
0 | 6231 //pSprite = v2->pTextureSurface; |
6232 //pSprite = (Sprite *)pSprite->pName; | |
6233 //v8 = pSprite; | |
670 | 6234 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 6235 Dst.dwSize = 124; |
670 | 6236 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
6237 { | |
6238 v9 = sprite_texture->pPixels; | |
6239 v10 = Dst.lpSurface; | |
6240 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 6241 { |
670 | 6242 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
6243 { | |
0 | 6244 *(int *)v10 = *(int *)v9; |
6245 v9 += 2; | |
6246 v10 = (char *)v10 + 4; | |
670 | 6247 } |
6248 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 6249 } |
670 | 6250 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
6251 } | |
6252 free(sprite_texture->pPixels); | |
6253 free(sprite_texture); | |
6254 return true; | |
6255 } | |
6256 return false; | |
0 | 6257 } |
6258 | |
6259 //----- (004A51CB) -------------------------------------------------------- | |
6260 void Render::BeginScene() | |
6261 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6262 //Render *v1; // esi@1 |
0 | 6263 unsigned int v2; // eax@1 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6264 /*int v3; // eax@5 |
0 | 6265 unsigned __int16 **v4; // edi@6 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6266 char *v5; // ebx@7*/ |
2334 | 6267 // DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 |
0 | 6268 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6269 //v1 = this; |
0 | 6270 v2 = this->uNumSceneBegins; |
6271 this->uNumSceneBegins = v2 + 1; | |
6272 if ( !v2 ) | |
6273 { | |
6274 if ( this->pRenderD3D ) | |
6275 { | |
2069 | 6276 /*if ( this->bColorKeySupported ) |
0 | 6277 { |
6278 memset(&Dst, 0, 0x7Cu); | |
6279 Dst.dwSize = 124; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6280 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
|
6281 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6282 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6283 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6284 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
|
6285 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6286 --this->uNumSceneBegins; |
2069 | 6287 }*/ |
0 | 6288 } |
6289 else | |
6290 { | |
6291 if ( !this->pTargetSurface ) | |
6292 { | |
6293 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
2154 | 6294 /*if ( this->pTargetSurface ) |
1151
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->field_18_locked_pitch = this->uTargetSurfacePitch; |
2154 | 6297 }*/ |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6298 --this->uNumSceneBegins; |
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 } |
0 | 6301 RestoreFrontBuffer(); |
6302 } | |
6303 } | |
6304 | |
6305 //----- (004A527D) -------------------------------------------------------- | |
6306 void Render::EndScene() | |
6307 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6308 if ( this->uNumSceneBegins ) |
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->uNumSceneBegins--; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
6311 if ( !this->uNumSceneBegins ) |
0 | 6312 { |
6313 if ( this->pRenderD3D ) | |
6314 { | |
2069 | 6315 /*if ( this->bColorKeySupported ) |
0 | 6316 { |
6317 this->pTargetSurface = 0; | |
6318 this->uTargetSurfacePitch = 0; | |
6319 this->field_18_locked_pitch = 0; | |
6320 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
2069 | 6321 }*/ |
0 | 6322 } |
6323 else | |
6324 { | |
6325 this->pTargetSurface = 0; | |
6326 this->uTargetSurfacePitch = 0; | |
2154 | 6327 //this->field_18_locked_pitch = 0; |
0 | 6328 UnlockBackBuffer(); |
6329 } | |
6330 } | |
6331 } | |
6332 } | |
6333 | |
2155 | 6334 //----- (004A52F1) -------------------------------------------------------- |
6335 void Render::ScreenFade(unsigned int color, float t) | |
0 | 6336 { |
6337 unsigned int v3; // esi@1 | |
2155 | 6338 //double v4; // st7@2 |
6339 //double v5; // st7@6 | |
0 | 6340 double v6; // st6@6 |
6341 unsigned int v7; // eax@6 | |
6342 double v8; // st5@6 | |
6343 double v9; // st4@6 | |
2334 | 6344 // HRESULT v10; // eax@6 |
6345 // HRESULT v11; // eax@6 | |
6346 // unsigned int result; // eax@6 | |
6347 // unsigned int v13; // eax@7 | |
6348 // unsigned __int16 *v14; // ecx@7 | |
6349 // int *v15; // eax@7 | |
6350 // unsigned int v16; // ecx@8 | |
6351 // __int16 v17; // ax@10 | |
6352 // int v18; // esi@10 | |
6353 // float v19; // edi@10 | |
6354 // void *v20; // esi@10 | |
6355 // int v21; // edx@10 | |
6356 // int v22; // ecx@11 | |
6357 // int v23; // edx@12 | |
6358 // __int16 v24; // ax@15 | |
6359 // int v25; // esi@15 | |
6360 // float v26; // edi@15 | |
6361 // char *v27; // esi@15 | |
6362 // int v28; // edx@15 | |
6363 // int v29; // ecx@16 | |
6364 // int v30; // edx@17 | |
6365 // int v31; // [sp-Ch] [bp-ACh]@11 | |
6366 // int v32; // [sp-Ch] [bp-ACh]@16 | |
6367 // const char *v33; // [sp+0h] [bp-A0h]@0 | |
6368 // int v34; // [sp+4h] [bp-9Ch]@0 | |
6369 // unsigned int v35; // [sp+8h] [bp-98h]@0 | |
0 | 6370 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 |
2334 | 6371 // unsigned int v37; // [sp+8Ch] [bp-14h]@7 |
6372 // int v38; // [sp+90h] [bp-10h]@7 | |
6373 // double v39; // [sp+94h] [bp-Ch]@6 | |
2155 | 6374 int v40; // [sp+9Ch] [bp-4h]@6 |
6375 | |
0 | 6376 v3 = 0; |
1574 | 6377 |
6378 //{ | |
2155 | 6379 if (t > 1.0f) |
6380 t = 1.0f; | |
6381 else if (t < 0.0f) | |
6382 t = 0.0f; | |
6383 | |
6384 v40 = (char)floorf(t * 255.0f + 0.5f); | |
6385 //v5 = (double)(signed int)pViewport->uViewportTL_X; | |
6386 v36[0].pos.x = pViewport->uViewportTL_X; | |
693 | 6387 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
2155 | 6388 v7 = color | (v40 << 24); |
6389 //this_ = pViewport->uViewportBR_Y + 1; | |
0 | 6390 v36[0].specular = 0; |
6391 v36[0].pos.y = v6; | |
6392 v36[0].diffuse = v7; | |
6393 v36[1].diffuse = v7; | |
6394 v36[0].pos.z = 0.0; | |
6395 v36[2].diffuse = v7; | |
6396 v36[3].diffuse = v7; | |
6397 v36[0].rhw = 1.0; | |
6398 v36[1].specular = 0; | |
6399 v36[0].texcoord.x = 0.0; | |
6400 v36[2].specular = 0; | |
6401 v36[3].specular = 0; | |
6402 v36[0].texcoord.y = 0.0; | |
2155 | 6403 v36[1].pos.x = pViewport->uViewportTL_X; |
693 | 6404 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 6405 v36[1].pos.y = v8; |
6406 v36[1].pos.z = 0.0; | |
6407 v36[1].rhw = 1.0; | |
6408 v36[1].texcoord.x = 0.0; | |
6409 v36[1].texcoord.y = 0.0; | |
693 | 6410 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 6411 v36[2].pos.x = v9; |
6412 v36[2].pos.y = v8; | |
6413 v36[2].pos.z = 0.0; | |
6414 v36[2].rhw = 1.0; | |
6415 v36[2].texcoord.x = 0.0; | |
6416 v36[2].texcoord.y = 0.0; | |
6417 v36[3].pos.x = v9; | |
6418 v36[3].pos.y = v6; | |
6419 v36[3].pos.z = 0.0; | |
6420 v36[3].rhw = 1.0; | |
6421 v36[3].texcoord.x = 0.0; | |
6422 v36[3].texcoord.y = 0.0; | |
6423 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 6424 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
6425 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6426 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6427 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
6428 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
6429 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6430 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 6431 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
6432 D3DPT_TRIANGLEFAN, | |
6433 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6434 v36, | |
6435 4, | |
6436 28)); | |
186 | 6437 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
6438 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6439 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
6440 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6441 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6442 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
1574 | 6443 /*} |
0 | 6444 else |
6445 { | |
6446 v40 = (1.0 - a3) * 65536.0; | |
6447 v39 = v40 + 6.7553994e15; | |
6448 LODWORD(a3) = LODWORD(v39); | |
693 | 6449 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
6450 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
6451 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
6452 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 6453 v37 = 2 * v13; |
6454 LODWORD(v40) = (int)v14; | |
6455 | |
6456 int __i = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
6457 v15 = dword_F1B430.data(); |
0 | 6458 do |
6459 { | |
6460 v16 = v3; | |
6461 v3 += LODWORD(a3); | |
6462 dword_F1B430[__i++] = v16 >> 16; | |
6463 } | |
6464 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
6465 while (__i < 32); | |
6466 | |
6467 if ( pRenderer->uTargetGBits == 6 ) | |
6468 { | |
1574 | 6469 v17 = sr_42690D_colors_cvt(this_); |
0 | 6470 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); |
6471 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); | |
6472 v19 = v40; | |
6473 v20 = off_4EFDB0; | |
6474 v21 = HIDWORD(v39); | |
6475 do | |
6476 { | |
6477 v22 = v38; | |
6478 v31 = v21; | |
6479 do | |
6480 { | |
6481 v23 = (*(int *)((char *)v20 | |
6482 + ((((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; | |
6483 result = this_ | |
6484 + (*((int *)v20 | |
6485 + (((unsigned __int8)(*((char *)v20 | |
6486 + ((((unsigned __int16)(*(short *)((char *)v20 | |
6487 + ((*(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); | |
6488 *(unsigned int *)LODWORD(v19) = result; | |
6489 LODWORD(v19) += 4; | |
6490 --v22; | |
6491 } | |
6492 while ( v22 ); | |
6493 LODWORD(v19) += v37; | |
6494 v21 = v31 - 1; | |
6495 } | |
6496 while ( v31 != 1 ); | |
6497 } | |
6498 else | |
6499 { | |
1574 | 6500 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_); |
0 | 6501 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); |
6502 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
6503 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
6504 v26 = v40; | |
6505 v27 = (char *)off_4EFDB0; | |
6506 v28 = HIDWORD(v39); | |
6507 do | |
6508 { | |
6509 v29 = v38; | |
6510 v32 = v28; | |
6511 do | |
6512 { | |
6513 v30 = 32 | |
6514 * *(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; | |
6515 result = this_ | |
6516 + (*(int *)&v27[4 | |
6517 * (((unsigned __int8)(32 | |
6518 * 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); | |
6519 *(unsigned int *)LODWORD(v26) = result; | |
6520 LODWORD(v26) += 4; | |
6521 --v29; | |
6522 } | |
6523 while ( v29 ); | |
6524 LODWORD(v26) += v37; | |
6525 v28 = v32 - 1; | |
6526 } | |
6527 while ( v32 != 1 ); | |
6528 } | |
1574 | 6529 }*/ |
0 | 6530 } |
6531 | |
6532 //----- (004A5B81) -------------------------------------------------------- | |
727 | 6533 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 6534 { |
6535 this->bClip = 1; | |
6536 this->uClipY = uY; | |
6537 this->uClipX = uX; | |
6538 this->uClipW = uW; | |
6539 this->uClipZ = uZ; | |
6540 } | |
6541 | |
6542 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 6543 void Render::ResetTextureClipRect() |
0 | 6544 { |
6545 this->uClipY = 0; | |
6546 this->uClipX = 0; | |
6547 this->bClip = 1; | |
6548 this->uClipW = 480; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
6549 this->uClipZ = window->GetWidth(); |
0 | 6550 } |
6551 | |
2069 | 6552 unsigned __int32 Color32(unsigned __int16 color16) |
6553 { | |
6554 unsigned __int32 c = color16; | |
6555 unsigned int b = (c & 31) * 8; | |
6556 unsigned int g = ((c >> 5) & 63) * 4; | |
6557 unsigned int r = ((c >> 11) & 31) * 8; | |
6558 | |
2078 | 6559 return (r << 16) | (g << 8) | b;// |
2069 | 6560 } |
6561 | |
6562 //----- (0040DEF3) -------------------------------------------------------- | |
6563 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b) | |
6564 { | |
6565 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + | |
6566 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + | |
6567 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
6568 return (b >> (8 - 5)) | | |
6569 0x7E0 & (g << (6 + 5 - 8)) | | |
6570 0xF800 & (r << (6 + 5 + 5 - 8)); | |
6571 } | |
6572 | |
6573 | |
0 | 6574 //----- (004A5BE3) -------------------------------------------------------- |
6575 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
6576 { | |
6577 int v4; // edi@3 | |
2069 | 6578 //unsigned __int16 *v5; // edx@3 |
0 | 6579 unsigned __int16 *v6; // esi@3 |
6580 unsigned int v8; // eax@5 | |
2334 | 6581 unsigned int v9; // ebx@5 |
0 | 6582 unsigned int v11; // eax@7 |
6583 unsigned int v12; // ebx@8 | |
6584 unsigned int v15; // eax@14 | |
2334 | 6585 int v19; // [sp+10h] [bp-8h]@3 |
6586 // unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
0 | 6587 int v23; // [sp+28h] [bp+10h]@3 |
6588 | |
6589 if ( this->uNumSceneBegins && a4 ) | |
6590 { | |
6591 v4 = a4->uWidth; | |
2069 | 6592 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6593 v6 = a4->pPixels; |
6594 v23 = a4->uHeight; | |
2334 | 6595 v19 = v4; |
0 | 6596 if ( this->bClip ) |
6597 { | |
1152 | 6598 if ( (signed int)uOutX < (signed int)this->uClipX ) |
6599 { | |
6600 v8 = this->uClipX - uOutX; | |
2334 | 6601 v9 = uOutX - this->uClipX; |
0 | 6602 v8 *= 2; |
2334 | 6603 v4 += v9; |
0 | 6604 v6 = (unsigned __int16 *)((char *)v6 + v8); |
2069 | 6605 //v5 = (unsigned __int16 *)((char *)v5 + v8); |
0 | 6606 } |
1152 | 6607 if ( (signed int)uOutY < (signed int)this->uClipY ) |
6608 { | |
6609 v11 = this->uClipY - uOutY; | |
2334 | 6610 v6 += v19 * v11; |
0 | 6611 v23 += uOutY - this->uClipY; |
2069 | 6612 //v5 += this->uTargetSurfacePitch * v11; |
0 | 6613 } |
1152 | 6614 v12 = max(this->uClipX, uOutX); |
6615 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | |
2334 | 6616 { |
1152 | 6617 v4 = this->uClipZ - max(this->uClipX, uOutX); |
2334 | 6618 } |
1152 | 6619 v15 = max(this->uClipY, uOutY); |
6620 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) | |
2334 | 6621 { |
1152 | 6622 v23 = this->uClipW - max(this->uClipY, uOutY); |
2334 | 6623 } |
1152 | 6624 } |
6625 | |
2069 | 6626 for (int y = 0; y < v23; y++) |
6627 { | |
6628 for (int x = 0; x < v4; x++) | |
6629 { | |
6630 WritePixel16(uOutX + x, uOutY + y, *v6); | |
6631 //*v5 = *v6; | |
6632 //++v5; | |
1152 | 6633 ++v6; |
6634 } | |
2334 | 6635 v6 += v19 - v4; |
2069 | 6636 //v5 += this->uTargetSurfacePitch - v4; |
0 | 6637 } |
6638 } | |
6639 } | |
6640 | |
6641 //----- (004A5D33) -------------------------------------------------------- | |
1675 | 6642 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) |
0 | 6643 { |
2069 | 6644 //unsigned __int16 *v7; // ebx@3 |
1675 | 6645 int full_width; // ecx@3 |
6646 int full_height; // edi@3 | |
2069 | 6647 //int v23; // edi@23 |
0 | 6648 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 |
6649 | |
6650 if ( this->uNumSceneBegins && pTexture ) | |
6651 { | |
2069 | 6652 /*auto v7 = this->pTargetSurface; |
6653 if (FORCE_16_BITS) | |
6654 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2); | |
6655 else | |
6656 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/ | |
1675 | 6657 full_width = pTexture->uWidth - move_X; |
6658 full_height = pTexture->uHeight - move_Y; | |
6659 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth]; | |
6660 if ( this->bClip ) | |
6661 { | |
6662 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó | |
6663 { | |
6664 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX))); | |
6665 full_width += pX - this->uClipX; | |
2069 | 6666 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX))); |
1675 | 6667 } |
6668 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó | |
6669 { | |
6670 pTexturea += pTexture->uWidth * (this->uClipY - pY); | |
6671 full_height += pY - this->uClipY; | |
2069 | 6672 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY)); |
1675 | 6673 } |
6674 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà | |
6675 this->uClipX = pX; | |
6676 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà | |
6677 this->uClipY = pY; | |
6678 if ( (full_width + this->uClipX) > this->uClipZ )//åñëè øèðèíà êàäðà âûõîäèò çà ïðàâóþ ãðàíèöó | |
6679 { | |
6680 if ( this->uClipX < pX ) | |
6681 this->uClipX = pX; | |
6682 full_width = this->uClipZ - this->uClipX; | |
6683 } | |
6684 if ( (full_height + this->uClipY) > this->uClipW )//åñëè âûñîòà êàäðà âûõîäèò çà íèæíþþ ãðàíèöó | |
6685 { | |
6686 if ( this->uClipY < pY ) | |
6687 this->uClipY = pY; | |
6688 full_height = this->uClipW - this->uClipY; | |
6689 } | |
6690 } | |
2069 | 6691 |
6692 for (int y = 0; y < full_height; ++y) | |
6693 { | |
6694 for (int x = 0; x < full_width; ++x) | |
6695 { | |
6696 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) ) | |
6697 { | |
6698 WritePixel16(pX + x, pY + y, *pTexturea); | |
6699 /*if (FORCE_16_BITS) | |
6700 *(unsigned __int16 *)v7 = *pTexturea; | |
6701 else | |
6702 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/ | |
6703 } | |
0 | 6704 ++pTexturea; |
2069 | 6705 //++v7; |
0 | 6706 } |
2069 | 6707 //v7 += this->uTargetSurfacePitch - full_width; |
1675 | 6708 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width)); |
2069 | 6709 } |
0 | 6710 } |
6711 } | |
6712 | |
6713 //----- (004A6E7E) -------------------------------------------------------- | |
2155 | 6714 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 6715 { |
2069 | 6716 //unsigned __int16 *v4; // eax@4 |
0 | 6717 int v5; // edx@4 |
6718 unsigned int v6; // edi@4 | |
6719 unsigned int v7; // edx@5 | |
6720 unsigned int v8; // edx@6 | |
6721 unsigned int v9; // edx@7 | |
6722 unsigned int v10; // edx@8 | |
6723 unsigned int v11; // ebx@9 | |
6724 unsigned int v12; // esi@11 | |
6725 unsigned int v13; // edx@12 | |
6726 unsigned int v14; // ebx@15 | |
6727 unsigned int v15; // esi@17 | |
6728 unsigned int v16; // edi@18 | |
2334 | 6729 // char v17; // zf@29 |
0 | 6730 int v18; // [sp+14h] [bp-Ch]@4 |
6731 int v19; // [sp+18h] [bp-8h]@4 | |
6732 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
2334 | 6733 // int v21; // [sp+28h] [bp+8h]@25 |
6734 // int v22; // [sp+28h] [bp+8h]@34 | |
6735 // unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
6736 // unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
0 | 6737 |
6738 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
6739 { | |
2069 | 6740 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
710 | 6741 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 6742 v5 = a4->uTextureWidth; |
6743 v6 = a4->uTextureHeight; | |
6744 v19 = a4->uTextureWidth; | |
6745 v18 = a4->uTextureWidth; | |
2069 | 6746 int clipped_out_x = a2; |
6747 int clipped_out_y = a3; | |
0 | 6748 if ( this->bClip ) |
6749 { | |
6750 v7 = this->uClipX; | |
6751 if ( (signed int)a2 < (signed int)v7 ) | |
6752 { | |
6753 v8 = v7 - a2; | |
6754 v20 += v8; | |
6755 v19 += a2 - this->uClipX; | |
2069 | 6756 //v4 += v8; |
6757 clipped_out_x = uClipX; | |
0 | 6758 } |
6759 v9 = this->uClipY; | |
6760 if ( (signed int)a3 < (signed int)v9 ) | |
6761 { | |
6762 v10 = v9 - a3; | |
6763 v20 += v18 * v10; | |
6764 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
2069 | 6765 //v4 += this->uTargetSurfacePitch * v10; |
6766 clipped_out_y = uClipY; | |
0 | 6767 } |
6768 v11 = this->uClipX; | |
6769 v5 = v19; | |
6770 if ( (signed int)v11 < (signed int)a2 ) | |
6771 v11 = a2; | |
6772 v12 = this->uClipZ; | |
6773 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
6774 { | |
6775 v13 = this->uClipX; | |
6776 if ( (signed int)v13 < (signed int)a2 ) | |
6777 v13 = a2; | |
6778 v5 = v12 - v13; | |
6779 } | |
6780 v14 = this->uClipY; | |
6781 if ( (signed int)v14 < (signed int)a3 ) | |
6782 v14 = a3; | |
6783 v15 = this->uClipW; | |
6784 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
6785 { | |
6786 v16 = this->uClipY; | |
6787 if ( (signed int)v16 < (signed int)a3 ) | |
6788 v16 = a3; | |
6789 v6 = v15 - v16; | |
6790 } | |
6791 } | |
2069 | 6792 |
6793 for (int y = 0; y < v6; ++y) | |
6794 { | |
6795 for (int x = 0; x < v5; ++x) | |
6796 { | |
6797 if ( *v20 ) | |
6798 WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF); | |
6799 ++v20; | |
6800 } | |
6801 v20 += v18 - v5; | |
6802 } | |
6803 | |
6804 /*if ( pRenderer->uTargetGBits == 5 ) | |
0 | 6805 { |
6806 if ( (signed int)v6 > 0 ) | |
6807 { | |
6808 v23 = v6; | |
6809 do | |
6810 { | |
6811 if ( v5 > 0 ) | |
6812 { | |
6813 v21 = v5; | |
6814 do | |
6815 { | |
6816 if ( *v20 ) | |
6817 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
6818 ++v4; | |
6819 ++v20; | |
6820 --v21; | |
6821 } | |
6822 while ( v21 ); | |
6823 } | |
6824 v20 += v18 - v5; | |
6825 v17 = v23-- == 1; | |
6826 v4 += this->uTargetSurfacePitch - v5; | |
6827 } | |
6828 while ( !v17 ); | |
6829 } | |
6830 } | |
6831 else | |
6832 { | |
6833 if ( (signed int)v6 > 0 ) | |
6834 { | |
6835 v24 = v6; | |
6836 do | |
6837 { | |
6838 if ( v5 > 0 ) | |
6839 { | |
6840 v22 = v5; | |
6841 do | |
6842 { | |
6843 if ( *v20 ) | |
6844 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
6845 ++v4; | |
6846 ++v20; | |
6847 --v22; | |
6848 } | |
6849 while ( v22 ); | |
6850 } | |
6851 v20 += v18 - v5; | |
6852 v17 = v24-- == 1; | |
6853 v4 += this->uTargetSurfacePitch - v5; | |
6854 } | |
6855 while ( !v17 ); | |
6856 } | |
2069 | 6857 }*/ |
0 | 6858 } |
6859 } | |
6860 | |
6861 //----- (004A6DF5) -------------------------------------------------------- | |
2069 | 6862 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) |
0 | 6863 { |
2219 | 6864 int width; // ecx@3 |
6865 unsigned __int16 *pixels; // ebx@4 | |
6866 int height; // esi@4 | |
0 | 6867 |
2069 | 6868 if ( !pBitmap || !pTarget) |
6869 return; | |
6870 | |
2219 | 6871 width = a7->z - a7->x; |
6872 height = a7->w - a7->y; | |
6873 pixels = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; | |
6874 for ( int y = 0; y < height; ++y ) | |
6875 { | |
6876 for ( int x = 0; x < width; ++x ) | |
6877 { | |
6878 WritePixel16(a7->x + x, a7->y + y, *pixels); | |
6879 ++pixels; | |
6880 } | |
6881 pixels += uTargetPitch - width; | |
2093 | 6882 } |
0 | 6883 } |
6884 | |
6885 //----- (004A6D87) -------------------------------------------------------- | |
6886 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
6887 { | |
6888 if (!uNumSceneBegins) | |
6889 return; | |
6890 | |
6891 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
6892 for (uint y = 0; y < uHeight; ++y) | |
6893 { | |
2069 | 6894 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch); |
6895 | |
6896 memset32(pDst, | |
2098 | 6897 FORCE_16_BITS ? twoColors : 0xFF000000 | Color32(uColor16), // two colors per int (16bit) or 1 (32bit) |
2069 | 6898 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit) |
6899 | |
6900 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit | |
6901 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16; | |
0 | 6902 } |
6903 } | |
6904 | |
6905 //----- (004A6C4F) -------------------------------------------------------- | |
2073 | 6906 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, |
6907 unsigned int uCharHeight, unsigned __int16 *pFontPalette, | |
6908 unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
0 | 6909 { |
6910 unsigned int v9; // edi@2 | |
6911 unsigned int v10; // esi@2 | |
2069 | 6912 //unsigned __int16 *v11; // eax@2 |
0 | 6913 unsigned int v12; // ebx@3 |
6914 signed int v13; // edx@5 | |
6915 int v14; // edx@6 | |
6916 signed int v15; // ebx@7 | |
6917 unsigned int v16; // edx@9 | |
6918 signed int v17; // edi@10 | |
6919 signed int v18; // ebx@13 | |
6920 unsigned int v19; // edx@15 | |
6921 signed int v20; // esi@16 | |
2069 | 6922 //unsigned int v21; // esi@22 |
0 | 6923 unsigned __int16 v22; // dx@24 |
2069 | 6924 //char v23; // zf@28 |
0 | 6925 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 |
2069 | 6926 //unsigned int uOutXa; // [sp+18h] [bp+8h]@20 |
6927 | |
6928 if (!this->uNumSceneBegins) | |
6929 return; | |
6930 | |
0 | 6931 v9 = uCharWidth; |
6932 v10 = uCharHeight; | |
2069 | 6933 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
0 | 6934 v24 = pFontPixels; |
2069 | 6935 |
6936 int clipped_out_x = uOutX, clipped_out_y = uOutY; | |
0 | 6937 if ( this->bClip ) |
6938 { | |
6939 v12 = this->uClipX; | |
6940 if ( uOutX < (signed int)v12 ) | |
6941 { | |
6942 v24 = &pFontPixels[v12 - uOutX]; | |
2069 | 6943 //v11 += v12 - uOutX; |
6944 clipped_out_x = uClipX; | |
0 | 6945 v9 = uCharWidth + uOutX - v12; |
6946 } | |
6947 v13 = this->uClipY; | |
6948 if ( uOutY < v13 ) | |
6949 { | |
6950 v14 = v13 - uOutY; | |
6951 v24 += uCharWidth * v14; | |
6952 v10 = uCharHeight + uOutY - this->uClipY; | |
2069 | 6953 //v11 += this->uTargetSurfacePitch * v14; |
6954 clipped_out_y = uClipY; | |
0 | 6955 } |
6956 v15 = this->uClipX; | |
6957 if ( v15 < uOutX ) | |
6958 v15 = uOutX; | |
6959 v16 = this->uClipZ; | |
6960 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
6961 { | |
6962 v17 = this->uClipX; | |
6963 if ( v17 < uOutX ) | |
6964 v17 = uOutX; | |
6965 v9 = v16 - v17; | |
6966 } | |
6967 v18 = this->uClipY; | |
6968 if ( v18 < uOutY ) | |
6969 v18 = uOutY; | |
6970 v19 = this->uClipW; | |
6971 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
6972 { | |
6973 v20 = this->uClipY; | |
6974 if ( v20 < uOutY ) | |
6975 v20 = uOutY; | |
6976 v10 = v19 - v20; | |
6977 } | |
6978 } | |
2069 | 6979 |
6980 for (int y = 0; y < v10; ++y) | |
6981 { | |
6982 for (int x = 0; x < v9; ++x) | |
6983 { | |
6984 if (*v24) | |
0 | 6985 { |
2069 | 6986 v22 = uShadowColor; |
6987 if ( *v24 != 1 ) | |
6988 v22 = uFaceColor; | |
2073 | 6989 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22); |
0 | 6990 } |
2073 | 6991 ++v24; |
6992 } | |
6993 v24 += uCharWidth - v9; | |
2069 | 6994 //v23 = uOutXa-- == 1; |
6995 //v11 += this->uTargetSurfacePitch - v9; | |
6996 } | |
0 | 6997 } |
6998 | |
6999 //----- (004A6A68) -------------------------------------------------------- | |
1496 | 7000 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) |
7001 { | |
0 | 7002 Texture tex; // [sp+Ch] [bp-48h]@1 |
1496 | 7003 |
0 | 7004 memcpy(&tex, a4, sizeof(tex)); |
1496 | 7005 tex.uTextureHeight = a4->uTextureHeight - height; |
7006 if ( (signed __int16)tex.uTextureHeight > 0 ) | |
0 | 7007 DrawTextureIndexed(a2, a3, &tex); |
7008 } | |
7009 | |
7010 //----- (004A6AB1) -------------------------------------------------------- | |
1268 | 7011 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
7012 { | |
0 | 7013 int v8; // edi@2 |
7014 unsigned int v9; // esi@2 | |
2069 | 7015 //unsigned __int16 *v10; // eax@2 |
0 | 7016 unsigned char *v11; // edx@2 |
7017 unsigned int v12; // ebx@3 | |
7018 signed int v13; // edx@5 | |
7019 int v14; // edx@6 | |
7020 signed int v15; // ebx@7 | |
7021 unsigned int v16; // edx@9 | |
7022 signed int v17; // edi@10 | |
7023 signed int v18; // ebx@13 | |
7024 unsigned int v19; // edx@15 | |
7025 signed int v20; // esi@16 | |
2334 | 7026 // int v21; // ebx@22 |
7027 // char v22; // zf@28 | |
7028 // int v23; // ebx@31 | |
0 | 7029 unsigned __int16 v24; // si@35 |
7030 int v25; // [sp+Ch] [bp-4h]@2 | |
2334 | 7031 // int v26; // [sp+1Ch] [bp+Ch]@24 |
7032 // int v27; // [sp+1Ch] [bp+Ch]@33 | |
0 | 7033 unsigned int v28; // [sp+20h] [bp+10h]@30 |
2334 | 7034 // unsigned int v29; // [sp+24h] [bp+14h]@22 |
7035 // unsigned int v30; // [sp+24h] [bp+14h]@31 | |
0 | 7036 |
1980 | 7037 int a2 = x; |
7038 int a3 = y; | |
7039 uint a6 = uFontHeight; | |
2069 | 7040 if (!this->uNumSceneBegins) |
7041 return; | |
7042 | |
0 | 7043 v8 = a5; |
7044 v9 = a6; | |
2069 | 7045 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; |
1268 | 7046 v11 = (unsigned char *)font_pixels; |
7047 v25 = (int)font_pixels; | |
2069 | 7048 int clipped_out_x = x; |
7049 int clipped_out_y = y; | |
0 | 7050 if ( this->bClip ) |
7051 { | |
7052 v12 = this->uClipX; | |
7053 if ( a2 < (signed int)v12 ) | |
7054 { | |
1268 | 7055 v25 = v12 - a2 + (int)font_pixels; |
2069 | 7056 //v10 += v12 - a2; |
0 | 7057 v8 = a5 + a2 - v12; |
2069 | 7058 clipped_out_x = uClipX; |
0 | 7059 } |
7060 v13 = this->uClipY; | |
7061 if ( a3 < v13 ) | |
7062 { | |
7063 v14 = v13 - a3; | |
7064 v25 += a5 * v14; | |
7065 v9 = a6 + a3 - this->uClipY; | |
2069 | 7066 //v10 += this->uTargetSurfacePitch * v14; |
7067 clipped_out_y = uClipY; | |
0 | 7068 } |
7069 v15 = this->uClipX; | |
7070 if ( v15 < a2 ) | |
7071 v15 = a2; | |
7072 v16 = this->uClipZ; | |
7073 if ( v8 + v15 > (signed int)v16 ) | |
7074 { | |
7075 v17 = this->uClipX; | |
7076 if ( v17 < a2 ) | |
7077 v17 = a2; | |
7078 v8 = v16 - v17; | |
7079 } | |
7080 v18 = this->uClipY; | |
7081 if ( v18 < a3 ) | |
7082 v18 = a3; | |
7083 v19 = this->uClipW; | |
7084 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
7085 { | |
7086 v20 = this->uClipY; | |
7087 if ( v20 < a3 ) | |
7088 v20 = a3; | |
7089 v9 = v19 - v20; | |
7090 } | |
7091 v11 = (unsigned char *)v25; | |
7092 } | |
2069 | 7093 |
0 | 7094 if ( a8 ) |
7095 { | |
2069 | 7096 v28 = 0x7FF; // 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask; |
7097 for (int dy = 0; dy < v9; ++dy) | |
7098 { | |
7099 for (int dx = 0; dx < v8; ++dx) | |
7100 { | |
7101 if ( *v11 ) | |
7102 v24 = pPalette[*v11]; | |
7103 else | |
7104 v24 = v28; | |
7105 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24); | |
7106 //*v10 = v24; | |
7107 //++v10; | |
2074 | 7108 ++v11; |
2069 | 7109 //--v27; |
2074 | 7110 |
2069 | 7111 } |
7112 v11 += a5 - v8; | |
7113 } | |
7114 /*if ( (signed int)v9 > 0 ) | |
0 | 7115 { |
7116 v23 = a5; | |
7117 v30 = v9; | |
7118 do | |
7119 { | |
7120 if ( v8 > 0 ) | |
7121 { | |
7122 v27 = v8; | |
7123 do | |
7124 { | |
7125 if ( *v11 ) | |
7126 v24 = pPalette[*v11]; | |
7127 else | |
7128 v24 = v28; | |
7129 *v10 = v24; | |
7130 ++v10; | |
7131 ++v11; | |
7132 --v27; | |
7133 } | |
7134 while ( v27 ); | |
7135 } | |
7136 v11 += v23 - v8; | |
7137 v22 = v30-- == 1; | |
7138 v10 += this->uTargetSurfacePitch - v8; | |
7139 } | |
7140 while ( !v22 ); | |
2069 | 7141 }*/ |
0 | 7142 } |
7143 else | |
7144 { | |
2069 | 7145 for (int dy = 0; dy < v9; ++dy) |
7146 { | |
7147 for (int dx = 0; dx < v8; ++dx) | |
7148 { | |
2074 | 7149 if ( *v11 ) |
2069 | 7150 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]); |
7151 //*v10 = v24; | |
7152 //++v10; | |
2074 | 7153 ++v11; |
2069 | 7154 //--v27; |
7155 } | |
7156 v11 += a5 - v8; | |
7157 } | |
7158 | |
7159 /*if ( (signed int)v9 > 0 ) | |
0 | 7160 { |
7161 v21 = a5; | |
7162 v29 = v9; | |
7163 do | |
7164 { | |
7165 if ( v8 > 0 ) | |
7166 { | |
7167 v26 = v8; | |
7168 do | |
7169 { | |
7170 if ( *v11 ) | |
7171 *v10 = pPalette[*v11]; | |
7172 ++v10; | |
7173 ++v11; | |
7174 --v26; | |
7175 } | |
7176 while ( v26 ); | |
7177 } | |
7178 v11 += v21 - v8; | |
7179 v22 = v29-- == 1; | |
7180 v10 += this->uTargetSurfacePitch - v8; | |
7181 } | |
7182 while ( !v22 ); | |
2069 | 7183 }*/ |
7184 } | |
0 | 7185 } |
7186 | |
7187 //----- (004A68EF) -------------------------------------------------------- | |
7188 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
7189 { | |
2069 | 7190 DrawMasked(a2, a3, pTexture, 0x07E0); |
7191 } | |
7192 | |
0 | 7193 |
7194 //----- (004A6776) -------------------------------------------------------- | |
315 | 7195 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 7196 { |
2069 | 7197 DrawMasked(a2, a3, a4, 0xF800); |
7198 /*Texture *v4; // edi@2 | |
0 | 7199 unsigned int v5; // ebx@4 |
7200 unsigned __int16 *v6; // eax@4 | |
7201 unsigned int v7; // edx@5 | |
7202 unsigned int v8; // edx@6 | |
7203 unsigned int v9; // edx@7 | |
7204 unsigned int v10; // edx@8 | |
7205 unsigned int v11; // edx@9 | |
7206 unsigned int v12; // esi@12 | |
7207 unsigned int v13; // esi@15 | |
7208 unsigned int v14; // edx@17 | |
7209 unsigned int v15; // esi@18 | |
7210 unsigned __int8 *v16; // ebx@22 | |
7211 char v17; // zf@28 | |
7212 int v18; // [sp+10h] [bp-10h]@4 | |
7213 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7214 int v20; // [sp+1Ch] [bp-4h]@4 | |
7215 int a2a; // [sp+28h] [bp+8h]@24 | |
7216 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
7217 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
7218 | |
7219 if ( this->uNumSceneBegins ) | |
7220 { | |
7221 v4 = a4; | |
7222 if ( a4 ) | |
7223 { | |
7224 if ( a4->pPalette16 ) | |
7225 { | |
7226 v5 = a4->uTextureHeight; | |
7227 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7228 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7229 v20 = a4->uTextureWidth; |
7230 v18 = a4->uTextureWidth; | |
7231 if ( this->bClip ) | |
7232 { | |
7233 v7 = this->uClipX; | |
7234 if ( (signed int)a2 < (signed int)v7 ) | |
7235 { | |
7236 v8 = v7 - a2; | |
7237 v19 += v8; | |
7238 v20 += a2 - this->uClipX; | |
7239 v6 += v8; | |
7240 } | |
7241 v9 = this->uClipY; | |
7242 v5 = a4->uTextureHeight; | |
7243 if ( (signed int)a3 < (signed int)v9 ) | |
7244 { | |
7245 v10 = v9 - a3; | |
7246 v19 += v18 * v10; | |
7247 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
7248 v4 = a4; | |
7249 v6 += this->uTargetSurfacePitch * v10; | |
7250 } | |
7251 v11 = this->uClipX; | |
7252 if ( (signed int)v11 < (signed int)a2 ) | |
7253 v11 = a2; | |
7254 a4a = this->uClipZ; | |
7255 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
7256 { | |
7257 v12 = this->uClipX; | |
7258 if ( (signed int)v12 < (signed int)a2 ) | |
7259 v12 = a2; | |
7260 v20 = a4a - v12; | |
7261 } | |
7262 v13 = this->uClipY; | |
7263 if ( (signed int)v13 < (signed int)a3 ) | |
7264 v13 = a3; | |
7265 v14 = this->uClipW; | |
7266 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7267 { | |
7268 v15 = this->uClipY; | |
7269 if ( (signed int)v15 < (signed int)a3 ) | |
7270 v15 = a3; | |
7271 v5 = v14 - v15; | |
7272 } | |
7273 } | |
7274 if ( (signed int)v5 > 0 ) | |
7275 { | |
7276 a3a = v5; | |
7277 v16 = v19; | |
7278 do | |
7279 { | |
7280 if ( v20 > 0 ) | |
7281 { | |
7282 a2a = v20; | |
7283 do | |
7284 { | |
7285 if ( *v16 ) | |
7286 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
7287 ++v6; | |
7288 ++v16; | |
7289 --a2a; | |
7290 } | |
7291 while ( a2a ); | |
7292 } | |
7293 v16 += v18 - v20; | |
7294 v17 = a3a-- == 1; | |
7295 v6 += this->uTargetSurfacePitch - v20; | |
7296 } | |
7297 while ( !v17 ); | |
7298 } | |
7299 } | |
7300 } | |
2069 | 7301 }*/ |
7302 } | |
7303 | |
7304 //----- (004A68EF) -------------------------------------------------------- | |
7305 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask) | |
7306 { | |
7307 unsigned int v5; // ebx@4 | |
7308 int v10; // edx@8 | |
7309 signed int v11; // edx@9 | |
7310 signed int v12; // esi@12 | |
7311 signed int v13; // esi@15 | |
7312 signed int v15; // esi@18 | |
7313 unsigned __int8 *v16; // ebx@22 | |
2334 | 7314 // char v17; // zf@28 |
2069 | 7315 int v18; // [sp+10h] [bp-10h]@4 |
7316 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7317 int v20; // [sp+1Ch] [bp-4h]@4 | |
2334 | 7318 // int v21; // [sp+28h] [bp+8h]@24 |
7319 // unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
2069 | 7320 |
7321 if (!uNumSceneBegins || !pTexture) | |
7322 return; | |
7323 | |
2325 | 7324 if ( pTexture->pPalette16 ) |
7325 { | |
7326 v5 = pTexture->uTextureHeight; | |
7327 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
7328 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; | |
7329 v20 = pTexture->uTextureWidth; | |
7330 v18 = pTexture->uTextureWidth; | |
7331 int clipped_out_x = a2; | |
7332 int clipped_out_y = a3; | |
7333 if ( this->bClip ) | |
7334 { | |
7335 if ( a2 < this->uClipX ) | |
7336 { | |
7337 v19 += this->uClipX - a2; | |
7338 v20 += a2 - this->uClipX; | |
7339 clipped_out_x = uClipX; | |
7340 } | |
7341 v5 = pTexture->uTextureHeight; | |
7342 if ( a3 < this->uClipY ) | |
7343 { | |
7344 v10 = this->uClipY - a3; | |
7345 v19 += v18 * v10; | |
7346 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7347 clipped_out_y = uClipY; | |
7348 } | |
7349 v11 = this->uClipX; | |
7350 if ( this->uClipX < a2 ) | |
7351 v11 = a2; | |
7352 if ( v11 + v20 > (signed int)this->uClipZ ) | |
7353 { | |
7354 v12 = this->uClipX; | |
7355 if ( v12 < a2 ) | |
7356 v12 = a2; | |
7357 v20 = this->uClipZ - v12; | |
2069 | 7358 } |
7359 v13 = this->uClipY; | |
2325 | 7360 if ( this->uClipY < a3 ) |
2069 | 7361 v13 = a3; |
2325 | 7362 if ( (signed int)(v5 + v13) > (signed int)this->uClipW ) |
2069 | 7363 { |
7364 v15 = this->uClipY; | |
2325 | 7365 if ( this->uClipY < a3 ) |
2069 | 7366 v15 = a3; |
2325 | 7367 v5 = this->uClipW - v15; |
2069 | 7368 } |
7369 } | |
7370 | |
7371 v16 = v19; | |
7372 for (int y = 0; y < v5; ++y) | |
7373 { | |
7374 for (int x = 0; x < v20; ++x) | |
7375 { | |
7376 if ( *v16 ) | |
2325 | 7377 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v16] & mask); |
2069 | 7378 ++v16; |
7379 } | |
7380 v16 += v18 - v20; | |
7381 } | |
7382 | |
7383 /*if ( (signed int)v5 > 0 ) | |
7384 { | |
7385 v22 = v5; | |
7386 v16 = v19; | |
7387 do | |
7388 { | |
7389 if ( v20 > 0 ) | |
7390 { | |
7391 v21 = v20; | |
7392 do | |
7393 { | |
7394 if ( *v16 ) | |
7395 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7396 ++v6; | |
7397 ++v16; | |
7398 --v21; | |
7399 } | |
7400 while ( v21 ); | |
7401 } | |
7402 v16 += v18 - v20; | |
7403 v17 = v22-- == 1; | |
7404 v6 += this->uTargetSurfacePitch - v20; | |
7405 } | |
7406 while ( !v17 ); | |
7407 }*/ | |
7408 } | |
7409 } | |
7410 | |
0 | 7411 |
7412 //----- (004A65CC) -------------------------------------------------------- | |
7413 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
7414 { | |
2198 | 7415 unsigned int uHeight; // edi@6 |
0 | 7416 unsigned int v14; // edx@11 |
7417 unsigned int v16; // edx@14 | |
7418 unsigned int v17; // edx@17 | |
7419 unsigned int v19; // edx@20 | |
7420 int v20; // eax@27 | |
7421 int v21; // edx@29 | |
2334 | 7422 // int v23; // [sp+Ch] [bp-Ch]@24 |
0 | 7423 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 |
2334 | 7424 // int xa; // [sp+20h] [bp+8h]@26 |
7425 // unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
2198 | 7426 int Width; // [sp+2Ch] [bp+14h]@6 |
0 | 7427 |
7428 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
7429 { | |
710 | 7430 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7431 Width = a4->uTextureWidth; |
7432 uHeight = a4->uTextureHeight; | |
2069 | 7433 int clipped_out_x = x; |
7434 int clipped_out_y = y; | |
0 | 7435 if ( this->bClip ) |
7436 { | |
2198 | 7437 if ( (signed int)x < (signed int)this->uClipX ) |
7438 { | |
7439 v24 += this->uClipX - x; | |
7440 Width += x - this->uClipX; | |
2069 | 7441 clipped_out_x = uClipX; |
0 | 7442 } |
2198 | 7443 if ( (signed int)y < (signed int)this->uClipY ) |
7444 { | |
7445 v24 += a4->uTextureWidth * (this->uClipY - y); | |
7446 uHeight = y - this->uClipY + a4->uTextureHeight; | |
2069 | 7447 clipped_out_y = uClipY; |
0 | 7448 } |
7449 v14 = this->uClipX; | |
2198 | 7450 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7451 v14 = x; |
2198 | 7452 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7453 { |
7454 v16 = this->uClipX; | |
2198 | 7455 if ( (signed int)this->uClipX < (signed int)x ) |
0 | 7456 v16 = x; |
2198 | 7457 Width = this->uClipZ - v16; |
0 | 7458 } |
7459 v17 = this->uClipY; | |
2198 | 7460 if ( (signed int)this->uClipY < (signed int)y ) |
0 | 7461 v17 = y; |
2198 | 7462 if ( (signed int)(uHeight + v17) > (signed int)this->uClipW ) |
0 | 7463 { |
7464 v19 = this->uClipY; | |
7465 if ( (signed int)v19 < (signed int)y ) | |
7466 v19 = y; | |
2198 | 7467 uHeight = this->uClipW - v19; |
7468 } | |
7469 } | |
7470 | |
7471 for (int dy = 0; dy < uHeight; ++dy) | |
7472 { | |
7473 for (int dx = 0; dx < Width; ++dx) | |
7474 { | |
7475 v20 = *v24; | |
7476 if ( v20 >= a7 && v20 <= a8 ) | |
7477 { | |
7478 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7479 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7480 v21 = 2 * a8 - v21 - a7; | |
7481 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]); | |
7482 } | |
7483 ++v24; | |
7484 } | |
7485 v24 += a4->uTextureWidth - Width; | |
2069 | 7486 } |
7487 /*if ( (signed int)v9 > 0 ) | |
0 | 7488 { |
7489 ya = v9; | |
7490 v23 = v22 - v27; | |
7491 do | |
7492 { | |
7493 if ( v27 > 0 ) | |
7494 { | |
7495 xa = v27; | |
7496 do | |
7497 { | |
7498 v20 = *v24; | |
7499 if ( v20 >= a7 && v20 <= a8 ) | |
7500 { | |
7501 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7502 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7503 v21 = 2 * a8 - v21 - a7; | |
7504 *v8 = a4->pPalette16[v21]; | |
7505 } | |
7506 ++v8; | |
7507 ++v24; | |
7508 --xa; | |
7509 } | |
7510 while ( xa ); | |
7511 } | |
7512 v8 += this->uTargetSurfacePitch - v27; | |
7513 v24 += v23; | |
7514 --ya; | |
7515 } | |
7516 while ( ya ); | |
2069 | 7517 }*/ |
0 | 7518 } |
7519 } | |
7520 | |
7521 //----- (004A63E6) -------------------------------------------------------- | |
1455 | 7522 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) |
0 | 7523 { |
7524 unsigned int v14; // edx@11 | |
7525 unsigned int v16; // edx@14 | |
7526 unsigned int v17; // edx@17 | |
7527 unsigned int v19; // edx@20 | |
7528 int v20; // eax@27 | |
7529 int v21; // edx@29 | |
2334 | 7530 // int v23; // [sp+Ch] [bp-Ch]@24 |
2198 | 7531 int Height; // [sp+10h] [bp-8h]@6 |
7532 int Width; // [sp+14h] [bp-4h]@6 | |
0 | 7533 int v27; // [sp+24h] [bp+Ch]@23 |
7534 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
7535 | |
7536 if ( this->uNumSceneBegins ) | |
7537 { | |
7538 if ( a4 ) | |
7539 { | |
7540 if ( a4->pPalette16 ) | |
7541 { | |
7542 if ( a5 ) | |
7543 { | |
7544 if ( a5->pPalette16 ) | |
7545 { | |
710 | 7546 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
2198 | 7547 Width = a4->uTextureWidth; |
7548 Height = a4->uTextureHeight; | |
2069 | 7549 int clipped_out_x = a2; |
7550 int clipped_out_y = a3; | |
0 | 7551 if ( this->bClip ) |
7552 { | |
2198 | 7553 if ( (signed int)a2 < (signed int)this->uClipX ) |
0 | 7554 { |
2198 | 7555 v28 += this->uClipX - a2; |
7556 Width += a2 - this->uClipX; | |
2069 | 7557 clipped_out_x = uClipX; |
0 | 7558 } |
2198 | 7559 |
7560 if ( (signed int)a3 < (signed int)this->uClipY ) | |
0 | 7561 { |
2198 | 7562 v28 += a4->uTextureWidth * (this->uClipY - a3); |
7563 Height += a3 - this->uClipY; | |
2069 | 7564 clipped_out_y = uClipY; |
0 | 7565 } |
2198 | 7566 |
0 | 7567 v14 = this->uClipX; |
2198 | 7568 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7569 v14 = a2; |
2198 | 7570 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) |
0 | 7571 { |
7572 v16 = this->uClipX; | |
2198 | 7573 if ( (signed int)this->uClipX < (signed int)a2 ) |
0 | 7574 v16 = a2; |
2198 | 7575 Width = this->uClipZ - v16; |
0 | 7576 } |
2198 | 7577 |
0 | 7578 v17 = this->uClipY; |
2198 | 7579 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7580 v17 = a3; |
2198 | 7581 if ( (signed int)(Height + v17) > (signed int)this->uClipW ) |
0 | 7582 { |
7583 v19 = this->uClipY; | |
2198 | 7584 if ( (signed int)this->uClipY < (signed int)a3 ) |
0 | 7585 v19 = a3; |
2198 | 7586 Height = this->uClipW - v19; |
0 | 7587 } |
7588 } | |
2069 | 7589 |
0 | 7590 v27 = 0; |
2198 | 7591 for (int y = 0; y < Height; ++y) |
2069 | 7592 { |
2198 | 7593 for (int x = 0; x < Width; ++x) |
2069 | 7594 { |
7595 if ( *v28 ) | |
7596 { | |
2101 | 7597 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); |
2069 | 7598 if ( v20 >= a7 ) |
7599 { | |
7600 if ( v20 <= a8 ) | |
7601 { | |
7602 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7603 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7604 v21 = 2 * a8 - v21 - a7; | |
7605 //v9 = a5; | |
7606 //*v10 = a5->pPalette16[v21]; | |
7607 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]); | |
7608 } | |
7609 } | |
7610 } | |
7611 v28++; | |
7612 } | |
2198 | 7613 v28 += a4->uTextureWidth - Width; |
2069 | 7614 } |
7615 | |
7616 /*if ( v24 > 0 ) | |
0 | 7617 { |
7618 v23 = v22 - v25; | |
7619 do | |
7620 { | |
7621 for ( i = 0; i < v25; ++v28 ) | |
7622 { | |
7623 if ( *v28 ) | |
7624 { | |
710 | 7625 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 7626 if ( v20 >= a7 ) |
7627 { | |
7628 if ( v20 <= a8 ) | |
7629 { | |
7630 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7631 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7632 v21 = 2 * a8 - v21 - a7; | |
7633 v9 = a5; | |
7634 *v10 = a5->pPalette16[v21]; | |
7635 } | |
7636 } | |
7637 } | |
7638 ++i; | |
7639 ++v10; | |
7640 } | |
7641 ++v27; | |
7642 v10 += this->uTargetSurfacePitch - v25; | |
7643 v28 += v23; | |
7644 } | |
7645 while ( v27 < v24 ); | |
2069 | 7646 }*/ |
7647 | |
0 | 7648 } |
7649 } | |
7650 } | |
7651 } | |
7652 } | |
7653 } | |
7654 | |
7655 //----- (004A6274) -------------------------------------------------------- | |
7656 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
7657 { | |
7658 int uHeight; // ebx@4 | |
7659 unsigned int v11; // edx@9 | |
7660 unsigned int v12; // esi@12 | |
7661 unsigned int v13; // esi@15 | |
7662 unsigned int v15; // esi@18 | |
7663 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7664 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
7665 | |
7666 if ( this->uNumSceneBegins ) | |
7667 { | |
7668 if ( pTexture ) | |
7669 { | |
7670 if ( pTexture->pPalette16 ) | |
7671 { | |
7672 uHeight = pTexture->uTextureHeight; | |
710 | 7673 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7674 uWidth = pTexture->uTextureWidth; |
2069 | 7675 |
7676 int clipped_out_x = uX; | |
7677 int clipped_out_y = uY; | |
0 | 7678 if ( this->bClip ) |
7679 { | |
2198 | 7680 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 7681 { |
2198 | 7682 v19 += this->uClipX - uX; |
0 | 7683 uWidth += uX - this->uClipX; |
2069 | 7684 clipped_out_x = uClipX; |
0 | 7685 } |
2198 | 7686 |
0 | 7687 uHeight = pTexture->uTextureHeight; |
2198 | 7688 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 7689 { |
2198 | 7690 v19 += pTexture->uTextureWidth * (this->uClipY - uY); |
0 | 7691 uHeight = uY - this->uClipY + pTexture->uTextureHeight; |
2069 | 7692 clipped_out_y = uClipY; |
0 | 7693 } |
7694 v11 = this->uClipX; | |
2198 | 7695 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7696 v11 = uX; |
2198 | 7697 |
7698 if ( (signed int)(v11 + uWidth) > (signed int)this->uClipZ ) | |
0 | 7699 { |
7700 v12 = this->uClipX; | |
2198 | 7701 if ( (signed int)this->uClipX < (signed int)uX ) |
0 | 7702 v12 = uX; |
2198 | 7703 uWidth = this->uClipZ - v12; |
0 | 7704 } |
7705 v13 = this->uClipY; | |
2198 | 7706 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7707 v13 = uY; |
2198 | 7708 |
7709 if ( (signed int)(uHeight + v13) > (signed int)this->uClipW ) | |
0 | 7710 { |
7711 v15 = this->uClipY; | |
2198 | 7712 if ( (signed int)this->uClipY < (signed int)uY ) |
0 | 7713 v15 = uY; |
2198 | 7714 uHeight = this->uClipW - v15; |
0 | 7715 } |
7716 } | |
2198 | 7717 |
2069 | 7718 for (int y = 0; y < uHeight; ++y) |
7719 { | |
7720 for (int x = 0; x < uWidth; ++x) | |
7721 { | |
2198 | 7722 if ( *v19 ) |
7723 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); | |
7724 ++v19; | |
2069 | 7725 } |
2198 | 7726 v19 += pTexture->uTextureWidth - uWidth; |
2069 | 7727 } |
7728 /*if ( (signed int)uHeight > 0 ) | |
0 | 7729 { |
7730 uYa = uHeight; | |
7731 v16 = v19; | |
7732 do | |
7733 { | |
7734 if ( uWidth > 0 ) | |
7735 { | |
7736 uXa = uWidth; | |
7737 do | |
7738 { | |
7739 if ( *v16 ) | |
7740 *v6 = pCurrentTexture->pPalette16[*v16]; | |
7741 ++v6; | |
7742 ++v16; | |
7743 } | |
7744 while ( uXa-- !=1 ); | |
7745 } | |
7746 v16 += v18 - uWidth; | |
7747 uFlag = uYa-- == 1; | |
7748 v6 += this->uTargetSurfacePitch - uWidth; | |
7749 } | |
7750 while ( !uFlag ); | |
2069 | 7751 }*/ |
0 | 7752 } |
7753 } | |
7754 } | |
7755 } | |
7756 | |
7757 //----- (004A612A) -------------------------------------------------------- | |
710 | 7758 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 7759 { |
7760 Texture *v5; // eax@2 | |
7761 unsigned int v6; // edx@3 | |
7762 int v7; // ebx@3 | |
7763 int v8; // edi@3 | |
7764 signed int v9; // eax@4 | |
7765 int v10; // eax@5 | |
7766 unsigned int v11; // esi@6 | |
7767 signed int v12; // esi@8 | |
7768 unsigned int v13; // eax@10 | |
7769 signed int v14; // esi@11 | |
7770 unsigned int v15; // esi@14 | |
7771 unsigned int v16; // eax@16 | |
7772 unsigned int v17; // ecx@17 | |
7773 int v18; // edx@23 | |
7774 int v19; // [sp+Ch] [bp-Ch]@3 | |
7775 int v20; // [sp+10h] [bp-8h]@3 | |
7776 int uOutXa; // [sp+20h] [bp+8h]@21 | |
7777 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
7778 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
7779 | |
7780 if ( this->uNumSceneBegins ) | |
7781 { | |
7782 v5 = pTexture; | |
7783 if ( pTexture ) | |
7784 { | |
7785 v6 = uOutY; | |
7786 v7 = pTexture->uTextureHeight; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7787 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; |
710 | 7788 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7789 v8 = v5->uTextureWidth; |
7790 v20 = v5->uTextureWidth; | |
7791 v19 = v5->uTextureWidth; | |
7792 if ( this->bClip ) | |
7793 { | |
7794 v9 = this->uClipX; | |
7795 if ( uOutX < v9 ) | |
7796 { | |
7797 v10 = v9 - uOutX; | |
7798 uOutYa += v10; | |
7799 v8 += uOutX - this->uClipX; | |
7800 v20 = v8; | |
7801 pZBuffer += v10; | |
7802 } | |
7803 v11 = this->uClipY; | |
7804 if ( (signed int)v6 < (signed int)v11 ) | |
7805 { | |
7806 uOutYa += v19 * (v11 - v6); | |
7807 v7 += v6 - v11; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7808 pZBuffer += window->GetWidth() * (v11 - v6); |
0 | 7809 v8 = v20; |
7810 } | |
7811 v12 = this->uClipX; | |
7812 if ( v12 < uOutX ) | |
7813 v12 = uOutX; | |
7814 v13 = this->uClipZ; | |
7815 if ( v8 + v12 > (signed int)v13 ) | |
7816 { | |
7817 v14 = this->uClipX; | |
7818 if ( v14 < uOutX ) | |
7819 v14 = uOutX; | |
7820 v8 = v13 - v14; | |
7821 } | |
7822 v15 = this->uClipY; | |
7823 if ( (signed int)v15 < (signed int)v6 ) | |
7824 v15 = v6; | |
7825 v16 = this->uClipW; | |
7826 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
7827 { | |
7828 v17 = this->uClipY; | |
7829 if ( (signed int)v17 >= (signed int)v6 ) | |
7830 v6 = v17; | |
7831 v7 = v16 - v6; | |
7832 } | |
7833 } | |
7834 if ( v7 > 0 ) | |
7835 { | |
7836 uOutXa = v7; | |
7837 do | |
7838 { | |
7839 if ( v8 > 0 ) | |
7840 { | |
7841 v18 = v8; | |
7842 do | |
7843 { | |
7844 if ( *uOutYa ) | |
7845 *pZBuffer = zVal; | |
7846 ++pZBuffer; | |
7847 ++uOutYa; | |
7848 --v18; | |
7849 } | |
7850 while ( v18 ); | |
7851 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7852 pZBuffer += window->GetWidth() - v8; |
0 | 7853 uOutYa += v19 - v8; |
7854 --uOutXa; | |
7855 } | |
7856 while ( uOutXa ); | |
7857 } | |
7858 } | |
7859 } | |
7860 } | |
7861 | |
7862 //----- (004A601E) -------------------------------------------------------- | |
991 | 7863 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 7864 { |
7865 signed int v5; // edx@3 | |
7866 int v6; // ebx@3 | |
7867 int v7; // esi@3 | |
7868 void *v8; // esi@3 | |
7869 unsigned int v9; // eax@4 | |
7870 unsigned int v10; // eax@6 | |
7871 signed int v11; // edi@8 | |
7872 unsigned int v12; // eax@10 | |
7873 signed int v13; // edi@11 | |
7874 unsigned int v14; // edi@14 | |
7875 unsigned int v15; // eax@16 | |
7876 unsigned int v16; // ecx@17 | |
7877 int v17; // [sp+18h] [bp+Ch]@3 | |
7878 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
7879 | |
7880 if ( this->uNumSceneBegins && pTexture ) | |
7881 { | |
7882 v5 = a3; | |
7883 v6 = pTexture->uTextureHeight; | |
7884 v7 = 5 * a3; | |
7885 v17 = pTexture->uTextureHeight; | |
7886 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
7887 pTexturea = pTexture->uTextureWidth; | |
7888 if ( this->bClip ) | |
7889 { | |
7890 v9 = this->uClipX; | |
7891 if ( a2 < (signed int)v9 ) | |
7892 { | |
7893 pTexturea += a2 - v9; | |
7894 v8 = (char *)v8 + 4 * (v9 - a2); | |
7895 } | |
7896 v10 = this->uClipY; | |
7897 if ( v5 < (signed int)v10 ) | |
7898 { | |
7899 v17 += v5 - v10; | |
7900 v8 = (char *)v8 + 2560 * (v10 - v5); | |
7901 } | |
7902 v11 = this->uClipX; | |
7903 if ( v11 < a2 ) | |
7904 v11 = a2; | |
7905 v12 = this->uClipZ; | |
7906 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
7907 { | |
7908 v13 = this->uClipX; | |
7909 if ( v13 < a2 ) | |
7910 v13 = a2; | |
7911 pTexturea = v12 - v13; | |
7912 } | |
7913 v14 = this->uClipY; | |
7914 if ( (signed int)v14 < v5 ) | |
7915 v14 = v5; | |
7916 v6 = v17; | |
7917 v15 = this->uClipW; | |
7918 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
7919 { | |
7920 v16 = this->uClipY; | |
7921 if ( (signed int)v16 < v5 ) | |
7922 v16 = v5; | |
7923 v6 = v15 - v16; | |
7924 } | |
7925 } | |
7926 if ( v6 > 0 ) | |
7927 { | |
7928 do | |
7929 { | |
7930 if ( (signed int)pTexturea > 0 ) | |
7931 { | |
7932 memset32(v8, a5, pTexturea); | |
7933 v8 = (char *)v8 + 4 * pTexturea; | |
7934 } | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
7935 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea); |
0 | 7936 --v6; |
7937 } | |
7938 while ( v6 ); | |
7939 } | |
7940 } | |
7941 } | |
7942 | |
7943 //----- (004A5EB2) -------------------------------------------------------- | |
7944 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
7945 { | |
2069 | 7946 int v5; // ebx@4 |
0 | 7947 unsigned int v8; // edx@6 |
7948 unsigned int v10; // edx@8 | |
7949 unsigned int v11; // edx@9 | |
7950 unsigned int v12; // esi@12 | |
7951 unsigned int v13; // esi@15 | |
7952 unsigned int v15; // esi@18 | |
2334 | 7953 // char v17; // zf@26 |
0 | 7954 int v18; // [sp+10h] [bp-10h]@4 |
7955 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7956 int v20; // [sp+1Ch] [bp-4h]@4 | |
2334 | 7957 // int uXa; // [sp+28h] [bp+8h]@24 |
7958 // unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
0 | 7959 |
7960 if ( this->uNumSceneBegins ) | |
7961 { | |
7962 if ( a4 ) | |
7963 { | |
7964 if ( a4->pPalette16 ) | |
7965 { | |
7966 v5 = a4->uTextureHeight; | |
2069 | 7967 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
710 | 7968 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7969 v20 = a4->uTextureWidth; |
7970 v18 = a4->uTextureWidth; | |
2069 | 7971 |
7972 int clipped_out_x = uX; | |
7973 int clipped_out_y = uY; | |
0 | 7974 if ( this->bClip ) |
7975 { | |
2198 | 7976 if ( (signed int)uX < (signed int)this->uClipX ) |
0 | 7977 { |
2198 | 7978 v8 = this->uClipX - uX; |
0 | 7979 v19 += v8; |
7980 v20 += uX - this->uClipX; | |
2069 | 7981 clipped_out_x = uClipX; |
0 | 7982 } |
2198 | 7983 |
0 | 7984 v5 = a4->uTextureHeight; |
2198 | 7985 if ( (signed int)uY < (signed int)this->uClipY ) |
0 | 7986 { |
2198 | 7987 v10 = this->uClipY - uY; |
0 | 7988 v19 += v18 * v10; |
7989 v5 = uY - this->uClipY + a4->uTextureHeight; | |
2198 | 7990 //v4 = a4; |
2069 | 7991 clipped_out_y = uClipY; |
0 | 7992 } |
2198 | 7993 |
0 | 7994 v11 = this->uClipX; |
7995 if ( (signed int)v11 < (signed int)uX ) | |
7996 v11 = uX; | |
2198 | 7997 |
7998 if ( (signed int)(v11 + v20) > (signed int)this->uClipZ ) | |
0 | 7999 { |
8000 v12 = this->uClipX; | |
8001 if ( (signed int)v12 < (signed int)uX ) | |
8002 v12 = uX; | |
2198 | 8003 v20 = this->uClipZ - v12; |
0 | 8004 } |
2198 | 8005 |
0 | 8006 v13 = this->uClipY; |
8007 if ( (signed int)v13 < (signed int)uY ) | |
8008 v13 = uY; | |
2069 | 8009 |
8010 if ( (signed int)(v5 + v13) > (signed int)uClipW ) | |
0 | 8011 { |
8012 v15 = this->uClipY; | |
8013 if ( (signed int)v15 < (signed int)uY ) | |
8014 v15 = uY; | |
2069 | 8015 v5 = uClipW - v15; |
0 | 8016 } |
8017 } | |
2198 | 8018 |
2069 | 8019 for (int y = 0; y < v5; ++y) |
8020 { | |
8021 for (int x = 0; x < v20; ++x) | |
8022 { | |
2198 | 8023 if ( a4->pPalette16[*v19] != 0x7FF )// 2047 |
8024 WritePixel16(clipped_out_x + x, clipped_out_y + y, a4->pPalette16[*v19]); | |
8025 ++v19; | |
2069 | 8026 } |
2198 | 8027 v19 += v18 - v20; |
2069 | 8028 } |
8029 /*if ( (signed int)v5 > 0 ) | |
0 | 8030 { |
8031 uYa = v5; | |
8032 v16 = v19; | |
8033 do | |
8034 { | |
8035 if ( v20 > 0 ) | |
8036 { | |
8037 uXa = v20; | |
8038 do | |
8039 { | |
8040 *pTarget = v4->pPalette16[*v16]; | |
8041 ++pTarget; | |
8042 ++v16; | |
8043 --uXa; | |
8044 } | |
8045 while ( uXa ); | |
8046 } | |
8047 v16 += v18 - v20; | |
8048 v17 = uYa-- == 1; | |
8049 pTarget += this->uTargetSurfacePitch - v20; | |
8050 } | |
8051 while ( !v17 ); | |
2069 | 8052 }*/ |
0 | 8053 } |
8054 } | |
8055 } | |
8056 } | |
8057 | |
8058 //----- (004667E9) -------------------------------------------------------- | |
8059 void Render::ChangeBetweenWinFullscreenModes() | |
8060 { | |
8061 float v0; // ST14_4@17 | |
8062 int v4; // edx@26 | |
8063 ObjectDesc *v5; // eax@26 | |
8064 RGBTexture *v6; // esi@33 | |
8065 const char *v8; // [sp-4h] [bp-28h]@33 | |
2334 | 8066 // struct tagRECT Rect; // [sp+14h] [bp-10h]@15 |
0 | 8067 |
2061 | 8068 /*if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) |
0 | 8069 { |
1458 | 8070 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 | 8071 return; |
2061 | 8072 }*/ |
2154 | 8073 if ( pRenderer->bWindowMode || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8074 { |
0 | 8075 if ( pEventTimer->bPaused ) |
2061 | 8076 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0800; |
0 | 8077 else |
8078 pEventTimer->Pause(); | |
8079 if ( pMiscTimer->bPaused ) | |
2061 | 8080 dword_6BE364_game_settings_1 |= GAME_SETTINGS_1000; |
0 | 8081 else |
8082 pMiscTimer->Pause(); | |
8083 pMouse->bActive = 0; | |
8084 if ( pRenderer->pRenderD3D ) | |
8085 { | |
8086 pBitmaps_LOD->ReleaseHardwareTextures(); | |
8087 pSprites_LOD->ReleaseAll(); | |
8088 } | |
8089 if ( pRenderer->bWindowMode ) | |
8090 { | |
1802 | 8091 //SetMenu(hWnd, 0); |
8092 //SetWindowLongA(hWnd, -20, 0); | |
8093 //SetWindowLongA(hWnd, -16, 0x10000000u); | |
8094 window->SetFullscreenMode(); | |
8095 pRenderer->InitializeFullscreen(); | |
0 | 8096 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; |
8097 pGame->pGammaController->Initialize(v0); | |
8098 } | |
8099 else | |
8100 { | |
1802 | 8101 //ClipCursor(0); |
8102 window->SetWindowedMode(window->GetWidth(), window->GetHeight()); | |
8103 pRenderer->SwitchToWindow(); | |
0 | 8104 } |
8105 if ( pRenderer->pRenderD3D ) | |
8106 { | |
8107 pBitmaps_LOD->_410423_move_textures_to_device(); | |
8108 pSprites_LOD->MoveSpritesToVideoMemory(); | |
8109 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8110 if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits |
0 | 8111 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8112 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8113 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8114 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8115 pPaletteManager->RecalculateAll(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8116 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8117 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8118 for (int i = 0; i < pObjectList->uNumObjects; i++) |
0 | 8119 { |
8120 BYTE3(v4) = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8121 v5 = &pObjectList->pObjects[i]; |
0 | 8122 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; |
8123 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
8124 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8125 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8126 SetUserInterface(pParty->alignment, true); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8127 if ( pVideoPlayer->pVideoFrame.pPixels ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8128 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); |
2006 | 8129 if ( sCurrentMenuID != MENU_CREATEPARTY ) |
8130 { | |
8131 if ( sCurrentMenuID == MENU_CREDITSPROC ) | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8132 dword_A74C88 = 1; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8133 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8134 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8135 { |
2006 | 8136 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8137 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8138 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8139 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8140 v8 = "makeme.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8141 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8142 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8143 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8144 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8145 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8146 v8 = "title.pcx"; |
2006 | 8147 if ( sCurrentMenuID ) |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8148 v8 = "lsave640.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8149 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8150 v6->Load(v8, 0); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8151 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8152 } |
0 | 8153 viewparams->bRedrawGameUI = 1; |
688 | 8154 viewparams->InitGrayPalette(); |
0 | 8155 pMouse->SetCurrentCursorBitmap(); |
1802 | 8156 /*if ( pRenderer->bWindowMode ) |
0 | 8157 { |
1655 | 8158 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); |
8159 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); | |
1586 | 8160 ShowWindow(hWnd, SW_SHOWNORMAL); |
1802 | 8161 }*/ |
8162 pMouse->bActive = true; | |
0 | 8163 if ( pVideoPlayer->AnyMovieLoaded() ) |
898 | 8164 pVideoPlayer->SelectMovieType(); |
2061 | 8165 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0800) |
8166 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0800; | |
0 | 8167 else |
8168 pEventTimer->Resume(); | |
2061 | 8169 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_1000) |
8170 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_1000; | |
0 | 8171 else |
8172 pMiscTimer->Resume(); | |
8173 } | |
8174 } | |
8175 | |
8176 | |
8177 //----- (004524D8) -------------------------------------------------------- | |
8178 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
8179 { | |
1583 | 8180 //int v11; // eax@13 |
8181 //int v12; // ecx@13 | |
0 | 8182 void *v13; // eax@13 |
1583 | 8183 //unsigned __int8 v14; // zf@13 |
8184 //unsigned __int8 v15; // sf@13 | |
0 | 8185 int v16; // esi@14 |
8186 int v17; // ecx@16 | |
8187 int v18; // esi@16 | |
8188 unsigned __int16 *v19; // eax@16 | |
8189 int v20; // edx@16 | |
8190 int v21; // ecx@16 | |
8191 int v22; // eax@16 | |
8192 int v23; // esi@16 | |
8193 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
8194 int v27; // [sp+28h] [bp-Ch]@14 | |
8195 int v28; // [sp+2Ch] [bp-8h]@13 | |
8196 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
8197 | |
8198 //v3 = this; | |
8199 //sprintf(Str1, "%s", pName); | |
8200 //v4 = uNumItems; | |
8201 if (!uNumItems) | |
8202 return nullptr; | |
8203 | |
8204 //{ | |
8205 //v5 = 0, pDesta = uNumItems; | |
8206 uint idx1 = 0, | |
8207 idx2 = uNumItems; | |
8208 while (true) | |
8209 { | |
1980 | 8210 uint i = idx1 + (idx2 - idx1) / 2; |
8211 | |
8212 int res = _stricmp(pName, pSpriteNames[i]); | |
0 | 8213 if (!res) |
8214 { | |
8215 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
8216 break; | |
8217 } | |
8218 else if (res < 0) | |
8219 idx2 = idx1 + (idx2 - idx1) / 2; | |
8220 else | |
8221 idx1 = i + 1; | |
8222 | |
8223 if ( idx1 >= idx2 ) | |
8224 return false; | |
8225 } | |
8226 | |
8227 | |
8228 uint uCompressedSize = 0; | |
8229 fread(&uCompressedSize, 4, 1, pFile); | |
8230 | |
1980 | 8231 HWLTexture* pTex = new HWLTexture; |
670 | 8232 fread(&pTex->uBufferWidth, 4, 1, pFile); |
8233 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
8234 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
8235 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 8236 fread(&pTex->uWidth, 4, 1, pFile); |
8237 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 8238 fread(&pTex->uAreaX, 4, 1, pFile); |
8239 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 8240 |
8241 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
8242 if (uCompressedSize) | |
8243 { | |
1980 | 8244 char* pCompressedData = new char[uCompressedSize]; |
0 | 8245 { |
8246 fread(pCompressedData, 1, uCompressedSize, pFile); | |
1980 | 8247 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); |
0 | 8248 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); |
8249 } | |
8250 delete [] pCompressedData; | |
8251 } | |
8252 else | |
8253 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
8254 | |
1583 | 8255 if ( scale_hwls_to_half ) |
8256 { | |
8257 pTex->uHeight /= 2; | |
8258 pTex->uWidth /= 2; | |
8259 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
0 | 8260 v28 = 0; |
8261 v26 = (unsigned __int16 *)v13; | |
1583 | 8262 if ( pTex->uHeight > 0 ) |
0 | 8263 { |
8264 v16 = pTex->uWidth; | |
8265 v27 = 1; | |
8266 do | |
8267 { | |
8268 pDestb = 0; | |
8269 if ( v16 > 0 ) | |
8270 { | |
8271 do | |
8272 { | |
8273 v17 = v16 * v27; | |
8274 v18 = v28 * v16; | |
8275 v19 = pTex->pPixels; | |
8276 v20 = pDestb + 2 * v18; | |
8277 v21 = (int)&v19[2 * (pDestb + v17)]; | |
8278 v22 = (int)&v19[2 * v20]; | |
8279 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
8280 LOWORD(v21) = *(unsigned short *)v21; | |
8281 v23 = pDestb++ + v18; | |
1583 | 8282 extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); |
8283 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
0 | 8284 v16 = pTex->uWidth; |
8285 } | |
8286 while (pDestb < pTex->uWidth); | |
8287 } | |
8288 ++v28; | |
8289 v27 += 2; | |
8290 } | |
8291 while ( v28 < (signed int)pTex->uHeight ); | |
8292 } | |
8293 delete [] pTex->pPixels; | |
8294 pTex->pPixels = v26; | |
8295 } | |
8296 return pTex; | |
8297 } | |
8298 | |
8299 //----- (0045271F) -------------------------------------------------------- | |
8300 bool RenderHWLContainer::Release() | |
8301 { | |
8302 __int32 v4; // eax@6 | |
8303 FILE *v5; // ST24_4@6 | |
8304 FILE *File; // [sp+4h] [bp-4h]@6 | |
8305 | |
1162 | 8306 if ( this->bDumpDebug) |
0 | 8307 { |
8308 File = fopen("logd3d.txt", "w"); | |
1162 | 8309 v4 = ftell(this->pFile); |
8310 v5 = this->pFile; | |
8311 this->uDataOffset = v4; | |
8312 fwrite(&this->uNumItems, 4u, 1u, v5); | |
8313 for (int i = 0; i < this->uNumItems; i++) | |
8314 { | |
8315 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
8316 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
8317 } | |
8318 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
8319 fseek(this->pFile, 4, 0); | |
8320 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
8321 fclose(this->pFile); | |
0 | 8322 fclose(File); |
8323 } | |
8324 else | |
8325 { | |
8326 fclose(this->pFile); | |
1162 | 8327 for (int i = 0; i < this->uNumItems; i++) |
8328 { | |
8329 free(this->pSpriteNames[i]); | |
0 | 8330 } |
8331 } | |
1093 | 8332 return true; |
0 | 8333 } |
8334 | |
8335 //----- (00452347) -------------------------------------------------------- | |
8336 RenderHWLContainer::RenderHWLContainer(): | |
8337 bDumpDebug(false) | |
8338 { | |
8339 this->pFile = 0; | |
8340 uSignature = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8341 this->uDataOffset = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8342 memset(&this->uNumItems, 0, 0x61A84u); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8343 this->uNumItems = 0; |
1583 | 8344 this->scale_hwls_to_half = false; |
0 | 8345 } |
8346 | |
8347 //----- (0045237F) -------------------------------------------------------- | |
8348 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
8349 { | |
8350 pFile = _wfopen(pFilename, L"rb"); | |
8351 if (!pFile) | |
8352 { | |
8353 Log::Warning(L"Failed to open file: %s", pFilename); | |
8354 return false; | |
8355 } | |
8356 | |
8357 fread(&uSignature, 1, 4, pFile); | |
8358 if (uSignature != 'TD3D') | |
8359 { | |
8360 Log::Warning(L"Invalid format: %s", pFilename); | |
8361 return false; | |
8362 } | |
8363 | |
8364 fread(&uDataOffset, 4, 1, pFile); | |
8365 fseek(pFile, uDataOffset, SEEK_SET); | |
8366 fread(&uNumItems, 4, 1, pFile); | |
8367 | |
8368 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
8369 for (uint i = 0; i < uNumItems; ++i) | |
8370 { | |
8371 pSpriteNames[i] = new char[20]; | |
8372 fread(pSpriteNames[i], 1, 20, pFile); | |
8373 } | |
8374 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
8375 | |
8376 return true; | |
8377 } | |
8378 | |
8379 //----- (004A1C1E) -------------------------------------------------------- | |
2153 | 8380 void Render::DoRenderBillboards_D3D() |
8381 { | |
8382 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
8383 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8384 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8385 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8386 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8387 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8388 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8389 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8390 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8391 { |
1390 | 8392 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; |
8393 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
8394 } | |
8395 p->pQuads[0].pos.x = 10; | |
8396 p->pQuads[0].pos.y = 10; | |
8397 | |
8398 p->pQuads[1].pos.x = 10; | |
8399 p->pQuads[1].pos.y = 200; | |
8400 | |
8401 p->pQuads[2].pos.x = 100; | |
8402 p->pQuads[2].pos.y = 200; | |
8403 | |
8404 p->pQuads[3].pos.x = 100; | |
8405 p->pQuads[3].pos.y = 10; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8406 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8407 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8408 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8409 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8410 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8411 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8412 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 8413 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8414 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8415 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8416 }*/ |
0 | 8417 |
2153 | 8418 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) |
8419 { | |
2155 | 8420 if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend) |
8421 SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity); | |
2114 | 8422 |
2153 | 8423 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture); |
8424 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
8425 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8426 pBillboardRenderListD3D[i].pQuads, pBillboardRenderListD3D[i].uNumVertices, | |
8427 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); | |
8428 } | |
8429 | |
8430 if (bFogEnabled) | |
8431 { | |
8432 bFogEnabled = false; | |
8433 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8434 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8435 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8436 } | |
8437 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
8438 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8439 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8440 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8441 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8442 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8443 } |
8444 | |
8445 //----- (004A1DA8) -------------------------------------------------------- | |
2153 | 8446 void Render::SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) |
0 | 8447 { |
8448 switch (a1) | |
8449 { | |
8450 case RenderBillboardD3D::Transparent: | |
8451 { | |
2153 | 8452 if (bFogEnabled) |
8453 { | |
8454 bFogEnabled = false; | |
8455 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8456 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
8457 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8458 } | |
8459 | |
8460 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
8461 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
8462 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 8463 } |
8464 break; | |
8465 | |
8466 case RenderBillboardD3D::Opaque_1: | |
8467 case RenderBillboardD3D::Opaque_2: | |
8468 case RenderBillboardD3D::Opaque_3: | |
8469 { | |
2153 | 8470 if (bUsingSpecular) |
8471 { | |
8472 if (!bFogEnabled) | |
0 | 8473 { |
2153 | 8474 bFogEnabled = true; |
8475 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
186 | 8476 } |
8477 } | |
8478 | |
2153 | 8479 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
8480 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8481 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 8482 } |
8483 break; | |
8484 | |
8485 default: | |
8486 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8487 assert(false); |
0 | 8488 break; |
8489 } | |
1787 | 8490 } |
1903 | 8491 //----- (00424CD7) -------------------------------------------------------- |
8492 int ODM_NearClip(unsigned int num_vertices) | |
8493 { | |
8494 bool current_vertices_flag; // edi@1 | |
8495 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 | |
8496 double t; // st6@10 | |
2320 | 8497 bool bFound; |
8498 | |
8499 bFound = false; | |
1903 | 8500 |
8501 if (!num_vertices) | |
8502 return 0; | |
2320 | 8503 for (uint i = 0; i < num_vertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû |
8504 { | |
8505 if ( array_50AC10[i].vWorldViewPosition.x > 8.0 ) | |
8506 { | |
8507 bFound = true; | |
8508 break; | |
8509 } | |
8510 } | |
8511 if ( !bFound ) | |
8512 return 0; | |
1903 | 8513 |
2318 | 8514 memcpy(&array_50AC10[num_vertices], &array_50AC10[0], sizeof(array_50AC10[0])); |
8515 current_vertices_flag = false; | |
8516 next_vertices_flag = false; | |
8517 if ( array_50AC10[0].vWorldViewPosition.x <= 8.0 ) | |
8518 current_vertices_flag = true; | |
2320 | 8519 //check for near clip plane(ïðîâåðêà ïî áëèæíåé ãðàíèöå) |
8520 // | |
8521 // v3.__________________. v0 | |
8522 // | | | |
8523 // | | | |
8524 // | | | |
8525 // ----------------------- 8.0(near_clip - 8.0) | |
8526 // | | | |
8527 // .__________________. | |
8528 // v2 v1 | |
1903 | 8529 |
8530 int out_num_vertices = 0; | |
8531 for (int i = 0; i < num_vertices; ++i) | |
8532 { | |
2318 | 8533 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x <= 8.0;// |
8534 if ( current_vertices_flag ^ next_vertices_flag ) | |
8535 { | |
8536 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé | |
1903 | 8537 { |
2191 | 8538 //t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) |
1903 | 8539 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
2318 | 8540 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; |
8541 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t; | |
8542 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t; | |
8543 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t; | |
8544 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t; | |
8545 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
8546 } | |
8547 else// òåêóùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé | |
8548 { | |
8549 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); | |
8550 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; | |
8551 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t; | |
8552 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t; | |
8553 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t; | |
8554 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t; | |
8555 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
8556 } | |
1904 | 8557 //array_507D30[out_num_vertices]._rhw = 0x3E000000u; |
1903 | 8558 ++out_num_vertices; |
8559 } | |
2318 | 8560 if ( !next_vertices_flag ) |
8561 { | |
8562 memcpy(&array_507D30[out_num_vertices], &array_50AC10[i + 1], sizeof(array_50AC10[i + 1])); | |
8563 out_num_vertices++; | |
1903 | 8564 } |
8565 current_vertices_flag = next_vertices_flag; | |
8566 } | |
8567 return out_num_vertices >= 3 ? out_num_vertices : 0; | |
8568 } | |
2321 | 8569 |
1787 | 8570 //----- (00424EE0) -------------------------------------------------------- |
1903 | 8571 int ODM_FarClip(unsigned int uNumVertices) |
1787 | 8572 { |
2318 | 8573 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 |
8574 bool next_vertices_flag; // edi@1 | |
1787 | 8575 double t; // st6@10 |
8576 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 | |
2318 | 8577 bool bFound; |
1787 | 8578 //Äîï èíôî "Ïðîãðàììèðîâàíèå òð¸õìåðíûõ èãð äëÿ windows" Ëàìîò ñòð 910 |
8579 | |
2318 | 8580 bFound = false; |
8581 | |
8582 memcpy(&array_50AC10[uNumVertices], &array_50AC10[0], sizeof(array_50AC10[uNumVertices])); | |
1787 | 8583 depth_num_vertices = 0; |
2318 | 8584 current_vertices_flag = false; |
8585 if ( array_50AC10[0].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist ) | |
8586 current_vertices_flag = true;//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè | |
1787 | 8587 if ( (signed int)uNumVertices <= 0 ) |
8588 return 0; | |
2318 | 8589 for (uint i = 0; i < uNumVertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû |
8590 { | |
8591 if ( array_50AC10[i].vWorldViewPosition.x < pODMRenderParams->shading_dist_mist ) | |
8592 { | |
8593 bFound = true; | |
8594 break; | |
8595 } | |
8596 } | |
8597 if ( !bFound ) | |
8598 return 0; | |
8599 //check for far clip plane(ïðîâåðêà ïî äàëüíåé ãðàíèöå) | |
8600 // | |
8601 // v3.__________________. v0 | |
8602 // | | | |
8603 // | | | |
8604 // | | | |
8605 // ----------------------- 8192.0(far_clip - 0x2000) | |
8606 // | | | |
8607 // .__________________. | |
8608 // v2 v1 | |
8609 | |
8610 for ( uint i = 0; i < uNumVertices; ++i ) | |
8611 { | |
8612 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist; | |
8613 if ( current_vertices_flag ^ next_vertices_flag )//îäíà èç ãðàíåé çà ãðàíèöåé âèäèìîñòè | |
8614 { | |
8615 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(íàñòîÿùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v3 | |
8616 { | |
8617 //t = far_clip - v2.x / v3.x - v2.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
2320 | 8618 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); |
2318 | 8619 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; |
8620 //New_y = v2.y + (v3.y - v2.y)*t | |
2320 | 8621 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 | 8622 //New_z = v2.z + (v3.z - v2.z)*t |
2320 | 8623 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t; |
8624 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t; | |
8625 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t; | |
2318 | 8626 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; |
8627 } | |
8628 else//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(ñëåäóþùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v0 | |
1787 | 8629 { |
8630 //t = far_clip - v1.x / v0.x - v1.x | |
2318 | 8631 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
8632 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; | |
8633 //New_y = (v0.y - v1.y)*t + v1.y | |
2320 | 8634 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 | 8635 //New_z = (v0.z - v1.z)*t + v1.z |
2320 | 8636 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t; |
8637 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t; | |
8638 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t; | |
2318 | 8639 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; |
8640 } | |
1787 | 8641 ++depth_num_vertices; |
8642 } | |
2318 | 8643 if ( !next_vertices_flag )//îáà â ãðàíèöå âèäèìîñòè |
8644 { | |
8645 memcpy(&array_507D30[depth_num_vertices], &array_50AC10[i + 1], sizeof(array_507D30[depth_num_vertices])); | |
8646 depth_num_vertices++; | |
8647 } | |
8648 current_vertices_flag = next_vertices_flag; | |
8649 } | |
8650 return depth_num_vertices >= 3 ? depth_num_vertices : 0; | |
1787 | 8651 } |
8652 | |
8653 //----- (0047840D) -------------------------------------------------------- | |
8654 void Render::DrawBuildingsD3D() | |
8655 { | |
8656 int v9; // ecx@8 | |
8657 Texture *pFaceTexture; // eax@10 | |
8658 unsigned int v16; // edi@22 | |
8659 int v27; // eax@57 | |
2334 | 8660 // int vertex_id; // eax@58 |
1787 | 8661 unsigned int v34; // eax@80 |
8662 int v40; // [sp-4h] [bp-5Ch]@2 | |
8663 int v49; // [sp+2Ch] [bp-2Ch]@10 | |
8664 int v50; // [sp+30h] [bp-28h]@34 | |
8665 int v51; // [sp+34h] [bp-24h]@35 | |
8666 int v52; // [sp+38h] [bp-20h]@36 | |
8667 int v53; // [sp+3Ch] [bp-1Ch]@8 | |
8668 int uNumVertices; // [sp+4Ch] [bp-Ch]@34 | |
8669 int unused; // [sp+50h] [bp-8h]@3 | |
8670 | |
8671 if ( !pRenderer->pRenderD3D ) | |
8672 { | |
8673 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); | |
8674 } | |
8675 | |
8676 unused = 0; | |
8677 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
8678 { | |
8679 for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++ ) | |
8680 { | |
8681 if ( IsBModelVisible(model_id, &unused) ) | |
8682 { | |
8683 pOutdoor->pBModels[model_id].field_40 |= 1; | |
8684 if ( pOutdoor->pBModels[model_id].uNumFaces > 0 ) | |
8685 { | |
8686 for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ ) | |
8687 { | |
8688 if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible()) | |
8689 { | |
8690 v53 = 0; | |
8691 array_77EC08[pODMRenderParams->uNumPolygons].flags = 0; | |
8692 array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0; | |
8693 v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID; | |
8694 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME) | |
8695 v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); | |
8696 pFaceTexture = pBitmaps_LOD->GetTexture(v9); | |
8697 array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture; | |
8698 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID) | |
8699 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2; | |
1922 | 8700 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_INDOOR_SKY ) |
1787 | 8701 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
2166 | 8702 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW8 ) |
1787 | 8703 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; |
8704 else | |
8705 { | |
2166 | 8706 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW9 ) |
1787 | 8707 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8; |
8708 } | |
2166 | 8709 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_UNKNOW10) |
1787 | 8710 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000; |
8711 else | |
8712 { | |
8713 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE) | |
8714 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10u; | |
8715 } | |
8716 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU; | |
8717 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV; | |
8718 v16 = GetTickCount() >> 4; | |
8719 if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 ) | |
8720 { | |
8721 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8722 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8723 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8724 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8725 } | |
8726 else | |
8727 { | |
8728 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8729 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8730 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8731 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8732 } | |
8733 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 ) | |
8734 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8735 else | |
8736 { | |
8737 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 ) | |
8738 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8739 } | |
8740 v50 = 0; | |
8741 v49 = 0; | |
8742 uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8743 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 ) | |
8744 { | |
8745 for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ ) | |
8746 { | |
8747 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; | |
8748 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; | |
8749 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; | |
8750 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); | |
8751 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); | |
8752 } | |
8753 for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ ) | |
8754 { | |
8755 if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z ) | |
8756 ++v53; | |
8757 pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); | |
8758 if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) | |
8759 { | |
8760 if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 ) | |
8761 v49 = 1; | |
8762 else | |
8763 v50 = 1; | |
8764 } | |
8765 else | |
8766 pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); | |
8767 } | |
8768 } | |
8769 if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices ) | |
8770 LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1; | |
8771 array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8772 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8773 array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5; | |
2207 | 8774 v51 = fixpoint_mul(-pOutdoor->vSunlight.x, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x); |
8775 v53 = fixpoint_mul(-pOutdoor->vSunlight.y, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y); | |
8776 v52 = fixpoint_mul(-pOutdoor->vSunlight.z, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z); | |
8777 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - fixpoint_mul(20, v51 + v53 + v52); | |
1787 | 8778 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 ) |
8779 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0; | |
8780 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 ) | |
8781 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31; | |
8782 if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) | |
8783 return; | |
2368
91b6c0a338ad
ODMFace::IsBackfaceCulled to ODMFace::IsBackfaceNotCulled, cleaned up a bit
Grumpy7
parents:
2358
diff
changeset
|
8784 if ( ODMFace::IsBackfaceNotCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) |
1787 | 8785 { |
8786 pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1; | |
8787 array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id; | |
8788 array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id; | |
8789 v27 = 8 * (face_id | (model_id << 6)); | |
8790 LOBYTE(v27) = v27 | 6; | |
8791 array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27; | |
8792 for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id) | |
8793 { | |
8794 memcpy(&array_50AC10[vertex_id], &array_73D150[vertex_id], sizeof(array_50AC10[vertex_id])); | |
8795 array_50AC10[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001); | |
8796 } | |
8797 static stru154 static_RenderBuildingsD3D_stru_73C834; | |
8798 /*static bool __init_flag = false; | |
8799 if (!__init_flag) | |
8800 { | |
8801 __init_flag = true; | |
8802 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; | |
8803 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); | |
8804 atexit(loc_4789D4); | |
8805 }*/ | |
8806 | |
8807 v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8808 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8809 pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); | |
8810 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
8811 int v31 = 0; | |
8812 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
8813 { | |
8814 v31 = v50 ? 3 : v49 != 0 ? 5 : 0; | |
8815 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices); | |
8816 if ( pDecalBuilder->uNumDecals > 0 ) | |
8817 { | |
8818 v40 = -1; | |
8819 pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834, | |
8820 pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, array_50AC10, 0, (char)v31, -1); | |
8821 } | |
8822 } | |
8823 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
8824 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); | |
8825 if ( v50 ) | |
8826 { | |
1903 | 8827 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8828 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8829 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8830 } | |
8831 if ( v49 ) | |
8832 { | |
1903 | 8833 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); |
1787 | 8834 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; |
8835 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8836 } | |
8837 if ( uNumVertices ) | |
8838 { | |
8839 if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 ) | |
8840 { | |
8841 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C ) | |
8842 v34 = pRenderer->pHDWaterBitmapIDs[0]; | |
8843 else | |
8844 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
8845 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; | |
8846 } | |
8847 else | |
8848 v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; | |
8849 pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40); | |
8850 } | |
8851 } | |
8852 } | |
8853 } | |
8854 } | |
8855 } | |
8856 } | |
8857 } | |
8858 return; | |
1911 | 8859 } |
8860 //----- (00479543) -------------------------------------------------------- | |
1923 | 8861 void Render::DrawOutdoorSkyD3D() |
1911 | 8862 { |
8863 int v9; // eax@4 | |
8864 int v10; // ebx@4 | |
8865 int v13; // edi@6 | |
8866 int v14; // ecx@6 | |
8867 int v15; // eax@8 | |
8868 int v16; // eax@12 | |
8869 signed __int64 v17; // qtt@13 | |
8870 signed int v18; // ecx@13 | |
8871 struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1 | |
8872 int v30; // [sp+134h] [bp-30h]@1 | |
8873 int v32; // [sp+13Ch] [bp-28h]@6 | |
8874 int v33; // [sp+140h] [bp-24h]@2 | |
8875 signed __int64 v34; // [sp+144h] [bp-20h]@1 | |
8876 int v35; // [sp+148h] [bp-1Ch]@4 | |
8877 int v36; // [sp+14Ch] [bp-18h]@2 | |
8878 int v37; // [sp+154h] [bp-10h]@8 | |
8879 int v38; // [sp+158h] [bp-Ch]@1 | |
8880 int v39; // [sp+15Ch] [bp-8h]@4 | |
2120 | 8881 |
8882 v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z) | |
1911 | 8883 / ((double)pODMRenderParams->int_fov_rad + 8192.0) |
2119 | 8884 + (double)(pViewport->uScreenCenterY)); |
8885 v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192 | |
2120 | 8886 v38 = (signed __int64)((double)(pViewport->uScreenCenterY) |
1911 | 8887 - (double)pODMRenderParams->int_fov_rad |
8888 / (v34 + 0.0000001) | |
8889 * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) | |
8890 * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist | |
8891 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); | |
8892 pSkyPolygon.Create_48607B(&stru_8019C8);//çàïîëíÿåòñÿ ptr_38 | |
8893 pSkyPolygon.ptr_38->_48694B_frustum_sky(); | |
2006 | 8894 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166) |
8895 pSkyPolygon.pTexture = (Texture *)(SLOWORD(pOutdoor->sSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->sSky_TextureID)] : 0); | |
1911 | 8896 if ( pSkyPolygon.pTexture ) |
8897 { | |
8898 pSkyPolygon.dimming_level = 0; | |
8899 pSkyPolygon.uNumVertices = 4; | |
2119 | 8900 //centering(öåíòðóåì)----------------------------------------------------------------- |
2120 | 8901 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8902 pSkyPolygon.v_18.y = 0; |
2120 | 8903 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); |
1911 | 8904 |
8905 //sky wiew position(ïîëîæåíèå íåáà íà ýêðàíå)------------------------------------------ | |
8906 // X | |
8907 // 0._____________________________.3 | |
8908 // |8,8 468,8 | | |
8909 // | | | |
8910 // | | | |
8911 // Y| | | |
8912 // | | | |
8913 // |8,351 468,351 | | |
8914 // 1._____________________________.2 | |
8915 // | |
2119 | 8916 array_50AC10[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 |
8917 array_50AC10[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8918 | |
8919 array_50AC10[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 | |
8920 array_50AC10[1].vWorldViewProjY = (double)v38;//247 | |
8921 | |
8922 array_50AC10[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8923 array_50AC10[2].vWorldViewProjY = (double)v38;//247 | |
8924 | |
8925 array_50AC10[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 | |
8926 array_50AC10[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 | |
8927 | |
8928 pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8929 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8930 | |
8931 pSkyPolygon.field_24 = 0x2000000u;//maybe attributes | |
2120 | 8932 v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2) / tan(0.6457717418670654) + 0.5); |
1911 | 8933 for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i ) |
8934 { | |
8935 //rotate skydome(âðàùåíèå êóïîëà íåáà)-------------------------------------- | |
8936 //  èãðå ïðèíÿòà ñâîÿ ñèñòåìà èçìåðåíèÿ óãëîâ. Ïîëíûé óãîë (180). Çíà÷åíèþ óãëà 0 ñîîòâåòñòâóåò | |
8937 // íàïðàâëåíèå íà ñåâåð è/èëè þã (ëèáî íà âîñòîê è/èëè çàïàä), çíà÷åíèþ 65536 åäåíèöàì(0õ10000) ñîîòâåòñòâóåò óãîë 90. | |
2119 | 8938 // äâå ïåðåìåííûå õðàíÿò äàííûå ïî óãëó îáçîðà. field_14 ïî çàïàäó è âîñòîêó. field_20 ïî þãó è ñåâåðó |
1911 | 8939 // îò -25080 äî 25080 |
2207 | 8940 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8941 v35 = v39 + pSkyPolygon.ptr_38->angle_from_north; |
8942 | |
2207 | 8943 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f))); |
2120 | 8944 v36 = v39 + pSkyPolygon.ptr_38->angle_from_east; |
8945 | |
2207 | 8946 v9 = fixpoint_mul(pSkyPolygon.v_18.z, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); |
2120 | 8947 v10 = pSkyPolygon.v_18.x + v9; |
2119 | 8948 if ( v10 > 0 ) |
1911 | 8949 v10 = 0; |
2120 | 8950 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX); |
8951 v34 = -pSkyPolygon.field_24; | |
8952 v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0; | |
8953 v14 = v33 * (v30 - v32); | |
1911 | 8954 while ( 1 ) |
8955 { | |
2120 | 8956 if ( v10 ) |
1911 | 8957 { |
2120 | 8958 v37 = abs((int)v34 >> 14); |
8959 v15 = abs(v10); | |
8960 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportTL_Y ) | |
8961 { | |
8962 if ( v10 <= 0 ) | |
8963 break; | |
8964 } | |
1911 | 8965 } |
2207 | 8966 v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14); |
1911 | 8967 --v32; |
8968 v14 += v33; | |
8969 v10 = pSkyPolygon.v_18.x + v16; | |
8970 } | |
8971 LODWORD(v17) = LODWORD(v34) << 16; | |
2120 | 8972 HIDWORD(v17) = v34 >> 16; |
8973 v18 = v17 / v10; | |
1911 | 8974 if ( v18 < 0 ) |
8975 v18 = pODMRenderParams->shading_dist_mist; | |
2207 | 8976 v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v13); |
8977 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v37, v18) >> 3); | |
2120 | 8978 array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0); |
8979 | |
2207 | 8980 v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v13); |
8981 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v36, v18) >> 3); | |
2120 | 8982 array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0); |
2119 | 8983 |
8984 array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192 | |
2120 | 8985 array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16); |
1911 | 8986 } |
1923 | 8987 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
2120 | 8988 array_50AC10[0].vWorldViewProjY = (double)v10; |
1911 | 8989 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; |
8990 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; | |
2120 | 8991 array_50AC10[3].vWorldViewProjY = (double)v10; |
1923 | 8992 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
1911 | 8993 return; |
8994 } | |
1913 | 8995 } |
8996 //----- (004226C2) -------------------------------------------------------- | |
8997 bool PauseGameDrawing() | |
8998 { | |
8999 if ( pCurrentScreen != SCREEN_GAME | |
9000 && pCurrentScreen != SCREEN_NPC_DIALOGUE | |
9001 && pCurrentScreen != SCREEN_CHANGE_LOCATION ) | |
9002 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2135
diff
changeset
|
9003 if (pCurrentScreen == SCREEN_INPUT_BLV) |
2356 | 9004 return pMovie;//pSmackerMovie != 0; |
1913 | 9005 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) |
9006 return true; | |
9007 } | |
9008 return false; | |
2154 | 9009 } |
9010 | |
9011 | |
9012 //----- (0045E03A) -------------------------------------------------------- | |
9013 unsigned short *Render::MakeScreenshot(signed int width, signed int height) | |
9014 { | |
9015 unsigned __int16 *v3; // ebx@1 | |
9016 int v4; // edx@7 | |
9017 unsigned __int8 v5; // cf@9 | |
9018 unsigned int v6; // ecx@9 | |
9019 unsigned __int16 *v7; // edi@9 | |
9020 int j; // ecx@9 | |
2334 | 9021 // unsigned int screen_x; // qax@18 |
9022 // HRESULT v14; // eax@21 | |
9023 // int v15; // edi@29 | |
9024 // signed __int64 v16; // qax@30 | |
9025 // signed int v17; // edx@34 | |
9026 // unsigned __int16 *v18; // edi@36 | |
9027 // int k; // ecx@36 | |
2154 | 9028 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 |
9029 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 | |
9030 float interval_x; // [sp+84h] [bp-20h]@1 | |
2334 | 9031 //unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 |
2154 | 9032 float interval_y; // [sp+8Ch] [bp-18h]@1 |
2334 | 9033 // unsigned int screen_y; // [sp+90h] [bp-14h]@17 |
9034 // int v28; // [sp+98h] [bp-Ch]@16 | |
9035 // int v29; // [sp+9Ch] [bp-8h]@15 | |
2154 | 9036 |
9037 interval_x = game_viewport_width / (double)width; | |
9038 interval_y = game_viewport_height / (double)height; | |
9039 | |
9040 pPixels = (unsigned __int16 *)malloc(2 * height * width); | |
9041 memset(pPixels, 0 , 2 * height * width); | |
9042 | |
9043 v3 = pPixels; | |
9044 | |
2182 | 9045 BeginSceneD3D(); |
9046 | |
9047 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9048 pIndoor->Draw(); | |
9049 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
9050 pOutdoor->Draw(); | |
9051 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
9052 memset(&Dst, 0, 0x7C); | |
9053 Dst.dwSize = sizeof(Dst); | |
9054 | |
9055 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
9056 { | |
9057 for (uint y = 0; y < height; ++y) | |
9058 { | |
9059 for (uint x = 0; x < width; ++x) | |
9060 { | |
9061 //*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 | 9062 /* |
9063 if (ddpfPrimarySuface.dwRGBBitCount == 32) | |
9064 { | |
9065 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
9066 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
9067 } | |
9068 else if (ddpfPrimarySuface.dwRGBBitCount == 16) | |
9069 { | |
9070 auto p = (unsigned __int16 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; | |
9071 *v3 = *p; | |
9072 } | |
9073 */ | |
9074 pRenderer->pTargetSurface; | |
2182 | 9075 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) |
2154 | 9076 { |
2182 | 9077 auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch; |
9078 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
9079 } | |
9080 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) | |
9081 { | |
9082 auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; | |
9083 *v3 = *p; | |
2154 | 9084 } |
2182 | 9085 else __debugbreak(); |
9086 ++v3; | |
9087 } | |
9088 } | |
9089 ErrD3D(pBackBuffer4->Unlock(0)); | |
9090 } | |
9091 else | |
9092 { | |
9093 __debugbreak(); // unrefactored - black screenshot | |
9094 v4 = height; | |
9095 if ( height > 0 ) | |
9096 { | |
9097 do | |
9098 { | |
9099 if ( width > 0 ) | |
2154 | 9100 { |
2182 | 9101 v5 = width & 1; |
9102 v6 = (unsigned int)width / 2; | |
9103 memset(v3, 0, 4 * ((unsigned int)width / 2)); | |
9104 v7 = &v3[2 * v6]; | |
9105 for ( j = v5; j; --j ) | |
2154 | 9106 { |
2182 | 9107 *v7 = 0; |
9108 ++v7; | |
2154 | 9109 } |
2182 | 9110 v3 += width; |
2154 | 9111 } |
2182 | 9112 --v4; |
9113 } | |
9114 while ( v4 ); | |
9115 } | |
9116 } | |
9117 | |
2154 | 9118 /*if (!pRenderer->pRenderD3D) |
9119 { | |
9120 pRenderer->BeginScene(); | |
9121 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
9122 { | |
9123 pIndoor->Draw(); | |
9124 } | |
9125 else | |
9126 { | |
9127 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
9128 pOutdoor->Draw(); | |
9129 } | |
9130 _this = pRenderer->pTargetSurface; | |
9131 v26 = pRenderer->uTargetSurfacePitch; | |
9132 if ( pRenderer->pTargetSurface ) | |
9133 { | |
9134 if ( height > 0 ) | |
9135 { | |
9136 for ( v29 = 0; v29 < height; ++v29 ) | |
9137 { | |
9138 if ( width > 0 ) | |
9139 { | |
9140 v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); | |
9141 for ( v28 = 0; v28 < width; v28++ ) | |
9142 { | |
9143 *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)]; | |
9144 ++v3; | |
9145 } | |
9146 } | |
9147 } | |
9148 } | |
9149 } | |
9150 else | |
9151 { | |
9152 if ( height > 0 ) | |
9153 { | |
9154 for ( v17 = height; v17; --v17 ) | |
9155 { | |
9156 if ( width > 0 ) | |
9157 { | |
9158 memset(v3, 0, 4 * ((unsigned int)width >> 1)); | |
9159 v18 = &v3[2 * ((unsigned int)width >> 1)]; | |
9160 for ( k = width & 1; k; --k ) | |
9161 { | |
9162 *v18 = 0; | |
9163 ++v18; | |
9164 } | |
9165 v3 += width; | |
9166 } | |
9167 } | |
9168 } | |
9169 } | |
9170 pRenderer->EndScene(); | |
9171 }*/ | |
9172 return pPixels; | |
9173 } | |
9174 //----- (0045E26C) -------------------------------------------------------- | |
9175 void Render::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height) | |
9176 { | |
9177 auto pixels = pRenderer->MakeScreenshot(width, height); | |
9178 pRenderer->SavePCXImage(pFilename, pixels, width, height); | |
9179 free(pixels); | |
9180 } | |
9181 | |
9182 void Render::PackScreenshot(unsigned int width, unsigned int height, void *data, unsigned int data_size, unsigned int *out_screenshot_size) | |
9183 { | |
9184 auto pixels = pRenderer->MakeScreenshot(150, 112); | |
9185 pRenderer->PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size); | |
9186 free(pixels); | |
9187 } | |
2155 | 9188 |
9189 | |
9190 //----- (0046A7C8) -------------------------------------------------------- | |
2182 | 9191 int Render::_46À6ÀÑ_GetActorsInViewport(int pDepth) |
9192 { | |
9193 unsigned int v3; // eax@2 ïðèìåíÿåòñÿ â çàêëå Æàð ïå÷è äëÿ ïîäñ÷¸òà êîë-âà ìîíñòðîâ âèäèìûõ ãðóïïå è çàïîëíåíèÿ ìàññèâà id âèäèìûõ ìîíñòðîâ | |
2155 | 9194 unsigned int v5; // eax@2 |
9195 unsigned int v6; // eax@4 | |
9196 unsigned int v12; // [sp+10h] [bp-14h]@1 | |
2182 | 9197 int mon_num; // [sp+1Ch] [bp-8h]@1 |
2155 | 9198 unsigned int a1a; // [sp+20h] [bp-4h]@1 |
9199 | |
2182 | 9200 mon_num = 0; |
2155 | 9201 v12 = GetBillboardDrawListSize(); |
9202 if ( (signed int)GetBillboardDrawListSize() > 0 ) | |
9203 { | |
9204 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) | |
9205 { | |
9206 v3 = GetParentBillboardID(a1a); | |
9207 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; | |
9208 if ( PID_TYPE(v5) == OBJECT_Actor) | |
9209 { | |
2182 | 9210 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) ) |
2155 | 9211 { |
9212 v6 = PID_ID(v5); | |
9213 if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed | |
9214 && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) | |
9215 { | |
2182 | 9216 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) ) |
2155 | 9217 { |
2182 | 9218 if ( mon_num < 100 ) |
2155 | 9219 { |
2182 | 9220 _50BF30_actors_in_viewport_ids[mon_num] = v6; |
9221 mon_num++; | |
2155 | 9222 } |
9223 } | |
9224 } | |
9225 } | |
9226 } | |
9227 } | |
9228 } | |
2182 | 9229 return mon_num; |
2155 | 9230 } |
9231 | |
9232 | |
9233 | |
9234 | |
9235 void Render::BeginLightmaps() | |
9236 { | |
9237 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9238 | |
9239 if (bUsingSpecular) | |
9240 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); | |
9241 | |
9242 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9243 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9244 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9245 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9246 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9247 } | |
9248 | |
9249 void Render::EndLightmaps() | |
9250 { | |
9251 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9252 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9253 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9254 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9255 | |
9256 if (bUsingSpecular) | |
9257 { | |
9258 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9259 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor)); | |
9260 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
9261 } | |
9262 } | |
9263 | |
9264 | |
9265 void Render::BeginLightmaps2() | |
9266 { | |
9267 if (bUsingSpecular) | |
9268 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9269 | |
9270 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9271 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9272 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9273 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9274 | |
9275 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9276 | |
9277 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9278 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9279 } | |
9280 | |
9281 | |
9282 void Render::EndLightmaps2() | |
9283 { | |
9284 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9285 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9286 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9287 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9288 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9289 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9290 | |
9291 if (bUsingSpecular) | |
9292 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9293 } | |
9294 | |
9295 | |
9296 | |
9297 //----- (00437C96) -------------------------------------------------------- | |
9298 void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) | |
9299 { | |
9300 double v6; // st7@2 | |
9301 //IDirect3DDevice3 *v7; // eax@2 | |
2334 | 9302 // HRESULT v8; // eax@2 |
2155 | 9303 std::string v9; // [sp-18h] [bp-60h]@3 |
2334 | 9304 // const char *v10; // [sp-Ch] [bp-54h]@2 |
9305 // const char *v11; // [sp-8h] [bp-50h]@2 | |
9306 // int v12; // [sp-4h] [bp-4Ch]@2 | |
2155 | 9307 RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2 |
9308 | |
9309 //if ( pRenderer->pRenderD3D ) | |
9310 { | |
9311 v6 = 0.001 - z_stuff; | |
9312 memcpy(v13, pLineBegin, 0x20u); | |
9313 memcpy(&v13[1], pLineEnd, sizeof(v13[1])); | |
9314 v13[0].pos.z = v6; | |
9315 v13[1].pos.z = v6; | |
9316 v13[0].diffuse = sDiffuseBegin; | |
9317 v13[1].diffuse = sDiffuseEnd; | |
9318 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9319 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
9320 D3DPT_LINELIST, | |
9321 452, | |
9322 v13, | |
9323 2, | |
9324 16)); | |
9325 } | |
9326 } | |
9327 | |
9328 | |
9329 void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9330 { | |
9331 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9332 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, | |
9333 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9334 (void *)vertices, | |
9335 num_vertices, | |
9336 D3DDP_DONOTLIGHT)); | |
9337 } | |
9338 | |
9339 | |
9340 void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9341 { | |
9342 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
9343 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); | |
9344 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9345 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9346 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9347 | |
9348 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9349 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9350 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9351 (void *)vertices, | |
9352 num_vertices, | |
9353 28)); | |
9354 | |
9355 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9356 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9357 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9358 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); | |
9359 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9360 } | |
9361 | |
9362 | |
9363 void Render::BeginDecals() | |
9364 { | |
9365 // code chunk from 0049C304 | |
9366 if (bUsingSpecular) | |
9367 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9368 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9369 | |
9370 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9371 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9372 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9373 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9374 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9375 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9376 | |
9377 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); | |
9378 } | |
9379 | |
9380 | |
9381 void Render::EndDecals() | |
9382 { | |
9383 // code chunk from 0049C304 | |
9384 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9385 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9386 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9387 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9388 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9389 | |
9390 if (bUsingSpecular) | |
9391 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9392 } | |
9393 | |
9394 | |
9395 | |
9396 //----- (0049C095) -------------------------------------------------------- | |
9397 void Render::DrawDecal(Decal *pDecal, float z_bias) | |
9398 { | |
9399 signed int v21; // [sp+Ch] [bp-864h]@15 | |
9400 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6 | |
9401 | |
9402 if (pDecal->uNumVertices < 3) | |
9403 { | |
9404 Log::Warning(L"Decal has < 3 vertices"); | |
9405 return; | |
9406 } | |
9407 | |
9408 float color_mult; | |
9409 if ( pDecal->field_C1C & 1 ) | |
9410 color_mult = 1.0; | |
9411 else | |
9412 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time(); | |
9413 | |
9414 for (uint i = 0; i < pDecal->uNumVertices; ++i) | |
9415 { | |
9416 uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr); | |
9417 | |
9418 uint uTintR = (uTint >> 16) & 0xFF, | |
9419 uTintG = (uTint >> 8) & 0xFF, | |
9420 uTintB = uTint & 0xFF; | |
9421 | |
9422 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF, | |
9423 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF, | |
9424 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF; | |
9425 | |
9426 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f), | |
9427 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f), | |
9428 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f); | |
9429 | |
9430 | |
9431 float v15; | |
9432 if (fabs(z_bias) < 1e-5) | |
9433 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); | |
9434 else | |
9435 { | |
9436 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; | |
9437 if (v15 < 0.000099999997) | |
9438 v15 = 0.000099999997; | |
9439 } | |
9440 | |
9441 pVerticesD3D[i].pos.z = v15; | |
9442 | |
9443 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX; | |
9444 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY; | |
9445 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u; | |
9446 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v; | |
9447 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB; | |
9448 pVerticesD3D[i].specular = 0; | |
9449 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x; | |
9450 } | |
9451 | |
9452 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9453 v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; | |
9454 else | |
9455 v21 = D3DDP_DONOTLIGHT; | |
9456 | |
9457 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9458 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9459 pVerticesD3D, | |
9460 pDecal->uNumVertices, | |
9461 v21)); | |
9462 } | |
9463 | |
9464 | |
9465 void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) | |
9466 { | |
9467 ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture)); | |
9468 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9469 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9470 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9471 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9472 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9473 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9474 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
9475 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9476 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9477 (void *)vertices, 4, 28)); | |
9478 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9479 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9480 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9481 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9482 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9483 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
9484 } |