Mercurial > mm7
annotate Render.cpp @ 1391:cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
stru148 -> struct Polygon
author | Nomad |
---|---|
date | Thu, 18 Jul 2013 14:42:54 +0200 |
parents | 613c77e51e38 |
children | 8ea496564034 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
4 |
140 | 5 #include <assert.h> |
6 | |
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 "Render.h" |
17 #include "OutdoorCamera.h" | |
18 #include "IndoorCamera.h" | |
19 #include "Outdoor.h" | |
20 #include "Party.h" | |
21 #include "LOD.h" | |
22 #include "Viewport.h" | |
23 #include "Math.h" | |
24 #include "PaletteManager.h" | |
25 #include "Time.h" | |
26 #include "Game.h" | |
27 #include "LightmapBuilder.h" | |
28 #include "stru220.h" | |
29 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
30 #include "SpriteObject.h" |
0 | 31 #include "DecorationList.h" |
32 #include "Allocator.h" | |
33 #include "OSInfo.h" | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
34 #include "Actor.h" |
0 | 35 #include "Log.h" |
179 | 36 #include "TileFrameTable.h" |
189 | 37 #include "texts.h" |
0 | 38 #include "mm7_data.h" |
860 | 39 #include "MM7.h" |
1262 | 40 #include "Lights.h" |
0 | 41 |
42 #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | |
43 #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | |
44 | |
45 struct IDirectDrawClipper *pDDrawClipper; | |
46 struct Render *pRenderer; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
47 struct RenderVertexD3D3 pVertices[50]; |
0 | 48 int uNumDecorationsDrawnThisFrame; // weak |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
49 RenderBillboard pBillboardRenderList[500]; |
0 | 50 unsigned int uNumBillboardsToDraw; |
51 int uNumSpritesDrawnThisFrame; // weak | |
52 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
53 RenderVertexSoft array_507D30[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
54 RenderVertexSoft array_508690[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
55 RenderVertexSoft array_508FF0[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
56 RenderVertexSoft array_509950[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
57 RenderVertexSoft array_50A2B0[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
58 RenderVertexSoft array_50AC10[50]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
59 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
60 RenderVertexSoft array_73D150[20]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
61 |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
62 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 63 |
64 RenderVertexSoft *ptr_801A04; | |
65 RenderVertexSoft *ptr_801A08; | |
66 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
67 RenderVertexSoft pVerticesSR_801A10[384]; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
68 RenderVertexSoft pVerticesSR_806210[384]; |
0 | 69 |
70 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
71 | |
72 /* 384 */ | |
73 #pragma pack(push, 1) | |
74 struct PCXHeader_1 | |
75 { | |
76 char manufacturer; | |
77 char version; | |
78 char encoding; | |
79 char bpp; | |
80 __int16 left; | |
81 __int16 up; | |
82 __int16 right; | |
83 __int16 bottom; | |
84 __int16 hdpi; | |
85 __int16 vdpi; | |
86 }; | |
87 #pragma pack(pop) | |
88 | |
89 /* 385 */ | |
90 #pragma pack(push, 1) | |
91 struct PCXHeader_2 | |
92 { | |
93 char reserved; | |
94 char planes; | |
95 __int16 pitch; | |
96 __int16 palette_info; | |
97 }; | |
98 #pragma pack(pop) | |
99 | |
100 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
101 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
102 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
103 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
104 | |
105 //----- (0049E79F) -------------------------------------------------------- | |
106 bool __cdecl CheckTextureStages() | |
107 { | |
108 bool v0; // edi@1 | |
109 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
110 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
111 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
112 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
113 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
114 | |
115 v0 = false; | |
116 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); | |
117 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
118 | |
119 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
186 | 120 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 121 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u)); |
122 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
123 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
124 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
125 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u)); | |
126 | |
127 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
186 | 128 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
0 | 129 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u)); |
130 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u)); | |
131 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u)); | |
132 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u)); | |
133 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u)); | |
134 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u)); | |
135 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u)); | |
136 | |
137 if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
138 v0 = true; | |
139 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); | |
140 pTexture1->Release(); | |
141 pTexture2->Release(); | |
142 pSurface1->Release(); | |
143 pSurface2->Release(); | |
144 return v0; | |
145 } | |
146 | |
147 //----- (00440CB8) -------------------------------------------------------- | |
148 void Render::DrawBillboardList_BLV() | |
149 { | |
150 __int16 v2; // ax@3 | |
151 int v5; // eax@11 | |
152 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
153 | |
154 soft_billboard.uParentBillboardID = -1; | |
155 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; | |
156 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
157 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
158 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
159 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
160 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
161 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
162 | |
617 | 163 pOutdoorCamera->uNumBillboards = ::uNumBillboardsToDraw; |
164 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) | |
0 | 165 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
166 auto p = pBillboardRenderList + i; |
0 | 167 |
168 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
169 soft_billboard.uParentBillboardID = i; | |
170 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
171 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
|
172 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 173 soft_billboard.sZValue = p->sZValue; |
174 soft_billboard.uFlags = p->field_1E; | |
175 soft_billboard.uTintColor = p->uTintColor; | |
176 v2 = p->uHwSpriteID; | |
177 if ( v2 != -1 ) | |
178 { | |
179 if ( pRenderer->pRenderD3D ) | |
657 | 180 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 181 else |
182 { | |
657 | 183 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 184 if (p->field_1E & 0x0100) |
185 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
186 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
187 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
188 v5 = p->uHwSpriteID; | |
189 if ( v5 >= 0 ) | |
733 | 190 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 191 } |
192 } | |
193 } | |
194 } | |
195 | |
196 //----- (004A16A5) -------------------------------------------------------- | |
197 bool __cdecl AreRenderSurfacesOk() | |
198 { | |
199 char v0; // zf@4 | |
200 bool result; // eax@8 | |
201 | |
202 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
203 { | |
204 if ( !pRenderer->pBackBuffer4 ) | |
205 goto LABEL_9; | |
206 v0 = pRenderer->pFrontBuffer4 == 0; | |
207 } | |
208 else | |
209 { | |
210 if ( !pRenderer->pBackBuffer2 ) | |
211 goto LABEL_9; | |
212 v0 = pRenderer->pFrontBuffer2 == 0; | |
213 } | |
214 if ( !v0 ) | |
215 { | |
216 LOBYTE(result) = 1; | |
217 return result; | |
218 } | |
219 LABEL_9: | |
220 LOBYTE(result) = 0; | |
221 return result; | |
222 } | |
223 | |
988 | 224 |
1338 | 225 void Render::RenderTerrainD3D() // New function |
86 | 226 { |
227 char result; // al@3 | |
228 int v6; // ecx@8 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
229 struct Polygon *pTile; // ebx@8 |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
230 struct Polygon *v16; |
86 | 231 unsigned int v18; // edi@22 |
232 int v35; // edi@63 | |
233 int v37; // eax@73 | |
234 int v39; // eax@80 | |
235 char v40; // [sp-18h] [bp-70h]@2 | |
236 int v41; // [sp-14h] [bp-6Ch]@2 | |
237 int v42; // [sp-10h] [bp-68h]@2 | |
238 int v43; // [sp-Ch] [bp-64h]@2 | |
239 const char *v44; // [sp-8h] [bp-60h]@2 | |
240 int v45; // [sp-4h] [bp-5Ch]@2 | |
241 int v56; | |
242 int v57; // [sp+38h] [bp-20h]@36 | |
243 int v64; // [sp+57h] [bp-1h]@2 | |
244 int v62; | |
186 | 245 |
246 //warning: the game uses CW culling by default, ccw is incosistent | |
247 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
248 | |
1338 | 249 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ |
250 | |
251 //Ãåíåðàöèÿ ìåñòîïîëîæåíèÿ âåðøèí------------------------------------------------------------------------- | |
252 //ðåø¸òêà âåðøèí äåëèòñÿ íà äâå ÷àñòè îò -64 äî 0 è îò 0 äî 64 | |
253 // | |
254 // -64 X 0 64 | |
255 // --------------- 64 | |
256 // | | | | |
257 // | | | | |
258 // | | | | |
259 // 0|------+------| Z | |
260 // | | | | |
261 // | | | | |
262 // | | | | |
263 // --------------- | |
264 // -64 | |
265 | |
266 int blockScale = 512; | |
267 int heightScale = 32; | |
268 for (unsigned int z = 0; z < 128; ++z) | |
269 { | |
270 for (unsigned int x = 0; x < 128; ++x) | |
271 { | |
272 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
273 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
274 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 275 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
276 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 277 } |
278 } | |
1338 | 279 //-------------------------------------------------------------------------------------------------------------------- |
280 | |
281 // | |
1344 | 282 for (unsigned int z = 0; z < 127; ++z) |
283 { | |
284 for (unsigned int x = 0; x < 127; ++x) | |
1338 | 285 { |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
286 pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; |
1338 | 287 pTile->flags = 0; |
288 pTile->field_32 = 0; | |
289 pTile->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
290 pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTile->uTileBitmapID]; | |
291 if (pTile->uTileBitmapID == 0xFFFF) | |
106 | 292 continue; |
186 | 293 |
1338 | 294 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
295 pTile->flags = pOutdoor->GetSomeOtherTileInfo(x, z); | |
296 pTile->field_32 = 0; | |
297 pTile->field_59 = 1; | |
298 pTile->sTextureDeltaU = 0; | |
299 pTile->sTextureDeltaV = 0; | |
300 // x,z x+1,z | |
301 // .____________. | |
302 // | | | |
303 // | | | |
304 // | | | |
305 // | | | |
306 // | | | |
307 // .____________. | |
308 // x,z+1 x+1,z+1 | |
309 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
106 | 310 array_73D150[0].u = 0; |
311 array_73D150[0].v = 0; | |
1338 | 312 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z |
106 | 313 array_73D150[1].u = 1; |
314 array_73D150[1].v = 0; | |
1338 | 315 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 |
106 | 316 array_73D150[2].u = 1; |
317 array_73D150[2].v = 1; | |
1338 | 318 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 |
106 | 319 array_73D150[3].u = 0; |
320 array_73D150[3].v = 1; | |
1338 | 321 //v58 = 0; |
322 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
323 //pTile->field_32 |= 0x0001; | |
324 pTile->pODMFace = nullptr; | |
325 pTile->uNumVertices = 4; | |
326 pTile->field_59 = 5; | |
327 | |
328 //shading (çàòåíåíèå)---------------------------------------------------------------------------- | |
329 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
330 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1];//åñòü íåñîâïàäåíèå â 1 êóáèê, òåíü íàäî ïîäíÿòü íà 1 | |
638 | 331 assert(norm_idx < uNumTerrainNormals); |
332 | |
333 auto norm = pTerrainNormals + norm_idx; | |
1338 | 334 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
335 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
336 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
337 pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); | |
338 //----------------------------------------------------------------------------------------------- | |
638 | 339 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
340 ++pOutdoorCamera->uNumPolygons; |
86 | 341 ++pOutdoorCamera->field_44; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
342 assert(pOutdoorCamera->uNumPolygons < 20000); |
265 | 343 |
1338 | 344 pTile->uBModelID = 0; |
345 pTile->uBModelFaceID = 0; | |
346 pTile->field_50 = (8 * (0 | (0 << 6))) | 6; | |
347 for (unsigned int k = 0; k < pTile->uNumVertices; ++k) | |
106 | 348 { |
349 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 350 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 351 } |
140 | 352 |
1338 | 353 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))---------------------- |
186 | 354 bool transparent = false; |
1338 | 355 if ( !( pTile->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable |
356 { | |
357 if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id) | |
358 { | |
359 //transparent = false; | |
360 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
361 } | |
362 else | |
363 { | |
364 v6 = pTile->uTileBitmapID; | |
365 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5) ) | |
366 transparent = true; | |
367 } | |
179 | 368 |
140 | 369 assert(v6 < 1000); // many random crashes here |
186 | 370 |
371 // for all shore tiles - draw a tile water under them since they're half-empty | |
1338 | 372 if (!_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX |
373 pTile->DrawBorderTiles(); | |
374 | |
375 pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
376 } | |
377 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû | |
378 //pTile->DrawBorderTiles(); | |
379 //-------------------------------------------------------------------------------------------------------------------------------- | |
186 | 380 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
381 --pOutdoorCamera->uNumPolygons; |
86 | 382 --pOutdoorCamera->field_44; |
106 | 383 } |
384 } | |
385 } | |
0 | 386 |
387 //----- (0048034E) -------------------------------------------------------- | |
985 | 388 void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) |
389 { | |
390 //int v3; // esi@1 | |
0 | 391 int v4; // edi@1 |
392 int v5; // ebx@2 | |
393 int v6; // eax@2 | |
394 int v7; // eax@3 | |
395 RenderVertexSoft *v8; // edi@3 | |
396 RenderVertexSoft *v9; // ebx@4 | |
397 RenderVertexSoft *v10; // ecx@4 | |
398 float v11; // eax@6 | |
399 double v12; // ST5C_8@6 | |
400 double v13; // ST2C_8@6 | |
401 int v14; // eax@6 | |
402 double v15; // st7@6 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
403 struct Polygon *pTile; // ebx@12 |
0 | 404 unsigned __int16 v17; // ax@12 |
405 int v18; // eax@13 | |
406 signed int v22; // eax@13 | |
1338 | 407 Vec3_float_ *norm; // eax@15 |
408 //double v24; // st6@17 | |
0 | 409 double v25; // ST54_8@17 |
410 unsigned __int8 v26; // sf@17 | |
411 unsigned __int8 v27; // of@17 | |
412 double v28; // st5@19 | |
413 double v29; // st5@19 | |
414 double v30; // st5@19 | |
415 double v31; // st5@19 | |
67 | 416 struct struct8 *v32; // esi@21 |
417 double v3a; // st7@32 | |
0 | 418 int v33; // edi@38 |
419 unsigned int v34; // ecx@47 | |
420 char v35; // zf@47 | |
421 unsigned int v36; // eax@50 | |
422 int v37; // eax@54 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
423 //Polygon *v38; // ecx@55 |
0 | 424 unsigned int v39; // eax@59 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
425 struct Polygon *v40; // ebx@62 |
86 | 426 unsigned __int16 pTileBitmapsID; // ax@62 |
0 | 427 int v42; // eax@63 |
428 LightmapBuilder *v43; // ecx@63 | |
67 | 429 int v44; // eax@63 |
0 | 430 int v45; // eax@63 |
431 int v46; // eax@63 | |
432 signed int v47; // eax@63 | |
433 Vec3_float_ *v48; // eax@65 | |
434 double v49; // st6@67 | |
435 double v50; // ST4C_8@67 | |
436 double v51; // st5@71 | |
437 double v52; // st5@71 | |
438 double v53; // st5@71 | |
439 double v54; // st7@84 | |
440 unsigned int v55; // ecx@98 | |
441 unsigned int v56; // eax@101 | |
442 int v57; // eax@105 | |
443 unsigned int v58; // eax@109 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
444 struct Polygon *v59; // esi@112 |
0 | 445 unsigned __int16 v60; // ax@112 |
67 | 446 int v61; // eax@113 |
0 | 447 signed int v62; // eax@113 |
448 Vec3_float_ *v63; // eax@114 | |
449 double v64; // st6@116 | |
450 double v65; // ST3C_8@116 | |
451 double v66; // st5@120 | |
452 double v67; // st5@120 | |
453 double v68; // st5@120 | |
454 double v69; // st7@133 | |
455 int v70; // edi@138 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
456 struct Polygon *v71; // esi@147 |
0 | 457 unsigned int v72; // ecx@147 |
458 unsigned int v73; // eax@150 | |
67 | 459 int v74; // eax@154 |
0 | 460 unsigned int v75; // eax@158 |
985 | 461 //unsigned int v76; // [sp-10h] [bp-E0h]@61 |
67 | 462 int v77; // [sp-Ch] [bp-DCh]@61 |
0 | 463 IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 |
985 | 464 //int v79; // [sp-4h] [bp-D4h]@61 |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
465 bool v80; // [sp+0h] [bp-D0h]@59 |
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
466 bool v81; // [sp+0h] [bp-D0h]@109 |
0 | 467 int v82; // [sp+54h] [bp-7Ch]@1 |
468 int v83; // [sp+60h] [bp-70h]@1 | |
469 int v84; // [sp+6Ch] [bp-64h]@1 | |
470 int v85; // [sp+70h] [bp-60h]@63 | |
1075 | 471 float a4; // [sp+74h] [bp-5Ch]@73 |
0 | 472 float v87; // [sp+78h] [bp-58h]@122 |
473 int v88; // [sp+7Ch] [bp-54h]@1 | |
474 int v89; // [sp+80h] [bp-50h]@6 | |
67 | 475 int v93; // [sp+90h] [bp-40h]@2 |
0 | 476 int X; // [sp+94h] [bp-3Ch]@1 |
477 float v95; // [sp+98h] [bp-38h]@21 | |
478 LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 | |
67 | 479 int v97; // [sp+A0h] [bp-30h]@6 |
0 | 480 int sX; // [sp+A4h] [bp-2Ch]@6 |
481 unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 | |
482 int v100; // [sp+ACh] [bp-24h]@122 | |
483 int sY; // [sp+B0h] [bp-20h]@6 | |
67 | 484 RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 |
0 | 485 unsigned int a5; // [sp+B8h] [bp-18h]@21 |
486 RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 | |
487 Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 | |
488 RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 | |
67 | 489 RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 |
0 | 490 char v108; // [sp+CFh] [bp-1h]@36 |
491 float thisd; // [sp+D8h] [bp+8h]@6 | |
492 float thise; // [sp+D8h] [bp+8h]@6 | |
493 float thisf; // [sp+D8h] [bp+8h]@17 | |
494 IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 | |
495 float thisg; // [sp+D8h] [bp+8h]@67 | |
496 IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 | |
497 float thish; // [sp+D8h] [bp+8h]@116 | |
498 IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 | |
499 char this_3; // [sp+DBh] [bp+Bh]@30 | |
500 char this_3a; // [sp+DBh] [bp+Bh]@82 | |
501 char this_3b; // [sp+DBh] [bp+Bh]@131 | |
502 | |
67 | 503 static stru154 static_sub_0048034E_stru_154; |
504 static stru154 stru_76D5A8; | |
985 | 505 //v3 = a1; |
67 | 506 v82 = a2; |
985 | 507 v83 = a3; |
508 X = abs(unk4); | |
0 | 509 v4 = 0; |
510 v88 = 0; | |
985 | 511 v84 = a1 - 1; |
1175 | 512 /* if ( a1 - 1 > 0 ) |
0 | 513 { |
514 while ( 1 ) | |
515 { | |
516 v5 = abs(X);//v5 = 13108 | |
517 v6 = abs(v83);//v6 = 13108 | |
518 --X; | |
985 | 519 //__debugbreak(); // uncoment & refactor following large if |
67 | 520 v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; |
521 /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), | |
0 | 522 v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), |
523 ((a8 = v9, | |
524 pVertices = &pVerticesSR_801A10[1] + v7, | |
525 v11 = v8->vWorldPosition.x, | |
526 v101 = v10, | |
527 v12 = v11 + 6.755399441055744e15, | |
528 sX = LODWORD(v12), | |
529 v13 = v8->vWorldPosition.y + 6.755399441055744e15, | |
530 sY = LODWORD(v13), | |
531 thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, | |
62 | 532 v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X |
0 | 533 v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, |
534 v89 = v14, | |
535 thise = v15 * 0.5, | |
62 | 536 _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z |
0 | 537 WorldPosToGridCellX(sX), |
538 WorldPosToGridCellZ(sY), | |
539 !byte_4D864C) | |
540 || !(pGame->uFlags & 0x80)) | |
67 | 541 && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ |
1175 | 542 /*if ( !&stru_76E5C8[(v5 << 7) + v6] ) |
543 goto LABEL_162*/ | |
67 | 544 v8 = &pVerticesSR_806210[v4]; |
1175 | 545 //pVertices2 = &pVerticesSR_801A10[v4 + 1]; |
546 //v102 = v8; | |
67 | 547 if (!v82) |
548 { | |
86 | 549 pVertices = &pVerticesSR_801A10[v4]; |
550 v101 = &pVerticesSR_806210[v4 + 1]; | |
67 | 551 } |
552 else | |
553 { | |
86 | 554 pVertices = &pVerticesSR_801A10[v4 + 1]; |
555 v101 = &pVerticesSR_806210[v4]; | |
556 } | |
67 | 557 sX = floorf(v8->vWorldPosition.x + 0.5f); |
558 sY = floorf(v8->vWorldPosition.z + 0.5f); | |
559 v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); | |
560 v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); | |
1175 | 561 /*WorldPosToGridCellX(sX); |
67 | 562 WorldPosToGridCellZ(sY); |
563 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) | |
86 | 564 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y |
565 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) | |
1175 | 566 break;*/ |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
567 pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; |
1338 | 568 pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); |
569 if ( pTile->uTileBitmapID != -1 ) | |
570 { | |
571 pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
572 pTile->field_32 = 0; | |
573 pTile->field_59 = 1; | |
574 pTile->terrain_grid_x = (char)v97; | |
575 pTile->field_34 = *(_WORD *)(v93 + 2); | |
576 pTile->terrain_grid_z = v89; | |
577 v22 = pTerrainNormalIndices[2 * (v97 + 128 * v89) + 1]; | |
86 | 578 if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) |
1338 | 579 norm = 0; |
86 | 580 else |
1338 | 581 norm = &pTerrainNormals[v22]; |
582 thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - | |
583 (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - | |
584 (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; | |
86 | 585 //v25 = thisf + 6.7553994e15; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
586 //v27 = pOutdoorCamera->uNumPolygons > 1999; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
587 //v26 = pOutdoorCamera->uNumPolygons - 1999 < 0; |
1338 | 588 pTile->dimming_level = floorf(thisf + 0.5f); |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
589 if ( pOutdoorCamera->uNumPolygons >= 1999 ) |
86 | 590 return; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
591 ++pOutdoorCamera->uNumPolygons; |
96 | 592 //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary |
4 | 593 //goto LABEL_126; |
96 | 594 //{ |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
595 //--pOutdoorCamera->uNumPolygons; |
96 | 596 //goto LABEL_162; |
597 //} | |
86 | 598 memcpy(&array_50AC10[0], v102, 0x30u); |
168 | 599 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 600 array_50AC10[0].u = 0.0; |
601 array_50AC10[0].v = 0.0; | |
602 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 603 array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 604 array_50AC10[1].u = 0.0; |
605 array_50AC10[1].v = 1.0; | |
606 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 607 array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 608 array_50AC10[2].u = 1.0; |
609 array_50AC10[2].v = 1.0; | |
610 memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); | |
168 | 611 array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 612 array_50AC10[3].u = 1.0; |
613 array_50AC10[3].v = 0.0; | |
614 /*if ( !(byte_76D5C0 & 1) ) | |
615 { | |
616 byte_76D5C0 |= 1u; | |
617 stru154(stru_76D5A8); | |
618 atexit(loc_481199); | |
619 }*/ | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
620 v32 = (struct8 *)array_50AC10; |
86 | 621 v97 = (int)pGame->pLightmapBuilder; |
1338 | 622 pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &v95, array_50AC10, 4, 1); |
623 pDecalBuilder->_49BE8A(pTile, norm, &v95, array_50AC10, 4, 1); | |
86 | 624 a5 = 4; |
625 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
626 { | |
627 thisa = pGame->pIndoorCameraD3D; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
628 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) |
86 | 629 goto LABEL_162; |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
630 thisa->ViewTransform(array_50AC10, a5); |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
631 thisa->Project(array_50AC10, a5, 0); |
86 | 632 } |
633 this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 | |
634 || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
635 v3a = (double)pOutdoorCamera->shading_dist_mist; | |
636 v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x | |
637 || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; | |
638 v33 = 0; | |
639 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
640 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
0 | 641 { |
86 | 642 if ( this_3 ) |
643 v33 = 3; | |
644 else | |
645 v33 = v108 != 0 ? 5 : 0; | |
1338 | 646 static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); |
86 | 647 if ( pDecalBuilder->uNumDecals > 0 ) |
1338 | 648 pDecalBuilder->ApplyDecals(31 - pTile->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); |
0 | 649 } |
86 | 650 if ( stru_F8AD28.uNumLightsApplied > 0 ) |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
651 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); |
86 | 652 v34 = a5; |
653 //v35 = byte_4D864C == 0; | |
1338 | 654 pTile->uNumVertices = a5; |
86 | 655 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) |
0 | 656 { |
86 | 657 if ( this_3 ) |
658 { | |
659 v36 = sr_424CD7(v34); | |
1338 | 660 pTile->uNumVertices = v36; |
86 | 661 OutdoorCamera::Project(v36); |
662 } | |
663 if ( v108 ) | |
664 { | |
665 v36 = sr_424EE0_MakeFanFromTriangle(v34); | |
1338 | 666 pTile->uNumVertices = v36; |
86 | 667 OutdoorCamera::Project(v36); |
668 } | |
0 | 669 } |
86 | 670 //v37 = *(int *)&v16->flags; |
1338 | 671 if ( ~pTile->flags & 1 ) |
86 | 672 { |
1338 | 673 if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 674 { |
675 v80 = false; | |
265 | 676 v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 677 } |
678 else | |
679 { | |
1338 | 680 v39 = pTile->uTileBitmapID; |
86 | 681 v80 = true; |
682 } | |
683 //v79 = 0; | |
684 //v78 = pBitmaps_LOD->pHardwareTextures[v39]; | |
1338 | 685 pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary |
686 v77 = (int)pTile; | |
86 | 687 //v76 = v16->uNumVertices; |
4 | 688 //LABEL_161: |
1338 | 689 pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); |
86 | 690 goto LABEL_162; |
691 } | |
0 | 692 LABEL_56: |
1338 | 693 pTile->DrawBorderTiles(); |
86 | 694 } |
0 | 695 LABEL_162: |
86 | 696 v4 = v88 + 1; |
697 if ( ++v88 >= v84 ) | |
698 return; | |
699 } | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
700 /* v40 = &array_77EC08[pOutdoorCamera->uNumPolygons]; |
86 | 701 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); |
702 if ( v40->uTileBitmapID == -1 ) | |
703 goto LABEL_162; | |
704 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
705 BYTE1(v42) |= 0x80u; | |
706 v43 = pGame->pLightmapBuilder; | |
707 *(int *)&v40->flags = v42; | |
708 v44 = v93; | |
709 v40->field_59 = 1; | |
638 | 710 v40->terrain_grid_x = (char)v43; |
86 | 711 v40->field_34 = *(_WORD *)(v44 + 2); |
712 v45 = v89; | |
638 | 713 v40->terrain_grid_z = v89; |
86 | 714 v46 = 4 * ((char)v43 + (v45 << 7)); |
715 v85 = v46; | |
716 v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; | |
717 if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) | |
718 v48 = 0; | |
719 else | |
720 v48 = &pTerrainNormals[v47]; | |
721 v49 = v92 * v48->y; | |
722 //v99 = v48; | |
723 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; | |
724 v50 = thisg + 6.755399441055744e15; | |
638 | 725 v40->dimming_level = LOBYTE(v50); |
86 | 726 if ( LOBYTE(v50) < 0 ) |
638 | 727 v40->dimming_level = 0; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
728 if ( pOutdoorCamera->uNumPolygons >= 1999 ) |
0 | 729 return; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
730 ++pOutdoorCamera->uNumPolygons; |
86 | 731 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary |
732 //goto LABEL_77; | |
733 { | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
734 --pOutdoorCamera->uNumPolygons; |
86 | 735 goto LABEL_112; |
736 }*/ | |
1175 | 737 /*memcpy(&array_50AC10[0], v102, 0x30u); |
168 | 738 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 739 array_50AC10[0].u = 0.0; |
740 array_50AC10[0].v = 0.0; | |
741 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 742 array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 743 array_50AC10[1].u = 0.0; |
744 array_50AC10[1].v = 1.0; | |
745 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 746 array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 747 array_50AC10[2].u = 1.0; |
748 array_50AC10[2].v = 1.0; | |
749 static stru154 static_sub_0048034E_stru_76D590; | |
750 /*static bool __init_flag2 = false; | |
751 if (!__init_flag2) | |
752 { | |
753 __init_flag2 = true; | |
754 stru154::stru154(&static_sub_0048034E_stru_76D590); | |
755 }*/ | |
756 /*if ( !(byte_76D5C0 & 2) ) | |
757 { | |
758 byte_76D5C0 |= 2; | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
759 Polygon(stru_76D590); |
86 | 760 atexit(loc_48118F); |
761 }*/ | |
1175 | 762 /*v96 = pGame->pLightmapBuilder; |
86 | 763 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); |
1075 | 764 pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); |
86 | 765 uNumVertices = 3; |
766 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
767 { | |
768 thisb = pGame->pIndoorCameraD3D; | |
769 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) | |
770 { | |
771 //LABEL_77: | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
772 --pOutdoorCamera->uNumPolygons; |
86 | 773 goto LABEL_112; |
774 } | |
775 thisb->ViewTransform(array_50AC10, uNumVertices); | |
776 thisb->Project(array_50AC10, uNumVertices, 0); | |
777 } | |
778 this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
779 v54 = (double)pOutdoorCamera->shading_dist_mist; | |
780 v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; | |
781 pVertices = 0; | |
782 v96->std__vector_000004_size = 0; | |
783 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
784 { | |
785 if ( this_3a ) | |
786 pVertices = (RenderVertexSoft *)3; | |
787 else | |
788 pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); | |
789 //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); | |
734 | 790 static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); |
86 | 791 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 792 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); |
86 | 793 } |
794 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
795 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); | |
796 v55 = uNumVertices; | |
797 //v35 = byte_4D864C == 0; | |
798 v40->uNumVertices = uNumVertices; | |
799 if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) | |
800 { | |
801 if ( this_3a ) | |
802 { | |
803 v56 = sr_424CD7(v55); | |
804 } | |
805 else | |
806 { | |
807 if ( !v108 ) | |
808 goto LABEL_105; | |
809 v56 = sr_424EE0_MakeFanFromTriangle(v55); | |
810 } | |
811 v40->uNumVertices = v56; | |
812 OutdoorCamera::Project(v56); | |
813 } | |
814 LABEL_105: | |
815 v57 = *(int *)&v40->flags; | |
816 if ( BYTE1(v57) & 1 ) | |
817 { | |
1338 | 818 v40->DrawBorderTiles(); |
86 | 819 } |
820 else | |
821 { | |
265 | 822 if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 823 { |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
824 v81 = false; |
265 | 825 v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 826 } |
827 else | |
828 { | |
829 v58 = v40->uTileBitmapID; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
830 v81 = true; |
86 | 831 } |
186 | 832 pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); |
86 | 833 } |
834 LABEL_112: | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
835 v59 = &array_77EC08[pOutdoorCamera->uNumPolygons]; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
836 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->uNumPolygons]; |
86 | 837 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); |
838 if ( v59->uTileBitmapID == -1 ) | |
839 goto LABEL_162; | |
840 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
841 v61 = v93; | |
842 v59->field_59 = 1; | |
843 v59->field_34 = *(_WORD *)(v61 + 2); | |
638 | 844 v59->terrain_grid_z = v89; |
845 v59->terrain_grid_x = v97; | |
86 | 846 v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); |
847 if ( v62 > (signed int)(uNumTerrainNormals - 1) ) | |
848 v63 = 0; | |
849 else | |
850 v63 = &pTerrainNormals[v62]; | |
851 v64 = v92 * v63->y; | |
852 //v99 = v63; | |
853 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; | |
638 | 854 v59->dimming_level = floorf(thish + 0.5f); |
855 if ( v59->dimming_level < 0 ) | |
856 v59->dimming_level = 0; | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
857 if ( pOutdoorCamera->uNumPolygons >= 1999 ) |
86 | 858 return; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
859 ++pOutdoorCamera->uNumPolygons; |
86 | 860 if ( !sub_481FC9(v101, v102, pVertices2, v59) ) |
861 { | |
862 //LABEL_126: | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
863 --pOutdoorCamera->uNumPolygons; |
86 | 864 goto LABEL_162; |
865 } | |
866 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 867 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 868 array_50AC10[0].u = 0.0; |
869 array_50AC10[0].v = 0.0; | |
870 memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); | |
168 | 871 array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 872 array_50AC10[1].u = 1.0; |
873 array_50AC10[1].v = 1.0; | |
874 memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); | |
168 | 875 array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 876 array_50AC10[2].u = 1.0; |
877 array_50AC10[2].v = 0.0; | |
878 static stru154 static_sub_0048034E_stru_76D578; | |
879 /*static bool __init_flag1 = false; | |
880 if (!__init_flag1) | |
881 { | |
882 __init_flag1 = true; | |
883 stru154::stru154(&static_sub_0048034E_stru_76D578); | |
884 }*/ | |
1175 | 885 /* v96 = pGame->pLightmapBuilder; |
86 | 886 pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); |
1075 | 887 pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); |
86 | 888 v100 = 3; |
889 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
890 { | |
891 thisc = pGame->pIndoorCameraD3D; | |
892 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) | |
893 //goto LABEL_126; | |
894 { | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
895 --pOutdoorCamera->uNumPolygons; |
86 | 896 goto LABEL_162; |
897 } | |
898 thisc->ViewTransform(array_50AC10, v100); | |
899 thisc->Project(array_50AC10, v100, 0); | |
900 } | |
901 this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 | |
902 || v101->vWorldViewPosition.x < 8.0; | |
903 v69 = (double)pOutdoorCamera->shading_dist_mist; | |
904 v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; | |
905 v70 = 0; | |
906 v96->std__vector_000004_size = 0; | |
907 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
908 { | |
909 if ( this_3b ) | |
910 v70 = 3; | |
911 else | |
912 v70 = v108 != 0 ? 5 : 0; | |
734 | 913 static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); |
86 | 914 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 915 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); |
86 | 916 } |
917 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
918 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); | |
919 v71 = v59; | |
920 v72 = v100; | |
921 //v35 = byte_4D864C == 0; | |
922 v59->uNumVertices = v100;//??? | |
923 if ( !byte_4D864C && pGame->uFlags & 0x80 ) | |
924 goto LABEL_154; | |
925 if ( this_3b ) | |
926 { | |
927 v73 = sr_424CD7(v72); | |
0 | 928 } |
929 else | |
930 { | |
931 if ( !v108 ) | |
86 | 932 { |
933 LABEL_154: | |
934 v74 = v71->flags; | |
935 if ( !(BYTE1(v74) & 1) ) | |
936 { | |
265 | 937 if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 938 { |
939 v80 = false; | |
265 | 940 v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 941 } |
942 else | |
943 { | |
944 v75 = v71->uTileBitmapID; | |
945 v80 = true; | |
946 } | |
947 //v79 = 0; | |
985 | 948 v78 = pBitmaps_LOD->pHardwareTextures[v75]; |
86 | 949 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary |
950 //v77 = (int)v71; | |
951 //v76 = v71->uNumVertices; | |
952 //goto LABEL_161; | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
953 pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80); |
86 | 954 goto LABEL_162; |
955 } | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
956 v38 = (Polygon *)v71; |
86 | 957 goto LABEL_56; |
958 } | |
959 v73 = sr_424EE0_MakeFanFromTriangle(v72); | |
960 } | |
961 v71->uNumVertices = v73; | |
962 OutdoorCamera::Project(v73); | |
0 | 963 goto LABEL_154; |
86 | 964 } |
1175 | 965 }*/ |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
966 |
0 | 967 |
968 //----- (0047BACF) -------------------------------------------------------- | |
969 void Render::TransformBillboardsAndSetPalettesODM() | |
970 { | |
142 | 971 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
972 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
973 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
974 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
975 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
976 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
977 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
978 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
979 //int v8; // ebx@4 |
0 | 980 unsigned __int16 *v9; // eax@7 |
981 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
982 //DWORD v11; // eax@13 |
0 | 983 int v12; // eax@13 |
984 int v13; // eax@14 | |
985 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
986 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 987 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
988 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 989 int v18; // [sp+60h] [bp-4h]@13 |
990 | |
991 billboard.uParentBillboardID = -1; | |
992 billboard.pTarget = pRenderer->pTargetSurface; | |
993 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
994 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 995 billboard.uViewportX = pViewport->uViewportTL_X; |
996 billboard.uViewportY = pViewport->uViewportTL_Y; | |
997 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
998 billboard.uViewportW = pViewport->uViewportBR_Y; | |
0 | 999 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; |
142 | 1000 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1001 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 1002 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1003 auto pBillboard = pBillboardRenderList + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1004 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1005 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1006 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1007 billboard.uParentBillboardID = i; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1008 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1009 billboard.uTintColor = pBillboard->uTintColor; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1010 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1011 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1012 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1013 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1014 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1015 if (pRenderer->pRenderD3D) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1016 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1017 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
657 | 1018 pBillboard->dimming_level, pBillboard); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1019 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1020 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1021 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1022 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1023 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 1024 if ( *(v1 - 10) & 2 ) |
1025 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
1026 else | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1027 v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 1028 v10 = (*(v1 - 9) & 1) == 0; |
1029 billboard.pPalette = v9; | |
1030 if ( !v10 ) | |
1031 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
1032 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
1033 { | |
323 | 1034 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 1035 v15 = abs(v12); |
1036 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
1037 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
1038 } | |
1039 v13 = *((short *)v1 - 8); | |
1040 if ( v13 >= 0 ) | |
733 | 1041 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1042 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1043 } |
0 | 1044 } |
1045 } | |
1046 | |
1047 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
1048 void Render::DrawSpriteObjects_ODM() |
0 | 1049 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1050 //char *v0; // edi@2 |
430 | 1051 //ObjectDesc *v1; // ebx@4 |
0 | 1052 __int16 v2; // cx@5 |
1053 RenderBillboard *v3; // esi@10 | |
1054 SpriteFrame *v4; // eax@10 | |
430 | 1055 //SpriteFrame *v5; // ebx@10 |
0 | 1056 unsigned int v6; // eax@10 |
430 | 1057 //int v7; // ecx@10 |
1058 //int v8; // edx@10 | |
0 | 1059 int v9; // ecx@10 |
1060 unsigned __int16 v10; // ax@10 | |
430 | 1061 //int *v11; // eax@14 |
0 | 1062 int v12; // eax@22 |
1063 int v13; // ST3C_4@23 | |
1064 int v14; // eax@23 | |
1065 int v15; // ecx@23 | |
1066 int v16; // ebx@23 | |
1067 int v17; // ecx@25 | |
1068 int v18; // eax@25 | |
1069 int v19; // ST40_4@26 | |
1070 int v20; // ecx@26 | |
1071 int v21; // ST44_4@28 | |
1072 int v22; // ST3C_4@29 | |
1073 signed __int64 v23; // qtt@30 | |
1074 int v24; // ebx@30 | |
1075 int v25; // ST3C_4@30 | |
1076 int v26; // eax@31 | |
1077 char v27; // zf@31 | |
430 | 1078 //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 |
1079 //__int16 a5; // [sp+10h] [bp-30h]@10 | |
0 | 1080 int v30; // [sp+14h] [bp-2Ch]@23 |
1081 int v31; // [sp+14h] [bp-2Ch]@29 | |
1082 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
1083 int v33; // [sp+18h] [bp-28h]@23 | |
1084 int v34; // [sp+18h] [bp-28h]@26 | |
1085 int v35; // [sp+18h] [bp-28h]@30 | |
1086 int v36; // [sp+1Ch] [bp-24h]@10 | |
1087 int v37; // [sp+1Ch] [bp-24h]@23 | |
1088 int a6; // [sp+20h] [bp-20h]@10 | |
1089 int a6a; // [sp+20h] [bp-20h]@23 | |
1090 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1091 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 1092 int v42; // [sp+2Ch] [bp-14h]@23 |
1093 int y; // [sp+30h] [bp-10h]@10 | |
1094 int x; // [sp+34h] [bp-Ch]@10 | |
1095 int z; // [sp+38h] [bp-8h]@10 | |
1096 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
1097 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1098 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
1099 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
|
1100 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1101 auto object = &pSpriteObjects[i]; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
1102 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
1103 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1104 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1105 //{ |
430 | 1106 if (!object->uObjectDescID) // item probably pciked up |
1107 continue; | |
1108 | |
1109 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
1110 auto object_desc = pObjectList->pObjects + object->uObjectDescID; | |
1111 if (object_desc->NoSprite()) | |
1112 continue; | |
1113 | |
1114 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
1115 //if ( !(v1->uFlags & 1) ) | |
1116 //{ | |
1117 //v2 = *((short *)v0 - 14) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
1118 v2 = object->uType; |
430 | 1119 if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) |
1120 { | |
1121 //a5 = *(short *)v0; | |
1122 x = object->vPosition.x; | |
1123 y = object->vPosition.y; | |
1124 z = object->vPosition.z; | |
1125 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; | |
1126 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
1127 //v5 = v4; | |
1128 //v28 = v4; | |
1129 v36 = v4->uFlags; | |
1130 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; | |
1131 v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCamera->pos.x, object->vPosition.y - pIndoorCamera->pos.y); | |
1132 //LOWORD(v7) = object->uFacing; | |
1133 //v8 = v36; | |
1134 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
1135 v10 = v4->pHwSpriteIDs[v9]; | |
0 | 1136 v3->uHwSpriteID = v10; |
1137 if ( v36 & 0x20 ) | |
1138 { | |
430 | 1139 //v8 = v36; |
1140 z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
0 | 1141 } |
1142 v46 = 0; | |
430 | 1143 if ( v36 & 2 ) |
0 | 1144 v46 = 2; |
430 | 1145 //v11 = (int *)(256 << v9); |
1146 if ( (256 << v9) & v36 ) | |
0 | 1147 v46 |= 4u; |
430 | 1148 if ( v36 & 0x40000 ) |
0 | 1149 v46 |= 0x40u; |
430 | 1150 if ( v36 & 0x20000 ) |
0 | 1151 LOBYTE(v46) = v46 | 0x80; |
1152 if ( a6 ) | |
1153 { | |
430 | 1154 //LOBYTE(v11) = byte_4E94D3; |
1155 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
0 | 1156 } |
1157 v12 = (x - pIndoorCamera->pos.x) << 16; | |
1158 if ( pIndoorCamera->sRotationX ) | |
1159 { | |
1160 v13 = (y - pIndoorCamera->pos.y) << 16; | |
1161 v30 = ((unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
1162 + ((unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
1163 v37 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
1164 a6a = (unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
1165 v33 = (z - pIndoorCamera->pos.z) << 16; | |
1166 v14 = (unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
1167 v15 = (unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
1168 v16 = v15 + v14; | |
1169 v42 = v15 + v14; | |
1170 if ( v15 + v14 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
1171 { | |
1172 v17 = a6a - v37; | |
1173 v40 = a6a - v37; | |
1174 v18 = ((unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | |
1175 - ((unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
1176 goto LABEL_29; | |
1177 } | |
1178 } | |
1179 else | |
1180 { | |
1181 v34 = (y - pIndoorCamera->pos.y) << 16; | |
1182 v19 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
1183 v20 = (unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
1184 v16 = v20 + v19; | |
1185 v42 = v20 + v19; | |
1186 if ( v20 + v19 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
1187 { | |
430 | 1188 v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; |
1189 v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
1190 v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
0 | 1191 v18 = (z - pIndoorCamera->pos.z) << 16; |
1192 LABEL_29: | |
1193 v31 = v18; | |
1194 v22 = abs(v17); | |
1195 if ( abs(v16) >= v22 ) | |
1196 { | |
1197 LODWORD(v23) = 0; | |
1198 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
1199 v24 = v23 / v42; | |
1200 v25 = v23 / v42; | |
1201 LODWORD(v23) = 0; | |
1202 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
430 | 1203 v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); |
1204 v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
1205 | |
1206 //if (::uNumBillboardsToDraw >= 500) | |
1207 // return; | |
1208 assert(::uNumBillboardsToDraw < 500); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1209 ++::uNumBillboardsToDraw; |
0 | 1210 ++uNumSpritesDrawnThisFrame; |
430 | 1211 |
1212 object->uAttributes |= 1; | |
1213 v3->uPalette = v4->uPaletteIndex; | |
1214 v3->uIndoorSectorID = object->uSectorID; | |
1215 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
1216 v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
1217 v3->pSpriteFrame = v4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1218 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 1219 v3->field_1E = v46; |
430 | 1220 v3->world_x = x; |
1221 v3->world_y = y; | |
1222 v3->world_z = z; | |
0 | 1223 v3->uScreenSpaceX = v35; |
1224 v3->uScreenSpaceY = v32; | |
1225 HIWORD(v26) = HIWORD(v42); | |
1226 LOWORD(v26) = 0; | |
430 | 1227 v27 = (object->uAttributes & 0x20) == 0; |
862 | 1228 v3->sZValue = v26 + (PID(OBJECT_Item,i)); |
657 | 1229 v3->dimming_level = 0; |
0 | 1230 v3->uTintColor = 0; |
1231 if ( !v27 ) | |
1232 { | |
1233 if ( !pRenderer->pRenderD3D ) | |
1234 v3->sZValue = 0; | |
1235 } | |
1236 } | |
1237 goto LABEL_34; | |
1238 } | |
1239 } | |
1240 } | |
430 | 1241 //} |
0 | 1242 LABEL_34: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1243 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1244 //++v41; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1245 //v0 += 112; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1246 //} |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
1247 //while ( v41 < (signed int)uNumSpriteObjects ); |
0 | 1248 } |
1249 } | |
1250 // 4E94D3: using guessed type char byte_4E94D3; | |
1251 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; | |
1252 | |
1253 //----- (0049D9BC) -------------------------------------------------------- | |
1254 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
1255 { | |
1256 size_t v4; // eax@1 | |
1257 size_t v5; // eax@1 | |
1258 IUnknown *v6; // eax@10 | |
1259 size_t v7; // eax@13 | |
1260 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
1261 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
1262 int v11; // [sp+430h] [bp-CCh]@16 | |
1263 int v12; // [sp+434h] [bp-C8h]@16 | |
1264 int v13; // [sp+438h] [bp-C4h]@16 | |
1265 int v14; // [sp+474h] [bp-88h]@16*/ | |
1266 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
1267 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
1268 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
1269 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
1270 int v19; // [sp+4C8h] [bp-34h]@16 | |
1271 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
1272 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
1273 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
1274 | |
1275 v4 = strlen(lpDriverName); | |
1276 v20.pDriverName = new char[v4 + 1]; | |
1277 v5 = strlen(lpDevDesc); | |
1278 v20.pDeviceDesc = new char[v5 + 1]; | |
1279 strcpy(v20.pDriverName, lpDriverName); | |
1280 strcpy(v20.pDeviceDesc, lpDevDesc); | |
1281 if ( lpGUID ) | |
1282 { | |
1283 v20.pGUID = new GUID; | |
1284 memcpy(v20.pGUID, lpGUID, 0x10u); | |
1285 } | |
1286 else | |
1287 { | |
1288 v20.pGUID = 0; | |
1289 } | |
1290 | |
1291 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
1292 { | |
1293 delete [] v20.pDriverName; | |
1294 delete [] v20.pDeviceDesc; | |
1295 if ( v20.pGUID ) | |
1296 delete v20.pGUID; | |
1297 } | |
1298 else | |
1299 { | |
1300 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
1301 { | |
1302 delete [] v20.pDriverName; | |
1303 delete [] v20.pDeviceDesc; | |
1304 if ( v20.pGUID ) | |
1305 delete v20.pGUID; | |
1306 v6 = (IUnknown *)pDirectDraw; | |
1307 } | |
1308 else | |
1309 { | |
1310 pDirectDraw->Release(); | |
1311 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
1312 { | |
1313 v20.pDDraw4DevDesc = 0; | |
1314 } | |
1315 else | |
1316 { | |
1317 v7 = strlen(ddDevId.szDescription); | |
1318 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
1319 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
1320 } | |
1321 memset(&ddsCaps, 0, 0x10u); | |
1322 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
1323 &ddsCaps, | |
1324 (LPDWORD)&v20.uVideoMem, | |
1325 (LPDWORD)&uFreeVideoMem))) | |
1326 v20.uVideoMem = 0; | |
1327 memset(&v10, 0, 0x7Cu); | |
1328 v10.dwSize = 124; | |
1329 v10.dwFlags = 6; | |
1330 v10.dwHeight = 640; | |
1331 v10.dwWidth = 480; | |
1332 v10.ddpfPixelFormat.dwSize = 32; | |
1333 | |
1334 v19 = 0; | |
1335 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
1336 0, | |
1337 0, | |
1338 &v19, | |
1339 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
1340 || !v19 | |
1341 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
1342 { | |
1343 delete [] v20.pDriverName; | |
1344 delete [] v20.pDeviceDesc; | |
1345 if ( v20.pDDraw4DevDesc ) | |
1346 free(v20.pDDraw4DevDesc); | |
1347 if ( v20.pGUID ) | |
1348 delete v20.pGUID; | |
1349 v6 = (IUnknown *)pDirectDraw4; | |
1350 } | |
1351 else | |
1352 { | |
1353 aux.pInfo = pOut; | |
1354 aux.ptr_4 = &v20; | |
1355 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
1356 delete [] v20.pDriverName; | |
1357 delete [] v20.pDeviceDesc; | |
1358 if ( v20.pDDraw4DevDesc ) | |
1359 free(v20.pDDraw4DevDesc); | |
1360 if ( v20.pGUID ) | |
1361 delete v20.pGUID; | |
1362 pDirectDraw4->Release(); | |
1363 v6 = (IUnknown *)pDirect3D3; | |
1364 pDirectDraw4 = 0; | |
1365 } | |
1366 } | |
1367 v6->Release(); | |
1368 } | |
1369 return 1; | |
1370 } | |
1371 | |
1372 //----- (0049D784) -------------------------------------------------------- | |
1373 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
1374 { | |
1375 int v6; // eax@1 | |
1376 signed int v7; // edi@1 | |
1377 signed int v8; // edi@14 | |
1378 size_t v9; // eax@30 | |
1379 size_t v10; // eax@30 | |
1380 size_t v11; // eax@30 | |
1381 size_t v12; // eax@30 | |
1382 size_t v13; // eax@30 | |
1383 | |
1384 v6 = pHWDesc->dwFlags; | |
1385 v7 = -1; | |
1386 if ( v6 ) | |
1387 { | |
1388 if ( !a6->ptr_4->pGUID ) | |
1389 v7 = 0; | |
1390 if ( v6 && a6->ptr_4->pGUID ) | |
1391 v7 = 1; | |
1392 } | |
1393 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
1394 v7 = 2; | |
1395 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
1396 v7 = 3; | |
1397 if ( v7 != -1 ) | |
1398 { | |
1399 v8 = v7; | |
1400 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
1401 a6->pInfo[v8].uCaps = 0; | |
1402 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
1403 a6->pInfo[v8].uCaps |= 2u; | |
1404 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
1405 a6->pInfo[v8].uCaps |= 4u; | |
1406 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
1407 a6->pInfo[v8].uCaps |= 8u; | |
1408 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
1409 a6->pInfo[v8].uCaps |= 0x10u; | |
1410 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
1411 a6->pInfo[v8].uCaps |= 0x20u; | |
1412 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
1413 a6->pInfo[v8].uCaps |= 0x40u; | |
1414 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
1415 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
1416 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
1417 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
1418 v9 = strlen(lpDeviceName); | |
1419 a6->pInfo[v8].pName = new char[v9 + 1]; | |
1420 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
1421 v10 = strlen(lpDeviceDesc); | |
1422 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
1423 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
1424 a6->pInfo[v8].pGUID = (GUID *)operator new(0x10u); | |
1425 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); | |
1426 v11 = strlen(a6->ptr_4->pDriverName); | |
1427 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
1428 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
1429 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
1430 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
1431 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
1432 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
1433 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
1434 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
1435 if ( a6->ptr_4->pGUID ) | |
1436 { | |
1437 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
1438 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
1439 } | |
1440 else | |
1441 { | |
1442 a6->pInfo[v8].pDirectDrawGUID = 0; | |
1443 } | |
1444 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
1445 } | |
1446 return 1; | |
1447 } | |
1448 | |
1449 //----- (0049D75C) -------------------------------------------------------- | |
1450 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
1451 { | |
1452 HRESULT result; // eax@3 | |
1453 | |
1454 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
1455 { | |
1456 *a2 = 1; | |
1457 result = 0; | |
1458 } | |
1459 else | |
1460 { | |
1461 result = 1; | |
1462 } | |
1463 return result; | |
1464 } | |
1465 | |
1466 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1467 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1468 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1469 //char *v0; // esi@2 |
639 | 1470 //DecorationDesc *v1; // ebx@6 |
0 | 1471 __int16 v2; // ax@6 |
1472 double v3; // st7@7 | |
639 | 1473 //int v4; // eax@9 |
1474 //int v5; // edx@9 | |
0 | 1475 unsigned int v6; // edi@9 |
1476 int v7; // eax@9 | |
1477 SpriteFrame *v8; // eax@9 | |
635 | 1478 //SpriteFrame *v9; // edi@9 |
0 | 1479 unsigned __int16 *v10; // eax@9 |
1480 int v11; // ecx@9 | |
1481 int v12; // eax@9 | |
1482 int v13; // ecx@9 | |
1483 int v14; // ecx@20 | |
1484 char v15; // dl@20 | |
1485 signed int v16; // eax@20 | |
1486 int v17; // eax@23 | |
1487 int v18; // ecx@24 | |
1488 int v19; // eax@24 | |
1489 int v20; // ecx@24 | |
1490 int v21; // ebx@26 | |
1491 int v22; // eax@26 | |
1492 int v23; // eax@30 | |
1493 signed __int64 v24; // qtt@31 | |
1494 int v25; // ebx@31 | |
1495 int v26; // ecx@32 | |
1496 RenderBillboard *v27; // eax@37 | |
1497 __int16 v28; // dx@37 | |
1498 __int16 v29; // cx@37 | |
1499 int v30; // ecx@37 | |
1500 int v31; // ebx@37 | |
619 | 1501 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
639 | 1502 //int x; // [sp+74h] [bp-30h]@9 |
1503 //int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1504 //int v35; // [sp+7Ch] [bp-28h]@1 |
639 | 1505 //int v36; // [sp+80h] [bp-24h]@9 |
0 | 1506 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
1507 int v38; // [sp+88h] [bp-1Ch]@9 | |
1508 int v39; // [sp+8Ch] [bp-18h]@24 | |
1509 int v40; // [sp+90h] [bp-14h]@24 | |
1510 int v41; // [sp+94h] [bp-10h]@24 | |
1511 int v42; // [sp+98h] [bp-Ch]@9 | |
1512 int a5; // [sp+9Ch] [bp-8h]@9 | |
1513 int b; // [sp+A0h] [bp-4h]@22 | |
1514 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1515 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1516 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1517 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1518 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1519 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1520 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1521 { |
1202 | 1522 auto decor = &pLevelDecorations[i]; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1523 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1524 |
639 | 1525 if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) ) |
1526 { | |
1527 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
1528 auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; | |
1529 v2 = decor_desc->uFlags; | |
0 | 1530 if ( (char)v2 >= 0 ) |
1531 { | |
1532 if ( !(v2 & 0x22) ) | |
1533 { | |
639 | 1534 //v4 = decor->vPosition.x; |
1535 //v5 = decor->vPosition.z; | |
0 | 1536 v6 = pMiscTimer->uTotalGameTimeElapsed; |
639 | 1537 //y = decor->vPosition.y; |
1538 //x = decor->vPosition.x; | |
1539 //v36 = decor->vPosition.z; | |
1540 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
635 | 1541 |
1542 | |
1543 #pragma region "New: seasons change" | |
1544 extern bool change_seasons; | |
1545 if (change_seasons) | |
1546 switch (pParty->uCurrentMonth) | |
1547 { | |
1548 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
1549 case 11: case 0: case 1: // winter | |
639 | 1550 switch (decor_desc->uSpriteID) |
635 | 1551 { |
1552 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
1553 case 548: // flower10 | |
1554 case 547: // flower09 | |
1555 case 541: // flower03 | |
1556 case 539: continue; // flower01 | |
1557 | |
1558 case 483: // tree01 | |
1559 case 486: // tree04 | |
1560 case 492: // tree10 | |
639 | 1561 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); |
1562 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
635 | 1563 break; |
1564 | |
1565 default: | |
639 | 1566 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1567 } |
1568 break; | |
1569 | |
1570 case 2: case 3: case 4: // spring | |
639 | 1571 switch (decor_desc->uSpriteID) |
635 | 1572 { |
1573 } | |
639 | 1574 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1575 break; |
1576 | |
1577 case 8: case 9: case 10: // autumn | |
639 | 1578 switch (decor_desc->uSpriteID) |
635 | 1579 { |
1580 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
1581 case 548: // flower10 | |
1582 case 547: // flower09 | |
1583 case 541: // flower03 | |
1584 case 539: continue; // flower01 | |
1585 | |
1586 case 483: // tree01 | |
1587 case 486: // tree04 | |
1588 case 492: // tree10 | |
639 | 1589 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); |
1590 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
635 | 1591 break; |
1592 | |
1593 default: | |
639 | 1594 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1595 } |
1596 break; | |
1597 | |
1598 case 5: case 6: case 7: // summer | |
1599 //all green by default | |
639 | 1600 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1601 break; |
1602 | |
1603 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
1604 } | |
637 | 1605 else |
639 | 1606 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1607 #pragma endregion |
639 | 1608 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 1609 |
1610 //v9 = v8; | |
0 | 1611 v42 = v8->uFlags; |
1612 a5 = v8->uGlowRadius; | |
639 | 1613 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, |
1614 decor->vPosition.y - pIndoorCamera->pos.y); | |
0 | 1615 v11 = *((int *)v0 + 2); |
1616 v37 = v10; | |
1617 v12 = v42; | |
1618 v38 = 0; | |
1619 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
1620 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
1621 + v11 | |
1622 - (signed int)v37) >> 8) & 7; | |
1623 v37 = (unsigned __int16 *)v13; | |
1624 if ( v42 & 2 ) | |
1625 v38 = 2; | |
1626 if ( (256 << v13) & v42 ) | |
1627 v38 |= 4u; | |
1628 if ( v12 & 0x40000 ) | |
1629 v38 |= 0x40u; | |
1630 if ( v12 & 0x20000 ) | |
1631 LOBYTE(v38) = v38 | 0x80; | |
1632 if ( a5 ) | |
1633 { | |
1634 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) | |
1635 { | |
639 | 1636 v14 = decor_desc->uColoredLightRed; |
1637 v15 = decor_desc->uColoredLightGreen; | |
1638 v16 = decor_desc->uColoredLightBlue; | |
0 | 1639 } |
1640 else | |
1641 { | |
1642 v16 = 255; | |
1643 v14 = 255; | |
1644 v15 = 255; | |
1645 } | |
1646 b = v16; | |
1647 pStationaryLightsStack->AddLight( | |
639 | 1648 decor->vPosition.x, |
1649 decor->vPosition.y, | |
1650 decor->vPosition.z + decor_desc->uDecorationHeight / 2, | |
0 | 1651 a5, |
1652 v14, | |
1653 v15, | |
1654 v16, | |
1655 byte_4E94D0); | |
1656 } | |
639 | 1657 v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
0 | 1658 if ( pIndoorCamera->sRotationX ) |
1659 { | |
639 | 1660 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; |
0 | 1661 v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) |
1662 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
1663 v42 = v18; | |
1664 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
1665 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
639 | 1666 v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 1667 v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; |
1668 v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
1669 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
1670 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
1671 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
1672 { | |
1673 v21 = a5 - b; | |
1674 v41 = a5 - b; | |
1675 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
1676 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
1677 v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; | |
1678 LABEL_30: | |
1679 v42 = v22; | |
1680 v40 = 2 * abs(v20); | |
1681 v23 = abs(v21); | |
1682 if ( v40 >= v23 ) | |
1683 { | |
1684 LODWORD(v24) = 0; | |
1685 HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
1686 a5 = v24 / v39; | |
1687 v25 = pViewport->uScreenCenterX | |
1688 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
1689 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
1690 v41 = v24 / v39; | |
1691 v40 = pViewport->uScreenCenterY | |
1692 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
635 | 1693 v42 = v8->scale; |
0 | 1694 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; |
635 | 1695 v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; |
0 | 1696 if ( pRenderer->pRenderD3D ) |
1697 { | |
1698 v26 = v41; | |
1699 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
1700 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
1701 } | |
1702 else | |
1703 { | |
1704 v26 = v41; | |
1705 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
1706 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
1707 } | |
693 | 1708 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
0 | 1709 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1710 if (::uNumBillboardsToDraw >= 500) |
0 | 1711 return; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1712 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; |
0 | 1713 ++uNumDecorationsDrawnThisFrame; |
1714 v27->uHwSpriteID = *v37; | |
635 | 1715 v28 = v8->uPaletteIndex; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1716 v27->_screenspace_x_scaler_packedfloat = v26; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1717 v27->_screenspace_y_scaler_packedfloat = v26; |
0 | 1718 v29 = v38; |
1719 v27->uScreenSpaceX = v25; | |
1720 HIBYTE(v29) |= 2u; | |
1721 v27->uPalette = v28; | |
1722 v27->field_1E = v29; | |
639 | 1723 v27->world_x = decor->vPosition.x; |
1724 v27->world_y = decor->vPosition.y; | |
1725 v27->world_z = decor->vPosition.z; | |
0 | 1726 v27->uScreenSpaceY = v40; |
1727 HIWORD(v30) = HIWORD(v39); | |
862 | 1728 v31 = PID(OBJECT_Decoration,i); |
0 | 1729 LOWORD(v30) = 0; |
1730 v27->uIndoorSectorID = 0; | |
1731 v27->sZValue = v30 + v31; | |
657 | 1732 v27->dimming_level = 0; |
635 | 1733 v27->pSpriteFrame = v8; |
0 | 1734 v27->uTintColor = 0; |
1735 } | |
1736 } | |
1737 goto LABEL_38; | |
1738 } | |
1739 } | |
1740 else | |
1741 { | |
639 | 1742 v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
1743 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; | |
0 | 1744 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; |
1745 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
1746 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
1747 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
1748 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
1749 { | |
1750 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
1751 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
1752 v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
1753 v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
639 | 1754 v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 1755 goto LABEL_30; |
1756 } | |
1757 } | |
1758 } | |
1759 } | |
1760 else | |
1761 { | |
1762 memset(&local_0, 0, 0x68u); | |
1763 v3 = (double)*((signed int *)v0 - 1); | |
619 | 1764 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
1765 local_0.uDiffuse = 0xFF3C1E; | |
0 | 1766 local_0.x = v3; |
1767 local_0.y = (double)*(signed int *)v0; | |
1768 local_0.z = (double)*((signed int *)v0 + 1); | |
1390 | 1769 local_0.r = 0.0; |
1770 local_0.g = 0.0; | |
1771 local_0.b = 0.0; | |
0 | 1772 local_0.flt_28 = 1.0; |
1773 local_0.timeToLive = (rand() & 0x80) + 128; | |
1774 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
1775 pGame->pParticleEngine->AddParticle(&local_0); | |
1776 } | |
1777 } | |
1778 LABEL_38: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1779 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1780 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1781 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1782 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
1783 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 1784 } |
1785 // 4E94D0: using guessed type char byte_4E94D0; | |
1786 // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; | |
1787 | |
1788 //----- (0049D717) -------------------------------------------------------- | |
1789 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1790 { | |
1791 HRESULT v2; // esi@2 | |
1792 | |
1793 if ( Src->dwFlags & 0x400 | 0x2000 ) | |
1794 { | |
1795 v2 = 0; | |
1796 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
1797 goto LABEL_6; | |
1798 if ( !Dst->dwSize ) | |
1799 { | |
1800 v2 = 1; | |
1801 LABEL_6: | |
1802 memcpy(Dst, Src, 0x20u); | |
1803 return v2; | |
1804 } | |
1805 } | |
1806 return 1; | |
1807 } | |
1808 | |
1809 //----- (0049DC28) -------------------------------------------------------- | |
1810 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1811 { | |
1812 RenderD3D__DevInfo *v2; // eax@1 | |
1813 | |
1814 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1815 *pOutDevices = v2; | |
1816 memset(v2, 0, 0xA0u); | |
1817 DirectDrawEnumerateA((LPDDENUMCALLBACKA)RenderD3D__DeviceEnumerator, *pOutDevices); | |
1818 } | |
1819 | |
1820 //----- (0049DC58) -------------------------------------------------------- | |
1821 RenderD3D::RenderD3D() | |
1822 { | |
1823 RenderD3D *v1; // esi@1 | |
1824 | |
1825 v1 = this; | |
1826 this->pHost = 0; | |
1827 this->pDirect3D = 0; | |
1828 this->pUnk = 0; | |
1829 this->pBackBuffer = 0; | |
1830 this->pFrontBuffer = 0; | |
1831 this->pZBuffer = 0; | |
1832 this->pDevice = 0; | |
1833 this->pViewport = 0; | |
1834 this->field_40 = 1; | |
1835 this->field_44 = 10; | |
1836 GetAvailableDevices(&this->pAvailableDevices); | |
1837 } | |
1838 | |
1839 //----- (0049DC90) -------------------------------------------------------- | |
1840 void RenderD3D::Release() | |
1841 { | |
1842 RenderD3D *v1; // esi@1 | |
1843 IDirectDraw4 *v2; // eax@2 | |
1844 signed int v3; // edi@4 | |
1845 IDirect3DViewport3 *v4; // eax@22 | |
1846 IUnknown *v5; // eax@24 | |
1847 IDirectDrawSurface4 *v6; // eax@26 | |
1848 IDirect3DDevice3 *v7; // eax@28 | |
1849 IDirect3D3 *v8; // eax@30 | |
1850 IDirectDrawSurface4 *v9; // eax@32 | |
1851 IDirectDrawSurface4 *v10; // eax@34 | |
1852 IDirectDraw4 *v11; // eax@36 | |
1853 | |
1854 v1 = this; | |
1855 if ( !this->bWindowed ) | |
1856 { | |
1857 v2 = this->pHost; | |
1858 if ( v2 ) | |
1859 { | |
1860 v2->RestoreDisplayMode(); | |
1861 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
1862 v1->pHost->FlipToGDISurface(); | |
1863 } | |
1864 } | |
1865 v3 = 0; | |
1866 do | |
1867 { | |
1868 if ( v1->pAvailableDevices[v3].pDriverName ) | |
1869 { | |
1870 free(v1->pAvailableDevices[v3].pDriverName); | |
1871 v1->pAvailableDevices[v3].pDriverName = 0; | |
1872 } | |
1873 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
1874 { | |
1875 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
1876 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
1877 } | |
1878 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
1879 { | |
1880 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
1881 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
1882 } | |
1883 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
1884 { | |
1885 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
1886 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
1887 } | |
1888 if ( v1->pAvailableDevices[v3].pName ) | |
1889 { | |
1890 free(v1->pAvailableDevices[v3].pName); | |
1891 v1->pAvailableDevices[v3].pName = 0; | |
1892 } | |
1893 if ( v1->pAvailableDevices[v3].pDescription ) | |
1894 { | |
1895 free(v1->pAvailableDevices[v3].pDescription); | |
1896 v1->pAvailableDevices[v3].pDescription = 0; | |
1897 } | |
1898 if ( v1->pAvailableDevices[v3].pGUID ) | |
1899 { | |
1900 free(v1->pAvailableDevices[v3].pGUID); | |
1901 v1->pAvailableDevices[v3].pGUID = 0; | |
1902 } | |
1903 ++v3; | |
1904 } | |
1905 while ( v3 < 4 ); | |
1906 if ( v1->pAvailableDevices ) | |
1907 { | |
1908 free(v1->pAvailableDevices); | |
1909 v1->pAvailableDevices = 0; | |
1910 } | |
1911 v4 = v1->pViewport; | |
1912 if ( v4 ) | |
1913 { | |
1914 v4->Release(); | |
1915 v1->pViewport = 0; | |
1916 } | |
1917 v5 = v1->pUnk; | |
1918 if ( v5 ) | |
1919 { | |
1920 v5->Release(); | |
1921 v1->pUnk = 0; | |
1922 } | |
1923 v6 = v1->pZBuffer; | |
1924 if ( v6 ) | |
1925 { | |
1926 v6->Release(); | |
1927 v1->pZBuffer = 0; | |
1928 } | |
1929 v7 = v1->pDevice; | |
1930 if ( v7 ) | |
1931 { | |
1932 v7->Release(); | |
1933 v1->pDevice = 0; | |
1934 } | |
1935 v8 = v1->pDirect3D; | |
1936 if ( v8 ) | |
1937 { | |
1938 v8->Release(); | |
1939 v1->pDirect3D = 0; | |
1940 } | |
1941 v9 = v1->pBackBuffer; | |
1942 if ( v9 ) | |
1943 { | |
1944 v9->Release(); | |
1945 v1->pBackBuffer = 0; | |
1946 } | |
1947 v10 = v1->pFrontBuffer; | |
1948 if ( v10 ) | |
1949 { | |
1950 v10->Release(); | |
1951 v1->pFrontBuffer = 0; | |
1952 } | |
1953 v11 = v1->pHost; | |
1954 if ( v11 ) | |
1955 { | |
1956 v11->Release(); | |
1957 v1->pHost = 0; | |
1958 } | |
1959 } | |
1960 | |
1961 //----- (0049DE14) -------------------------------------------------------- | |
1962 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | |
1963 { | |
1964 //IDirectDraw4 *v8; // eax@12 | |
1965 //IDirectDraw4 *v9; // eax@16 | |
1966 //IDirectDraw4 *v10; // eax@20 | |
1967 //IDirectDraw4 *v13; // eax@35 | |
1968 const char *v23; // [sp-4h] [bp-DCh]@9 | |
1969 const char *v24; // [sp-4h] [bp-DCh]@13 | |
1970 const char *v25; // [sp-4h] [bp-DCh]@19 | |
1971 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1972 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1973 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1974 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1975 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
1976 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1977 | |
1978 this->bWindowed = bWindowed; | |
1979 this->hWindow = hWnd; | |
1980 | |
1981 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
1982 { | |
1983 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1984 return 0; | |
1985 } | |
1986 | |
1987 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1988 { | |
1989 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1990 if (lpDD) | |
1991 lpDD->Release(); | |
1992 return 0; | |
1993 } | |
1994 lpDD->Release(); | |
1995 lpDD = 0; | |
1996 | |
1997 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1998 { | |
1999 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
2000 { | |
2001 v23 = "Init - Failed to set cooperative level.\n"; | |
2002 sprintf(pErrorMessage, v23); | |
2003 LABEL_65: | |
2004 if (pHost) | |
2005 { | |
2006 pHost->Release(); | |
2007 pHost = 0; | |
2008 } | |
2009 return 0; | |
2010 } | |
2011 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
2012 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
2013 ddsd2.dwFlags = DDSD_CAPS; | |
2014 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
2015 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
2016 { | |
2017 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
2018 pHost->GetDisplayMode(&ddsd2); | |
2019 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
2020 { | |
2021 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
2022 goto LABEL_14; | |
2023 } | |
2024 | |
2025 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
2026 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
2027 ddsd2.dwWidth = 640; | |
2028 ddsd2.dwHeight = 480; | |
2029 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | |
2030 { | |
2031 v24 = "Init - Failed to create back buffer.\n"; | |
2032 LABEL_14: | |
2033 sprintf(pErrorMessage, v24); | |
2034 if (pFrontBuffer) | |
2035 { | |
2036 pFrontBuffer->Release(); | |
2037 pFrontBuffer = 0; | |
2038 } | |
2039 goto LABEL_65; | |
2040 } | |
2041 if ( pHost->CreateClipper(0, &v30, 0) ) | |
2042 { | |
2043 v25 = "Init - Failed to create clipper.\n"; | |
2044 goto LABEL_45; | |
2045 } | |
2046 v30->SetHWnd(0, hWnd); | |
2047 pFrontBuffer->SetClipper(v30); | |
2048 | |
2049 v30->Release(); | |
2050 v30 = 0; | |
2051 | |
2052 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
2053 | |
2054 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
2055 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
2056 ddsd2.dwWidth = 640; | |
2057 ddsd2.dwHeight = 480; | |
2058 | |
2059 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
2060 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
2061 &ddsd2.ddpfPixelFormat) ) | |
2062 goto LABEL_21; | |
2063 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
2064 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
2065 | |
2066 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
2067 { | |
2068 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
2069 { | |
2070 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
2071 pBackBuffer, | |
2072 &pDevice, | |
2073 0) ) | |
2074 { | |
2075 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
2076 d3dvp2.dvClipWidth = 2.0; | |
2077 d3dvp2.dvClipY = 1.0; | |
2078 d3dvp2.dvClipHeight = 2.0; | |
2079 d3dvp2.dvMaxZ = 1.0; | |
2080 d3dvp2.dvMinZ = 0.0; | |
2081 goto LABEL_54; | |
2082 } | |
2083 LABEL_51: | |
2084 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
2085 if (pDirect3D) | |
2086 { | |
2087 pDirect3D->Release(); | |
2088 pDirect3D = 0; | |
2089 } | |
2090 goto LABEL_59; | |
2091 } | |
2092 LABEL_48: | |
2093 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
2094 if (pZBuffer) | |
2095 { | |
2096 pZBuffer->Release(); | |
2097 pZBuffer = 0; | |
2098 } | |
2099 goto LABEL_61; | |
2100 } | |
2101 goto LABEL_44; | |
2102 } | |
2103 LABEL_36: | |
2104 v23 = "Init - Failed to create front buffer.\n"; | |
2105 sprintf(pErrorMessage, v23); | |
2106 goto LABEL_65; | |
2107 } | |
2108 if ( uDeviceID == 1 ) | |
2109 v26 = 1045; | |
2110 else | |
2111 v26 = 1041; | |
2112 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
2113 { | |
2114 v23 = "Init - Failed to set cooperative level.\n"; | |
2115 sprintf(pErrorMessage, v23); | |
2116 goto LABEL_65; | |
2117 } | |
2118 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
2119 { | |
2120 v23 = "Init - Failed to set display mode.\n"; | |
2121 sprintf(pErrorMessage, v23); | |
2122 goto LABEL_65; | |
2123 } | |
2124 | |
2125 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
2126 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
2127 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
2128 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
2129 ddsd2.dwBackBufferCount = 1; | |
2130 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
2131 goto LABEL_36; | |
2132 //a3a = &pBackBuffer; | |
2133 //v14 = *v34; | |
2134 memset(&v27, 0, sizeof(DDSCAPS2)); | |
2135 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
2136 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
2137 //hWnda = &pDirect3D; | |
2138 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
2139 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
2140 { | |
2141 v25 = "Init - Failed to get D3D interface.\n"; | |
2142 goto LABEL_45; | |
2143 } | |
2144 | |
2145 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
2146 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
2147 ddsd2.dwWidth = 640; | |
2148 ddsd2.dwHeight = 480; | |
2149 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
2150 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
2151 &ddsd2.ddpfPixelFormat) ) | |
2152 { | |
2153 LABEL_21: | |
2154 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
2155 goto LABEL_45; | |
2156 } | |
2157 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
2158 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
2159 //uDeviceIDa = &pZBuffer; | |
2160 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
2161 { | |
2162 LABEL_44: | |
2163 v25 = "Init - Failed to create z-buffer.\n"; | |
2164 LABEL_45: | |
2165 sprintf(pErrorMessage, v25); | |
2166 if (pBackBuffer) | |
2167 { | |
2168 pBackBuffer->Release(); | |
2169 pBackBuffer = 0; | |
2170 } | |
2171 LABEL_63: | |
2172 //v19 = &pFrontBuffer; | |
2173 if (pFrontBuffer) | |
2174 { | |
2175 pFrontBuffer->Release(); | |
2176 pFrontBuffer= 0; | |
2177 } | |
2178 goto LABEL_65; | |
2179 } | |
2180 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
2181 goto LABEL_48; | |
2182 //v33 = &pDevice; | |
2183 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
2184 pBackBuffer, | |
2185 &pDevice, | |
2186 0) ) | |
2187 goto LABEL_51; | |
2188 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
2189 d3dvp2.dvClipWidth = 2.0; | |
2190 d3dvp2.dvClipY = 1.0; | |
2191 d3dvp2.dvClipHeight = 2.0; | |
2192 d3dvp2.dvMaxZ = 1.0; | |
2193 | |
2194 LABEL_54: | |
2195 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
2196 //v17 = *hWnda; | |
2197 d3dvp2.dwWidth = 640; | |
2198 d3dvp2.dwHeight = 480; | |
2199 d3dvp2.dvClipX = -1.0; | |
2200 //v18 = v17->lpVtbl; | |
2201 //v32 = &v4->pViewport; | |
2202 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
2203 { | |
2204 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
2205 if (pDevice) | |
2206 { | |
2207 pDevice->Release(); | |
2208 pDevice = 0; | |
2209 } | |
2210 if (pDirect3D) | |
2211 { | |
2212 pDirect3D->Release(); | |
2213 pDirect3D = 0; | |
2214 } | |
2215 LABEL_59: | |
2216 if (pZBuffer) | |
2217 { | |
2218 pZBuffer->Release(); | |
2219 pZBuffer = 0; | |
2220 } | |
2221 LABEL_61: | |
2222 if (pBackBuffer) | |
2223 { | |
2224 pBackBuffer->Release(); | |
2225 pBackBuffer = 0; | |
2226 } | |
2227 goto LABEL_63; | |
2228 } | |
2229 | |
2230 pDevice->AddViewport(pViewport); | |
2231 pViewport->SetViewport2(&d3dvp2); | |
2232 pDevice->SetCurrentViewport(pViewport); | |
2233 return 1; | |
2234 } | |
2235 | |
2236 //----- (0049E444) -------------------------------------------------------- | |
2237 unsigned int RenderD3D::GetDeviceCaps() | |
2238 { | |
2239 unsigned int v1; // ebx@1 | |
2240 RenderD3D *v2; // edi@1 | |
2241 IDirect3DDevice3 *v3; // eax@1 | |
2242 unsigned int result; // eax@2 | |
2243 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
2244 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
2245 | |
2246 v1 = 0; | |
2247 v2 = this; | |
2248 memset(&halCaps, 0, 0xFCu); | |
2249 halCaps.dwSize = 252; | |
2250 memset(&refCaps, 0, 0xFCu); | |
2251 v3 = v2->pDevice; | |
2252 refCaps.dwSize = 252; | |
2253 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
2254 { | |
2255 result = 1; | |
2256 } | |
2257 else | |
2258 { | |
2259 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
2260 v1 = 2; | |
2261 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
2262 v1 |= 4u; | |
2263 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
2264 v1 |= 8u; | |
2265 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
2266 v1 |= 0x10u; | |
2267 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
2268 v1 |= 0x20u; | |
2269 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
2270 v1 |= 0x40u; | |
2271 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
2272 LOBYTE(v1) = v1 | 0x80; | |
2273 result = v1; | |
2274 } | |
2275 return result; | |
2276 } | |
2277 | |
2278 //----- (0049E4FC) -------------------------------------------------------- | |
2279 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
2280 { | |
2281 uint uClearFlags = 0; | |
2282 | |
2283 if (bClearColor) | |
2284 uClearFlags |= D3DCLEAR_TARGET; | |
2285 if (bClearDepth) | |
2286 uClearFlags |= D3DCLEAR_ZBUFFER; | |
2287 | |
2288 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
2289 if (uClearFlags) | |
2290 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
2291 } | |
2292 | |
2293 //----- (0049E54D) -------------------------------------------------------- | |
2294 void RenderD3D::Present(bool bForceBlit) | |
2295 { | |
2296 RECT v5; // [sp+18h] [bp-18h]@1 | |
2297 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
2298 | |
2299 v5.left = 0; | |
2300 v5.top = 0; | |
2301 v5.bottom = 480; | |
2302 v5.right = 640; | |
2303 | |
2304 if (bWindowed || bForceBlit) | |
2305 { | |
2306 RECT rc; | |
2307 GetClientRect(hWindow, &rc); | |
2308 Point.y = 0; | |
2309 Point.x = 0; | |
2310 ClientToScreen(hWindow, &Point); | |
2311 OffsetRect(&rc, Point.x, Point.y); | |
2312 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
2313 } | |
2314 else | |
2315 pFrontBuffer->Flip(0, 1); | |
2316 } | |
2317 | |
2318 //----- (0049E5D4) -------------------------------------------------------- | |
2319 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
2320 { | |
2321 unsigned int v8; // edx@4 | |
2322 unsigned int v9; // ebx@5 | |
2323 unsigned int v10; // eax@5 | |
2324 DWORD v11; // edx@5 | |
2325 //int v12; // edx@7 | |
2326 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
2327 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
2328 | |
2329 //v15 = this; | |
2330 memset(&ddsd2, 0, 0x7Cu); | |
2331 ddsd2.dwSize = 0x7Cu; | |
2332 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
2333 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
2334 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
2335 ddsd2.dwHeight = uTextureHeight; | |
2336 ddsd2.dwWidth = uTextureWidth; | |
2337 if ( bMipmaps ) | |
2338 { | |
2339 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
2340 { | |
2341 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
2342 LABEL_8: | |
2343 ddsd2.dwMipMapCount = v8; | |
2344 if ( !v8 ) | |
2345 goto LABEL_12; | |
2346 goto LABEL_11; | |
2347 } | |
2348 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
2349 { | |
2350 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
2351 goto LABEL_8; | |
2352 } | |
2353 v9 = GetMaxMipLevels(uTextureWidth); | |
2354 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
2355 ddsd2.dwMipMapCount = v9 - v10; | |
2356 if ( v9 == v10 ) | |
2357 { | |
2358 ddsd2.dwFlags = 0x1007u; | |
2359 ddsd2.ddsCaps.dwCaps = v11; | |
2360 goto LABEL_12; | |
2361 } | |
2362 } | |
2363 else | |
2364 { | |
2365 ddsd2.dwMipMapCount = 1; | |
2366 } | |
2367 LABEL_11: | |
2368 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
2369 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
2370 LABEL_12: | |
2371 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
2372 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
2373 if (bAlphaChannel) | |
2374 { | |
2375 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
2376 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
2377 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
2378 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
2379 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
2380 } | |
2381 else | |
2382 { | |
2383 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
2384 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
2385 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
2386 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
2387 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
2388 } | |
2389 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
2390 return false; | |
2391 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
2392 { | |
2393 (*pOutSurface)->Release(); | |
2394 *pOutSurface = 0; | |
2395 return false; | |
2396 } | |
2397 return true; | |
2398 } | |
2399 | |
2400 //----- (004A5190) -------------------------------------------------------- | |
2401 void RenderD3D::HandleLostResources() | |
2402 { | |
2403 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
2404 pBitmaps_LOD->_410423_move_textures_to_device(); | |
2405 pSprites_LOD->ReleaseLostHardwareSprites(); | |
2406 } | |
2407 | |
2408 //----- (004A2050) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
2409 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) |
0 | 2410 { |
2411 Render *v5; // edi@1 | |
2412 unsigned int v6; // ebx@1 | |
2413 LightmapBuilder *v7; // esi@3 | |
2414 int v8; // eax@7 | |
2415 ODMFace *v9; // eax@12 | |
2416 char *v10; // esi@12 | |
2417 double v11; // st7@14 | |
2418 double v12; // st7@14 | |
2419 int v13; // eax@14 | |
2420 ODMFace *v14; // ecx@14 | |
2421 double v15; // st7@14 | |
2422 float v16; // ST48_4@15 | |
2423 int v17; // eax@15 | |
2424 char v18; // zf@17 | |
2425 HRESULT v19; // eax@18 | |
2426 HRESULT v20; // eax@18 | |
2427 HRESULT v21; // eax@20 | |
2428 HRESULT v22; // eax@20 | |
2429 unsigned int v23; // ecx@20 | |
2430 char *v24; // eax@21 | |
2431 HRESULT v25; // eax@23 | |
2432 HRESULT v26; // eax@23 | |
2433 HRESULT v27; // eax@24 | |
2434 HRESULT v28; // eax@25 | |
2435 HRESULT v29; // eax@25 | |
2436 HRESULT v30; // eax@25 | |
2437 HRESULT v31; // eax@25 | |
2438 HRESULT v32; // eax@26 | |
2439 unsigned int v33; // ecx@26 | |
2440 char *v34; // eax@27 | |
2441 int v35; // edx@28 | |
2442 HRESULT v36; // eax@29 | |
2443 HRESULT v37; // eax@29 | |
2444 HRESULT v38; // eax@29 | |
2445 HRESULT v39; // eax@29 | |
2446 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
2447 unsigned int v41; // eax@29 | |
2448 HRESULT v42; // eax@30 | |
2449 HRESULT v43; // eax@30 | |
2450 HRESULT v44; // eax@30 | |
2451 char *v45; // esi@34 | |
2452 int v46; // ecx@35 | |
2453 double v47; // st6@35 | |
2454 int v48; // eax@36 | |
2455 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
2456 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
2457 int v51; // [sp+50h] [bp-18h]@0 | |
2458 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
2459 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
2460 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
2461 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
2462 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
2463 int v57; // [sp+60h] [bp-8h]@34 | |
638 | 2464 unsigned int a2; // [sp+64h] [bp-4h]@4 |
0 | 2465 |
2466 v5 = this; | |
2467 v6 = 0; | |
2468 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
2469 { | |
2470 v7 = pGame->pLightmapBuilder; | |
2471 v53 = v7; | |
2472 v54 = v7->std__vector_000004_size; | |
2473 if ( v7->std__vector_000004_size) | |
638 | 2474 a2 = 0xFFFFFFFF; |
2475 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 2476 if ( byte_4D864C && pGame->uFlags & 1 ) |
2477 { | |
638 | 2478 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
0 | 2479 v7->_45D74F_MessWithLight(v8, 0); |
2480 } | |
2481 else | |
2482 { | |
2483 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
2484 { | |
323 | 2485 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 2486 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
2487 if (bUsingSpecular) | |
2488 { | |
186 | 2489 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
2490 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
2491 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 2492 } |
1073 | 2493 for (uint i = 0; i < uNumVertices; ++i) |
2494 { | |
2495 | |
2496 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
2497 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
2498 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
2499 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
2500 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
2501 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
2502 | |
2503 if ( this->bUsingSpecular ) | |
0 | 2504 { |
1073 | 2505 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 2506 } |
1073 | 2507 else |
2508 { | |
2509 d3d_vertex_buffer[i].specular = 0; | |
2510 } | |
2511 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
2512 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
2513 | |
2514 } | |
323 | 2515 |
2516 if (a4->uAttributes & FACE_OUTLINED) | |
2517 { | |
2518 int color; | |
2519 if (GetTickCount() % 300 >= 150) | |
2520 color = 0xFFFF2020; | |
2521 else color = 0xFF901010; | |
2522 | |
2523 for (uint i = 0; i < uNumVertices; ++i) | |
2524 d3d_vertex_buffer[i].diffuse = color; | |
2525 } | |
2526 | |
0 | 2527 pRenderD3D->pDevice->SetTexture(0, pTexture); |
2528 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
2529 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2530 d3d_vertex_buffer, |
0 | 2531 uNumVertices, |
2532 D3DDP_DONOTLIGHT); | |
2533 } | |
2534 else | |
2535 { | |
1073 | 2536 for (uint i = 0; i < uNumVertices; ++i) |
2537 { | |
2538 | |
2539 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
2540 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
2541 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
2542 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
2543 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
2544 if ( this->bUsingSpecular ) | |
0 | 2545 { |
1073 | 2546 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 2547 } |
1073 | 2548 else |
2549 { | |
2550 d3d_vertex_buffer[i].specular = 0; | |
2551 } | |
2552 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
2553 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
2554 | |
2555 } | |
2556 | |
186 | 2557 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
2558 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 2559 if (bUsingSpecular) |
186 | 2560 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 2561 |
2562 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
2563 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
2564 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2565 d3d_vertex_buffer, |
0 | 2566 uNumVertices, |
2567 D3DDP_DONOTLIGHT)); | |
2568 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
2569 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
2570 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
2571 v53->_45D74F_MessWithLight(-1, 0); | |
1073 | 2572 for (uint i = 0; i < uNumVertices; ++i) |
2573 { | |
2574 d3d_vertex_buffer[i].diffuse = a2; | |
2575 } | |
0 | 2576 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 2577 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 2578 if ( !pRenderer->bUsingSpecular ) |
186 | 2579 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
2580 | |
2581 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
2582 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
2583 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 2584 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
2585 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2586 d3d_vertex_buffer, |
0 | 2587 uNumVertices, |
2588 D3DDP_DONOTLIGHT)); | |
2589 if (bUsingSpecular) | |
2590 { | |
186 | 2591 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 2592 |
1073 | 2593 for (uint i = 0; i < uNumVertices; ++i) |
2594 { | |
2595 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
2596 d3d_vertex_buffer[i].specular = 0; | |
2597 } | |
2598 | |
0 | 2599 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 2600 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
2601 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 2602 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
2603 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2604 d3d_vertex_buffer, |
0 | 2605 uNumVertices, |
2606 D3DDP_DONOTLIGHT)); | |
186 | 2607 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 2608 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
2609 v41 = GetLevelFogColor(); | |
2610 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
2611 v6 = 0; | |
2612 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
2613 } | |
186 | 2614 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
2615 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 2616 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
2617 } | |
2618 } | |
2619 } | |
2620 } | |
2621 // 4D864C: using guessed type char byte_4D864C; | |
2622 | |
2623 //----- (0049EB79) -------------------------------------------------------- | |
2624 Render::~Render() | |
2625 { | |
2626 Render *v1; // esi@1 | |
2627 | |
2628 v1 = this; | |
2629 pAllocator->FreeChunk(this->pDefaultZBuffer); | |
2630 v1->pD3DBitmaps.Release(); | |
2631 v1->pD3DSprites.Release(); | |
2632 Release(); | |
2633 v1->bWindowMode = 1; | |
2634 //nullsub_1(); | |
2635 //nullsub_1(); | |
2636 } | |
2637 | |
2638 //----- (0049E756) -------------------------------------------------------- | |
2639 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
2640 { | |
2641 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
2642 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
2643 | |
2644 halCaps.dwSize = 380; | |
2645 refCaps.dwSize = 380; | |
2646 this_->GetCaps(&halCaps, &refCaps); | |
2647 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
2648 } | |
2649 | |
2650 //----- (0049E992) -------------------------------------------------------- | |
2651 Render::Render() | |
2652 { | |
2653 Render *v1; // esi@1 | |
2654 int v2; // eax@1 | |
2655 char v3; // zf@1 | |
2656 | |
2657 v1 = this; | |
2658 this->pDirectDraw4 = 0; | |
2659 this->pFrontBuffer4 = 0; | |
2660 this->pBackBuffer4 = 0; | |
2661 this->pColorKeySurface4 = 0; | |
2662 this->pDirectDraw2 = 0; | |
2663 this->pFrontBuffer2 = 0; | |
2664 this->pBackBuffer2 = 0; | |
2665 this->pSomeSurface2 = 0; | |
2666 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
2667 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2668 v1->bWindowMode = 1; | |
2669 v1->field_40054 = 0; | |
2670 v1->field_10 = 640; | |
2671 v1->field_14 = 480; | |
2672 v1->field_40030 = 0; | |
2673 v1->field_4002C = 0; | |
2674 v1->pActiveZBuffer = 0; | |
2675 v1->pDefaultZBuffer = 0; | |
709 | 2676 v1->raster_clip_y = 0; |
2677 v1->raster_clip_x = 0; | |
2678 v1->raster_clip_z = 639; | |
2679 v1->raster_clip_w = 479; | |
0 | 2680 v1->field_4003C = (int)&unk_4EED80; |
2681 v1->field_40040 = dword_4EED78; | |
2682 v1->uClipZ = 640; | |
2683 v1->field_40044 = 2; | |
2684 v1->field_40048 = 6; | |
2685 v1->pFrontBuffer4 = 0; | |
2686 v1->pBackBuffer4 = 0; | |
2687 v1->pColorKeySurface4 = 0; | |
2688 v1->pDirectDraw4 = 0; | |
2689 v1->pRenderD3D = 0; | |
2690 v1->uNumSceneBegins = 0; | |
2691 v1->uNumD3DSceneBegins = 0; | |
2692 v1->field_40110 = 0; | |
2693 v1->pTargetSurface = 0; | |
2694 v1->uTargetSurfacePitch = 0; | |
2695 v1->uClipY = 0; | |
2696 v1->uClipX = 0; | |
2697 v1->uClipW = 480; | |
2698 v1->bClip = 1; | |
2699 v1->bColorKeySupported = 0; | |
2700 v1->bRequiredTextureStagesAvailable = 0; | |
2701 v1->bTinting = 1; | |
2702 LOBYTE(v1->field_103668) = 0; | |
2703 v1->field_1036B8 = 0; | |
2704 v1->_gpu_memory_used = 0; | |
2705 uNumBillboardsToDraw = 0; | |
2706 bFogEnabled = false; | |
265 | 2707 |
2708 hd_water_tile_id = -1; | |
2709 hd_water_current_frame = 0; | |
0 | 2710 } |
2711 | |
781 | 2712 bool Render::Initialize(bool bWindowed, uint uDefaultDevice, bool bColoredLights, uint uDetailLevel, uint bTinting) |
0 | 2713 { |
2714 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
2715 bStartInWindow = bWindowed; | |
2716 | |
2717 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | |
2718 | |
2719 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
2720 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
2721 | |
2722 this->bTinting = bTinting; | |
2723 | |
2724 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
2725 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
2726 | |
2727 return r1 && r2; | |
2728 } | |
2729 | |
2730 //----- (0049EBF1) -------------------------------------------------------- | |
2731 void Render::_49EBF1() | |
2732 { | |
2733 signed int uNumRedBits; // edx@1 | |
2734 signed int uNuGreenBits; // edi@1 | |
2735 signed int uNumBlueBits; // esi@1 | |
2736 unsigned int v4; // edx@4 | |
2737 unsigned int v5; // edi@4 | |
2738 int v6; // ebx@4 | |
2739 int v7; // edx@4 | |
2740 signed int v8; // [sp+8h] [bp-24h]@1 | |
2741 signed int v9; // [sp+Ch] [bp-20h]@1 | |
2742 signed int v10; // [sp+20h] [bp-Ch]@1 | |
2743 signed int i; // [sp+24h] [bp-8h]@2 | |
2744 signed int v12; // [sp+28h] [bp-4h]@3 | |
2745 | |
2746 v10 = 0; | |
2747 uNumRedBits = 1 << this->uTargetRBits; | |
2748 uNuGreenBits = 1 << this->uTargetGBits; | |
2749 uNumBlueBits = 1 << this->uTargetBBits; | |
2750 v9 = 1 << this->uTargetRBits; | |
2751 v8 = 1 << this->uTargetGBits; | |
2752 if ( uNumRedBits > 0 ) | |
2753 { | |
2754 do | |
2755 { | |
2756 for ( i = 0; i < uNuGreenBits; ++i ) | |
2757 { | |
2758 v12 = 0; | |
2759 if ( uNumBlueBits > 0 ) | |
2760 { | |
2761 do | |
2762 { | |
2763 v4 = this->uTargetBBits; | |
2764 v5 = v4 + this->uTargetGBits; | |
2765 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
2766 v7 = (v10 << v5) + v12++ + (i << v4); | |
2767 this->field_2C[v7] = v6; | |
2768 } | |
2769 while ( v12 < uNumBlueBits ); | |
2770 uNumRedBits = v9; | |
2771 uNuGreenBits = v8; | |
2772 } | |
2773 } | |
2774 ++v10; | |
2775 } | |
2776 while ( v10 < uNumRedBits ); | |
2777 } | |
2778 } | |
2779 | |
2780 //----- (0049ECC4) -------------------------------------------------------- | |
2781 void Render::ClearBlack() | |
2782 { | |
2783 if (pRenderD3D) | |
2784 { | |
2785 if (field_40110) | |
2786 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
2787 } | |
2788 else | |
2789 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
2790 } | |
2791 | |
2792 //----- (0049ED18) -------------------------------------------------------- | |
2793 void Render::PresentBlackScreen() | |
2794 { | |
2795 LONG w; // edx@3 | |
2796 IDirectDrawSurface *v2; // eax@3 | |
2797 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
2798 RECT x; // [sp+68h] [bp-10h]@3 | |
2799 | |
2800 memset(&v3, 0, sizeof(DDBLTFX)); | |
2801 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
2802 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
2803 { | |
2804 x.left = uWindowX; | |
2805 x.right = uWindowX + uWindowHeight; | |
2806 x.top = uWindowY; | |
2807 w = uWindowY + uWindowWidth; | |
2808 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
2809 } | |
2810 else | |
2811 { | |
2812 x.left = uWindowX; | |
2813 x.right = uWindowX + uWindowHeight; | |
2814 x.top = uWindowY; | |
2815 w = uWindowY + uWindowWidth; | |
2816 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
2817 } | |
2818 x.bottom = w; | |
2819 v3.dwFillColor = 0; | |
2820 v3.dwSize = 100; | |
2821 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
2822 pRenderer->Present(); | |
2823 } | |
2824 | |
2825 //----- (0049EDB6) -------------------------------------------------------- | |
2826 void Render::SavePCXScreenshot() | |
2827 { | |
2828 Render *v1; // esi@1 | |
2829 __int16 v2; // di@1 | |
2830 int v3; // eax@4 | |
2831 int v4; // ecx@4 | |
2832 int v5; // eax@8 | |
2833 FILE *v6; // edi@10 | |
2834 int v7; // ecx@11 | |
2835 int v8; // eax@11 | |
2836 int v9; // eax@13 | |
2837 int v10; // ecx@15 | |
2838 unsigned __int8 v11; // dl@15 | |
2839 signed int v12; // eax@18 | |
2840 char v13; // zf@27 | |
2841 HRESULT v14; // eax@29 | |
2842 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
2843 __int16 v16; // [sp+44h] [bp-120h]@10 | |
2844 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2845 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2846 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2847 char *v20; // [sp+11Ch] [bp-48h]@14 | |
2848 char *v21; // [sp+120h] [bp-44h]@14 | |
2849 int v24; // [sp+124h] [bp-40h]@11 | |
2850 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
2851 int var38; // [sp+12Ch] [bp-38h]@4 | |
2852 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2853 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2854 void *ptr; // [sp+148h] [bp-1Ch]@10 | |
2855 void *v28; // [sp+14Ch] [bp-18h]@8 | |
2856 int v29; // [sp+150h] [bp-14h]@4 | |
2857 int v30; // [sp+154h] [bp-10h]@4 | |
2858 char v31; // [sp+15Ah] [bp-Ah]@25 | |
2859 unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 | |
2860 int i; // [sp+15Ch] [bp-8h]@10 | |
2861 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | |
2862 | |
2863 v1 = this; | |
2864 v2 = 0; | |
2865 if ( !this->pRenderD3D || this->field_40110 ) | |
2866 { | |
2867 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | |
2868 File = fopen(Filename, "wb"); | |
2869 if ( File ) | |
2870 { | |
2871 v3 = v1->field_10; | |
2872 v4 = v1->field_14; | |
2873 var38 = v3; | |
2874 v29 = v4; | |
2875 v30 = v3; | |
2876 if ( v3 & 1 ) | |
2877 v30 = v3 + 1; | |
2878 if ( v1->pRenderD3D ) | |
2879 { | |
2880 memset(&Dst, 0, 0x7Cu); | |
2881 Dst.dwSize = 124; | |
168 | 2882 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 2883 return; |
2884 v28 = Dst.lpSurface; | |
2885 v5 = Dst.lPitch >> 1; | |
2886 v2 = 0; | |
2887 } | |
2888 else | |
2889 { | |
2890 pRenderer->BeginScene(); | |
2891 v28 = pRenderer->pTargetSurface; | |
2892 v5 = pRenderer->uTargetSurfacePitch; | |
2893 } | |
2894 i = v5; | |
2895 header1.right = var38 - 1; | |
2896 header1.left = v2; | |
2897 header1.bottom = v29 - 1; | |
2898 header1.up = v2; | |
2899 header2.pitch = v30; | |
2900 memset(color_map, 0, sizeof(color_map)); | |
2901 memset(v15, 0, sizeof(v15)); | |
2902 header2.reserved = 0; | |
2903 header1.manufacturer = 10; | |
2904 v16 = 0; | |
2905 v6 = File; | |
2906 header1.version = 5; | |
2907 header1.encoding = 1; | |
2908 header1.bpp = 8; | |
2909 header1.hdpi = 75; | |
2910 header1.vdpi = 75; | |
2911 header2.planes = 3; | |
2912 header2.palette_info = 1; | |
2913 fwrite(&header1, 1u, 1u, File); | |
2914 fwrite(&header1.version, 1u, 1u, v6); | |
2915 fwrite(&header1.encoding, 1u, 1u, v6); | |
2916 fwrite(&header1.bpp, 1u, 1u, v6); | |
2917 fwrite(&header1.left, 2u, 1u, v6); | |
2918 fwrite(&header1.up, 2u, 1u, v6); | |
2919 fwrite(&header1.right, 2u, 1u, v6); | |
2920 fwrite(&header1.bottom, 2u, 1u, v6); | |
2921 fwrite(&header1.hdpi, 2u, 1u, v6); | |
2922 fwrite(&header1.vdpi, 2u, 1u, v6); | |
2923 fwrite(color_map, 0x30u, 1u, v6); | |
2924 fwrite(&header2, 1u, 1u, v6); | |
2925 fwrite(&header2.planes, 1u, 1u, v6); | |
2926 fwrite(&header2.pitch, 2u, 1u, v6); | |
2927 fwrite(&header2.palette_info, 2u, 1u, v6); | |
2928 fwrite(v15, 0x3Au, 1u, v6); | |
2929 ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); | |
2930 if ( v29 > 0 ) | |
2931 { | |
2932 v7 = v30; | |
2933 File = (FILE *)v29; | |
2934 v29 = 3 * v30; | |
2935 v24 = 2 * i; | |
2936 v8 = (int)v28; | |
2937 while ( 1 ) | |
2938 { | |
2939 i = v8; | |
2940 v9 = 0; | |
2941 if ( var38 > 0 ) | |
2942 { | |
2943 v21 = (char *)ptr + v7; | |
2944 v20 = (char *)ptr + 2 * v30; | |
2945 do | |
2946 { | |
2947 *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) | |
2948 + LOBYTE(v1->uTargetBBits) | |
2949 + v1->uTargetRBits | |
2950 - 8); | |
2951 v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) | |
2952 + LOBYTE(v1->uTargetGBits) | |
2953 - 8); | |
2954 v10 = i; | |
2955 v11 = LOBYTE(v1->uTargetBMask); | |
2956 i += 2; | |
2957 v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); | |
2958 } | |
2959 while ( v9 < var38 ); | |
2960 } | |
2961 for ( i = 0; i < v29; i += v34 ) | |
2962 { | |
2963 v34 = 1; | |
2964 v32 = *((char *)ptr + i); | |
2965 do | |
2966 { | |
2967 v12 = i + v34; | |
2968 if ( *((char *)ptr + v12) != v32 ) | |
2969 break; | |
2970 if ( !(v12 % v30) ) | |
2971 break; | |
2972 ++v34; | |
2973 } | |
2974 while ( v34 < 0x3Fu ); | |
2975 if ( i + v34 > v29 ) | |
2976 v34 = 3 * v30 - i; | |
2977 if ( v34 > 1u || v32 >= 0xC0u ) | |
2978 { | |
2979 v31 = v34 | 0xC0; | |
2980 fwrite(&v31, 1u, 1u, v6); | |
2981 } | |
2982 fwrite(&v32, 1u, 1u, v6); | |
2983 } | |
2984 v8 = (int)((char *)v28 + v24); | |
2985 v13 = File == (FILE *)1; | |
2986 File = (FILE *)((char *)File - 1); | |
2987 v28 = (char *)v28 + v24; | |
2988 if ( v13 ) | |
2989 break; | |
2990 v7 = v30; | |
2991 } | |
2992 } | |
2993 if ( v1->pRenderD3D ) | |
2994 { | |
2995 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
2996 } | |
2997 else | |
2998 { | |
2999 pRenderer->EndScene(); | |
3000 } | |
3001 | |
3002 pAllocator->FreeChunk(ptr); | |
3003 fclose(v6); | |
3004 } | |
3005 } | |
3006 } | |
3007 // 4EFA80: using guessed type int dword_4EFA80; | |
3008 | |
3009 //----- (0049F1BC) -------------------------------------------------------- | |
3010 void Render::_49F1BC(const char *a1) | |
3011 { | |
3012 Render *v2; // esi@1 | |
3013 __int16 v3; // di@1 | |
3014 int v4; // eax@4 | |
3015 char *v5; // ecx@4 | |
3016 unsigned int v6; // eax@8 | |
3017 FILE *v7; // edi@10 | |
3018 int v8; // ecx@11 | |
3019 int v9; // eax@11 | |
3020 int v10; // eax@13 | |
3021 const char *v11; // ecx@15 | |
3022 unsigned __int8 v12; // dl@15 | |
3023 signed int v13; // eax@18 | |
3024 char v14; // zf@27 | |
3025 HRESULT v15; // eax@29 | |
3026 char v16; // [sp+Ch] [bp-12Ch]@10 | |
3027 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
3028 int Dst; // [sp+48h] [bp-F0h]@7 | |
3029 int v19; // [sp+58h] [bp-E0h]@8 | |
3030 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
3031 char v21; // [sp+C4h] [bp-74h]@10 | |
3032 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
3033 char *v23; // [sp+F8h] [bp-40h]@14 | |
3034 int v24; // [sp+FCh] [bp-3Ch]@11 | |
3035 int v25; // [sp+100h] [bp-38h]@4 | |
3036 FILE *File; // [sp+104h] [bp-34h]@3 | |
3037 char Str; // [sp+108h] [bp-30h]@10 | |
3038 char v28; // [sp+109h] [bp-2Fh]@10 | |
3039 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
3040 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
3041 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
3042 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
3043 __int16 v33; // [sp+110h] [bp-28h]@10 | |
3044 __int16 v34; // [sp+112h] [bp-26h]@10 | |
3045 __int16 v35; // [sp+114h] [bp-24h]@10 | |
3046 __int16 v36; // [sp+116h] [bp-22h]@10 | |
3047 char v37; // [sp+118h] [bp-20h]@10 | |
3048 char v38; // [sp+119h] [bp-1Fh]@10 | |
3049 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
3050 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
3051 void *ptr; // [sp+120h] [bp-18h]@10 | |
3052 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
3053 int v43; // [sp+128h] [bp-10h]@4 | |
3054 char v44; // [sp+12Fh] [bp-9h]@25 | |
3055 char *i; // [sp+130h] [bp-8h]@10 | |
3056 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
3057 | |
3058 v2 = this; | |
3059 v3 = 0; | |
3060 if ( !this->pRenderD3D || this->field_40110 ) | |
3061 { | |
3062 ++dword_4EFA84; | |
3063 File = fopen(a1, "wb"); | |
3064 if ( File ) | |
3065 { | |
3066 v4 = v2->field_10; | |
3067 v5 = (char *)v2->field_14; | |
3068 v25 = v4; | |
3069 a1 = v5; | |
3070 v43 = v4; | |
3071 if ( v4 & 1 ) | |
3072 v43 = v4 + 1; | |
3073 if ( v2->pRenderD3D ) | |
3074 { | |
3075 memset(&Dst, 0, 0x7Cu); | |
3076 Dst = 124; | |
168 | 3077 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 3078 return; |
3079 v42 = v20; | |
3080 v6 = v19 >> 1; | |
3081 v3 = 0; | |
3082 } | |
3083 else | |
3084 { | |
3085 pRenderer->BeginScene(); | |
3086 v42 = pRenderer->pTargetSurface; | |
3087 v6 = pRenderer->uTargetSurfacePitch; | |
3088 } | |
3089 i = (char *)v6; | |
3090 v33 = v25 - 1; | |
3091 v31 = v3; | |
3092 v34 = (short)a1 - 1; | |
3093 v32 = v3; | |
3094 v39 = v43; | |
3095 memset(&v21, 0, 0x30u); | |
3096 memset(&v16, 0, 0x38u); | |
3097 v37 = 0; | |
3098 Str = 10; | |
3099 v17 = 0; | |
3100 v7 = File; | |
3101 v28 = 5; | |
3102 v29 = 1; | |
3103 v30 = 8; | |
3104 v35 = 75; | |
3105 v36 = 75; | |
3106 v38 = 3; | |
3107 v40 = 1; | |
3108 fwrite(&Str, 1u, 1u, File); | |
3109 fwrite(&v28, 1u, 1u, v7); | |
3110 fwrite(&v29, 1u, 1u, v7); | |
3111 fwrite(&v30, 1u, 1u, v7); | |
3112 fwrite(&v31, 2u, 1u, v7); | |
3113 fwrite(&v32, 2u, 1u, v7); | |
3114 fwrite(&v33, 2u, 1u, v7); | |
3115 fwrite(&v34, 2u, 1u, v7); | |
3116 fwrite(&v35, 2u, 1u, v7); | |
3117 fwrite(&v36, 2u, 1u, v7); | |
3118 fwrite(&v21, 0x30u, 1u, v7); | |
3119 fwrite(&v37, 1u, 1u, v7); | |
3120 fwrite(&v38, 1u, 1u, v7); | |
3121 fwrite(&v39, 2u, 1u, v7); | |
3122 fwrite(&v40, 2u, 1u, v7); | |
3123 fwrite(&v16, 0x3Au, 1u, v7); | |
3124 ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); | |
3125 if ( (signed int)a1 > 0 ) | |
3126 { | |
3127 v8 = v43; | |
3128 File = (FILE *)a1; | |
3129 v24 = 3 * v43; | |
3130 v22 = 2 * (int)i; | |
3131 v9 = (int)v42; | |
3132 while ( 1 ) | |
3133 { | |
3134 a1 = (const char *)v9; | |
3135 v10 = 0; | |
3136 if ( v25 > 0 ) | |
3137 { | |
3138 i = (char *)ptr + v8; | |
3139 v23 = (char *)ptr + 2 * v43; | |
3140 do | |
3141 { | |
3142 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
3143 + LOBYTE(v2->uTargetBBits) | |
3144 + v2->uTargetRBits | |
3145 - 8); | |
3146 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
3147 + LOBYTE(v2->uTargetGBits) | |
3148 - 8); | |
3149 v11 = a1; | |
3150 v12 = LOBYTE(v2->uTargetBMask); | |
3151 a1 += 2; | |
3152 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
3153 } | |
3154 while ( v10 < v25 ); | |
3155 } | |
3156 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
3157 { | |
3158 BYTE3(a1) = 1; | |
3159 v46 = *((char *)ptr + (int)i); | |
3160 do | |
3161 { | |
3162 v13 = (signed int)&i[BYTE3(a1)]; | |
3163 if ( *((char *)ptr + v13) != v46 ) | |
3164 break; | |
3165 if ( !(v13 % v43) ) | |
3166 break; | |
3167 ++BYTE3(a1); | |
3168 } | |
3169 while ( BYTE3(a1) < 0x3Fu ); | |
3170 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
3171 BYTE3(a1) = 3 * v43 - (char)i; | |
3172 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
3173 { | |
3174 v44 = BYTE3(a1) | 0xC0; | |
3175 fwrite(&v44, 1u, 1u, v7); | |
3176 } | |
3177 fwrite(&v46, 1u, 1u, v7); | |
3178 } | |
3179 v9 = (int)&v42[v22 / 2]; | |
3180 v14 = File == (FILE *)1; | |
3181 File = (FILE *)((char *)File - 1); | |
3182 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
3183 if ( v14 ) | |
3184 break; | |
3185 v8 = v43; | |
3186 } | |
3187 } | |
3188 if ( v2->pRenderD3D ) | |
3189 { | |
3190 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
3191 } | |
3192 else | |
3193 { | |
3194 pRenderer->EndScene(); | |
3195 } | |
3196 pAllocator->FreeChunk(ptr); | |
3197 fclose(v7); | |
3198 } | |
3199 } | |
3200 } | |
3201 // 4EFA84: using guessed type int dword_4EFA84; | |
3202 | |
3203 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 3204 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
3205 { | |
0 | 3206 Render *v7; // ebx@1 |
3207 void *v8; // esi@3 | |
3208 void *v9; // esi@3 | |
3209 int v10; // ecx@4 | |
810 | 3210 unsigned short* v11; // eax@4 |
0 | 3211 int v12; // eax@6 |
3212 int v13; // eax@8 | |
3213 int v14; // ecx@8 | |
3214 signed int v15; // eax@11 | |
3215 char v16; // zf@20 | |
3216 int result; // eax@21 | |
3217 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
3218 // __int16 v19; // [sp+44h] [bp-74h]@3 | |
3219 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 3220 char *lineG; // [sp+78h] [bp-40h]@7 |
3221 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 3222 int v23; // [sp+80h] [bp-38h]@4 |
3223 int v24; // [sp+84h] [bp-34h]@4 | |
3224 int v25; // [sp+88h] [bp-30h]@4 | |
3225 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 3226 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
3227 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
3228 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
3229 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 3230 char v43; // [sp+B3h] [bp-5h]@18 |
3231 int i; // [sp+B4h] [bp-4h]@6 | |
810 | 3232 unsigned short* line_pictute_data; |
3233 byte test_byte; | |
3234 unsigned char pict_byte; | |
0 | 3235 |
3236 v7 = this; | |
810 | 3237 pitch = wight; |
3238 if ( wight & 1 ) | |
3239 pitch = wight + 1; | |
3240 Src.left = 0; | |
3241 Src.up = 0; | |
3242 Src.right = wight - 1; | |
3243 Src.bottom = heidth - 1; | |
3244 v27.pitch = pitch; | |
0 | 3245 memset(&v20, 0, 0x30u); |
3246 memset(&v18, 0, 0x38u); | |
810 | 3247 v8 = data_buff; |
3248 v27.reserved = 0; | |
0 | 3249 *(_WORD *)&v18[56] = 0; |
810 | 3250 Src.manufacturer = 10; |
3251 Src.version = 5; | |
3252 Src.encoding = 1; | |
3253 Src.bpp = 8; | |
3254 Src.hdpi = 75; | |
3255 Src.vdpi = 75; | |
3256 v27.planes = 3; | |
3257 v27.palette_info = 1; | |
3258 memcpy(data_buff, &Src, 1u); | |
0 | 3259 v8 = (char *)v8 + 1; |
810 | 3260 memcpy(v8, &Src.version, 1u); |
0 | 3261 v8 = (char *)v8 + 1; |
810 | 3262 memcpy(v8, &Src.encoding, 1u); |
0 | 3263 v8 = (char *)v8 + 1; |
810 | 3264 memcpy(v8, &Src.bpp, 1u); |
0 | 3265 v8 = (char *)v8 + 1; |
810 | 3266 memcpy(v8, &Src.left, 2u); |
0 | 3267 v8 = (char *)v8 + 2; |
810 | 3268 memcpy(v8, &Src.up, 2u); |
0 | 3269 v8 = (char *)v8 + 2; |
810 | 3270 memcpy(v8, &Src.right, 2u); |
0 | 3271 v8 = (char *)v8 + 2; |
810 | 3272 memcpy(v8, &Src.bottom, 2u); |
0 | 3273 v8 = (char *)v8 + 2; |
810 | 3274 memcpy(v8, &Src.hdpi, 2u); |
0 | 3275 v8 = (char *)v8 + 2; |
810 | 3276 memcpy(v8, &Src.vdpi, 2u); |
0 | 3277 v8 = (char *)v8 + 2; |
3278 memcpy(v8, &v20, 0x30u); | |
3279 v8 = (char *)v8 + 48; | |
810 | 3280 memcpy(v8, &v27, 1u); |
0 | 3281 v8 = (char *)v8 + 1; |
810 | 3282 memcpy(v8, &v27.planes, 1u); |
0 | 3283 v8 = (char *)v8 + 1; |
810 | 3284 memcpy(v8, &v27.pitch, 2u); |
0 | 3285 v8 = (char *)v8 + 2; |
810 | 3286 memcpy(v8, &v27.palette_info, 2u); |
0 | 3287 v8 = (char *)v8 + 2; |
3288 memcpy(v8, &v18, 0x3Au); | |
3289 v9 = (char *)v8 + 58; | |
810 | 3290 |
3291 lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); | |
3292 if ( heidth > 0 ) | |
3293 { | |
3294 v10 = pitch; | |
3295 v25 = heidth; | |
3296 v26 = 3 * pitch; | |
3297 v23 = 2 * wight; | |
3298 v11 = picture_data; | |
3299 v24 = (int)picture_data; | |
0 | 3300 while ( 1 ) |
3301 { | |
810 | 3302 line_pictute_data = v11; |
0 | 3303 v12 = 0; |
3304 i = 0; | |
810 | 3305 if ( wight > 0 ) |
3306 { | |
3307 lineG = (char *)lineRGB + pitch; | |
3308 lineB = (char *)lineRGB + 2 * pitch; | |
0 | 3309 do |
3310 { | |
810 | 3311 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); |
3312 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); | |
3313 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); | |
3314 | |
3315 v12++; | |
3316 } | |
3317 while ( v12 < wight ); | |
0 | 3318 } |
3319 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
3320 { | |
810 | 3321 test_byte = 1; |
3322 pict_byte = lineRGB [i]; | |
0 | 3323 do |
3324 { | |
810 | 3325 v15 = i + test_byte; |
3326 if ( *((char *)lineRGB + v15) != pict_byte ) | |
0 | 3327 break; |
810 | 3328 if ( !(v15 % pitch) ) |
0 | 3329 break; |
810 | 3330 ++test_byte; |
3331 } | |
3332 while ( test_byte < 0x3Fu ); | |
3333 if ( i + test_byte > v26 ) | |
3334 test_byte = 3 * pitch - i; | |
3335 if ( test_byte > 1u || pict_byte >= 0xC0u ) | |
3336 { | |
3337 v43 = test_byte | 0xC0; | |
0 | 3338 memcpy(v9, &v43, 1u); |
3339 v9 = (char *)v9 + 1; | |
3340 } | |
810 | 3341 memcpy(v9, &pict_byte, 1u); |
3342 i += test_byte; | |
3343 } | |
3344 v11 +=wight ; | |
0 | 3345 v16 = v25-- == 1; |
810 | 3346 |
0 | 3347 if ( v16 ) |
3348 break; | |
810 | 3349 v10 = pitch; |
3350 } | |
3351 } | |
3352 pAllocator->FreeChunk(lineRGB); | |
3353 *(int *)packed_size = (char *)v9 - data_buff; | |
3354 | |
0 | 3355 } |
3356 | |
3357 //----- (0049F8B5) -------------------------------------------------------- | |
3358 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) | |
3359 { | |
3360 Render *v5; // esi@1 | |
3361 FILE *result; // eax@1 | |
3362 FILE *v7; // edi@4 | |
3363 int v8; // ecx@5 | |
3364 int v9; // eax@5 | |
3365 int v10; // eax@7 | |
3366 int v11; // ecx@9 | |
3367 signed int v12; // eax@12 | |
3368 char v13; // zf@21 | |
3369 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
3370 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
3371 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
3372 int v17; // [sp+70h] [bp-34h]@5 | |
3373 int v18; // [sp+74h] [bp-30h]@5 | |
3374 char *v19; // [sp+78h] [bp-2Ch]@5 | |
3375 int v20; // [sp+7Ch] [bp-28h]@5 | |
3376 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
3377 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
3378 void *ptr; // [sp+98h] [bp-Ch]@4 | |
3379 int v24; // [sp+9Ch] [bp-8h]@2 | |
3380 char *i; // [sp+A0h] [bp-4h]@8 | |
3381 | |
3382 v5 = this; | |
3383 result = fopen(Filename, "wb"); | |
3384 Filename = (const char *)result; | |
3385 if ( result ) | |
3386 { | |
3387 v24 = a4; | |
3388 if ( a4 & 1 ) | |
3389 v24 = a4 + 1; | |
3390 header1.left = 0; | |
3391 header1.up = 0; | |
3392 header1.right = a4 - 1; | |
3393 header1.bottom = a5 - 1; | |
3394 header2.pitch = v24; | |
3395 memset(color_map, 0, sizeof(color_map)); | |
3396 header2.reserved = 0; | |
3397 memset(v14, 0, sizeof(v14)); | |
3398 v15 = 0; | |
3399 header1.manufacturer = 10; | |
3400 header1.version = 5; | |
3401 header1.encoding = 1; | |
3402 header1.bpp = 8; | |
3403 header1.hdpi = 75; | |
3404 header1.vdpi = 75; | |
3405 header2.planes = 3; | |
3406 header2.palette_info = 1; | |
3407 fwrite(&header1, 1u, 1u, (FILE *)Filename); | |
3408 v7 = (FILE *)Filename; | |
3409 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); | |
3410 fwrite(&header1.encoding, 1u, 1u, v7); | |
3411 fwrite(&header1.bpp, 1u, 1u, v7); | |
3412 fwrite(&header1.left, 2u, 1u, v7); | |
3413 fwrite(&header1.up, 2u, 1u, v7); | |
3414 fwrite(&header1.right, 2u, 1u, v7); | |
3415 fwrite(&header1.bottom, 2u, 1u, v7); | |
3416 fwrite(&header1.hdpi, 2u, 1u, v7); | |
3417 fwrite(&header1.vdpi, 2u, 1u, v7); | |
3418 fwrite(color_map, 0x30u, 1u, v7); | |
3419 fwrite(&header2, 1u, 1u, v7); | |
3420 fwrite(&header2.planes, 1u, 1u, v7); | |
3421 fwrite(&header2.pitch, 2u, 1u, v7); | |
3422 fwrite(&header2.palette_info, 2u, 1u, v7); | |
3423 fwrite(v14, 0x3Au, 1u, v7); | |
3424 ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); | |
3425 if ( a5 > 0 ) | |
3426 { | |
3427 v8 = v24; | |
3428 v18 = a5; | |
3429 v20 = 3 * v24; | |
3430 v17 = 2 * a4; | |
3431 v9 = (int)a3; | |
3432 v19 = a3; | |
3433 while ( 1 ) | |
3434 { | |
3435 a5 = v9; | |
3436 v10 = 0; | |
3437 if ( a4 > 0 ) | |
3438 { | |
3439 a3 = (char *)ptr + v8; | |
3440 i = (char *)ptr + 2 * v24; | |
3441 do | |
3442 { | |
3443 *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) | |
3444 + LOBYTE(v5->uTargetBBits) | |
3445 + v5->uTargetRBits | |
3446 - 8); | |
3447 a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) | |
3448 + LOBYTE(v5->uTargetGBits) | |
3449 - 8); | |
3450 v11 = a5; | |
3451 a5 += 2; | |
3452 i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); | |
3453 } | |
3454 while ( v10 < a4 ); | |
3455 } | |
3456 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) | |
3457 { | |
3458 BYTE3(a5) = 1; | |
3459 BYTE3(Filename) = *((char *)ptr + (int)i); | |
3460 do | |
3461 { | |
3462 v12 = (signed int)&i[BYTE3(a5)]; | |
3463 if ( *((char *)ptr + v12) != BYTE3(Filename) ) | |
3464 break; | |
3465 if ( !(v12 % v24) ) | |
3466 break; | |
3467 ++BYTE3(a5); | |
3468 } | |
3469 while ( BYTE3(a5) < 0x3Fu ); | |
3470 if ( (signed int)&i[BYTE3(a5)] > v20 ) | |
3471 BYTE3(a5) = 3 * v24 - (char)i; | |
3472 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) | |
3473 { | |
3474 BYTE3(a3) = BYTE3(a5) | 0xC0; | |
3475 fwrite((char *)&a3 + 3, 1u, 1u, v7); | |
3476 } | |
3477 fwrite((char *)&Filename + 3, 1u, 1u, v7); | |
3478 } | |
3479 v9 = (int)&v19[v17]; | |
3480 v13 = v18-- == 1; | |
3481 v19 += v17; | |
3482 if ( v13 ) | |
3483 break; | |
3484 v8 = v24; | |
3485 } | |
3486 } | |
3487 pAllocator->FreeChunk(ptr); | |
3488 result = (FILE *)fclose(v7); | |
3489 } | |
3490 return result; | |
3491 } | |
3492 | |
3493 //----- (0049FBCD) -------------------------------------------------------- | |
3494 void Render::ClearTarget(unsigned int uColor) | |
3495 { | |
3496 if (pRenderD3D) | |
3497 { | |
3498 if (field_40110) | |
3499 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
3500 } | |
3501 else | |
3502 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
3503 } | |
3504 | |
3505 //----- (0049FC23) -------------------------------------------------------- | |
3506 void Render::Release2() | |
3507 { | |
3508 Release(); | |
3509 bWindowMode = 1; | |
3510 } | |
3511 | |
3512 //----- (0049FC37) -------------------------------------------------------- | |
3513 void Render::Present() | |
3514 { | |
3515 Render *v1; // esi@1 | |
3516 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
3517 RECT a4; // [sp+18h] [bp-18h]@11 | |
3518 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
3519 | |
3520 v1 = this; | |
3521 if ( !pRenderer->pRenderD3D || this->field_40110 ) | |
3522 { | |
3523 this->pBeforePresentFunction(); | |
3524 if ( v1->pRenderD3D ) | |
3525 { | |
3526 if ( v1->field_40110 ) | |
3527 { | |
3528 pRenderD3D->Present(false); | |
3529 } | |
3530 } | |
3531 else | |
3532 { | |
3533 if ( v1->bWindowMode ) | |
3534 { | |
3535 RestoreFrontBuffer(); | |
3536 GetClientRect(v1->hWnd, &Rect); | |
3537 Point.y = 0; | |
3538 Point.x = 0; | |
3539 ClientToScreen(v1->hWnd, &Point); | |
3540 OffsetRect(&Rect, Point.x, Point.y); | |
3541 a4.top = 0; | |
3542 a4.bottom = 480; | |
3543 a4.left = 0; | |
3544 a4.right = 640; | |
3545 PresentRect(&Rect, &a4); | |
3546 } | |
3547 else | |
3548 { | |
3549 RestoreFrontBuffer(); | |
3550 a4.top = 0; | |
3551 a4.bottom = 480; | |
3552 a4.left = 0; | |
3553 a4.right = 640; | |
3554 BltBackToFontFast(0, 0, &a4); | |
3555 } | |
3556 } | |
3557 } | |
3558 } | |
3559 | |
3560 //----- (0049FD3A) -------------------------------------------------------- | |
3561 void Render::_49FD3A() | |
3562 { | |
3563 Render *v2; // esi@1 | |
3564 IDirectDrawSurface4 *v3; // eax@6 | |
3565 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
3566 RECT v5; // [sp+8h] [bp-10h]@6 | |
3567 | |
3568 auto a1 = this; | |
3569 v2 = a1; | |
3570 if ( a1->pRenderD3D ) | |
3571 { | |
3572 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
3573 pFrontBuffer4->Restore(); | |
3574 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
3575 pBackBuffer4->Restore(); | |
3576 v3 = v2->pBackBuffer4; | |
3577 v4 = v2->pFrontBuffer4; | |
3578 v5.top = 0; | |
3579 v5.bottom = 480; | |
3580 v5.left = 0; | |
3581 v5.right = 640; | |
3582 v3->BltFast(0, 0, v4, &v5, 16u); | |
3583 } | |
3584 } | |
3585 | |
3586 //----- (0049FDBF) -------------------------------------------------------- | |
3587 void Render::CreateZBuffer() | |
3588 { | |
3589 if (!pDefaultZBuffer) | |
3590 { | |
3591 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
3592 pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); | |
871 | 3593 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 3594 } |
3595 } | |
3596 | |
3597 //----- (0049FE05) -------------------------------------------------------- | |
3598 void Render::Release() | |
3599 { | |
3600 Render *v1; // esi@1 | |
3601 RenderD3D *v2; // ecx@1 | |
3602 char v3; // zf@4 | |
3603 void *v4; // ebx@6 | |
3604 IDirectDraw *v5; // eax@10 | |
3605 IDirectDrawSurface2 *v6; // eax@11 | |
3606 IDirectDrawSurface2 *v7; // eax@13 | |
3607 IDirectDrawSurface2 *v8; // eax@15 | |
3608 IDirectDraw2 *v9; // eax@17 | |
3609 IDirectDraw4 *v10; // eax@19 | |
3610 IDirectDrawSurface4 *v11; // eax@20 | |
3611 IDirectDrawSurface4 *v12; // eax@22 | |
3612 IDirectDrawSurface4 *v13; // eax@24 | |
3613 IDirectDraw4 *v14; // eax@26 | |
3614 unsigned __int16 **v15; // ebx@28 | |
3615 void **v16; // esi@29 | |
3616 | |
3617 v1 = this; | |
3618 v2 = this->pRenderD3D; | |
3619 if ( v2 ) | |
3620 { | |
3621 if ( v1->field_40110 ) | |
3622 { | |
3623 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
3624 pRenderD3D->Present(0); | |
3625 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
3626 } | |
3627 v1->pColorKeySurface4 = 0; | |
3628 v1->pBackBuffer4 = 0; | |
3629 v3 = v1->pTargetSurface == 0; | |
3630 v1->pFrontBuffer4 = 0; | |
3631 v1->pDirectDraw4 = 0; | |
3632 if ( !v3 ) | |
3633 { | |
3634 free(v1->ptr_400E8); | |
3635 v1->pTargetSurface = 0; | |
3636 v1->ptr_400E8 = 0; | |
3637 } | |
3638 v4 = v1->pRenderD3D; | |
3639 if ( v4 ) | |
3640 { | |
3641 pRenderD3D->Release(); | |
3642 free(v4); | |
3643 } | |
3644 v1->pRenderD3D = 0; | |
3645 } | |
3646 else | |
3647 { | |
3648 if ( bWinNT4_0 == 1 ) | |
3649 { | |
3650 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
3651 if ( !v5 ) | |
3652 return; | |
3653 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
3654 v1->pDirectDraw2->FlipToGDISurface(); | |
3655 v6 = v1->pSomeSurface2; | |
3656 if ( v6 ) | |
3657 { | |
3658 v6->Release(); | |
3659 v1->pSomeSurface2 = 0; | |
3660 } | |
3661 v7 = v1->pBackBuffer2; | |
3662 if ( v7 ) | |
3663 { | |
3664 v7->Release(); | |
3665 v1->pBackBuffer2 = 0; | |
3666 } | |
3667 v8 = v1->pFrontBuffer2; | |
3668 if ( v8 ) | |
3669 { | |
3670 v8->Release(); | |
3671 v1->pFrontBuffer2 = 0; | |
3672 } | |
3673 v9 = v1->pDirectDraw2; | |
3674 if ( v9 ) | |
3675 { | |
3676 v9->Release(); | |
3677 v1->pDirectDraw2 = 0; | |
3678 } | |
3679 } | |
3680 else | |
3681 { | |
3682 v10 = v1->pDirectDraw4; | |
3683 if ( !v10 ) | |
3684 return; | |
3685 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
3686 v1->pDirectDraw4->FlipToGDISurface(); | |
3687 v11 = v1->pColorKeySurface4; | |
3688 if ( v11 ) | |
3689 { | |
3690 v11->Release(); | |
3691 v1->pColorKeySurface4 = 0; | |
3692 } | |
3693 v12 = v1->pBackBuffer4; | |
3694 if ( v12 ) | |
3695 { | |
3696 v12->Release(); | |
3697 v1->pBackBuffer4 = 0; | |
3698 } | |
3699 v13 = v1->pFrontBuffer4; | |
3700 if ( v13 ) | |
3701 { | |
3702 v13->Release(); | |
3703 v1->pFrontBuffer4 = 0; | |
3704 } | |
3705 v14 = v1->pDirectDraw4; | |
3706 if ( v14 ) | |
3707 { | |
3708 v14->Release(); | |
3709 v1->pDirectDraw4 = 0; | |
3710 } | |
3711 } | |
3712 v15 = &v1->pTargetSurface; | |
3713 if ( v1->pTargetSurface ) | |
3714 { | |
3715 v16 = (void **)&v1->ptr_400E8; | |
3716 free(*v16); | |
3717 *v15 = 0; | |
3718 *v16 = 0; | |
3719 } | |
3720 } | |
3721 } | |
3722 | |
3723 //----- (0049FFD7) -------------------------------------------------------- | |
3724 void Render::CreateSomeTexture() | |
3725 { | |
3726 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
3727 } | |
3728 | |
3729 //----- (0049FFFB) -------------------------------------------------------- | |
3730 bool Render::InitializeFullscreen(HWND hWnd) | |
3731 { | |
3732 //Render *v2; // esi@1 | |
3733 //HWND v3; // ebx@1 | |
3734 //void *v4; // eax@2 | |
3735 //RenderD3D *v5; // eax@3 | |
3736 unsigned int v6; // edx@5 | |
3737 RenderD3D__DevInfo *v7; // ecx@5 | |
3738 bool v8; // eax@6 | |
3739 RenderD3D *v9; // ecx@13 | |
3740 unsigned int v10; // eax@13 | |
3741 RenderD3D *v11; // eax@25 | |
3742 HRESULT v12; // eax@25 | |
3743 int v13; // ecx@25 | |
3744 int v14; // eax@27 | |
3745 signed int v15; // ebx@31 | |
3746 bool v16; // eax@35 | |
3747 char v17; // zf@35 | |
3748 IDirectDraw4 *v18; // eax@38 | |
3749 HRESULT v19; // eax@38 | |
3750 int *v20; // eax@39 | |
3751 int *v22; // eax@42 | |
3752 int v23; // ecx@42 | |
3753 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3754 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3755 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
3756 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
3757 void *v28; // [sp+2FCh] [bp-10h]@2 | |
3758 int v29; // [sp+308h] [bp-4h]@2 | |
3759 | |
3760 //v2 = this; | |
3761 this->field_40110 = 0; | |
3762 this->pColorKeySurface4 = 0; | |
3763 this->pBackBuffer4 = 0; | |
3764 this->pFrontBuffer4 = 0; | |
3765 this->pDirectDraw4 = 0; | |
3766 this->bColorKeySupported = 0; | |
3767 Release(); | |
3768 //v3 = hWnd; | |
3769 this->hWnd = hWnd; | |
3770 CreateZBuffer(); | |
3771 if ( bUserDirect3D ) | |
3772 { | |
3773 pRenderD3D = new RenderD3D; | |
3774 v28 = pRenderD3D; | |
3775 v6 = uDesiredDirect3DDevice; | |
3776 v29 = -1; | |
3777 v7 = pRenderD3D->pAvailableDevices; | |
3778 if ( v7[v6].bIsDeviceCompatible ) | |
3779 { | |
3780 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | |
3781 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
3782 } | |
3783 else | |
3784 { | |
3785 if ( v7[1].bIsDeviceCompatible ) | |
3786 { | |
3787 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | |
3788 uAcquiredDirect3DDevice = 1; | |
3789 } | |
3790 else | |
3791 { | |
3792 if ( !v7->bIsDeviceCompatible ) | |
3793 Abortf("There aren't any D3D devices to create."); | |
3794 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); | |
3795 uAcquiredDirect3DDevice = 0; | |
3796 } | |
3797 } | |
3798 if ( !v8 ) | |
3799 Abortf("D3Drend->Init failed."); | |
3800 v9 = pRenderD3D; | |
3801 pBackBuffer4 = v9->pBackBuffer; | |
3802 pFrontBuffer4 = v9->pFrontBuffer; | |
3803 pDirectDraw4 = v9->pHost; | |
3804 v10 = pRenderD3D->GetDeviceCaps(); | |
3805 if ( v10 & 1 ) | |
3806 { | |
3807 if ( pRenderD3D ) | |
3808 { | |
3809 pRenderD3D->Release(); | |
3810 delete pRenderD3D; | |
3811 } | |
3812 pRenderD3D = 0; | |
3813 pBackBuffer4 = 0; | |
3814 pFrontBuffer4 = 0; | |
3815 pDirectDraw4 = 0; | |
3816 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
3817 } | |
3818 if ( v10 & 0x3E ) | |
3819 { | |
3820 if ( pRenderD3D ) | |
3821 { | |
3822 pRenderD3D->Release(); | |
3823 delete pRenderD3D; | |
3824 } | |
3825 pColorKeySurface4 = 0; | |
3826 pRenderD3D = 0; | |
3827 pBackBuffer4 = 0; | |
3828 pFrontBuffer4 = 0; | |
3829 pDirectDraw4 = 0; | |
3830 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
3831 } | |
3832 if ( (v10 & 0x80u) != 0 ) | |
3833 { | |
3834 if ( pRenderD3D ) | |
3835 { | |
3836 pRenderD3D->Release(); | |
3837 delete pRenderD3D; | |
3838 } | |
3839 pRenderD3D = 0; | |
3840 pBackBuffer4 = 0; | |
3841 pFrontBuffer4 = 0; | |
3842 pDirectDraw4 = 0; | |
3843 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
3844 } | |
3845 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
3846 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
3847 memset(&halCaps, 0, 0xFCu); | |
3848 halCaps.dwSize = 252; | |
3849 memset(&refCaps, 0, 0xFCu); | |
3850 v11 = pRenderD3D; | |
3851 refCaps.dwSize = 252; | |
3852 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
3853 v13 = halCaps.dwMinTextureWidth; | |
3854 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3855 v13 = halCaps.dwMinTextureHeight; | |
3856 v14 = halCaps.dwMaxTextureWidth; | |
3857 uMinDeviceTextureDim = v13; | |
3858 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
3859 v14 = halCaps.dwMaxTextureHeight; | |
3860 uMaxDeviceTextureDim = v14; | |
3861 if ( (unsigned int)v13 < 4 ) | |
3862 uMinDeviceTextureDim = 4; | |
3863 CreateSomeTexture(); | |
3864 v15 = 1; | |
3865 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3866 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
3867 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
3868 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
3869 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3870 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
3871 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
3872 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
3873 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
3874 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
3875 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
3876 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3877 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
3878 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
3879 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3880 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
3881 } | |
3882 else | |
3883 { | |
3884 CreateDirectDraw(); | |
3885 SetDirectDrawCooperationMode(hWnd, 1); | |
3886 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3887 CreateDirectDrawPrimarySurface(); | |
3888 v15 = 1; | |
3889 } | |
3890 ddpfPrimareSuface.dwSize = 32; | |
3891 GetTargetPixelFormat(&ddpfPrimareSuface); | |
3892 ParseTargetPixelFormat(); | |
3893 _49EBF1(); | |
3894 if ( pRenderD3D ) | |
3895 { | |
3896 v16 = IsColorKeySupported(pDirectDraw4); | |
3897 v17 = uAcquiredDirect3DDevice == v15; | |
3898 bColorKeySupported = v16; | |
3899 if ( !v17 ) | |
3900 bColorKeySupported = 0; | |
3901 if ( bColorKeySupported ) | |
3902 { | |
3903 memset(&ddsd2, 0, 0x7Cu); | |
3904 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3905 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3906 v18 = pDirectDraw4; | |
3907 ddsd2.dwSize = 124; | |
3908 ddsd2.dwFlags = 65543; | |
3909 ddsd2.ddsCaps.dwCaps = 2112; | |
3910 ddsd2.dwWidth = 640; | |
3911 ddsd2.dwHeight = 480; | |
3912 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
3913 pBeforePresentFunction = Present_ColorKey; | |
3914 } | |
3915 else | |
3916 { | |
3917 pTargetSurface = 0; | |
3918 ptr_400E8 = 0; | |
3919 v20 = (int *)operator new(0x96020u); | |
3920 ptr_400E8 = v20; | |
3921 if ( !v20 | |
3922 || (memset(&pDesc, 0, 0x7Cu), | |
3923 pDesc.dwSize = 124, | |
3924 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
3925 return 0; | |
3926 pBackBuffer4->Unlock(0); | |
3927 v22 = ptr_400E8 + 4; | |
3928 v23 = (unsigned int)pDesc.lpSurface & 7; | |
3929 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
3930 uTargetSurfacePitch = 640; | |
3931 pBeforePresentFunction = Present_NoColorKey; | |
3932 v15 = 1; | |
3933 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | |
3934 } | |
3935 field_40110 = v15; | |
3936 } | |
3937 else | |
3938 { | |
3939 pBeforePresentFunction = 0;//nullsub_1; | |
3940 } | |
3941 bWindowMode = 0; | |
3942 pParty->uFlags |= 2u; | |
3943 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; | |
3944 pViewport->_4C02F8(36044); | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
3945 return v15 != 0; |
0 | 3946 } |
3947 // 6BE3A0: using guessed type float flt_6BE3A0; | |
3948 | |
3949 //----- (004A05F3) -------------------------------------------------------- | |
3950 bool Render::SwitchToWindow(HWND hWnd) | |
3951 { | |
3952 //Render *v2; // esi@1 | |
3953 //void *v3; // eax@2 | |
3954 //RenderD3D *v4; // eax@3 | |
3955 //unsigned int v5; // edx@5 | |
3956 //RenderD3D__DevInfo *v6; // ecx@5 | |
3957 bool v7; // eax@7 | |
3958 //RenderD3D *v8; // ecx@12 | |
3959 unsigned int v9; // eax@12 | |
3960 RenderD3D *v10; // eax@24 | |
3961 HRESULT v11; // eax@24 | |
3962 int v12; // eax@24 | |
3963 int v13; // eax@26 | |
3964 bool v14; // eax@32 | |
3965 char v15; // zf@32 | |
3966 IDirectDraw4 *v16; // eax@35 | |
3967 HRESULT v17; // eax@35 | |
3968 int *v18; // eax@36 | |
3969 int *v19; // edx@38 | |
3970 int v20; // eax@38 | |
3971 unsigned int v21; // ecx@38 | |
3972 int v22; // eax@41 | |
3973 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
3974 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3975 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
3976 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
3977 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
3978 int v29; // [sp+308h] [bp-4h]@2 | |
3979 | |
3980 pParty->uFlags |= 2u; | |
3981 //v2 = this; | |
3982 flt_6BE3A0 = 0.55000001f; | |
3983 pViewport->_4C02F8(36044); | |
3984 field_40110 = 0; | |
3985 Release(); | |
3986 pColorKeySurface4 = 0; | |
3987 pBackBuffer4 = 0; | |
3988 pFrontBuffer4 = 0; | |
3989 pDirectDraw4 = 0; | |
3990 bColorKeySupported = 0; | |
3991 CreateZBuffer(); | |
3992 if ( bUserDirect3D ) | |
3993 { | |
3994 /*v3 = operator new(0x148u); | |
3995 thisa = (RenderD3D *)v3; | |
3996 v29 = 0; | |
3997 if ( v3 ) | |
3998 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3999 else | |
4000 v4 = 0;*/ | |
4001 pRenderD3D = new RenderD3D; | |
4002 //v4 = pRenderD3D; | |
4003 //v5 = uDesiredDirect3DDevice; | |
4004 v29 = -1; | |
4005 //v6 = pRenderD3D->pAvailableDevices; | |
4006 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
4007 uDesiredDirect3DDevice != 1 ) | |
4008 { | |
4009 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | |
4010 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
4011 } | |
4012 else | |
4013 { | |
4014 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
4015 Abortf("There aren't any D3D devices to init."); | |
4016 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); | |
4017 uAcquiredDirect3DDevice = 0; | |
4018 } | |
4019 if ( !v7 ) | |
4020 Abortf("D3Drend->Init failed."); | |
4021 | |
4022 //v8 = pRenderD3D; | |
4023 pColorKeySurface4 = 0; | |
4024 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
4025 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
4026 pDirectDraw4 = pRenderD3D->pHost; | |
4027 v9 = pRenderD3D->GetDeviceCaps(); | |
4028 if ( v9 & 1 ) | |
4029 { | |
4030 if (pRenderD3D) | |
4031 { | |
4032 pRenderD3D->Release(); | |
4033 delete pRenderD3D; | |
4034 } | |
4035 pRenderD3D = 0; | |
4036 pBackBuffer4 = 0; | |
4037 pFrontBuffer4 = 0; | |
4038 pDirectDraw4 = 0; | |
4039 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
4040 } | |
4041 if ( v9 & 0x3E ) | |
4042 { | |
4043 if (pRenderD3D) | |
4044 { | |
4045 pRenderD3D->Release(); | |
4046 delete pRenderD3D; | |
4047 } | |
4048 pColorKeySurface4 = 0; | |
4049 pRenderD3D = 0; | |
4050 pBackBuffer4 = 0; | |
4051 pFrontBuffer4 = 0; | |
4052 pDirectDraw4 = 0; | |
4053 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
4054 } | |
4055 if ( (v9 & 0x80u) != 0 ) | |
4056 { | |
4057 if (pRenderD3D) | |
4058 { | |
4059 pRenderD3D->Release(); | |
4060 delete pRenderD3D; | |
4061 } | |
4062 pRenderD3D = 0; | |
4063 pBackBuffer4 = 0; | |
4064 pFrontBuffer4 = 0; | |
4065 pDirectDraw4 = 0; | |
4066 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
4067 } | |
4068 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
4069 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
4070 memset(&halCaps, 0, 0xFCu); | |
4071 halCaps.dwSize = 252; | |
4072 memset(&refCaps, 0, 0xFCu); | |
4073 //v10 = v2->pRenderD3D; | |
4074 refCaps.dwSize = 252; | |
4075 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
4076 v12 = halCaps.dwMinTextureWidth; | |
4077 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
4078 v12 = halCaps.dwMinTextureHeight; | |
4079 uMinDeviceTextureDim = v12; | |
4080 v13 = halCaps.dwMaxTextureWidth; | |
4081 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
4082 v13 = halCaps.dwMaxTextureHeight; | |
4083 uMaxDeviceTextureDim = v13; | |
4084 CreateSomeTexture(); | |
4085 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
4086 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
4087 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
4088 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
4089 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
4090 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
4091 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
4092 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
4093 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
4094 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
4095 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
4096 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
4097 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
4098 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
4099 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
4100 } | |
4101 else | |
4102 { | |
4103 CreateDirectDraw(); | |
4104 SetDirectDrawCooperationMode(hWnd, 0); | |
4105 field_4004C = 1; | |
4106 CreateFrontBuffer(); | |
4107 CreateClipper(hWnd); | |
4108 CreateBackBuffer(); | |
4109 field_40030 = 0; | |
4110 field_18_locked_pitch = 0; | |
4111 } | |
4112 ddpfPrimareSuface.dwSize = 32; | |
4113 GetTargetPixelFormat(&ddpfPrimareSuface); | |
4114 ParseTargetPixelFormat(); | |
4115 _49EBF1(); | |
4116 if ( !pRenderD3D ) | |
4117 { | |
4118 pBeforePresentFunction = 0;//nullsub_1; | |
4119 goto LABEL_47; | |
4120 } | |
4121 v14 = IsColorKeySupported(pDirectDraw4); | |
4122 v15 = uAcquiredDirect3DDevice == 1; | |
4123 bColorKeySupported = v14; | |
4124 if ( !v15 ) | |
4125 bColorKeySupported = 0; | |
4126 if ( bColorKeySupported ) | |
4127 { | |
4128 memset(&ddsd2, 0, 0x7Cu); | |
4129 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
4130 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
4131 v16 = pDirectDraw4; | |
4132 ddsd2.dwSize = 124; | |
4133 ddsd2.dwFlags = 65543; | |
4134 ddsd2.ddsCaps.dwCaps = 2112; | |
4135 ddsd2.dwWidth = 640; | |
4136 ddsd2.dwHeight = 480; | |
4137 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
4138 pBeforePresentFunction = Present_ColorKey; | |
4139 LABEL_45: | |
4140 field_40110 = 1; | |
4141 LABEL_47: | |
4142 bWindowMode = 1; | |
4143 hWnd = hWnd; | |
4144 return 0; | |
4145 } | |
4146 pTargetSurface = 0; | |
4147 ptr_400E8 = 0; | |
4148 v18 = (int *)new char[0x96020]; | |
4149 memset(v18, -1, 0x96020); | |
4150 ptr_400E8 = v18; | |
4151 if ( v18 ) | |
4152 { | |
4153 memset(&pDesc, 0, 0x7Cu); | |
4154 pDesc.dwSize = 124; | |
168 | 4155 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) |
0 | 4156 { |
4157 pRenderer->pBackBuffer4->Unlock(0); | |
4158 v19 = ptr_400E8; | |
4159 v20 = (unsigned int)pDesc.lpSurface & 7; | |
4160 v21 = (unsigned int)ptr_400E8 & 7; | |
4161 if ( v21 == v20 ) | |
4162 { | |
4163 pTargetSurface = (unsigned __int16 *)v19; | |
4164 } | |
4165 else | |
4166 { | |
4167 if ( (signed int)v21 >= v20 ) | |
4168 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
4169 else | |
4170 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
4171 pTargetSurface = (unsigned __int16 *)v22; | |
4172 } | |
4173 uTargetSurfacePitch = 640; | |
4174 pBeforePresentFunction = Present_NoColorKey; | |
4175 goto LABEL_45; | |
4176 } | |
4177 } | |
4178 return 0; | |
4179 } | |
4180 | |
4181 //----- (004A0BEE) -------------------------------------------------------- | |
709 | 4182 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) |
0 | 4183 { |
4184 int v6; // edi@1 | |
4185 int v7; // edx@5 | |
4186 unsigned int v8; // ebx@5 | |
4187 int v9; // eax@7 | |
4188 unsigned int v10; // ecx@9 | |
4189 unsigned int v11; // esi@13 | |
4190 int v12; // eax@17 | |
4191 int v13; // eax@21 | |
4192 Render *v14; // edi@21 | |
4193 int v15; // eax@25 | |
4194 int v16; // eax@27 | |
4195 signed int v17; // eax@28 | |
4196 signed int v18; // edi@30 | |
4197 signed __int64 v19; // qax@41 | |
4198 int v20; // edi@41 | |
4199 unsigned int v21; // edi@46 | |
4200 int v22; // esi@47 | |
4201 int v23; // ebx@47 | |
4202 signed int v24; // edx@50 | |
4203 signed int v25; // esi@52 | |
4204 unsigned __int16 *v26; // ecx@52 | |
4205 int v27; // ebx@54 | |
4206 int v28; // edi@55 | |
4207 int v29; // edx@55 | |
4208 int v30; // ebx@60 | |
4209 int v31; // edx@61 | |
4210 int v32; // edi@61 | |
4211 int v34; // [sp+Ch] [bp-10h]@3 | |
4212 Render *v35; // [sp+10h] [bp-Ch]@1 | |
4213 __int64 v36; // [sp+14h] [bp-8h]@1 | |
4214 signed int v37; // [sp+18h] [bp-4h]@28 | |
4215 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
4216 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | |
4217 int uYb; // [sp+28h] [bp+Ch]@47 | |
4218 int uZa; // [sp+2Ch] [bp+10h]@38 | |
4219 | |
4220 v36 = 0i64; | |
709 | 4221 v6 = this->raster_clip_x; |
0 | 4222 v35 = this; |
4223 if ( (signed int)uX < v6 ) | |
4224 HIDWORD(v36) = 8; | |
709 | 4225 v34 = this->raster_clip_z; |
4226 if ( (signed int)uX > this->raster_clip_z ) | |
0 | 4227 HIDWORD(v36) |= 4u; |
709 | 4228 v7 = this->raster_clip_y; |
0 | 4229 v8 = uY; |
4230 if ( (signed int)uY < v7 ) | |
4231 HIDWORD(v36) |= 2u; | |
709 | 4232 v9 = this->raster_clip_w; |
0 | 4233 if ( (signed int)uY > v9 ) |
4234 HIDWORD(v36) |= 1u; | |
4235 v10 = uZ; | |
4236 if ( (signed int)uZ < v6 ) | |
4237 LODWORD(v36) = 8; | |
4238 if ( (signed int)uZ > v34 ) | |
4239 LODWORD(v36) = v36 | 4; | |
4240 v11 = uW; | |
4241 if ( (signed int)uW < v7 ) | |
4242 LODWORD(v36) = v36 | 2; | |
4243 if ( (signed int)uW > v9 ) | |
4244 LODWORD(v36) = v36 | 1; | |
4245 LOBYTE(v12) = v36; | |
4246 if ( (unsigned int)v36 & HIDWORD(v36) ) | |
4247 return v12; | |
4248 if ( !v36 ) | |
4249 { | |
4250 LABEL_46: | |
4251 v21 = pRenderer->uTargetSurfacePitch; | |
4252 if ( pRenderer->uTargetSurfacePitch ) | |
4253 { | |
4254 v12 = uX + v8 * pRenderer->uTargetSurfacePitch; | |
4255 v22 = v11 - v8; | |
4256 v23 = v22; | |
4257 uYb = v22; | |
4258 if ( v22 < 0 ) | |
4259 { | |
4260 v23 = -v22; | |
4261 uYb = -v22; | |
4262 v21 = -pRenderer->uTargetSurfacePitch; | |
4263 } | |
4264 uXa = v10 - uX; | |
4265 if ( (uXa & 0x80000000u) == 0 ) | |
4266 { | |
4267 v24 = 1; | |
4268 } | |
4269 else | |
4270 { | |
4271 uXa = -uXa; | |
4272 v24 = -1; | |
4273 } | |
4274 v25 = 0; | |
4275 v26 = v35->pTargetSurface; | |
4276 if ( v26 ) | |
4277 { | |
4278 if ( (signed int)uXa <= v23 ) | |
4279 { | |
4280 v30 = v23 + 1; | |
4281 if ( v30 > 0 ) | |
4282 { | |
4283 v31 = 2 * v24; | |
4284 v32 = 2 * v21; | |
4285 v12 = (int)&v26[v12]; | |
4286 do | |
4287 { | |
4288 v25 += uXa; | |
4289 *(short *)v12 = uColor; | |
4290 v12 += v32; | |
4291 if ( v25 > 0 ) | |
4292 { | |
4293 v25 -= uYb; | |
4294 v12 += v31; | |
4295 } | |
4296 --v30; | |
4297 } | |
4298 while ( v30 ); | |
4299 } | |
4300 } | |
4301 else | |
4302 { | |
4303 v27 = uXa + 1; | |
4304 if ( (signed int)(uXa + 1) > 0 ) | |
4305 { | |
4306 v28 = 2 * v21; | |
4307 v29 = 2 * v24; | |
4308 v12 = (int)&v26[v12]; | |
4309 do | |
4310 { | |
4311 v25 += uYb; | |
4312 *(short *)v12 = uColor; | |
4313 v12 += v29; | |
4314 if ( v25 > (signed int)uXa ) | |
4315 { | |
4316 v25 -= uXa; | |
4317 v12 += v28; | |
4318 } | |
4319 --v27; | |
4320 } | |
4321 while ( v27 ); | |
4322 } | |
4323 } | |
4324 } | |
4325 } | |
4326 return v12; | |
4327 } | |
4328 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | |
4329 { | |
4330 if ( BYTE4(v36) & 8 ) | |
4331 { | |
4332 v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX); | |
4333 v14 = v35; | |
4334 v8 = v13 + uY; | |
709 | 4335 uX = v35->raster_clip_x; |
0 | 4336 goto LABEL_24; |
4337 } | |
4338 v10 = v6; | |
4339 v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW; | |
4340 } | |
4341 v14 = v35; | |
4342 LABEL_24: | |
4343 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
4344 { | |
709 | 4345 v15 = v14->raster_clip_z; |
0 | 4346 if ( BYTE4(v36) & 4 ) |
4347 { | |
4348 v14 = v35; | |
4349 v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX); | |
709 | 4350 uX = v35->raster_clip_z; |
0 | 4351 } |
4352 else | |
4353 { | |
4354 v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10); | |
709 | 4355 v10 = v14->raster_clip_z; |
0 | 4356 v11 += v16; |
4357 } | |
4358 } | |
709 | 4359 v17 = v14->raster_clip_y; |
0 | 4360 v37 = 0; |
709 | 4361 uYa = v14->raster_clip_y; |
0 | 4362 if ( (signed int)v8 < v17 ) |
4363 v37 = 2; | |
709 | 4364 v18 = v14->raster_clip_w; |
0 | 4365 if ( (signed int)v8 > v18 ) |
4366 v37 |= 1u; | |
4367 if ( (signed int)v11 >= v17 ) | |
4368 v12 = 0; | |
4369 else | |
4370 v12 = 2; | |
4371 if ( (signed int)v11 > v18 ) | |
4372 LOBYTE(v12) = v12 | 1; | |
4373 if ( !(v12 & v37) ) | |
4374 { | |
4375 v12 ^= v37; | |
4376 uZa = v12; | |
4377 if ( v12 & 2 ) | |
4378 { | |
4379 if ( v37 & 2 ) | |
4380 { | |
4381 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | |
4382 LOBYTE(v12) = (char)v35; | |
709 | 4383 v8 = v35->raster_clip_y; |
0 | 4384 } |
4385 else | |
4386 { | |
4387 v19 = (signed int)((uX - v10) * (uYa - v11)); | |
4388 v20 = v8 - v11; | |
4389 v11 = uYa; | |
4390 v12 = v19 / v20; | |
4391 v10 += v12; | |
4392 } | |
4393 } | |
4394 if ( uZa & 1 ) | |
4395 { | |
4396 if ( v37 & 1 ) | |
4397 { | |
709 | 4398 uX += (signed int)((v10 - uX) * (v35->raster_clip_w - v8)) / (signed int)(v11 - v8); |
0 | 4399 LOBYTE(v12) = (char)v35; |
709 | 4400 v8 = v35->raster_clip_w; |
0 | 4401 } |
4402 else | |
4403 { | |
709 | 4404 v12 = (signed int)((uX - v10) * (v35->raster_clip_w - v11)) / (signed int)(v8 - v11); |
4405 v11 = v35->raster_clip_w; | |
0 | 4406 v10 += v12; |
4407 } | |
4408 } | |
4409 goto LABEL_46; | |
4410 } | |
4411 return v12; | |
4412 } | |
4413 | |
4414 //----- (004A0E80) -------------------------------------------------------- | |
4415 void Render::ClearZBuffer(int a2, int a3) | |
4416 { | |
4417 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
4418 } | |
4419 | |
4420 //----- (004A0E97) -------------------------------------------------------- | |
709 | 4421 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
4422 { | |
4423 this->raster_clip_x = uX; | |
4424 this->raster_clip_y = uY; | |
4425 this->raster_clip_z = uZ; | |
4426 this->raster_clip_w = uW; | |
0 | 4427 } |
4428 | |
4429 //----- (004A0EB6) -------------------------------------------------------- | |
4430 void Render::ParseTargetPixelFormat() | |
4431 { | |
4432 Render *v1; // eax@1 | |
4433 signed int v2; // ecx@1 | |
4434 DWORD uRedMask; // edx@1 | |
4435 unsigned int uGreenMask; // esi@5 | |
4436 signed int v5; // ecx@5 | |
4437 unsigned int uBlueMask; // edx@9 | |
4438 signed int v7; // ecx@9 | |
4439 unsigned int v8; // ecx@13 | |
4440 | |
4441 v1 = this; | |
4442 v2 = 0; | |
4443 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | |
4444 v1->uTargetBBits = 0; | |
4445 v1->uTargetGBits = 0; | |
4446 v1->uTargetRBits = 0; | |
4447 do | |
4448 { | |
4449 if ( (1 << v2) & uRedMask ) | |
4450 ++v1->uTargetRBits; | |
4451 ++v2; | |
4452 } | |
4453 while ( v2 < 16 ); | |
4454 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | |
4455 v5 = 0; | |
4456 do | |
4457 { | |
4458 if ( (1 << v5) & uGreenMask ) | |
4459 ++v1->uTargetGBits; | |
4460 ++v5; | |
4461 } | |
4462 while ( v5 < 16 ); | |
4463 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | |
4464 v7 = 0; | |
4465 do | |
4466 { | |
4467 if ( (1 << v7) & uBlueMask ) | |
4468 ++v1->uTargetBBits; | |
4469 ++v7; | |
4470 } | |
4471 while ( v7 < 16 ); | |
4472 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
4473 v1->uTargetGMask = uGreenMask; | |
4474 v1->uTargetRMask = v8; | |
4475 v1->uTargetBMask = uBlueMask; | |
4476 } | |
4477 | |
4478 //----- (004A0F40) -------------------------------------------------------- | |
4479 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
4480 { | |
4481 IDirectDrawSurface4 *v4; // esi@1 | |
168 | 4482 HRESULT result; // eax@1 |
0 | 4483 HRESULT v6; // eax@4 |
4484 int v7; // [sp-8h] [bp-14h]@10 | |
4485 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
4486 char v9; // [sp+Bh] [bp-1h]@1 | |
4487 | |
4488 v4 = pSurface; | |
4489 v9 = 1; | |
4490 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
4491 if ( result == DDERR_SURFACELOST ) | |
4492 { | |
4493 v6 = v4->Restore(); | |
4494 if ( v6 ) | |
4495 { | |
4496 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
4497 { | |
4498 LABEL_20: | |
4499 v9 = 0; | |
4500 result = (bool)memset(pDesc, 0, 4u); | |
4501 goto LABEL_21; | |
4502 } | |
4503 pRenderer->pFrontBuffer4->Restore(); | |
4504 v4->Restore(); | |
4505 } | |
4506 result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
4507 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
4508 goto LABEL_20; | |
4509 ErrD3D(result); | |
4510 if ( result ) | |
4511 { | |
4512 //v8 = 0; | |
4513 //v7 = 2161; | |
4514 LABEL_19: | |
4515 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
4516 goto LABEL_20; | |
4517 } | |
4518 if ( pRenderer->pRenderD3D ) | |
4519 pRenderD3D->HandleLostResources(); | |
4520 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
4521 } | |
4522 else | |
4523 { | |
4524 if ( result ) | |
4525 { | |
4526 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
4527 goto LABEL_20; | |
4528 ErrD3D(result); | |
4529 //v8 = 0; | |
4530 //v7 = 2199; | |
4531 //goto LABEL_19; | |
4532 } | |
4533 } | |
4534 LABEL_21: | |
4535 LOBYTE(result) = v9; | |
4536 return result; | |
4537 } | |
4538 | |
4539 //----- (004A1032) -------------------------------------------------------- | |
4540 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
4541 { | |
4542 IDirectDrawSurface2 *v4; // esi@1 | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
4543 HRESULT v5; // eax@1 |
0 | 4544 HRESULT v6; // eax@2 |
4545 int v7; // [sp-8h] [bp-10h]@8 | |
4546 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
4547 | |
4548 v4 = pSurface; | |
4549 v5 = pSurface->Lock( | |
4550 0, | |
4551 pDesc, | |
4552 uLockFlags, | |
4553 0); | |
4554 BYTE3(pSurface) = 1; | |
4555 if ( v5 == DDERR_SURFACELOST ) | |
4556 { | |
4557 v6 = v4->Restore(); | |
4558 if ( !v6 ) | |
4559 goto LABEL_5; | |
4560 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
4561 { | |
4562 pRenderer->pFrontBuffer2->Restore(); | |
4563 v4->Restore(); | |
4564 LABEL_5: | |
4565 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
4566 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
4567 goto LABEL_14; | |
4568 if ( !v5 ) | |
4569 return true; | |
4570 ErrD3D(v5); | |
4571 //v8 = 0; | |
4572 //v7 = 2247; | |
4573 goto LABEL_13; | |
4574 } | |
4575 else | |
4576 { | |
4577 pDesc->dwSize = 0; | |
4578 return false; | |
4579 } | |
4580 } | |
4581 else | |
4582 { | |
4583 if ( !v5 ) | |
4584 return true; | |
4585 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
4586 { | |
4587 //v8 = 0; | |
4588 //v7 = 2269; | |
4589 ErrD3D(v5); | |
4590 pDesc->dwSize = 0; | |
4591 return false; | |
4592 LABEL_13: | |
4593 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
4594 goto LABEL_14; | |
4595 } | |
4596 } | |
4597 LABEL_14: | |
4598 return true; | |
4599 } | |
4600 | |
4601 //----- (004A10E4) -------------------------------------------------------- | |
4602 void Render::CreateDirectDraw() | |
4603 { | |
4604 Render *v1; // edi@1 | |
4605 HRESULT v2; // eax@1 | |
4606 HRESULT v3; // eax@5 | |
4607 int v6; // [sp-Ch] [bp-20h]@3 | |
4608 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
4609 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
4610 | |
4611 v1 = this; | |
4612 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
4613 | |
4614 pDirectDraw2 = nullptr; | |
4615 pDirectDraw4 = nullptr; | |
4616 | |
4617 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4618 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
4619 else | |
4620 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
4621 | |
4622 lpDD->Release(); | |
4623 lpDD = nullptr; | |
4624 } | |
4625 | |
4626 //----- (004A1169) -------------------------------------------------------- | |
4627 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
4628 { | |
4629 DWORD flags; // eax@1 | |
4630 IDirectDraw *v4; // ecx@3 | |
4631 HRESULT v5; // eax@5 | |
4632 int v6; // [sp-8h] [bp-8h]@3 | |
4633 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
4634 | |
4635 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
4636 DDSCL_NORMAL; | |
4637 | |
4638 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4639 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
4640 else | |
4641 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
4642 } | |
4643 | |
4644 //----- (004A11C6) -------------------------------------------------------- | |
4645 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
4646 { | |
4647 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4648 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
4649 else | |
4650 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
4651 } | |
4652 | |
4653 //----- (004A121C) -------------------------------------------------------- | |
4654 void Render::CreateFrontBuffer() | |
4655 { | |
4656 Render *v1; // esi@1 | |
4657 IDirectDraw *pDD; // eax@3 | |
4658 IDirectDrawSurface **pOutSurf; // esi@3 | |
4659 struct _DDSURFACEDESC *v4; // edx@3 | |
4660 HRESULT v5; // eax@5 | |
4661 int v6; // [sp-8h] [bp-8Ch]@3 | |
4662 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4663 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4664 | |
4665 v1 = this; | |
4666 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4667 { | |
4668 memset(&a2, 0, 0x7Cu); | |
4669 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
4670 a2.dwSize = 124; | |
4671 a2.dwFlags = 1; | |
4672 v7 = 0; | |
4673 a2.ddsCaps.dwCaps = 512; | |
4674 v6 = 2357; | |
4675 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
4676 v4 = (struct _DDSURFACEDESC *)&a2; | |
4677 } | |
4678 else | |
4679 { | |
4680 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
4681 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
4682 a2.lPitch = 108; | |
4683 a2.dwBackBufferCount = 1; | |
4684 v7 = 0; | |
4685 a2.dwTextureStage = 512; | |
4686 v6 = 2346; | |
4687 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
4688 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
4689 } | |
4690 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
4691 } | |
4692 | |
4693 //----- (004A12CD) -------------------------------------------------------- | |
4694 void Render::CreateBackBuffer() | |
4695 { | |
4696 Render *v1; // esi@1 | |
4697 IDirectDraw *v2; // eax@3 | |
4698 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
4699 struct _DDSURFACEDESC *v4; // edx@3 | |
4700 HRESULT v5; // eax@5 | |
4701 int v6; // [sp-8h] [bp-8Ch]@3 | |
4702 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4703 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4704 | |
4705 v1 = this; | |
4706 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4707 { | |
4708 memset(&a2, 0, 0x7Cu); | |
4709 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
4710 a2.dwSize = 124; | |
4711 a2.dwFlags = 7; | |
4712 v7 = 0; | |
4713 a2.ddsCaps.dwCaps = 2112; | |
4714 a2.dwWidth = 640; | |
4715 a2.dwHeight = 480; | |
4716 v6 = 2387; | |
4717 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4718 v4 = (struct _DDSURFACEDESC *)&a2; | |
4719 } | |
4720 else | |
4721 { | |
4722 memset(&a2.lPitch, 0, 0x6Cu); | |
4723 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4724 a2.lPitch = 108; | |
4725 a2.dwBackBufferCount = 7; | |
4726 v7 = 0; | |
4727 a2.dwTextureStage = 2112; | |
4728 a2.dwAlphaBitDepth = 640; | |
4729 a2.dwMipMapCount = 480; | |
4730 v6 = 2374; | |
4731 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4732 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
4733 } | |
4734 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
4735 } | |
4736 | |
4737 //----- (004A139A) -------------------------------------------------------- | |
4738 void Render::CreateDirectDrawPrimarySurface() | |
4739 { | |
4740 Render *v1; // esi@1 | |
4741 int v2; // ebx@3 | |
4742 IDirectDraw2 *v3; // eax@3 | |
4743 HRESULT v4; // eax@3 | |
4744 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
4745 DDSCAPS2 *v6; // edx@3 | |
4746 IDirectDraw4 *v7; // eax@4 | |
4747 HRESULT v8; // eax@4 | |
4748 int v9; // ST14_4@5 | |
4749 IDirectDrawSurface *v10; // ST10_4@5 | |
4750 HRESULT v11; // eax@5 | |
4751 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
4752 const char *v13; // [sp+0h] [bp-A0h]@0 | |
4753 int v14; // [sp+4h] [bp-9Ch]@0 | |
4754 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
4755 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
4756 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
4757 int a4; // [sp+98h] [bp-8h]@3 | |
4758 | |
4759 v1 = this; | |
4760 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4761 { | |
4762 v2 = 0; | |
4763 this->field_4004C = 1; | |
4764 memset(&ddsd2, 0, 0x7Cu); | |
4765 v7 = v1->pDirectDraw4; | |
4766 ddsd2.dwBackBufferCount = 1; | |
4767 ddsd2.dwSize = 0x7Cu; | |
4768 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4769 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4770 ErrD3D(v7->CreateSurface( | |
4771 &ddsd2, | |
4772 &pFrontBuffer4, | |
4773 0)); | |
4774 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
4775 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
4776 } | |
4777 else | |
4778 { | |
4779 v2 = 0; | |
4780 this->field_4004C = 1; | |
4781 | |
4782 DDSURFACEDESC ddsd; | |
4783 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4784 | |
4785 ddsd.lpSurface = (LPVOID)1; | |
4786 ddsd.lPitch = 108; | |
4787 ddsd.dwBackBufferCount = 33; | |
4788 ddsd.ddsCaps.dwCaps = 8728; | |
4789 ErrD3D(pDirectDraw2->CreateSurface( | |
4790 &ddsd, | |
4791 (IDirectDrawSurface **)&pFrontBuffer2, | |
4792 0)); | |
4793 | |
4794 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4795 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4796 } | |
4797 v9 = (int)v6; | |
4798 v10 = pFrontBuffer; // BUG | |
4799 | |
4800 v17.dwCaps = 4; | |
4801 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4802 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
4803 v1->field_40030 = v2; | |
4804 v1->field_18_locked_pitch = v2; | |
4805 } | |
4806 | |
4807 //----- (004A14F4) -------------------------------------------------------- | |
4808 void Render::CreateClipper(HWND a2) | |
4809 { | |
4810 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4811 { | |
4812 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
4813 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4814 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
4815 } | |
4816 else | |
4817 { | |
4818 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
4819 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4820 } | |
4821 } | |
4822 | |
4823 //----- (004A15D8) -------------------------------------------------------- | |
4824 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4825 { | |
4826 IDirectDrawSurface *v2; // eax@3 | |
4827 | |
4828 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4829 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4830 else | |
4831 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4832 v2->GetPixelFormat(pOut); | |
4833 } | |
4834 | |
4835 //----- (004A1605) -------------------------------------------------------- | |
4836 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4837 { | |
4838 Render *v3; // esi@1 | |
4839 signed int v4; // eax@3 | |
4840 | |
4841 v3 = this; | |
4842 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4843 { | |
4844 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4845 memset(&pDesc, 0, 0x7Cu); | |
4846 pDesc.dwSize = 124; | |
168 | 4847 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4848 *pOutSurfacePtr = pDesc.lpSurface; |
4849 v4 = pDesc.lPitch; | |
4850 } | |
4851 else | |
4852 { | |
4853 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4854 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4855 pDesc.lPitch = 108; | |
4856 LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); | |
4857 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
4858 v4 = pDesc.dwReserved; | |
4859 } | |
4860 *pOutPixelsPerRow = v4 >> 1; | |
4861 } | |
4862 | |
4863 //----- (004A169E) -------------------------------------------------------- | |
4864 bool Render::UsingDirect3D() | |
4865 { | |
4866 return bUserDirect3D == 0; | |
4867 } | |
4868 | |
4869 //----- (004A16E1) -------------------------------------------------------- | |
4870 void Render::UnlockBackBuffer() | |
4871 { | |
4872 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4873 ErrD3D(pBackBuffer4->Unlock(0)); | |
4874 else | |
4875 ErrD3D(pBackBuffer2->Unlock(0)); | |
4876 } | |
4877 | |
4878 //----- (004A172E) -------------------------------------------------------- | |
4879 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4880 { | |
4881 Render *v3; // esi@1 | |
4882 signed int v4; // eax@3 | |
4883 | |
4884 v3 = this; | |
4885 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4886 { | |
4887 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4888 memset(&pDesc, 0, 0x7Cu); | |
4889 pDesc.dwSize = 124; | |
168 | 4890 LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 4891 *pOutSurface = pDesc.lpSurface; |
4892 v4 = pDesc.lPitch; | |
4893 } | |
4894 else | |
4895 { | |
4896 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4897 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4898 pDesc.lPitch = 108; | |
4899 LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); | |
4900 *pOutSurface = (void *)pDesc.lpSurface; | |
4901 v4 = pDesc.dwReserved; | |
4902 } | |
4903 *pOutPixelsPerRow = v4 >> 1; | |
4904 } | |
4905 | |
4906 //----- (004A17C7) -------------------------------------------------------- | |
4907 void Render::UnlockFrontBuffer() | |
4908 { | |
4909 IDirectDrawSurface *pFront; // eax@3 | |
4910 HRESULT v2; // eax@5 | |
4911 signed int v3; // [sp-8h] [bp-Ch]@3 | |
4912 int v4; // [sp-4h] [bp-8h]@3 | |
4913 | |
4914 auto a5 = this; | |
4915 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4916 { | |
4917 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
4918 v4 = 0; | |
4919 v3 = 2615; | |
4920 } | |
4921 else | |
4922 { | |
4923 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
4924 v4 = 0; | |
4925 v3 = 2611; | |
4926 } | |
4927 ErrD3D(pFront->Unlock(0)); | |
4928 } | |
4929 | |
4930 //----- (004A1814) -------------------------------------------------------- | |
4931 void Render::RestoreFrontBuffer() | |
4932 { | |
4933 IDirectDrawSurface **v1; // esi@2 | |
4934 | |
4935 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
4936 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
4937 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
4938 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
4939 (*v1)->Restore(); | |
4940 } | |
4941 | |
4942 //----- (004A184C) -------------------------------------------------------- | |
4943 HRESULT Render::_4A184C() | |
4944 { | |
4945 IDirectDrawSurface **pBack; // esi@2 | |
4946 HRESULT result; // eax@4 | |
4947 | |
4948 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
4949 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
4950 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
4951 result = (*pBack)->IsLost(); | |
4952 if ( result == DDERR_SURFACELOST ) | |
4953 result = (*pBack)->Restore(); | |
4954 return result; | |
4955 } | |
4956 | |
4957 //----- (004A1884) -------------------------------------------------------- | |
4958 void Render::PresentRect(RECT *a2, RECT *a3) | |
4959 { | |
4960 IDirectDrawSurface *pFront; // eax@3 | |
4961 HRESULT v4; // eax@5 | |
4962 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
4963 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
4964 DWORD v7; // [sp-14h] [bp-14h]@3 | |
4965 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
4966 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
4967 int v10; // [sp-8h] [bp-8h]@3 | |
4968 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
4969 | |
4970 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4971 { | |
4972 v11 = 0; | |
4973 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4974 v10 = 2657; | |
4975 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4976 v8 = 0; | |
4977 v7 = DDBLT_WAIT; | |
4978 v6 = a3; | |
4979 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4980 } | |
4981 else | |
4982 { | |
4983 v11 = 0; | |
4984 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4985 v10 = 2653; | |
4986 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4987 v8 = 0; | |
4988 v7 = DDBLT_WAIT; | |
4989 v6 = a3; | |
4990 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
4991 } | |
4992 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
4993 } | |
4994 | |
4995 //----- (004A18F5) -------------------------------------------------------- | |
4996 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4997 { | |
4998 IDirectDrawSurface *pFront; // eax@3 | |
4999 HRESULT v6; // eax@5 | |
5000 int v7; // [sp-8h] [bp-8h]@3 | |
5001 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
5002 | |
5003 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
5004 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
5005 else | |
5006 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
5007 } | |
5008 | |
5009 //----- (004A194A) -------------------------------------------------------- | |
5010 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
5011 { | |
5012 IDirectDrawSurface *pFront; // eax@3 | |
5013 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
5014 | |
5015 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
5016 { | |
5017 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
5018 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
5019 } | |
5020 else | |
5021 { | |
5022 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
5023 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
5024 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5025 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 5026 } |
5027 | |
5028 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5029 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5030 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5031 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5032 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5033 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5034 //int v6; // ecx@5 |
0 | 5035 unsigned int v7; // edx@6 |
5036 char *v8; // ecx@12 | |
5037 void *v9; // edi@16 | |
5038 unsigned int v10; // eax@16 | |
5039 void *v11; // edi@21 | |
5040 unsigned int v12; // eax@21 | |
5041 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5042 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5043 if (uNumBillboardsToDraw >= 999 ) |
0 | 5044 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5045 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5046 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5047 uNumBillboardsToDraw = 1; |
0 | 5048 return 0; |
5049 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5050 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5051 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5052 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5053 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5054 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5055 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5056 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5057 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5058 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5059 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5060 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5061 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5062 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5063 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5064 if (z > *(float *)v8 ) |
0 | 5065 { |
5066 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
5067 { | |
5068 v7 = pRenderer->uNumBillboardsToDraw; | |
5069 } | |
5070 else | |
5071 { | |
5072 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
5073 { | |
5074 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
5075 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
5076 do | |
5077 { | |
5078 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
5079 v9 = (char *)v9 - 156; | |
5080 --v10; | |
5081 } | |
5082 while ( v10 ); | |
5083 } | |
5084 ++v7; | |
5085 } | |
717 | 5086 //LABEL_23: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5087 uNumBillboardsToDraw++; |
0 | 5088 return v7; |
5089 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
5090 if (z <= *(float *)v8 ) |
0 | 5091 { |
5092 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
5093 { | |
5094 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
5095 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
5096 do | |
5097 { | |
5098 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
5099 v11 = (char *)v11 - 156; | |
5100 --v12; | |
5101 } | |
5102 while ( v12 ); | |
5103 } | |
717 | 5104 //goto LABEL_23; |
5105 uNumBillboardsToDraw++; | |
5106 return v7; | |
0 | 5107 } |
5108 return v7; | |
5109 } | |
5110 | |
5111 //----- (004A1E9D) -------------------------------------------------------- | |
5112 unsigned int Render::GetBillboardDrawListSize() | |
5113 { | |
5114 return pRenderer->uNumBillboardsToDraw; | |
5115 } | |
5116 | |
5117 //----- (004A1EA3) -------------------------------------------------------- | |
5118 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
5119 { | |
5120 return pRenderer->pBillboardRenderListD3D[uBillboardID].uParentBillboardID; | |
5121 } | |
5122 | |
5123 //----- (004A1EB6) -------------------------------------------------------- | |
5124 void Render::BeginSceneD3D() | |
5125 { | |
5126 if (!uNumD3DSceneBegins++) | |
5127 { | |
5128 if (pRenderD3D) | |
5129 { | |
5130 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
5131 pRenderer->uNumBillboardsToDraw = 0; | |
5132 pRenderD3D->pDevice->BeginScene(); | |
1390 | 5133 |
0 | 5134 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
5135 uFogColor = GetLevelFogColor(); | |
5136 else | |
5137 uFogColor = 0; | |
5138 | |
5139 if ( uFogColor & 0xFF000000 ) | |
5140 { | |
5141 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
5142 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
5143 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
5144 bUsingSpecular = true; | |
5145 } | |
5146 else | |
5147 { | |
5148 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
5149 bUsingSpecular = 0; | |
5150 } | |
5151 } | |
5152 else | |
5153 { | |
5154 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
5155 if (pTargetSurface) | |
5156 field_18_locked_pitch = uTargetSurfacePitch; | |
5157 else | |
5158 --uNumD3DSceneBegins; | |
5159 } | |
5160 } | |
5161 } | |
5162 | |
5163 //----- (004A1FE1) -------------------------------------------------------- | |
5164 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
5165 { | |
5166 --uNumD3DSceneBegins; | |
5167 if (uNumD3DSceneBegins) | |
5168 return; | |
5169 | |
5170 if (pRenderD3D) | |
5171 { | |
5172 pGame->draw_debug_outlines(); | |
161 | 5173 DoRenderBillboards_D3D(); |
0 | 5174 pGame->pStru6Instance->RenderSpecialEffects(); |
5175 pRenderD3D->pDevice->EndScene(); | |
5176 } | |
5177 else | |
5178 pGame->pStru6Instance->RenderSpecialEffects(); | |
5179 } | |
5180 | |
5181 //----- (004A2031) -------------------------------------------------------- | |
349 | 5182 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
5183 { | |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
5184 // __debugbreak(); // should not fire outside decal builder |
349 | 5185 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 5186 } |
5187 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
5188 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 5189 { |
5190 int v5; // ebx@1 | |
5191 int v6; // edi@1 | |
5192 int v8; // eax@7 | |
5193 float v9; // eax@12 | |
5194 float *v10; // esi@12 | |
5195 float v11; // ecx@14 | |
5196 double v12; // st7@14 | |
5197 double v13; // st7@14 | |
5198 double v14; // st7@14 | |
5199 signed int v15; // eax@14 | |
5200 int v16; // eax@15 | |
5201 float v17; // ST48_4@15 | |
5202 char v18; // zf@17 | |
5203 int v19; // eax@18 | |
5204 int v20; // eax@18 | |
5205 int v21; // edx@20 | |
5206 signed int v22; // ecx@20 | |
5207 int v23; // eax@20 | |
5208 const char *v24; // ST4C_4@20 | |
5209 unsigned int v25; // ST50_4@20 | |
5210 int v26; // ST54_4@20 | |
5211 int v27; // eax@20 | |
5212 _UNKNOWN *v28; // eax@21 | |
5213 int v29; // ecx@23 | |
5214 int v30; // eax@23 | |
5215 int v31; // eax@23 | |
5216 int v32; // eax@24 | |
5217 int v33; // eax@25 | |
5218 int v34; // eax@25 | |
5219 int v35; // eax@25 | |
5220 int v36; // eax@25 | |
5221 signed int v37; // ecx@26 | |
5222 int v38; // eax@26 | |
5223 _UNKNOWN *v39; // eax@27 | |
5224 int v40; // edx@28 | |
5225 int v41; // eax@29 | |
5226 int v42; // eax@29 | |
5227 int v43; // eax@29 | |
5228 int v44; // eax@29 | |
5229 unsigned int v46; // eax@29 | |
5230 int v47; // eax@30 | |
5231 int v48; // eax@30 | |
5232 int v49; // eax@30 | |
5233 double v52; // st6@35 | |
5234 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
5235 int v57; // [sp+5Ch] [bp-Ch]@3 | |
5236 signed int v59; // [sp+60h] [bp-8h]@12 | |
5237 int v61; // [sp+64h] [bp-4h]@4 | |
5238 int i; | |
5239 | |
5240 v6 = (int)this; | |
5241 v5 = 0; | |
5242 if (!this->uNumD3DSceneBegins) | |
5243 return; | |
5244 | |
5245 | |
5246 | |
5247 | |
186 | 5248 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 5249 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
5250 if (this->bUsingSpecular) | |
5251 { | |
186 | 5252 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
5253 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
5254 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 5255 } |
5256 | |
5257 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
5258 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
5259 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
5260 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); | |
5261 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
5262 pVertices[0].specular = 0; | |
5263 pVertices[0].texcoord.x = array_50AC10[0].u; | |
5264 pVertices[0].texcoord.y = array_50AC10[0].v; | |
5265 | |
5266 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
5267 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
5268 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
5269 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); | |
5270 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
5271 pVertices[1].specular = 0; | |
5272 pVertices[1].texcoord.x = array_50AC10[3].u; | |
5273 pVertices[1].texcoord.y = array_50AC10[3].v; | |
5274 | |
5275 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
5276 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
5277 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
5278 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); | |
5279 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
5280 pVertices[2].specular = 0; | |
5281 pVertices[2].texcoord.x = array_50AC10[1].u; | |
5282 pVertices[2].texcoord.y = array_50AC10[1].v; | |
5283 | |
5284 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
5285 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
5286 | |
5287 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
5288 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
5289 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
5290 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); | |
5291 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
5292 pVertices[5].specular = 0; | |
5293 pVertices[5].texcoord.x = array_50AC10[2].u; | |
5294 pVertices[5].texcoord.y = array_50AC10[2].v; | |
5295 | |
5296 | |
5297 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
5298 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
5299 | |
186 | 5300 }*/ |
5301 | |
0 | 5302 //----- (004A26BC) -------------------------------------------------------- |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
5303 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
186 | 5304 { |
5305 //RenderVertexSoft *pVertices; // esi@0 | |
5306 //int v7; // edi@1 | |
0 | 5307 unsigned int v8; // ebx@1 |
5308 LightmapBuilder *v9; // esi@3 | |
5309 unsigned int v10; // edx@3 | |
5310 int v11; // eax@5 | |
5311 int v12; // eax@11 | |
5312 char *v13; // esi@11 | |
5313 double v14; // st7@13 | |
5314 double v15; // st7@13 | |
5315 signed int v16; // eax@13 | |
5316 int v17; // ecx@13 | |
5317 double v18; // st7@13 | |
5318 float v19; // ST78_4@14 | |
5319 int v20; // eax@14 | |
5320 char v21; // zf@16 | |
5321 HRESULT v22; // eax@17 | |
5322 HRESULT v23; // eax@17 | |
5323 HRESULT v24; // eax@19 | |
5324 HRESULT v25; // eax@19 | |
5325 unsigned int v26; // ecx@19 | |
5326 char *v27; // eax@20 | |
5327 HRESULT v28; // eax@22 | |
5328 HRESULT v29; // eax@22 | |
5329 HRESULT v30; // eax@23 | |
5330 HRESULT v31; // eax@24 | |
5331 HRESULT v32; // eax@24 | |
5332 HRESULT v33; // eax@24 | |
5333 HRESULT v34; // eax@24 | |
5334 HRESULT v35; // eax@25 | |
5335 HRESULT v36; // eax@25 | |
5336 unsigned int v37; // ecx@25 | |
5337 char *v38; // eax@26 | |
5338 int v39; // edx@27 | |
5339 HRESULT v40; // eax@28 | |
5340 HRESULT v41; // eax@28 | |
5341 HRESULT v42; // eax@28 | |
5342 HRESULT v43; // eax@28 | |
5343 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
5344 unsigned int v45; // eax@28 | |
5345 HRESULT v46; // eax@29 | |
5346 HRESULT v47; // eax@29 | |
5347 HRESULT v48; // eax@29 | |
186 | 5348 //IDirect3DDevice3 *v49; // eax@35 |
0 | 5349 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
5350 int v51; // eax@40 | |
5351 char *v52; // esi@40 | |
5352 double v53; // st7@42 | |
5353 double v54; // st7@42 | |
5354 signed int v55; // eax@42 | |
5355 int v56; // ecx@42 | |
5356 double v57; // st7@42 | |
5357 float v58; // ST7C_4@43 | |
5358 int v59; // eax@43 | |
186 | 5359 //signed int v60; // [sp+78h] [bp-14h]@31 |
5360 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 5361 const char *v62; // [sp+80h] [bp-Ch]@0 |
5362 const char *v63; // [sp+80h] [bp-Ch]@19 | |
5363 int v64; // [sp+84h] [bp-8h]@0 | |
5364 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
5365 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
5366 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 5367 int a7; |
5368 | |
5369 //v7 = (int)this; | |
0 | 5370 v8 = 0; |
186 | 5371 if (!this->uNumD3DSceneBegins) |
75 | 5372 return; |
5373 if ( uNumVertices < 3) | |
5374 return; | |
5375 | |
186 | 5376 //v61 = pVertices; |
5377 | |
75 | 5378 /* v9 = pGame->pLightmapBuilder; |
0 | 5379 v65 = v9; |
75 | 5380 v10 = v9->std__vector_000004_size;*/ |
0 | 5381 if ( byte_4D864C && pGame->uFlags & 1 ) |
5382 { | |
638 | 5383 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
75 | 5384 pGame->pLightmapBuilder->_45D74F_MessWithLight(v11, 0); |
0 | 5385 } |
5386 else | |
5387 { | |
186 | 5388 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 5389 byte_4D864C && pGame->uFlags & 2 ) |
5390 { | |
186 | 5391 if (clampAtTextureBorders) |
5392 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 5393 else |
186 | 5394 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
5395 | |
5396 if (transparent || this->bUsingSpecular) | |
5397 { | |
5398 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
5399 if (transparent) | |
0 | 5400 { |
186 | 5401 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
5402 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
5403 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
5404 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 5405 } |
5406 else | |
5407 { | |
186 | 5408 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
5409 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 5410 } |
186 | 5411 } |
1073 | 5412 |
5413 for (uint i = 0; i < uNumVertices; ++i) | |
5414 { | |
5415 | |
5416 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
5417 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
5418 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
5419 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
5420 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
5421 if ( this->bUsingSpecular ) | |
0 | 5422 { |
1073 | 5423 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 5424 } |
1073 | 5425 else |
5426 { | |
5427 d3d_vertex_buffer[i].specular = 0; | |
5428 } | |
5429 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
5430 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
5431 } | |
5432 | |
5433 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5434 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
186 | 5435 if (transparent) |
5436 { | |
5437 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
5438 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
5439 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 5440 } |
5441 } | |
5442 else | |
5443 { | |
1073 | 5444 for (uint i = 0; i < uNumVertices; ++i) |
5445 { | |
5446 | |
5447 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
5448 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
5449 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
5450 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
5451 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
5452 if ( this->bUsingSpecular ) | |
0 | 5453 { |
1073 | 5454 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 5455 } |
1073 | 5456 else |
5457 { | |
5458 d3d_vertex_buffer[i].specular = 0; | |
5459 } | |
5460 d3d_vertex_buffer[i].specular = v20; | |
5461 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
5462 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
5463 } | |
186 | 5464 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
5465 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
5466 if (pRenderer->bUsingSpecular) | |
5467 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 5468 |
5469 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 5470 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5471 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5472 d3d_vertex_buffer, |
0 | 5473 uNumVertices, |
5474 16)); | |
5475 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 5476 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 5477 //(*(void (**)(void))(*(int *)v63 + 88))(); |
5478 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
1073 | 5479 for (uint i = 0; i < uNumVertices; ++i) |
5480 { | |
5481 d3d_vertex_buffer[i].diffuse = -1; | |
5482 } | |
0 | 5483 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 5484 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 5485 if ( !pRenderer->bUsingSpecular ) |
5486 { | |
186 | 5487 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
5488 } | |
5489 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5490 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5491 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
5492 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 5493 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5494 d3d_vertex_buffer, |
0 | 5495 uNumVertices, |
5496 16)); | |
5497 if ( pRenderer->bUsingSpecular ) | |
5498 { | |
186 | 5499 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 5500 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 5501 for (uint i = 0; i < uNumVertices; ++i) |
5502 { | |
5503 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
5504 d3d_vertex_buffer[i].specular = 0; | |
5505 } | |
5506 | |
75 | 5507 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 5508 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
5509 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
5510 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 5511 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5512 d3d_vertex_buffer, |
0 | 5513 uNumVertices, |
5514 16)); | |
186 | 5515 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 5516 //v44 = pRenderer->pRenderD3D->pDevice; |
5517 v45 = GetLevelFogColor(); | |
5518 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
5519 v8 = 0; | |
5520 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
5521 } | |
186 | 5522 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
5523 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 5524 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
5525 } | |
5526 } | |
186 | 5527 |
791 | 5528 if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5529 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 5530 } |
5531 // 4A26BC: could not find valid save-restore pair for esi | |
5532 // 4D864C: using guessed type char byte_4D864C; | |
5533 | |
5534 //----- (004A2DA3) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
5535 void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *a3, IDirect3DTexture2 *pTexture) |
852 | 5536 { |
67 | 5537 int v7; // eax@7 |
0 | 5538 float v13; // ST3C_4@8 |
67 | 5539 int i; |
5540 | |
5541 if ( !this->uNumD3DSceneBegins ) | |
5542 return; | |
5543 if ( uNumVertices >= 3 ) | |
5544 { | |
186 | 5545 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 5546 if ( this->bUsingSpecular ) |
5547 { | |
186 | 5548 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
5549 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
5550 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 5551 } |
840 | 5552 for ( i = 0; i < uNumVertices; ++i ) |
67 | 5553 { |
5554 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
5555 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
5556 pVertices[i].pos.z = 0.99989998; | |
168 | 5557 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 5558 |
840 | 5559 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 5560 v7 = 0; |
5561 if (this->bUsingSpecular) | |
5562 { | |
5563 v13 = array_50AC10[i].vWorldViewPosition.x; | |
5564 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); | |
5565 } | |
5566 pVertices[i].specular = v7; | |
5567 pVertices[i].texcoord.x = array_50AC10[i].u; | |
5568 pVertices[i].texcoord.y = array_50AC10[i].v; | |
5569 } | |
5570 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
5571 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 5572 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 5573 } |
5574 } | |
5575 | |
5576 //----- (004A2ED5) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
5577 void Render::_4A2ED5(signed int a2, struct Polygon *a3, IDirect3DTexture2 *pHwTex) |
0 | 5578 { |
5579 signed int v4; // edi@2 | |
5580 int v5; // eax@3 | |
5581 int v6; // edx@5 | |
1072 | 5582 RenderVertexD3D3 *v7; // eax@6 |
5583 RenderVertexSoft *v8; // ecx@6 | |
5584 //double v9; // st6@7 | |
5585 //int v10; // ebx@7 | |
5586 //int v11; // ebx@7 | |
0 | 5587 |
5588 if ( this->uNumD3DSceneBegins ) | |
5589 { | |
5590 v4 = a2; | |
5591 if ( a2 >= 3 ) | |
5592 { | |
186 | 5593 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
638 | 5594 v5 = 31 - (a3->dimming_level & 0x1F); |
5595 if ( v5 < pOutdoor->max_terrain_dimming_level ) | |
5596 v5 = pOutdoor->max_terrain_dimming_level; | |
0 | 5597 v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); |
1072 | 5598 for (uint i = 0; i < a2; ++i) |
5599 { | |
5600 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5601 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5602 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / array_507D30[i].vWorldViewPosition.y; | |
5603 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; | |
5604 d3d_vertex_buffer[i].diffuse = v6; | |
5605 d3d_vertex_buffer[i].specular = 0; | |
5606 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
5607 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
5608 } | |
5609 | |
0 | 5610 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 5611 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 5612 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
5613 d3d_vertex_buffer, |
0 | 5614 a2, |
5615 28)); | |
5616 } | |
5617 } | |
5618 } | |
5619 | |
1390 | 5620 |
5621 //----- (00479A53) -------------------------------------------------------- | |
5622 void Render::DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID) | |
5623 { | |
5624 BLVFace *pFace; // esi@1 | |
5625 unsigned int v3; // edi@1 | |
5626 PolygonType v4; // al@1 | |
5627 double v5; // st7@3 | |
5628 signed __int64 v6; // qax@3 | |
5629 PolygonType v7; // cl@3 | |
5630 int v8; // esi@7 | |
5631 int v9; // eax@7 | |
5632 unsigned int v10; // eax@7 | |
5633 double v11; // st6@7 | |
5634 int v12; // edx@7 | |
5635 int v13; // eax@7 | |
5636 char *v14; // esi@8 | |
5637 void *v15; // ecx@9 | |
5638 int v16; // eax@9 | |
5639 int v17; // edi@9 | |
5640 double v18; // st7@9 | |
5641 signed int v19; // ebx@9 | |
5642 void *v20; // ecx@9 | |
5643 int v21; // ebx@11 | |
5644 int v22; // eax@14 | |
5645 signed __int64 v23; // qtt@16 | |
5646 double v24; // st7@16 | |
5647 unsigned __int8 v25; // sf@16 | |
5648 unsigned __int8 v26; // of@16 | |
5649 Render *v27; // ecx@17 | |
5650 double v28; // st7@20 | |
5651 char *v29; // ebx@20 | |
5652 char *v30; // edx@20 | |
5653 unsigned __int8 v31; // c0@21 | |
5654 unsigned __int8 v32; // c3@21 | |
5655 double v33; // st6@23 | |
5656 char *v34; // esi@30 | |
5657 const void *v35; // ecx@31 | |
5658 int v36; // eax@31 | |
5659 const void *v37; // edi@31 | |
5660 signed __int64 v38; // qax@31 | |
5661 int v39; // ecx@31 | |
5662 int v40; // ebx@33 | |
5663 int v41; // eax@36 | |
5664 signed __int64 v42; // qtt@39 | |
5665 int v43; // eax@39 | |
5666 char v44; // zf@39 | |
5667 double v45; // st7@39 | |
5668 double v46; // st7@39 | |
5669 unsigned int v47; // edx@40 | |
5670 double v48; // st7@41 | |
5671 RenderVertexSoft *v49; // ebx@41 | |
5672 void *v50; // edi@43 | |
5673 double v51; // st7@46 | |
5674 RenderVertexSoft *v52; // edx@46 | |
5675 void *v53; // edi@48 | |
5676 char *v54; // ebx@52 | |
5677 unsigned int v55; // eax@53 | |
5678 unsigned int v56; // eax@55 | |
5679 int v57; // ST10_4@55 | |
5680 Texture *v58; // eax@55 | |
5681 signed int v59; // [sp-4h] [bp-178h]@17 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
5682 struct Polygon *v60; // [sp+0h] [bp-174h]@17 |
1390 | 5683 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
5684 struct Polygon v62; // [sp+14h] [bp-160h]@6 |
1390 | 5685 unsigned int v63; // [sp+120h] [bp-54h]@7 |
5686 double v64; // [sp+124h] [bp-50h]@7 | |
5687 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
5688 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
5689 float v67; // [sp+130h] [bp-44h]@7 | |
5690 __int64 v68; // [sp+134h] [bp-40h]@3 | |
5691 __int64 v69; // [sp+13Ch] [bp-38h]@3 | |
5692 int v70; // [sp+144h] [bp-30h]@3 | |
5693 int X; // [sp+148h] [bp-2Ch]@9 | |
5694 int v72; // [sp+14Ch] [bp-28h]@7 | |
5695 float v73; // [sp+150h] [bp-24h]@16 | |
5696 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
5697 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 | |
5698 float v76; // [sp+15Ch] [bp-18h]@9 | |
5699 int v77; // [sp+160h] [bp-14h]@9 | |
5700 int v78; // [sp+164h] [bp-10h]@7 | |
5701 void *v79; // [sp+168h] [bp-Ch]@9 | |
5702 float v80; // [sp+16Ch] [bp-8h]@3 | |
5703 const void *v81; // [sp+170h] [bp-4h]@7 | |
5704 | |
5705 __debugbreak(); | |
5706 | |
5707 pFace = &pIndoor->pFaces[uFaceID]; | |
5708 v65 = uFaceID; | |
5709 v3 = uNumVertices; | |
5710 v4 = pFace->uPolygonType; | |
5711 if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor ) | |
5712 { | |
5713 if ( (signed int)uNumVertices > 0 ) | |
5714 { | |
5715 v54 = (char *)&array_507D30[0].u; | |
5716 LODWORD(v80) = uNumVertices; | |
5717 do | |
5718 { | |
5719 v69 = (GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x; | |
5720 *(float *)v54 = (double)v69 + *(float *)v54; | |
5721 *(float *)v54 = *(float *)v54 * 0.25; | |
5722 v55 = GetTickCount(); | |
5723 v54 += 48; | |
5724 v44 = LODWORD(v80)-- == 1; | |
5725 v68 = pBLVRenderParams->vPartyPos.y + (v55 >> 5); | |
5726 *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25; | |
5727 } | |
5728 while ( !v44 ); | |
5729 uFaceID = v65; | |
5730 } | |
5731 v56 = 8 * uFaceID; | |
5732 LOBYTE(v56) = PID(OBJECT_BModel,uFaceID); | |
5733 v57 = v56; | |
5734 v58 = pFace->GetTexture(); | |
5735 pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0); | |
5736 return; | |
5737 } | |
5738 HIDWORD(v69) = pIndoorCamera->sRotationX; | |
5739 HIDWORD(v68) = pIndoorCamera->pos.z; | |
5740 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY; | |
5741 v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z) | |
5742 / (((double)pBLVRenderParams->field_40 + 16192.0) | |
5743 * 65536.0) | |
5744 + *(float *)&v74); | |
5745 v5 = (double)pIndoorCamera->sRotationX * 0.0030664064; | |
5746 *(float *)&v75 = v5; | |
5747 v80 = cos(v5) * 16192.0; | |
5748 v6 = (signed __int64)(*(float *)&v74 | |
5749 - (double)pBLVRenderParams->field_40 | |
5750 / ((v80 + 0.0000001) | |
5751 * 65535.0) | |
5752 * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68))); | |
5753 v7 = pFace->uPolygonType; | |
5754 if ( v7 == 4 || v7 == 3 ) | |
5755 v70 = v6; | |
5756 stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0); | |
5757 v62._48607B(&stru_8019C8); | |
5758 v62.uTileBitmapID = pFace->uBitmapID; | |
5759 v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0); | |
5760 if ( !v62.pTexture ) | |
5761 return; | |
5762 v8 = pBLVRenderParams->sPartyRotX; | |
5763 v62.dimming_level = 0; | |
5764 v62.uNumVertices = v3; | |
5765 v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX + 16); | |
5766 v62.v_18.y = 0; | |
5767 v62.v_18.x = -v9; | |
5768 v62.v_18.z = -stru_5C6E00->Cos(v8 + 16); | |
5769 v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX; | |
5770 memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3])); | |
5771 LODWORD(v80) = v10; | |
5772 v62.field_24 = 33554432; | |
5773 v64 = (double)(signed int)v10 * 0.5; | |
5774 v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); | |
5775 LODWORD(v80) = v62.pTexture->uTextureWidth; | |
5776 v11 = 1.0 / (double)SLODWORD(v80); | |
5777 LODWORD(v80) = v62.pTexture->uTextureHeight; | |
5778 v12 = v62.pTexture->uWidthMinus1; | |
5779 v13 = v62.pTexture->uHeightMinus1; | |
5780 v67 = v11; | |
5781 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; | |
5782 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
5783 v78 = 0; | |
5784 v81 = 0; | |
5785 *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80); | |
5786 if ( (signed int)v62.uNumVertices <= 0 ) | |
5787 { | |
5788 LABEL_17: | |
5789 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; | |
5790 v27 = pRenderer; | |
5791 v60 = &v62; | |
5792 v59 = v62.uNumVertices; | |
5793 goto LABEL_18; | |
5794 } | |
5795 v14 = (char *)&array_507D30[0].vWorldViewProjY; | |
5796 while ( 2 ) | |
5797 { | |
5798 v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14)); | |
5799 LODWORD(v80) = v62.ptr_38->field_14; | |
5800 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; | |
5801 v16 = v77 + v62.ptr_38->field_C; | |
5802 v77 = (int)v15; | |
5803 v74 = v16; | |
5804 LODWORD(v80) = v62.ptr_38->field_20; | |
5805 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; | |
5806 v79 = v15; | |
5807 v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18); | |
5808 LODWORD(v80) = v62.v_18.z; | |
5809 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16); | |
5810 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1)); | |
5811 v18 = *(float *)v14 - 1.0; | |
5812 v19 = -v62.field_24; | |
5813 v77 = -v62.field_24; | |
5814 X = (int)((char *)v79 + v62.v_18.x); | |
5815 LODWORD(v76) = (signed __int64)v18; | |
5816 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
5817 while ( 1 ) | |
5818 { | |
5819 v79 = v20; | |
5820 if ( !X ) | |
5821 goto LABEL_14; | |
5822 v21 = abs(v19 >> 14); | |
5823 if ( v21 <= abs(X) ) | |
5824 break; | |
5825 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5826 break; | |
5827 v19 = v77; | |
5828 v20 = v79; | |
5829 LABEL_14: | |
5830 LODWORD(v80) = v62.v_18.z; | |
5831 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16); | |
5832 v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16; | |
5833 --LODWORD(v76); | |
5834 v20 = (char *)v20 + v72; | |
5835 X = v22 + v62.v_18.x; | |
5836 v78 = 1; | |
5837 } | |
5838 if ( !v78 ) | |
5839 { | |
5840 LODWORD(v23) = v77 << 16; | |
5841 HIDWORD(v23) = v77 >> 16; | |
5842 v79 = (void *)(v23 / X); | |
5843 v77 = v17; | |
5844 LODWORD(v80) = v62.ptr_38->field_10; | |
5845 v77 = v17; | |
5846 LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16); | |
5847 LODWORD(v80) = v62.ptr_38->field_1C; | |
5848 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16)); | |
5849 v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16; | |
5850 LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16; | |
5851 v14 += 48; | |
5852 LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4); | |
5853 v81 = (char *)v81 + 1; | |
5854 v24 = (double)SLODWORD(v80) * 0.000015259022; | |
5855 LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4); | |
5856 v26 = __OFSUB__((int)v81, v62.uNumVertices); | |
5857 v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0; | |
5858 *((float *)v14 - 10) = v24 * v67; | |
5859 *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1); | |
5860 *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79; | |
5861 if ( !(v25 ^ v26) ) | |
5862 goto LABEL_17; | |
5863 continue; | |
5864 } | |
5865 break; | |
5866 } | |
5867 LODWORD(v73) = 0; | |
5868 v80 = v76; | |
5869 if ( (signed int)v62.uNumVertices > 0 ) | |
5870 { | |
5871 v28 = (double)SLODWORD(v76); | |
5872 LODWORD(v76) = (int)(char *)array_50AC10 + 28; | |
5873 v29 = (char *)&array_50AC10[0].vWorldViewProjX; | |
5874 v30 = (char *)&array_507D30[1].vWorldViewProjY; | |
5875 v79 = array_50AC10; | |
5876 v81 = array_507D30; | |
5877 v78 = v62.uNumVertices; | |
5878 do | |
5879 { | |
5880 v31 = v28 < *((float *)v30 - 12); | |
5881 v32 = v28 == *((float *)v30 - 12); | |
5882 ++LODWORD(v73); | |
5883 memcpy(v79, v81, 0x30u); | |
5884 v79 = (char *)v79 + 48; | |
5885 LODWORD(v76) += 48; | |
5886 v29 += 48; | |
5887 if ( v31 | v32 || v28 >= *(float *)v30 ) | |
5888 { | |
5889 if ( v28 >= *((float *)v30 - 12) || v28 <= *(float *)v30 ) | |
5890 goto LABEL_28; | |
5891 v33 = (*((float *)v30 - 1) - *((float *)v30 - 13)) * v28 / (*(float *)v30 - *((float *)v30 - 12)) | |
5892 + *((float *)v30 - 1); | |
5893 } | |
5894 else | |
5895 { | |
5896 v33 = (*((float *)v30 - 13) - *((float *)v30 - 1)) * v28 / (*((float *)v30 - 12) - *(float *)v30) | |
5897 + *((float *)v30 - 13); | |
5898 } | |
5899 *(float *)v29 = v33; | |
5900 v79 = (char *)v79 + 48; | |
5901 v29 += 48; | |
5902 ++LODWORD(v73); | |
5903 *(unsigned int *)LODWORD(v76) = v28; | |
5904 LODWORD(v76) += 48; | |
5905 LABEL_28: | |
5906 v81 = (char *)v81 + 48; | |
5907 v30 += 48; | |
5908 --v78; | |
5909 } | |
5910 while ( v78 ); | |
5911 } | |
5912 if ( SLODWORD(v73) <= 0 ) | |
5913 goto LABEL_40; | |
5914 v34 = (char *)&array_50AC10[0].vWorldViewProjY; | |
5915 v65 = v77 >> 14; | |
5916 HIDWORD(v69) = LODWORD(v73); | |
5917 do | |
5918 { | |
5919 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34)); | |
5920 v78 = v62.ptr_38->field_14; | |
5921 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); | |
5922 v36 = (int)((char *)v81 + v62.ptr_38->field_C); | |
5923 v81 = v35; | |
5924 v74 = v36; | |
5925 v78 = v62.ptr_38->field_20; | |
5926 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); | |
5927 v78 = (int)v35; | |
5928 v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18); | |
5929 v81 = (const void *)v62.v_18.z; | |
5930 v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16; | |
5931 v37 = (const void *)(v72 | |
5932 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1))); | |
5933 v38 = (signed __int64)(*(float *)v34 - 1.0); | |
5934 v81 = 0; | |
5935 LODWORD(v76) = v38; | |
5936 v39 = v72 * (v70 - v38); | |
5937 while ( 1 ) | |
5938 { | |
5939 v78 = v39; | |
5940 if ( !X ) | |
5941 goto LABEL_36; | |
5942 v40 = abs(X); | |
5943 if ( abs((signed __int64)v65) <= v40 ) | |
5944 break; | |
5945 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5946 break; | |
5947 v39 = v78; | |
5948 LABEL_36: | |
5949 v78 = v62.v_18.z; | |
5950 v41 = (unsigned __int64)(v62.v_18.z * (signed __int64)v39) >> 16; | |
5951 --LODWORD(v76); | |
5952 v39 += v72; | |
5953 X = v41 + v62.v_18.x; | |
5954 v81 = (const void *)1; | |
5955 } | |
5956 if ( v81 ) | |
5957 { | |
5958 v79 = (void *)v62.v_18.z; | |
5959 v78 = 2 * LODWORD(v76); | |
5960 v81 = (const void *)((unsigned __int64)(v62.v_18.z | |
5961 * (signed __int64)(signed int)(signed __int64)(((double)v70 | |
5962 - ((double)(2 * LODWORD(v76)) | |
5963 - *(float *)v34)) | |
5964 * (double)v72)) >> 16); | |
5965 X = (int)((char *)v81 + v62.v_18.x); | |
5966 } | |
5967 LODWORD(v42) = v77 << 16; | |
5968 HIDWORD(v42) = v77 >> 16; | |
5969 v79 = (void *)(v42 / X); | |
5970 v81 = v37; | |
5971 v78 = v62.ptr_38->field_10; | |
5972 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); | |
5973 v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); | |
5974 v74 = (unsigned int)v37; | |
5975 LODWORD(v76) = v43; | |
5976 v78 = v62.ptr_38->field_1C; | |
5977 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16)); | |
5978 v74 = (unsigned __int64)(v43 * v42 / X) >> 16; | |
5979 v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16); | |
5980 v34 += 48; | |
5981 v78 = v66 + ((signed int)v74 >> 4); | |
5982 v44 = HIDWORD(v69)-- == 1; | |
5983 v45 = (double)v78 * 0.000015259022; | |
5984 v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4); | |
5985 *((float *)v34 - 10) = v45 * v67; | |
5986 *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1); | |
5987 v46 = (double)(signed int)v79; | |
5988 *((float *)v34 - 16) = 0.000015258789 * v46; | |
5989 *((float *)v34 - 11) = 65536.0 / v46; | |
5990 } | |
5991 while ( !v44 ); | |
5992 LABEL_40: | |
5993 v47 = 0; | |
5994 if ( SLODWORD(v73) > 0 ) | |
5995 { | |
5996 v48 = (double)SLODWORD(v80); | |
5997 v75 = array_507D30; | |
5998 v49 = array_50AC10; | |
5999 HIDWORD(v69) = LODWORD(v73); | |
6000 do | |
6001 { | |
6002 if ( v48 >= v49->vWorldViewProjY ) | |
6003 { | |
6004 v50 = v75; | |
6005 ++v47; | |
6006 ++v75; | |
6007 memcpy(v50, v49, 0x30u); | |
6008 } | |
6009 ++v49; | |
6010 --HIDWORD(v69); | |
6011 } | |
6012 while ( HIDWORD(v69) ); | |
6013 } | |
6014 v62.uNumVertices = v47; | |
6015 pRenderer->_4A2ED5(v47, &v62, pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]); | |
6016 *(float *)&v74 = 0.0; | |
6017 if ( SLODWORD(v73) > 0 ) | |
6018 { | |
6019 v51 = (double)SLODWORD(v80); | |
6020 v75 = array_507D30; | |
6021 v52 = array_50AC10; | |
6022 v80 = v73; | |
6023 do | |
6024 { | |
6025 if ( v51 <= v52->vWorldViewProjY ) | |
6026 { | |
6027 v53 = v75; | |
6028 ++v74; | |
6029 ++v75; | |
6030 memcpy(v53, v52, 0x30u); | |
6031 } | |
6032 ++v52; | |
6033 --LODWORD(v80); | |
6034 } | |
6035 while ( v80 != 0.0 ); | |
6036 } | |
6037 v62.uNumVertices = v74; | |
6038 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; | |
6039 v60 = &v62; | |
6040 v59 = v74; | |
6041 v27 = pRenderer; | |
6042 LABEL_18: | |
6043 v27->_4A2ED5(v59, v60, v61); | |
6044 } | |
6045 | |
6046 | |
0 | 6047 //----- (004A2FC0) -------------------------------------------------------- |
6048 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
6049 { | |
6050 //Render *v8; // edi@1 | |
6051 //unsigned int v9; // esi@3 | |
1072 | 6052 RenderVertexSoft *v12; // ecx@9 |
6053 RenderVertexD3D3 *v13; // eax@9 | |
0 | 6054 double v14; // st6@10 |
6055 int v15; // edx@10 | |
6056 Texture *v16; // edx@10 | |
6057 double v17; // st6@10 | |
6058 //char v18; // zf@10 | |
6059 Texture *v19; // edx@10 | |
595 | 6060 //Texture *v23; // edx@16 |
6061 //char *v24; // ecx@16 | |
6062 //char *v25; // eax@16 | |
6063 //double v26; // st6@17 | |
6064 //int v27; // esi@17 | |
6065 //double v28; // st6@17 | |
6066 //unsigned int v33; // ecx@18 | |
6067 //char *v34; // eax@19 | |
0 | 6068 //Texture *v45; // edx@23 |
6069 //char *v46; // ecx@23 | |
6070 //char *v47; // eax@23 | |
6071 //double v48; // st6@24 | |
6072 //int v49; // esi@24 | |
6073 //double v50; // st6@24 | |
6074 const char *v53; // [sp-Ch] [bp-20h]@21 | |
6075 //int v54; // [sp-8h] [bp-1Ch]@21 | |
6076 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
6077 const char *v56; // [sp+0h] [bp-14h]@0 | |
6078 int v57; // [sp+4h] [bp-10h]@0 | |
6079 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
6080 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
6081 //int a3a; // [sp+10h] [bp-4h]@4 | |
6082 | |
6083 //v8 = this; | |
6084 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
6085 return; | |
6086 | |
6087 //auto a3 = pFace; | |
6088 //auto a6 = uPackedID; | |
6089 //v59 = pGame->pLightmapBuilder; | |
6090 //v9 = v59->std__vector_000004_size; | |
6091 | |
6092 auto uCorrectedColor = uColor; | |
6093 if (pGame->pLightmapBuilder->std__vector_000004_size) | |
6094 uCorrectedColor = 0xFFFFFFFF; | |
638 | 6095 pGame->AlterGamma_BLV(pFace, &uCorrectedColor); |
0 | 6096 |
792 | 6097 |
6098 if (pFace->uAttributes & FACE_OUTLINED) | |
6099 { | |
6100 int color; | |
6101 if (GetTickCount() % 300 >= 150) | |
6102 uColor = uCorrectedColor = 0xFF20FF20; | |
6103 else uColor = uCorrectedColor = 0xFF109010; | |
6104 } | |
6105 | |
0 | 6106 if (byte_4D864C && pGame->uFlags & 1) |
6107 { | |
6108 __debugbreak(); | |
6109 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 6110 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 6111 for (uint i = 0; i < uNumVertices; ++i) |
6112 { | |
6113 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
6114 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
6115 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
6116 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
6117 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
6118 d3d_vertex_buffer[i].specular = 0; | |
6119 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
6120 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
6121 } | |
6122 | |
186 | 6123 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 6124 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
6125 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
6126 D3DPT_TRIANGLEFAN, | |
6127 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
6128 d3d_vertex_buffer, |
0 | 6129 uNumVertices, |
6130 28)); | |
6131 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
6132 } | |
6133 else | |
6134 { | |
6135 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
6136 byte_4D864C && pGame->uFlags & 2) | |
6137 { | |
6138 for (uint i = 0; i < uNumVertices; ++i) | |
6139 { | |
186 | 6140 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
6141 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
6142 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
6143 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
6144 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
6145 d3d_vertex_buffer[i].specular = 0; | |
6146 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
6147 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
6148 } | |
6149 | |
6150 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 6151 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
6152 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
6153 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
6154 d3d_vertex_buffer, |
0 | 6155 uNumVertices, |
6156 28)); | |
6157 } | |
6158 else | |
6159 { | |
595 | 6160 for (uint i = 0; i < uNumVertices; ++i) |
6161 { | |
6162 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
6163 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
6164 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
6165 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
6166 d3d_vertex_buffer[i].diffuse = uColor; | |
6167 d3d_vertex_buffer[i].specular = 0; | |
6168 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
6169 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
6170 } | |
6171 //__debugbreak(); | |
6172 //if ( (signed int)uNumVertices > 0 ) | |
6173 //{ | |
6174 //v23 = pTex; | |
6175 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
6176 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
6177 //pTex = (Texture *)uNumVertices; | |
6178 //uint v18; | |
6179 //do | |
6180 //{ | |
6181 //v26 = *(float *)v24 * 0.061758894; | |
6182 //v27 = *((int *)v24 + 3); | |
6183 //*((int *)v25 + 4) = 0; | |
6184 //*((int *)v25 - 1) = v27; | |
6185 //*(int *)v25 = *((int *)v24 + 4); | |
6186 //*((int *)v25 + 3) = uColor; | |
6187 //v25 += 32; | |
6188 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
6189 //v28 = 1.0 / *(float *)v24; | |
6190 //v24 += 48; | |
6191 //v18 = pTex == (Texture *)1; | |
6192 //pTex = (Texture *)((char *)pTex - 1); | |
6193 //*((float *)v25 - 6) = v28; | |
0 | 6194 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 6195 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 6196 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 6197 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
6198 //} | |
6199 //while ( !v18 ); | |
6200 //} | |
0 | 6201 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 6202 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 6203 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 6204 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 6205 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
6206 d3d_vertex_buffer, |
0 | 6207 uNumVertices, |
6208 28)); | |
595 | 6209 |
6210 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 6211 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); |
595 | 6212 |
6213 for (uint i = 0; i < uNumVertices; ++i) | |
6214 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
6215 /*v33 = uNumVertices; | |
0 | 6216 if ( (signed int)uNumVertices > 0 ) |
6217 { | |
186 | 6218 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 6219 do |
6220 { | |
6221 *(int *)v34 = uCorrectedColor; | |
6222 v34 += 32; | |
6223 --v33; | |
6224 } | |
6225 while ( v33 ); | |
595 | 6226 }*/ |
0 | 6227 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 6228 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
6229 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6230 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6231 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
6232 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
6233 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 6234 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
6235 d3d_vertex_buffer, |
0 | 6236 uNumVertices, |
6237 28)); | |
186 | 6238 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
6239 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6240 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 6241 } |
6242 } | |
6243 } | |
6244 // 4D864C: using guessed type char byte_4D864C; | |
6245 | |
6246 //----- (004A43B1) -------------------------------------------------------- | |
717 | 6247 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
6248 { | |
6249 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
6250 //double v5; // st7@2 | |
6251 //float v6; // ST08_4@2 | |
0 | 6252 unsigned int v7; // eax@2 |
717 | 6253 //int v8; // ecx@2 |
6254 //unsigned int v9; // esi@2 | |
6255 //Sprite *v10; // edi@5 | |
0 | 6256 signed int v11; // eax@9 |
6257 signed int v12; // eax@9 | |
717 | 6258 //double v13; // st7@12 |
6259 //double v14; // st6@12 | |
0 | 6260 double v15; // st5@12 |
6261 double v16; // st4@12 | |
6262 double v17; // st3@12 | |
6263 double v18; // st2@12 | |
6264 int v19; // ecx@14 | |
6265 double v20; // st3@14 | |
6266 int v21; // ecx@16 | |
6267 double v22; // st3@16 | |
717 | 6268 //IDirect3DTexture2 *v23; // eax@18 |
6269 //signed int v24; // [sp+18h] [bp-18h]@5 | |
6270 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
6271 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 6272 float v27; // [sp+24h] [bp-Ch]@5 |
6273 int v28; // [sp+28h] [bp-8h]@2 | |
6274 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 6275 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 6276 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 6277 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 6278 float a1; // [sp+40h] [bp+10h]@5 |
6279 | |
717 | 6280 //v26 = this; |
0 | 6281 if ( this->uNumD3DSceneBegins ) |
6282 { | |
717 | 6283 //v4 = pSoftBillboard; |
6284 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
6285 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
6286 //v6 = pSoftBillboard->zbuffer_depth; | |
6287 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
6288 //v8 = dimming_level; | |
6289 //v9 = v7; | |
657 | 6290 v28 = dimming_level & 0xFF000000; |
6291 if ( dimming_level & 0xFF000000 ) | |
717 | 6292 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; |
0 | 6293 else |
717 | 6294 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; |
6295 //v10 = a3; | |
6296 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
6297 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
6298 pBillboardRenderListD3D[v7].uParentBillboardID = pSoftBillboard->uParentBillboardID; | |
6299 //v25 = pSoftBillboard->uScreenSpaceX; | |
6300 //v24 = pSoftBillboard->uScreenSpaceY; | |
6301 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
6302 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
6303 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
6304 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
6305 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 6306 v31 = v31 * -1.0; |
717 | 6307 if ( pSoftBillboard->uTintColor && this->bTinting ) |
6308 { | |
6309 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
737 | 6310 v12 = BlendColors(pSoftBillboard->uTintColor, v11); |
0 | 6311 if ( v28 ) |
6312 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
6313 } | |
6314 else | |
6315 { | |
717 | 6316 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
6317 } | |
6318 //v13 = (double)v25; | |
1390 | 6319 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; |
6320 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
6321 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
717 | 6322 //v14 = (double)v24; |
6323 //v32 = v14; | |
1390 | 6324 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; |
717 | 6325 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); |
1390 | 6326 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; |
717 | 6327 v16 = 1.0 / pSoftBillboard->zbuffer_depth; |
1390 | 6328 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; |
6329 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
6330 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
717 | 6331 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); |
6332 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
6333 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 6334 v17 = v17 * -1.0; |
1390 | 6335 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; |
6336 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
6337 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
6338 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
6339 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
6340 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
6341 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
6342 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
717 | 6343 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; |
6344 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
6345 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 6346 v20 = v20 * -1.0; |
1390 | 6347 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; |
6348 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
6349 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
6350 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
6351 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
6352 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
6353 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
6354 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
717 | 6355 v21 = pSprite->uBufferHeight - pSprite->uAreaY; |
6356 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
6357 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 6358 v22 = v22 * -1.0; |
1390 | 6359 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; |
6360 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
6361 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
6362 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
6363 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
6364 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
6365 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
6366 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
717 | 6367 //v23 = pSprite->pTexture; |
6368 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
6369 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
6370 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 6371 } |
6372 } | |
6373 | |
6374 //----- (004A354F) -------------------------------------------------------- | |
6375 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
6376 { | |
743 | 6377 //double v5; // st7@3 |
6378 //float v6; // ST20_4@3 | |
6379 //float v7; // ST00_4@3 | |
0 | 6380 unsigned int v8; // esi@3 |
743 | 6381 //int v9; // eax@3 |
6382 //int v10; // ebx@3 | |
0 | 6383 float v11; // ST28_4@3 |
743 | 6384 //double v12; // st7@3 |
6385 //float v13; // ST24_4@3 | |
6386 //double v14; // st6@3 | |
6387 //float v15; // ST1C_4@3 | |
0 | 6388 float v16; // ST2C_4@3 |
6389 float v17; // ST30_4@3 | |
6390 signed int v18; // ST18_4@3 | |
6391 signed int v19; // ST14_4@3 | |
6392 signed int v20; // ST10_4@3 | |
6393 signed int v21; // eax@3 | |
6394 double v22; // st6@3 | |
6395 float v23; // ST2C_4@3 | |
6396 float v24; // ST30_4@3 | |
6397 signed int v25; // ST10_4@3 | |
6398 signed int v26; // ST14_4@3 | |
6399 signed int v27; // ST18_4@3 | |
6400 signed int v28; // eax@3 | |
6401 double v29; // st6@3 | |
6402 float v30; // ecx@3 | |
6403 float v31; // ST2C_4@3 | |
6404 float v32; // ST30_4@3 | |
6405 signed int v33; // ST10_4@3 | |
6406 signed int v34; // ST14_4@3 | |
6407 signed int v35; // ST18_4@3 | |
6408 signed int v36; // eax@3 | |
6409 float v37; // ecx@3 | |
6410 double v38; // st6@3 | |
6411 float v39; // ST2C_4@3 | |
6412 float v40; // ST30_4@3 | |
6413 signed int v41; // ST10_4@3 | |
6414 signed int v42; // ST14_4@3 | |
6415 signed int v43; // ST18_4@3 | |
6416 signed int v44; // eax@3 | |
6417 double v45; // st6@3 | |
6418 float v46; // eax@3 | |
6419 | |
6420 if ( this->uNumD3DSceneBegins ) | |
6421 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6422 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6423 { |
743 | 6424 //v5 = (double)a2->zbuffer_depth; |
6425 //v6 = v5; | |
6426 //v7 = v5; | |
6427 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
0 | 6428 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; |
6429 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
6430 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
6431 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
743 | 6432 //v9 = a2->uScreenSpaceX; |
6433 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6434 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 6435 //v12 = (double) a2->uScreenSpaceX; |
6436 //v13 = v12; | |
6437 //v14 = (double)(a2->uScreenSpaceY - 12); | |
6438 //v15 = v14; | |
6439 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
6440 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 6441 v18 = stru_5C6E00->Cos(angle); |
6442 v19 = stru_5C6E00->Sin(angle); | |
6443 v20 = stru_5C6E00->Sin(angle); | |
6444 v21 = stru_5C6E00->Cos(angle); | |
1390 | 6445 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 6446 + (double)(v18 >> 16)) |
6447 * v16 | |
6448 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
6449 + (double)(v19 >> 16)) | |
6450 * v17) | |
743 | 6451 * v11 + (double) a2->uScreenSpaceX; |
0 | 6452 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
6453 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
6454 - 12.0) | |
6455 * v11 | |
6456 + (double)a2->uScreenSpaceY; | |
1390 | 6457 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
6458 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
6459 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
6460 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
6461 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
6462 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
6463 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
743 | 6464 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
6465 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 6466 v25 = stru_5C6E00->Cos(angle); |
6467 v26 = stru_5C6E00->Sin(angle); | |
6468 v27 = stru_5C6E00->Sin(angle); | |
6469 v28 = stru_5C6E00->Cos(angle); | |
1390 | 6470 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
0 | 6471 + (double)(v25 >> 16)) |
740 | 6472 * v31 |
0 | 6473 - ((double)(unsigned __int16)v26 * 0.000015259022 |
6474 + (double)(v26 >> 16)) | |
740 | 6475 * v32) |
743 | 6476 * v11 + (double) a2->uScreenSpaceX; |
740 | 6477 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
6478 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 6479 - 12.0) |
6480 * v11 | |
6481 + (double)a2->uScreenSpaceY; | |
1390 | 6482 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
6483 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
6484 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
6485 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
6486 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
6487 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
6488 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
6489 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
743 | 6490 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
6491 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 6492 v33 = stru_5C6E00->Cos(angle); |
6493 v34 = stru_5C6E00->Sin(angle); | |
6494 v35 = stru_5C6E00->Sin(angle); | |
6495 v36 = stru_5C6E00->Cos(angle); | |
1390 | 6496 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
0 | 6497 + (double)(v33 >> 16)) |
740 | 6498 * v23 |
0 | 6499 - ((double)(unsigned __int16)v34 * 0.000015259022 |
6500 + (double)(v34 >> 16)) | |
740 | 6501 * v24) |
743 | 6502 * v11 + (double) a2->uScreenSpaceX; |
1390 | 6503 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
740 | 6504 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
6505 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 6506 - 12.0) |
6507 * v11 | |
6508 + (double)a2->uScreenSpaceY; | |
1390 | 6509 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
6510 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
6511 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
6512 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
6513 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
6514 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
6515 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
743 | 6516 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
6517 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 6518 v41 = stru_5C6E00->Cos(angle); |
6519 v42 = stru_5C6E00->Sin(angle); | |
6520 v43 = stru_5C6E00->Sin(angle); | |
6521 v44 = stru_5C6E00->Cos(angle); | |
1390 | 6522 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
0 | 6523 + (double)(v41 >> 16)) |
6524 * v39 | |
6525 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
6526 + (double)(v42 >> 16)) | |
6527 * v40) | |
743 | 6528 * v11 + (double) a2->uScreenSpaceX; |
0 | 6529 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
6530 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
6531 - 12.0) | |
6532 * v11 | |
6533 + (double)a2->uScreenSpaceY; | |
1390 | 6534 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; |
6535 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
6536 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
6537 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
6538 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 6539 pBillboardRenderListD3D[v8].pTexture = a3; |
743 | 6540 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 6541 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 6542 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; |
6543 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
6544 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 6545 } |
6546 } | |
6547 } | |
6548 | |
6549 //----- (004A3AD9) -------------------------------------------------------- | |
6550 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
6551 { | |
6552 double v5; // st7@2 | |
6553 float v6; // ST28_4@2 | |
6554 float v7; // ST00_4@2 | |
6555 unsigned int v8; // esi@2 | |
6556 int v9; // eax@2 | |
6557 int v10; // ebx@2 | |
6558 float v11; // ST34_4@2 | |
6559 double v12; // st7@2 | |
6560 float v13; // ST2C_4@2 | |
6561 double v14; // st6@2 | |
6562 float v15; // ST24_4@2 | |
6563 float v16; // ST38_4@2 | |
6564 float v17; // ST3C_4@2 | |
6565 signed int v18; // ST1C_4@2 | |
6566 int v19; // ST30_4@2 | |
6567 signed int v20; // ST20_4@2 | |
6568 signed int v21; // ST18_4@2 | |
6569 signed int v22; // eax@2 | |
6570 double v23; // st6@2 | |
6571 float v24; // ST20_4@2 | |
6572 float v25; // ST1C_4@2 | |
6573 float v26; // ST38_4@2 | |
6574 float v27; // ST3C_4@2 | |
6575 signed int v28; // ST18_4@2 | |
6576 signed int v29; // ST14_4@2 | |
6577 signed int v30; // ST10_4@2 | |
6578 signed int v31; // eax@2 | |
6579 double v32; // st6@2 | |
6580 float v33; // ST38_4@2 | |
6581 float v34; // ST3C_4@2 | |
6582 signed int v35; // ST10_4@2 | |
6583 signed int v36; // ST14_4@2 | |
6584 signed int v37; // ST18_4@2 | |
6585 signed int v38; // eax@2 | |
6586 double v39; // st6@2 | |
6587 float v40; // ST38_4@2 | |
6588 float v41; // ST3C_4@2 | |
6589 signed int v42; // ST10_4@2 | |
6590 signed int v43; // ST14_4@2 | |
6591 signed int v44; // ST18_4@2 | |
6592 signed int v45; // eax@2 | |
6593 double v46; // st6@2 | |
6594 | |
6595 if ( this->uNumD3DSceneBegins ) | |
6596 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6597 v5 = (double)a2->zbuffer_depth; |
0 | 6598 v6 = v5; |
6599 v7 = v5; | |
6600 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
6601 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
6602 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
6603 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
6604 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
6605 v9 = a2->uScreenSpaceX; | |
6606 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6607 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 6608 v12 = (double)v9; |
6609 v13 = v12; | |
6610 v14 = (double)(v10 - 12); | |
6611 v15 = v14; | |
6612 v16 = (double)(v9 - 12) - v12; | |
6613 v17 = (double)(v10 - 25) - v14; | |
323 | 6614 v18 = stru_5C6E00->Cos(angle); |
0 | 6615 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 6616 v20 = stru_5C6E00->Sin(angle); |
6617 v21 = stru_5C6E00->Sin(angle); | |
6618 v22 = stru_5C6E00->Cos(angle); | |
1390 | 6619 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
0 | 6620 + (double)(v18 >> 16)) |
6621 * v16 | |
6622 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
6623 + (double)(v20 >> 16)) | |
6624 * v17) | |
6625 * v11 + v13; | |
6626 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
6627 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
6628 - 12.0) | |
6629 * v11 | |
6630 + (double)a2->uScreenSpaceY; | |
1390 | 6631 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; |
6632 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
6633 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
0 | 6634 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); |
1390 | 6635 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; |
0 | 6636 v25 = 1.0 / v6; |
1390 | 6637 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; |
6638 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
6639 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
0 | 6640 v26 = (double)(a2->uScreenSpaceX - 12) - v13; |
6641 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 6642 v28 = stru_5C6E00->Cos(angle); |
6643 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6644 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6645 v31 = stru_5C6E00->Cos(angle); | |
1390 | 6646 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
0 | 6647 + (double)(v28 >> 16)) |
6648 * v26 | |
6649 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
6650 + (double)(v29 >> 16)) | |
6651 * v27) | |
6652 * v11 + v13; | |
6653 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
6654 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
6655 - 12.0) | |
6656 * v11 | |
6657 + (double)a2->uScreenSpaceY; | |
1390 | 6658 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; |
6659 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
6660 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
6661 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
6662 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
6663 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
6664 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
0 | 6665 v33 = (double)(a2->uScreenSpaceX + 12) - v13; |
6666 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 6667 v35 = stru_5C6E00->Cos(angle); |
6668 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6669 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6670 v38 = stru_5C6E00->Cos(angle); | |
1390 | 6671 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
0 | 6672 + (double)(v35 >> 16)) |
6673 * v33 | |
6674 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
6675 + (double)(v36 >> 16)) | |
6676 * v34) | |
6677 * v11 + v13; | |
6678 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
6679 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
6680 - 12.0) | |
6681 * v11 | |
6682 + (double)a2->uScreenSpaceY; | |
1390 | 6683 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; |
6684 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
6685 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
6686 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
6687 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
6688 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
6689 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
0 | 6690 v40 = (double)(a2->uScreenSpaceX + 12) - v13; |
6691 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 6692 v42 = stru_5C6E00->Cos(angle); |
6693 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6694 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
6695 v45 = stru_5C6E00->Cos(angle); | |
1390 | 6696 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
0 | 6697 + (double)(v42 >> 16)) |
6698 * v40 | |
6699 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
6700 + (double)(v43 >> 16)) | |
6701 * v41) | |
6702 * v11 + v13; | |
6703 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
6704 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
6705 - 12.0) | |
6706 * v11 | |
6707 + (double)a2->uScreenSpaceY; | |
1390 | 6708 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; |
6709 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
6710 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
6711 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
0 | 6712 pBillboardRenderListD3D[v8].pTexture = a3; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6713 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 6714 pBillboardRenderListD3D[v8].uNumVertices = 4; |
1390 | 6715 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; |
6716 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
6717 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
0 | 6718 } |
6719 } | |
6720 | |
6721 //----- (004A4023) -------------------------------------------------------- | |
657 | 6722 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
|
6723 { |
0 | 6724 unsigned int v8; // esi@2 |
6725 double v14; // st6@14 | |
6726 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6727 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6728 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6729 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6730 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6731 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6732 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6733 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6734 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6735 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6736 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 6737 float v29; // [sp+28h] [bp-8h]@5 |
6738 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6739 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6740 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6741 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6742 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6743 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6744 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6745 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6746 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
|
6747 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
|
6748 |
657 | 6749 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6750 if (a2->uTintColor & 0x00FFFFFF && bTinting) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6751 { |
737 | 6752 diffuse = BlendColors(a2->uTintColor, diffuse); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6753 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6754 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6755 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6756 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6757 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6758 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6759 specular = sub_47C3D7_get_fog_related_stuff(0, 0, a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6760 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6761 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6762 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6763 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6764 v14 *= -1.0; |
1390 | 6765 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; |
6766 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
6767 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
6768 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
6769 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
6770 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
6771 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
6772 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6773 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6774 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6775 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6776 if ( a2->uFlags & 4 ) |
0 | 6777 v14 = v14 * -1.0; |
1390 | 6778 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; |
6779 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
6780 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
6781 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
6782 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
6783 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; | |
6784 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
6785 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6786 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6787 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
|
6788 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6789 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6790 v14 *= -1.0; |
1390 | 6791 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; |
6792 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
6793 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
6794 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
6795 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
6796 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; | |
6797 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
6798 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6799 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6800 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
|
6801 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6802 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6803 v14 *= -1.0; |
1390 | 6804 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; |
6805 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
6806 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
6807 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
6808 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
6809 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; | |
6810 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
6811 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6812 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6813 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6814 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6815 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6816 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6817 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6818 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6819 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6820 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6821 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6822 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
6823 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 6824 } |
6825 | |
6826 //----- (004A48E4) -------------------------------------------------------- | |
6827 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
6828 { | |
6829 int v6; // ecx@1 | |
6830 int v7; // ebx@1 | |
6831 int v8; // ecx@1 | |
6832 int v9; // edx@1 | |
6833 int v10; // edi@1 | |
6834 unsigned int x; // esi@1 | |
6835 int result; // eax@8 | |
6836 int v13; // [sp+Ch] [bp-10h]@1 | |
6837 int v14; // [sp+10h] [bp-Ch]@1 | |
6838 int v15; // [sp+14h] [bp-8h]@1 | |
6839 int v16; // [sp+18h] [bp-4h]@1 | |
6840 int v17; // [sp+24h] [bp+8h]@1 | |
6841 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
6842 int v19; // [sp+34h] [bp+18h]@1 | |
6843 | |
6844 v6 = screenSpaceX; | |
6845 v7 = (a6 >> 1) + screenSpaceY; | |
6846 v17 = 0; | |
6847 v15 = 0; | |
6848 v8 = (a6 >> 1) + v6; | |
6849 v14 = (a6 >> 1) * (a6 >> 1); | |
6850 v9 = 2 * (a6 >> 1); | |
6851 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
6852 x = v8 - (a6 >> 1); | |
6853 v16 = (a6 >> 1) + screenSpaceY - v8; | |
6854 v19 = a6 >> 1; | |
6855 v13 = v9; | |
6856 v18 = v8; | |
6857 do | |
6858 { | |
6859 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
6860 if ( v15 ) | |
6861 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
6862 v14 -= v15; | |
6863 if ( v14 <= v10 ) | |
6864 { | |
6865 if ( v19 != v17 ) | |
6866 { | |
6867 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
6868 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
6869 } | |
6870 --v19; | |
6871 v13 -= 2; | |
6872 ++x; | |
6873 v10 -= v13; | |
6874 } | |
6875 result = v17++; | |
6876 v15 += 2; | |
6877 --v18; | |
6878 } | |
6879 while ( result < v19 ); | |
6880 return result; | |
6881 } | |
6882 | |
6883 //----- (004A49D0) -------------------------------------------------------- | |
6884 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
6885 { | |
1159 | 6886 int absXDifference; // eax@1 |
6887 int absYDifference; // eax@1 | |
6888 unsigned int smallerabsdiff; // ebx@1 | |
6889 unsigned int largerabsdiff; | |
0 | 6890 double v16; // st7@7 |
6891 double v17; // st7@7 | |
6892 double v18; // st6@7 | |
6893 double v20; // st4@8 | |
6894 double v21; // st4@10 | |
6895 double v22; // st4@10 | |
6896 double v23; // st4@10 | |
6897 double v25; // st4@11 | |
6898 double v26; // st4@13 | |
6899 double v28; // st4@13 | |
6900 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
1159 | 6901 int xDifference; // [sp+88h] [bp-Ch]@1 |
0 | 6902 signed int v32; // [sp+8Ch] [bp-8h]@1 |
1159 | 6903 int yDifference; // [sp+90h] [bp-4h]@1 |
6904 | |
6905 xDifference = bankersRounding(dstX - srcX); | |
6906 yDifference = bankersRounding(dstY - srcY); | |
6907 absYDifference = abs(yDifference); | |
6908 absXDifference = abs(xDifference); | |
6909 smallerabsdiff = min(absXDifference, absYDifference); | |
6910 largerabsdiff = max(absXDifference, absYDifference); | |
6911 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
0 | 6912 v16 = 1.0 / (double)v32; |
1159 | 6913 v17 = (double)yDifference * v16 * a4; |
6914 v18 = (double)xDifference * v16 * a4; | |
6915 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
6916 { | |
6917 v20 = a3 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
6918 v25 = a7 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
6919 } | |
6920 else | |
6921 { | |
6922 v20 = a3 * 0.061758894; | |
6923 v25 = a7 * 0.061758894; | |
6924 } | |
6925 v21 = 1.0 / a3; | |
6926 v22 = (double)yDifference * v16 * a8; | |
6927 v23 = (double)xDifference * v16 * a8; | |
6928 v26 = 1.0 - 1.0 / v25; | |
6929 v28 = 1.0 / a7; | |
0 | 6930 v29[0].pos.x = srcX + v17; |
6931 v29[0].pos.y = srcY - v18; | |
1159 | 6932 v29[0].pos.z = 1.0 - 1.0 / v20; |
6933 v29[0].rhw = v21; | |
0 | 6934 v29[0].diffuse = -1; |
6935 v29[0].specular = 0; | |
6936 v29[0].texcoord.x = 1.0; | |
6937 v29[0].texcoord.y = 0.0; | |
1159 | 6938 |
0 | 6939 v29[1].pos.x = v22 + dstX; |
6940 v29[1].pos.y = dstY - v23; | |
1159 | 6941 v29[1].pos.z = v26; |
6942 v29[1].rhw = v28; | |
0 | 6943 v29[1].diffuse = -16711936; |
6944 v29[1].specular = 0; | |
6945 v29[1].texcoord.x = 1.0; | |
6946 v29[1].texcoord.y = 1.0; | |
1159 | 6947 |
6948 v29[2].pos.x = dstX - v22; | |
6949 v29[2].pos.y = v23 + dstY; | |
6950 v29[2].pos.z = v26; | |
0 | 6951 v29[2].rhw = v28; |
1159 | 6952 v29[2].diffuse = -1; |
6953 v29[2].specular = 0; | |
0 | 6954 v29[2].texcoord.x = 0.0; |
6955 v29[2].texcoord.y = 1.0; | |
1159 | 6956 |
0 | 6957 v29[3].pos.x = srcX - v17; |
6958 v29[3].pos.y = v18 + srcY; | |
1159 | 6959 v29[3].pos.z = v29[0].pos.z; |
6960 v29[3].rhw = v21; | |
6961 v29[3].diffuse = -1; | |
6962 v29[3].specular = 0; | |
0 | 6963 v29[3].texcoord.x = 0.0; |
6964 v29[3].texcoord.y = 0.0; | |
186 | 6965 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
6966 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6967 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
6968 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6969 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6970 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 6971 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
6972 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
6973 D3DPT_TRIANGLEFAN, | |
6974 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
6975 v29, | |
6976 4, | |
6977 24)); | |
186 | 6978 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
6979 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6980 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6981 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6982 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6983 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 6984 } |
6985 | |
6986 //----- (004A4CC9) -------------------------------------------------------- | |
1390 | 6987 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) |
6988 { | |
0 | 6989 unsigned int v5; // eax@7 |
6990 char *v7; // edx@8 | |
6991 double v10; // st6@9 | |
6992 double v11; // st6@10 | |
6993 int v12; // ebx@13 | |
1390 | 6994 |
6995 if (a1->uNumVertices < 3) | |
6996 return; | |
6997 | |
6998 float depth = 1000000.0; | |
6999 for (uint i = 0; i < a1->uNumVertices; ++i) | |
7000 { | |
7001 if (a1->field_104[i].z < depth) | |
7002 depth = a1->field_104[i * 4].z; | |
7003 } | |
7004 | |
7005 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
7006 pBillboardRenderListD3D[v5].field_90 = 0; | |
7007 pBillboardRenderListD3D[v5].uParentBillboardID = -1; | |
7008 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | |
7009 pBillboardRenderListD3D[v5].pTexture = 0; | |
7010 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
7011 pBillboardRenderListD3D[v5].z_order = depth; | |
7012 | |
7013 for (uint i = 0; i < a1->uNumVertices; ++i) | |
7014 { | |
7015 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
7016 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
7017 | |
7018 v10 = a1->field_104[i].z; | |
7019 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
7020 v11 = v10 * 0.061758894; | |
7021 else | |
7022 v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
7023 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; | |
7024 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
7025 | |
7026 if (diffuse & 0xFF000000) | |
7027 v12 = a1->field_104[i].diffuse; | |
7028 else | |
7029 v12 = diffuse; | |
7030 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
7031 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
7032 | |
7033 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
7034 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
0 | 7035 } |
7036 } | |
7037 | |
7038 //----- (004A4DE1) -------------------------------------------------------- | |
7039 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
7040 { | |
7041 HRESULT v12; // eax@14 | |
7042 unsigned __int16 *v13; // ecx@19 | |
7043 unsigned __int16 *v14; // eax@19 | |
7044 DWORD v15; // edx@20 | |
7045 HRESULT v16; // eax@23 | |
7046 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
7047 | |
7048 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
7049 if ( pHWLTexture ) | |
7050 { | |
7051 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
7052 if ( !pRenderD3D->CreateTexture( | |
7053 pHWLTexture->uWidth, | |
7054 pHWLTexture->uHeight, | |
7055 pOutSurface, | |
7056 pOutTexture, | |
7057 true, | |
7058 bMipMaps, | |
7059 uMinDeviceTextureDim) ) | |
7060 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
7061 //v10 = *pOutSurface; | |
7062 //v11 = 0; | |
7063 if ( bMipMaps ) | |
7064 { | |
7065 Dst._450DDE(); | |
7066 //v20 = 0; | |
7067 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
7068 | |
7069 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
7070 while ( 1 ) | |
7071 { | |
7072 DDSCAPS2 v19; | |
7073 memset(&v19, 0, sizeof(DDSCAPS2)); | |
7074 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
7075 | |
7076 DDSURFACEDESC2 desc; | |
7077 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
7078 desc.dwSize = sizeof(DDSURFACEDESC2); | |
7079 | |
168 | 7080 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 7081 { |
7082 Dst.sub_451007_scale_image_bicubic( | |
7083 pHWLTexture->pPixels, | |
7084 pHWLTexture->uWidth, | |
7085 pHWLTexture->uHeight, | |
7086 pHWLTexture->uWidth, | |
7087 (unsigned short *)desc.lpSurface, | |
7088 desc.dwWidth, | |
7089 desc.dwHeight, | |
7090 desc.lPitch >> 1, | |
7091 0, | |
7092 0); | |
7093 ErrD3D(pNextSurf->Unlock(0)); | |
7094 //bMipMaps = 0x4D86ACu; | |
7095 } | |
7096 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
7097 break; | |
7098 //v10 = (IDirectDrawSurface4 *)pName; | |
7099 //v11 = 0; | |
7100 } | |
7101 //v20 = -1; | |
7102 //nullsub_1(); | |
7103 } | |
7104 else | |
7105 { | |
7106 DDSCAPS2 v19; | |
7107 memset(&v19, 0, sizeof(DDSCAPS2)); | |
7108 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
7109 | |
7110 DDSURFACEDESC2 desc; | |
7111 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
7112 desc.dwSize = sizeof(DDSURFACEDESC2); | |
7113 | |
168 | 7114 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 7115 { |
7116 bMipMaps = 0; | |
7117 v13 = pHWLTexture->pPixels; | |
7118 v14 = (unsigned __int16 *)desc.lpSurface; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7119 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
|
7120 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7121 for (v15 = 0; v15 < desc.dwWidth; v15++) |
0 | 7122 { |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7123 *v14 = *v13; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7124 ++v14; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7125 ++v13; |
0 | 7126 } |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7127 v14 += (desc.lPitch >> 1) - desc.dwWidth; |
0 | 7128 } |
7129 ErrD3D((*pOutSurface)->Unlock(0)); | |
7130 } | |
7131 } | |
7132 delete [] pHWLTexture->pPixels; | |
7133 delete pHWLTexture; | |
7134 return true; | |
7135 } | |
7136 return false; | |
7137 } | |
7138 | |
7139 //----- (004A5048) -------------------------------------------------------- | |
670 | 7140 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
7141 { | |
7142 | |
7143 HWLTexture *sprite_texture; // eax@1 | |
0 | 7144 unsigned __int16 *v9; // edx@5 |
7145 LPVOID v10; // eax@5 | |
7146 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
7147 | |
670 | 7148 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
7149 if ( sprite_texture ) | |
7150 { | |
7151 _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; | |
7152 pSprite->uAreaX = sprite_texture->uAreaX; | |
7153 pSprite->uAreaY = sprite_texture->uAreaY; | |
7154 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
7155 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
7156 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
7157 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7158 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7159 //v7 = v3->pRenderD3D; |
670 | 7160 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
0 | 7161 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
7162 //pSprite = v2->pTextureSurface; | |
7163 //pSprite = (Sprite *)pSprite->pName; | |
7164 //v8 = pSprite; | |
670 | 7165 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 7166 Dst.dwSize = 124; |
670 | 7167 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
7168 { | |
7169 v9 = sprite_texture->pPixels; | |
7170 v10 = Dst.lpSurface; | |
7171 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 7172 { |
670 | 7173 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
7174 { | |
0 | 7175 *(int *)v10 = *(int *)v9; |
7176 v9 += 2; | |
7177 v10 = (char *)v10 + 4; | |
670 | 7178 } |
7179 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 7180 } |
670 | 7181 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
7182 } | |
7183 free(sprite_texture->pPixels); | |
7184 free(sprite_texture); | |
7185 return true; | |
7186 } | |
7187 return false; | |
0 | 7188 } |
7189 | |
7190 //----- (004A51CB) -------------------------------------------------------- | |
7191 void Render::BeginScene() | |
7192 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7193 //Render *v1; // esi@1 |
0 | 7194 unsigned int v2; // eax@1 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7195 /*int v3; // eax@5 |
0 | 7196 unsigned __int16 **v4; // edi@6 |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7197 char *v5; // ebx@7*/ |
0 | 7198 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 |
7199 | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7200 //v1 = this; |
0 | 7201 v2 = this->uNumSceneBegins; |
7202 this->uNumSceneBegins = v2 + 1; | |
7203 if ( !v2 ) | |
7204 { | |
7205 if ( this->pRenderD3D ) | |
7206 { | |
7207 if ( this->bColorKeySupported ) | |
7208 { | |
7209 memset(&Dst, 0, 0x7Cu); | |
7210 Dst.dwSize = 124; | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7211 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
|
7212 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7213 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7214 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7215 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
|
7216 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7217 --this->uNumSceneBegins; |
0 | 7218 } |
7219 } | |
7220 else | |
7221 { | |
7222 if ( !this->pTargetSurface ) | |
7223 { | |
7224 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7225 if ( this->pTargetSurface ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7226 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7227 this->field_18_locked_pitch = this->uTargetSurfacePitch; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7228 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7229 --this->uNumSceneBegins; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7230 } |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7231 } |
0 | 7232 RestoreFrontBuffer(); |
7233 } | |
7234 } | |
7235 | |
7236 //----- (004A527D) -------------------------------------------------------- | |
7237 void Render::EndScene() | |
7238 { | |
1151
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7239 if ( this->uNumSceneBegins ) |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7240 { |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7241 this->uNumSceneBegins--; |
4eca5bb63dc0
some small rendering cleanups - if+do while to for, unnecessary variable removal
Grumpy7
parents:
1117
diff
changeset
|
7242 if ( !this->uNumSceneBegins ) |
0 | 7243 { |
7244 if ( this->pRenderD3D ) | |
7245 { | |
7246 if ( this->bColorKeySupported ) | |
7247 { | |
7248 this->pTargetSurface = 0; | |
7249 this->uTargetSurfacePitch = 0; | |
7250 this->field_18_locked_pitch = 0; | |
7251 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
7252 } | |
7253 } | |
7254 else | |
7255 { | |
7256 this->pTargetSurface = 0; | |
7257 this->uTargetSurfacePitch = 0; | |
7258 this->field_18_locked_pitch = 0; | |
7259 UnlockBackBuffer(); | |
7260 } | |
7261 } | |
7262 } | |
7263 } | |
7264 | |
7265 //----- ( ) -------------------------------------------------------- | |
7266 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
7267 { | |
7268 unsigned int v3; // esi@1 | |
7269 double v4; // st7@2 | |
7270 double v5; // st7@6 | |
7271 double v6; // st6@6 | |
7272 unsigned int v7; // eax@6 | |
7273 double v8; // st5@6 | |
7274 double v9; // st4@6 | |
7275 HRESULT v10; // eax@6 | |
7276 HRESULT v11; // eax@6 | |
7277 unsigned int result; // eax@6 | |
7278 unsigned int v13; // eax@7 | |
7279 unsigned __int16 *v14; // ecx@7 | |
7280 int *v15; // eax@7 | |
7281 unsigned int v16; // ecx@8 | |
7282 __int16 v17; // ax@10 | |
7283 int v18; // esi@10 | |
7284 float v19; // edi@10 | |
7285 void *v20; // esi@10 | |
7286 int v21; // edx@10 | |
7287 int v22; // ecx@11 | |
7288 int v23; // edx@12 | |
7289 __int16 v24; // ax@15 | |
7290 int v25; // esi@15 | |
7291 float v26; // edi@15 | |
7292 char *v27; // esi@15 | |
7293 int v28; // edx@15 | |
7294 int v29; // ecx@16 | |
7295 int v30; // edx@17 | |
7296 int v31; // [sp-Ch] [bp-ACh]@11 | |
7297 int v32; // [sp-Ch] [bp-ACh]@16 | |
7298 const char *v33; // [sp+0h] [bp-A0h]@0 | |
7299 int v34; // [sp+4h] [bp-9Ch]@0 | |
7300 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
7301 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
7302 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
7303 int v38; // [sp+90h] [bp-10h]@7 | |
7304 double v39; // [sp+94h] [bp-Ch]@6 | |
7305 float v40; // [sp+9Ch] [bp-4h]@6 | |
7306 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
7307 __debugbreak(); |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
7308 |
0 | 7309 auto ecx0 = this; |
7310 v3 = 0; | |
7311 if ( ecx0->pRenderD3D ) | |
7312 { | |
7313 v4 = a3; | |
7314 if ( a3 <= 1.0 ) | |
7315 { | |
7316 if ( v4 < 0.0 ) | |
7317 v4 = 0.0; | |
7318 } | |
7319 else | |
7320 { | |
7321 v4 = 1.0; | |
7322 } | |
7323 a3 = v4 * 255.0; | |
7324 v39 = a3 + 6.7553994e15; | |
7325 LODWORD(v40) = LODWORD(v39); | |
693 | 7326 v5 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 7327 v36[0].pos.x = v5; |
693 | 7328 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 7329 v7 = this_ | (LODWORD(v39) << 24); |
693 | 7330 this_ = pViewport->uViewportBR_Y + 1; |
0 | 7331 v36[0].specular = 0; |
7332 v36[0].pos.y = v6; | |
7333 v36[0].diffuse = v7; | |
7334 v36[1].diffuse = v7; | |
7335 v36[0].pos.z = 0.0; | |
7336 v36[2].diffuse = v7; | |
7337 v36[3].diffuse = v7; | |
7338 v36[0].rhw = 1.0; | |
7339 v36[1].specular = 0; | |
7340 v36[0].texcoord.x = 0.0; | |
7341 v36[2].specular = 0; | |
7342 v36[3].specular = 0; | |
7343 v36[0].texcoord.y = 0.0; | |
7344 v36[1].pos.x = v5; | |
693 | 7345 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 7346 v36[1].pos.y = v8; |
7347 v36[1].pos.z = 0.0; | |
7348 v36[1].rhw = 1.0; | |
7349 v36[1].texcoord.x = 0.0; | |
7350 v36[1].texcoord.y = 0.0; | |
693 | 7351 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 7352 v36[2].pos.x = v9; |
7353 v36[2].pos.y = v8; | |
7354 v36[2].pos.z = 0.0; | |
7355 v36[2].rhw = 1.0; | |
7356 v36[2].texcoord.x = 0.0; | |
7357 v36[2].texcoord.y = 0.0; | |
7358 v36[3].pos.x = v9; | |
7359 v36[3].pos.y = v6; | |
7360 v36[3].pos.z = 0.0; | |
7361 v36[3].rhw = 1.0; | |
7362 v36[3].texcoord.x = 0.0; | |
7363 v36[3].texcoord.y = 0.0; | |
7364 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 7365 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
7366 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7367 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
7368 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
7369 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
7370 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
7371 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 7372 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7373 D3DPT_TRIANGLEFAN, | |
7374 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7375 v36, | |
7376 4, | |
7377 28)); | |
186 | 7378 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7379 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
7380 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
7381 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
7382 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
7383 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
0 | 7384 } |
7385 else | |
7386 { | |
7387 v40 = (1.0 - a3) * 65536.0; | |
7388 v39 = v40 + 6.7553994e15; | |
7389 LODWORD(a3) = LODWORD(v39); | |
693 | 7390 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
7391 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
7392 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
7393 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 7394 v37 = 2 * v13; |
7395 LODWORD(v40) = (int)v14; | |
7396 | |
7397 int __i = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
7398 v15 = dword_F1B430.data(); |
0 | 7399 do |
7400 { | |
7401 v16 = v3; | |
7402 v3 += LODWORD(a3); | |
7403 dword_F1B430[__i++] = v16 >> 16; | |
7404 } | |
7405 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
7406 while (__i < 32); | |
7407 | |
7408 if ( pRenderer->uTargetGBits == 6 ) | |
7409 { | |
7410 v17 = _42690D_colors_cvt(this_); | |
7411 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); | |
7412 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); | |
7413 v19 = v40; | |
7414 v20 = off_4EFDB0; | |
7415 v21 = HIDWORD(v39); | |
7416 do | |
7417 { | |
7418 v22 = v38; | |
7419 v31 = v21; | |
7420 do | |
7421 { | |
7422 v23 = (*(int *)((char *)v20 | |
7423 + ((((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; | |
7424 result = this_ | |
7425 + (*((int *)v20 | |
7426 + (((unsigned __int8)(*((char *)v20 | |
7427 + ((((unsigned __int16)(*(short *)((char *)v20 | |
7428 + ((*(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); | |
7429 *(unsigned int *)LODWORD(v19) = result; | |
7430 LODWORD(v19) += 4; | |
7431 --v22; | |
7432 } | |
7433 while ( v22 ); | |
7434 LODWORD(v19) += v37; | |
7435 v21 = v31 - 1; | |
7436 } | |
7437 while ( v31 != 1 ); | |
7438 } | |
7439 else | |
7440 { | |
7441 v24 = _4268E3_smthn_to_a1r5g5b5(this_); | |
7442 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); | |
7443 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
7444 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
7445 v26 = v40; | |
7446 v27 = (char *)off_4EFDB0; | |
7447 v28 = HIDWORD(v39); | |
7448 do | |
7449 { | |
7450 v29 = v38; | |
7451 v32 = v28; | |
7452 do | |
7453 { | |
7454 v30 = 32 | |
7455 * *(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; | |
7456 result = this_ | |
7457 + (*(int *)&v27[4 | |
7458 * (((unsigned __int8)(32 | |
7459 * 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); | |
7460 *(unsigned int *)LODWORD(v26) = result; | |
7461 LODWORD(v26) += 4; | |
7462 --v29; | |
7463 } | |
7464 while ( v29 ); | |
7465 LODWORD(v26) += v37; | |
7466 v28 = v32 - 1; | |
7467 } | |
7468 while ( v32 != 1 ); | |
7469 } | |
7470 } | |
7471 return result; | |
7472 } | |
7473 | |
7474 //----- (004A5B81) -------------------------------------------------------- | |
727 | 7475 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 7476 { |
7477 this->bClip = 1; | |
7478 this->uClipY = uY; | |
7479 this->uClipX = uX; | |
7480 this->uClipW = uW; | |
7481 this->uClipZ = uZ; | |
7482 } | |
7483 | |
7484 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 7485 void Render::ResetTextureClipRect() |
0 | 7486 { |
7487 this->uClipY = 0; | |
7488 this->uClipX = 0; | |
7489 this->bClip = 1; | |
7490 this->uClipW = 480; | |
7491 this->uClipZ = 640; | |
7492 } | |
7493 | |
7494 //----- (004A5BE3) -------------------------------------------------------- | |
7495 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
7496 { | |
7497 int v4; // edi@3 | |
7498 unsigned __int16 *v5; // edx@3 | |
7499 unsigned __int16 *v6; // esi@3 | |
7500 unsigned int v8; // eax@5 | |
7501 unsigned int v9; // ebx@5 | |
7502 unsigned int v11; // eax@7 | |
7503 unsigned int v12; // ebx@8 | |
7504 unsigned int v15; // eax@14 | |
7505 int v19; // [sp+10h] [bp-8h]@3 | |
7506 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
7507 int v23; // [sp+28h] [bp+10h]@3 | |
7508 | |
7509 if ( this->uNumSceneBegins && a4 ) | |
7510 { | |
7511 v4 = a4->uWidth; | |
7512 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
7513 v6 = a4->pPixels; | |
7514 v23 = a4->uHeight; | |
7515 v19 = v4; | |
7516 if ( this->bClip ) | |
7517 { | |
1152 | 7518 if ( (signed int)uOutX < (signed int)this->uClipX ) |
7519 { | |
7520 v8 = this->uClipX - uOutX; | |
7521 v9 = uOutX - this->uClipX; | |
0 | 7522 v8 *= 2; |
7523 v4 += v9; | |
7524 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
7525 v5 = (unsigned __int16 *)((char *)v5 + v8); | |
7526 } | |
1152 | 7527 if ( (signed int)uOutY < (signed int)this->uClipY ) |
7528 { | |
7529 v11 = this->uClipY - uOutY; | |
0 | 7530 v6 += v19 * v11; |
7531 v23 += uOutY - this->uClipY; | |
7532 v5 += this->uTargetSurfacePitch * v11; | |
7533 } | |
1152 | 7534 v12 = max(this->uClipX, uOutX); |
7535 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | |
7536 { | |
7537 v4 = this->uClipZ - max(this->uClipX, uOutX); | |
7538 } | |
7539 v15 = max(this->uClipY, uOutY); | |
7540 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) | |
7541 { | |
7542 v23 = this->uClipW - max(this->uClipY, uOutY); | |
7543 } | |
7544 } | |
7545 | |
7546 for (int outerCounter = 0; outerCounter < v23; outerCounter++) | |
7547 { | |
7548 for (int counter = 0; counter < v4; counter++) | |
7549 { | |
7550 *v5 = *v6; | |
7551 ++v5; | |
7552 ++v6; | |
7553 } | |
7554 v6 += v19 - v4; | |
7555 v5 += this->uTargetSurfacePitch - v4; | |
0 | 7556 } |
7557 } | |
7558 } | |
7559 | |
7560 //----- (004A5D33) -------------------------------------------------------- | |
7561 void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture) | |
7562 { | |
7563 Render *v6; // esi@1 | |
7564 unsigned __int16 *v7; // ebx@3 | |
7565 int v8; // ecx@3 | |
7566 int v9; // edx@3 | |
7567 int v10; // ecx@3 | |
7568 int v11; // edi@3 | |
7569 signed int v12; // eax@4 | |
7570 unsigned int v13; // eax@5 | |
7571 signed int v14; // eax@6 | |
7572 unsigned int v15; // eax@7 | |
7573 unsigned int v16; // edx@8 | |
7574 int v17; // eax@10 | |
7575 unsigned int v18; // ecx@11 | |
7576 unsigned int v19; // ecx@14 | |
7577 int v20; // eax@16 | |
7578 unsigned int v21; // ecx@17 | |
7579 int v22; // eax@21 | |
7580 int v23; // edi@23 | |
7581 int v24; // [sp+Ch] [bp-4h]@3 | |
7582 int a2a; // [sp+18h] [bp+8h]@21 | |
7583 unsigned int teal; // [sp+1Ch] [bp+Ch]@20 | |
7584 int a4a; // [sp+20h] [bp+10h]@3 | |
7585 int a4b; // [sp+20h] [bp+10h]@21 | |
7586 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
7587 | |
7588 v6 = this; | |
7589 if ( this->uNumSceneBegins && pTexture ) | |
7590 { | |
7591 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | |
7592 v8 = pTexture->uWidth; | |
7593 v24 = pTexture->uWidth; | |
7594 v9 = a4 + a5 * v8; | |
7595 v10 = v8 - a4; | |
7596 a4a = v10; | |
7597 v11 = pTexture->uHeight - a5; | |
7598 pTexturea = &pTexture->pPixels[v9]; | |
7599 if ( v6->bClip ) | |
7600 { | |
7601 v12 = v6->uClipX; | |
7602 if ( (signed int)pX < v12 ) | |
7603 { | |
7604 v13 = 2 * (v12 - pX); | |
7605 pTexturea = (unsigned __int16 *)((char *)pTexturea + v13); | |
7606 v10 += pX - v6->uClipX; | |
7607 v7 = (unsigned __int16 *)((char *)v7 + v13); | |
7608 a4a = v10; | |
7609 } | |
7610 v14 = v6->uClipY; | |
7611 if ( (signed int)pY < v14 ) | |
7612 { | |
7613 v15 = v14 - pY; | |
7614 pTexturea += v24 * v15; | |
7615 v11 += pY - v6->uClipY; | |
7616 v10 = a4a; | |
7617 v7 += v6->uTargetSurfacePitch * v15; | |
7618 } | |
7619 v16 = v6->uClipX; | |
7620 if ( (signed int)v16 < (signed int)pX ) | |
7621 v16 = pX; | |
7622 v17 = v6->uClipZ; | |
7623 if ( (signed int)(v10 + v16) > v17 ) | |
7624 { | |
7625 v18 = v6->uClipX; | |
7626 if ( (signed int)v18 < (signed int)pX ) | |
7627 v18 = pX; | |
7628 a4a = v17 - v18; | |
7629 } | |
7630 v19 = v6->uClipY; | |
7631 if ( (signed int)v19 < (signed int)pY ) | |
7632 v19 = pY; | |
7633 v20 = v6->uClipW; | |
7634 if ( (signed int)(v11 + v19) > v20 ) | |
7635 { | |
7636 v21 = v6->uClipY; | |
7637 if ( (signed int)v21 < (signed int)pY ) | |
7638 v21 = pY; | |
7639 v11 = v20 - v21; | |
7640 } | |
7641 } | |
949 | 7642 teal = TargetColor(0, 0xFFu, 0xFFu); |
0 | 7643 if ( v11 > 0 ) |
7644 { | |
7645 v22 = a4a; | |
7646 a2a = v11; | |
7647 a4b = 2 * (v24 - a4a); | |
7648 do | |
7649 { | |
7650 if ( v22 > 0 ) | |
7651 { | |
7652 v23 = v22; | |
7653 do | |
7654 { | |
7655 if ( *pTexturea != teal ) | |
7656 *v7 = *pTexturea; | |
7657 ++pTexturea; | |
7658 ++v7; | |
7659 --v23; | |
7660 } | |
7661 while ( v23 ); | |
7662 } | |
7663 v7 += v6->uTargetSurfacePitch - v22; | |
7664 pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b); | |
7665 --a2a; | |
7666 } | |
7667 while ( a2a ); | |
7668 } | |
7669 } | |
7670 } | |
7671 | |
7672 //----- (004A6E7E) -------------------------------------------------------- | |
7673 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
7674 { | |
7675 unsigned __int16 *v4; // eax@4 | |
7676 int v5; // edx@4 | |
7677 unsigned int v6; // edi@4 | |
7678 unsigned int v7; // edx@5 | |
7679 unsigned int v8; // edx@6 | |
7680 unsigned int v9; // edx@7 | |
7681 unsigned int v10; // edx@8 | |
7682 unsigned int v11; // ebx@9 | |
7683 unsigned int v12; // esi@11 | |
7684 unsigned int v13; // edx@12 | |
7685 unsigned int v14; // ebx@15 | |
7686 unsigned int v15; // esi@17 | |
7687 unsigned int v16; // edi@18 | |
7688 char v17; // zf@29 | |
7689 int v18; // [sp+14h] [bp-Ch]@4 | |
7690 int v19; // [sp+18h] [bp-8h]@4 | |
7691 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
7692 int v21; // [sp+28h] [bp+8h]@25 | |
7693 int v22; // [sp+28h] [bp+8h]@34 | |
7694 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
7695 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
7696 | |
7697 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
7698 { | |
7699 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 7700 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 7701 v5 = a4->uTextureWidth; |
7702 v6 = a4->uTextureHeight; | |
7703 v19 = a4->uTextureWidth; | |
7704 v18 = a4->uTextureWidth; | |
7705 if ( this->bClip ) | |
7706 { | |
7707 v7 = this->uClipX; | |
7708 if ( (signed int)a2 < (signed int)v7 ) | |
7709 { | |
7710 v8 = v7 - a2; | |
7711 v20 += v8; | |
7712 v19 += a2 - this->uClipX; | |
7713 v4 += v8; | |
7714 } | |
7715 v9 = this->uClipY; | |
7716 if ( (signed int)a3 < (signed int)v9 ) | |
7717 { | |
7718 v10 = v9 - a3; | |
7719 v20 += v18 * v10; | |
7720 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
7721 v4 += this->uTargetSurfacePitch * v10; | |
7722 } | |
7723 v11 = this->uClipX; | |
7724 v5 = v19; | |
7725 if ( (signed int)v11 < (signed int)a2 ) | |
7726 v11 = a2; | |
7727 v12 = this->uClipZ; | |
7728 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
7729 { | |
7730 v13 = this->uClipX; | |
7731 if ( (signed int)v13 < (signed int)a2 ) | |
7732 v13 = a2; | |
7733 v5 = v12 - v13; | |
7734 } | |
7735 v14 = this->uClipY; | |
7736 if ( (signed int)v14 < (signed int)a3 ) | |
7737 v14 = a3; | |
7738 v15 = this->uClipW; | |
7739 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
7740 { | |
7741 v16 = this->uClipY; | |
7742 if ( (signed int)v16 < (signed int)a3 ) | |
7743 v16 = a3; | |
7744 v6 = v15 - v16; | |
7745 } | |
7746 } | |
7747 if ( pRenderer->uTargetGBits == 5 ) | |
7748 { | |
7749 if ( (signed int)v6 > 0 ) | |
7750 { | |
7751 v23 = v6; | |
7752 do | |
7753 { | |
7754 if ( v5 > 0 ) | |
7755 { | |
7756 v21 = v5; | |
7757 do | |
7758 { | |
7759 if ( *v20 ) | |
7760 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
7761 ++v4; | |
7762 ++v20; | |
7763 --v21; | |
7764 } | |
7765 while ( v21 ); | |
7766 } | |
7767 v20 += v18 - v5; | |
7768 v17 = v23-- == 1; | |
7769 v4 += this->uTargetSurfacePitch - v5; | |
7770 } | |
7771 while ( !v17 ); | |
7772 } | |
7773 } | |
7774 else | |
7775 { | |
7776 if ( (signed int)v6 > 0 ) | |
7777 { | |
7778 v24 = v6; | |
7779 do | |
7780 { | |
7781 if ( v5 > 0 ) | |
7782 { | |
7783 v22 = v5; | |
7784 do | |
7785 { | |
7786 if ( *v20 ) | |
7787 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
7788 ++v4; | |
7789 ++v20; | |
7790 --v22; | |
7791 } | |
7792 while ( v22 ); | |
7793 } | |
7794 v20 += v18 - v5; | |
7795 v17 = v24-- == 1; | |
7796 v4 += this->uTargetSurfacePitch - v5; | |
7797 } | |
7798 while ( !v17 ); | |
7799 } | |
7800 } | |
7801 } | |
7802 } | |
7803 | |
7804 //----- (004A6DF5) -------------------------------------------------------- | |
7805 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
7806 { | |
7807 int result; // eax@0 | |
7808 int v8; // ecx@3 | |
7809 unsigned __int16 *v9; // edi@4 | |
7810 unsigned __int16 *v10; // ebx@4 | |
7811 int v11; // esi@4 | |
7812 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | |
7813 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | |
7814 | |
7815 if ( pBitmap ) | |
7816 { | |
7817 if ( pTarget ) | |
7818 { | |
7819 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | |
7820 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | |
7821 v8 = a7->z - a7->x; | |
7822 result = a7->w - a7->y; | |
7823 if ( result > 0 ) | |
7824 { | |
7825 v9 = pBitmapa; | |
7826 v10 = pTargeta; | |
7827 v11 = a7->w - a7->y; | |
7828 do | |
7829 { | |
7830 if ( v8 > 0 ) | |
7831 { | |
7832 result = v8; | |
7833 do | |
7834 { | |
7835 *v9 = *v10; | |
7836 ++v9; | |
7837 ++v10; | |
7838 --result; | |
7839 } | |
7840 while ( result ); | |
7841 } | |
7842 v9 += uBitmapPitch - v8; | |
7843 v10 += uTargetPitch - v8; | |
7844 --v11; | |
7845 } | |
7846 while ( v11 ); | |
7847 } | |
7848 } | |
7849 } | |
7850 return result; | |
7851 } | |
7852 | |
7853 //----- (004A6D87) -------------------------------------------------------- | |
7854 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
7855 { | |
7856 if (!uNumSceneBegins) | |
7857 return; | |
7858 | |
7859 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
7860 for (uint y = 0; y < uHeight; ++y) | |
7861 { | |
7862 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | |
7863 | |
7864 memset32(pDst, twoColors, uWidth / 2); | |
7865 if (uWidth & 1) | |
7866 pDst[uWidth - 1] = uColor16; | |
7867 } | |
7868 } | |
7869 | |
7870 //----- (004A6C4F) -------------------------------------------------------- | |
7871 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
7872 { | |
7873 unsigned int v9; // edi@2 | |
7874 unsigned int v10; // esi@2 | |
7875 unsigned __int16 *v11; // eax@2 | |
7876 unsigned int v12; // ebx@3 | |
7877 signed int v13; // edx@5 | |
7878 int v14; // edx@6 | |
7879 signed int v15; // ebx@7 | |
7880 unsigned int v16; // edx@9 | |
7881 signed int v17; // edi@10 | |
7882 signed int v18; // ebx@13 | |
7883 unsigned int v19; // edx@15 | |
7884 signed int v20; // esi@16 | |
7885 unsigned int v21; // esi@22 | |
7886 unsigned __int16 v22; // dx@24 | |
7887 char v23; // zf@28 | |
7888 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
7889 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | |
7890 | |
7891 if ( this->uNumSceneBegins ) | |
7892 { | |
7893 v9 = uCharWidth; | |
7894 v10 = uCharHeight; | |
7895 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
7896 v24 = pFontPixels; | |
7897 if ( this->bClip ) | |
7898 { | |
7899 v12 = this->uClipX; | |
7900 if ( uOutX < (signed int)v12 ) | |
7901 { | |
7902 v24 = &pFontPixels[v12 - uOutX]; | |
7903 v11 += v12 - uOutX; | |
7904 v9 = uCharWidth + uOutX - v12; | |
7905 } | |
7906 v13 = this->uClipY; | |
7907 if ( uOutY < v13 ) | |
7908 { | |
7909 v14 = v13 - uOutY; | |
7910 v24 += uCharWidth * v14; | |
7911 v10 = uCharHeight + uOutY - this->uClipY; | |
7912 v11 += this->uTargetSurfacePitch * v14; | |
7913 } | |
7914 v15 = this->uClipX; | |
7915 if ( v15 < uOutX ) | |
7916 v15 = uOutX; | |
7917 v16 = this->uClipZ; | |
7918 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
7919 { | |
7920 v17 = this->uClipX; | |
7921 if ( v17 < uOutX ) | |
7922 v17 = uOutX; | |
7923 v9 = v16 - v17; | |
7924 } | |
7925 v18 = this->uClipY; | |
7926 if ( v18 < uOutY ) | |
7927 v18 = uOutY; | |
7928 v19 = this->uClipW; | |
7929 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
7930 { | |
7931 v20 = this->uClipY; | |
7932 if ( v20 < uOutY ) | |
7933 v20 = uOutY; | |
7934 v10 = v19 - v20; | |
7935 } | |
7936 } | |
7937 if ( (signed int)v10 > 0 ) | |
7938 { | |
7939 uOutXa = v10; | |
7940 do | |
7941 { | |
7942 if ( (signed int)v9 > 0 ) | |
7943 { | |
7944 v21 = v9; | |
7945 do | |
7946 { | |
7947 if ( *v24 ) | |
7948 { | |
7949 v22 = uShadowColor; | |
7950 if ( *v24 != 1 ) | |
7951 v22 = uFaceColor; | |
7952 *v11 = v22; | |
7953 } | |
7954 ++v11; | |
7955 ++v24; | |
7956 --v21; | |
7957 } | |
7958 while ( v21 ); | |
7959 } | |
7960 v24 += uCharWidth - v9; | |
7961 v23 = uOutXa-- == 1; | |
7962 v11 += this->uTargetSurfacePitch - v9; | |
7963 } | |
7964 while ( !v23 ); | |
7965 } | |
7966 } | |
7967 } | |
7968 | |
7969 //----- (004A6A68) -------------------------------------------------------- | |
7970 void Render::_4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | |
7971 { | |
7972 Render *v5; // ebx@1 | |
7973 unsigned __int16 v6; // ax@1 | |
7974 | |
7975 v5 = this; | |
7976 | |
7977 Texture tex; // [sp+Ch] [bp-48h]@1 | |
7978 //Texture::Texture(&tex); | |
7979 | |
7980 v6 = a4->uTextureHeight - height; | |
7981 memcpy(&tex, a4, sizeof(tex)); | |
7982 tex.uTextureHeight = v6; | |
7983 if ( (signed __int16)v6 > 0 ) | |
7984 DrawTextureIndexed(a2, a3, &tex); | |
7985 } | |
7986 | |
7987 //----- (004A6AB1) -------------------------------------------------------- | |
1268 | 7988 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
7989 { | |
0 | 7990 int v8; // edi@2 |
7991 unsigned int v9; // esi@2 | |
7992 unsigned __int16 *v10; // eax@2 | |
7993 unsigned char *v11; // edx@2 | |
7994 unsigned int v12; // ebx@3 | |
7995 signed int v13; // edx@5 | |
7996 int v14; // edx@6 | |
7997 signed int v15; // ebx@7 | |
7998 unsigned int v16; // edx@9 | |
7999 signed int v17; // edi@10 | |
8000 signed int v18; // ebx@13 | |
8001 unsigned int v19; // edx@15 | |
8002 signed int v20; // esi@16 | |
8003 int v21; // ebx@22 | |
8004 char v22; // zf@28 | |
8005 int v23; // ebx@31 | |
8006 unsigned __int16 v24; // si@35 | |
8007 int v25; // [sp+Ch] [bp-4h]@2 | |
8008 int v26; // [sp+1Ch] [bp+Ch]@24 | |
8009 int v27; // [sp+1Ch] [bp+Ch]@33 | |
8010 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
8011 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
8012 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
8013 | |
8014 auto a2 = x; | |
8015 auto a3 = y; | |
8016 auto a6 = uFontHeight; | |
8017 if ( this->uNumSceneBegins ) | |
8018 { | |
8019 v8 = a5; | |
8020 v9 = a6; | |
8021 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
1268 | 8022 v11 = (unsigned char *)font_pixels; |
8023 v25 = (int)font_pixels; | |
0 | 8024 if ( this->bClip ) |
8025 { | |
8026 v12 = this->uClipX; | |
8027 if ( a2 < (signed int)v12 ) | |
8028 { | |
1268 | 8029 v25 = v12 - a2 + (int)font_pixels; |
0 | 8030 v10 += v12 - a2; |
8031 v8 = a5 + a2 - v12; | |
8032 } | |
8033 v13 = this->uClipY; | |
8034 if ( a3 < v13 ) | |
8035 { | |
8036 v14 = v13 - a3; | |
8037 v25 += a5 * v14; | |
8038 v9 = a6 + a3 - this->uClipY; | |
8039 v10 += this->uTargetSurfacePitch * v14; | |
8040 } | |
8041 v15 = this->uClipX; | |
8042 if ( v15 < a2 ) | |
8043 v15 = a2; | |
8044 v16 = this->uClipZ; | |
8045 if ( v8 + v15 > (signed int)v16 ) | |
8046 { | |
8047 v17 = this->uClipX; | |
8048 if ( v17 < a2 ) | |
8049 v17 = a2; | |
8050 v8 = v16 - v17; | |
8051 } | |
8052 v18 = this->uClipY; | |
8053 if ( v18 < a3 ) | |
8054 v18 = a3; | |
8055 v19 = this->uClipW; | |
8056 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
8057 { | |
8058 v20 = this->uClipY; | |
8059 if ( v20 < a3 ) | |
8060 v20 = a3; | |
8061 v9 = v19 - v20; | |
8062 } | |
8063 v11 = (unsigned char *)v25; | |
8064 } | |
8065 if ( a8 ) | |
8066 { | |
8067 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
8068 if ( (signed int)v9 > 0 ) | |
8069 { | |
8070 v23 = a5; | |
8071 v30 = v9; | |
8072 do | |
8073 { | |
8074 if ( v8 > 0 ) | |
8075 { | |
8076 v27 = v8; | |
8077 do | |
8078 { | |
8079 if ( *v11 ) | |
8080 v24 = pPalette[*v11]; | |
8081 else | |
8082 v24 = v28; | |
8083 *v10 = v24; | |
8084 ++v10; | |
8085 ++v11; | |
8086 --v27; | |
8087 } | |
8088 while ( v27 ); | |
8089 } | |
8090 v11 += v23 - v8; | |
8091 v22 = v30-- == 1; | |
8092 v10 += this->uTargetSurfacePitch - v8; | |
8093 } | |
8094 while ( !v22 ); | |
8095 } | |
8096 } | |
8097 else | |
8098 { | |
8099 if ( (signed int)v9 > 0 ) | |
8100 { | |
8101 v21 = a5; | |
8102 v29 = v9; | |
8103 do | |
8104 { | |
8105 if ( v8 > 0 ) | |
8106 { | |
8107 v26 = v8; | |
8108 do | |
8109 { | |
8110 if ( *v11 ) | |
8111 *v10 = pPalette[*v11]; | |
8112 ++v10; | |
8113 ++v11; | |
8114 --v26; | |
8115 } | |
8116 while ( v26 ); | |
8117 } | |
8118 v11 += v21 - v8; | |
8119 v22 = v29-- == 1; | |
8120 v10 += this->uTargetSurfacePitch - v8; | |
8121 } | |
8122 while ( !v22 ); | |
8123 } | |
8124 } | |
8125 } | |
8126 } | |
8127 | |
8128 //----- (004A68EF) -------------------------------------------------------- | |
8129 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
8130 { | |
8131 Texture *v4; // edi@2 | |
8132 unsigned int v5; // ebx@4 | |
8133 unsigned __int16 *v6; // eax@4 | |
8134 signed int v7; // edx@5 | |
8135 int v8; // edx@6 | |
8136 signed int v9; // edx@7 | |
8137 int v10; // edx@8 | |
8138 signed int v11; // edx@9 | |
8139 signed int v12; // esi@12 | |
8140 signed int v13; // esi@15 | |
8141 unsigned int v14; // edx@17 | |
8142 signed int v15; // esi@18 | |
8143 unsigned __int8 *v16; // ebx@22 | |
8144 char v17; // zf@28 | |
8145 int v18; // [sp+10h] [bp-10h]@4 | |
8146 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
8147 int v20; // [sp+1Ch] [bp-4h]@4 | |
8148 int v21; // [sp+28h] [bp+8h]@24 | |
8149 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
8150 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
8151 | |
8152 if ( this->uNumSceneBegins ) | |
8153 { | |
8154 v4 = pTexture; | |
8155 if ( pTexture ) | |
8156 { | |
8157 if ( pTexture->pPalette16 ) | |
8158 { | |
8159 v5 = pTexture->uTextureHeight; | |
8160 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 8161 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8162 v20 = pTexture->uTextureWidth; |
8163 v18 = pTexture->uTextureWidth; | |
8164 if ( this->bClip ) | |
8165 { | |
8166 v7 = this->uClipX; | |
8167 if ( a2 < v7 ) | |
8168 { | |
8169 v8 = v7 - a2; | |
8170 v19 += v8; | |
8171 v20 += a2 - this->uClipX; | |
8172 v6 += v8; | |
8173 } | |
8174 v9 = this->uClipY; | |
8175 v5 = pTexture->uTextureHeight; | |
8176 if ( a3 < v9 ) | |
8177 { | |
8178 v10 = v9 - a3; | |
8179 v19 += v18 * v10; | |
8180 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
8181 v4 = pTexture; | |
8182 v6 += this->uTargetSurfacePitch * v10; | |
8183 } | |
8184 v11 = this->uClipX; | |
8185 if ( v11 < a2 ) | |
8186 v11 = a2; | |
8187 pTexturea = this->uClipZ; | |
8188 if ( v11 + v20 > (signed int)pTexturea ) | |
8189 { | |
8190 v12 = this->uClipX; | |
8191 if ( v12 < a2 ) | |
8192 v12 = a2; | |
8193 v20 = pTexturea - v12; | |
8194 } | |
8195 v13 = this->uClipY; | |
8196 if ( v13 < a3 ) | |
8197 v13 = a3; | |
8198 v14 = this->uClipW; | |
8199 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
8200 { | |
8201 v15 = this->uClipY; | |
8202 if ( v15 < a3 ) | |
8203 v15 = a3; | |
8204 v5 = v14 - v15; | |
8205 } | |
8206 } | |
8207 if ( (signed int)v5 > 0 ) | |
8208 { | |
8209 v22 = v5; | |
8210 v16 = v19; | |
8211 do | |
8212 { | |
8213 if ( v20 > 0 ) | |
8214 { | |
8215 v21 = v20; | |
8216 do | |
8217 { | |
8218 if ( *v16 ) | |
8219 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
8220 ++v6; | |
8221 ++v16; | |
8222 --v21; | |
8223 } | |
8224 while ( v21 ); | |
8225 } | |
8226 v16 += v18 - v20; | |
8227 v17 = v22-- == 1; | |
8228 v6 += this->uTargetSurfacePitch - v20; | |
8229 } | |
8230 while ( !v17 ); | |
8231 } | |
8232 } | |
8233 } | |
8234 } | |
8235 } | |
8236 | |
8237 //----- (004A6776) -------------------------------------------------------- | |
315 | 8238 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 8239 { |
8240 Texture *v4; // edi@2 | |
8241 unsigned int v5; // ebx@4 | |
8242 unsigned __int16 *v6; // eax@4 | |
8243 unsigned int v7; // edx@5 | |
8244 unsigned int v8; // edx@6 | |
8245 unsigned int v9; // edx@7 | |
8246 unsigned int v10; // edx@8 | |
8247 unsigned int v11; // edx@9 | |
8248 unsigned int v12; // esi@12 | |
8249 unsigned int v13; // esi@15 | |
8250 unsigned int v14; // edx@17 | |
8251 unsigned int v15; // esi@18 | |
8252 unsigned __int8 *v16; // ebx@22 | |
8253 char v17; // zf@28 | |
8254 int v18; // [sp+10h] [bp-10h]@4 | |
8255 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
8256 int v20; // [sp+1Ch] [bp-4h]@4 | |
8257 int a2a; // [sp+28h] [bp+8h]@24 | |
8258 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
8259 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
8260 | |
8261 if ( this->uNumSceneBegins ) | |
8262 { | |
8263 v4 = a4; | |
8264 if ( a4 ) | |
8265 { | |
8266 if ( a4->pPalette16 ) | |
8267 { | |
8268 v5 = a4->uTextureHeight; | |
8269 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 8270 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8271 v20 = a4->uTextureWidth; |
8272 v18 = a4->uTextureWidth; | |
8273 if ( this->bClip ) | |
8274 { | |
8275 v7 = this->uClipX; | |
8276 if ( (signed int)a2 < (signed int)v7 ) | |
8277 { | |
8278 v8 = v7 - a2; | |
8279 v19 += v8; | |
8280 v20 += a2 - this->uClipX; | |
8281 v6 += v8; | |
8282 } | |
8283 v9 = this->uClipY; | |
8284 v5 = a4->uTextureHeight; | |
8285 if ( (signed int)a3 < (signed int)v9 ) | |
8286 { | |
8287 v10 = v9 - a3; | |
8288 v19 += v18 * v10; | |
8289 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
8290 v4 = a4; | |
8291 v6 += this->uTargetSurfacePitch * v10; | |
8292 } | |
8293 v11 = this->uClipX; | |
8294 if ( (signed int)v11 < (signed int)a2 ) | |
8295 v11 = a2; | |
8296 a4a = this->uClipZ; | |
8297 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
8298 { | |
8299 v12 = this->uClipX; | |
8300 if ( (signed int)v12 < (signed int)a2 ) | |
8301 v12 = a2; | |
8302 v20 = a4a - v12; | |
8303 } | |
8304 v13 = this->uClipY; | |
8305 if ( (signed int)v13 < (signed int)a3 ) | |
8306 v13 = a3; | |
8307 v14 = this->uClipW; | |
8308 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
8309 { | |
8310 v15 = this->uClipY; | |
8311 if ( (signed int)v15 < (signed int)a3 ) | |
8312 v15 = a3; | |
8313 v5 = v14 - v15; | |
8314 } | |
8315 } | |
8316 if ( (signed int)v5 > 0 ) | |
8317 { | |
8318 a3a = v5; | |
8319 v16 = v19; | |
8320 do | |
8321 { | |
8322 if ( v20 > 0 ) | |
8323 { | |
8324 a2a = v20; | |
8325 do | |
8326 { | |
8327 if ( *v16 ) | |
8328 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
8329 ++v6; | |
8330 ++v16; | |
8331 --a2a; | |
8332 } | |
8333 while ( a2a ); | |
8334 } | |
8335 v16 += v18 - v20; | |
8336 v17 = a3a-- == 1; | |
8337 v6 += this->uTargetSurfacePitch - v20; | |
8338 } | |
8339 while ( !v17 ); | |
8340 } | |
8341 } | |
8342 } | |
8343 } | |
8344 } | |
8345 | |
8346 //----- (004A65CC) -------------------------------------------------------- | |
8347 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
8348 { | |
8349 unsigned __int16 *v8; // esi@6 | |
8350 unsigned int v9; // edi@6 | |
8351 unsigned int v10; // eax@7 | |
8352 unsigned int v11; // eax@8 | |
8353 unsigned int v12; // eax@9 | |
8354 unsigned int v13; // eax@10 | |
8355 unsigned int v14; // edx@11 | |
8356 unsigned int v15; // eax@13 | |
8357 unsigned int v16; // edx@14 | |
8358 unsigned int v17; // edx@17 | |
8359 unsigned int v18; // eax@19 | |
8360 unsigned int v19; // edx@20 | |
8361 int v20; // eax@27 | |
8362 int v21; // edx@29 | |
8363 int v22; // [sp+Ch] [bp-Ch]@6 | |
8364 int v23; // [sp+Ch] [bp-Ch]@24 | |
8365 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
8366 int xa; // [sp+20h] [bp+8h]@26 | |
8367 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
8368 int v27; // [sp+2Ch] [bp+14h]@6 | |
8369 | |
8370 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
8371 { | |
8372 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | |
710 | 8373 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8374 v27 = a4->uTextureWidth; |
8375 v9 = a4->uTextureHeight; | |
8376 v22 = a4->uTextureWidth; | |
8377 if ( this->bClip ) | |
8378 { | |
8379 v10 = this->uClipX; | |
8380 if ( (signed int)x < (signed int)v10 ) | |
8381 { | |
8382 v11 = v10 - x; | |
8383 v24 += v11; | |
8384 v27 += x - this->uClipX; | |
8385 v8 += v11; | |
8386 } | |
8387 v12 = this->uClipY; | |
8388 if ( (signed int)y < (signed int)v12 ) | |
8389 { | |
8390 v13 = v12 - y; | |
8391 v24 += v22 * v13; | |
8392 v9 = y - this->uClipY + a4->uTextureHeight; | |
8393 v8 += this->uTargetSurfacePitch * v13; | |
8394 } | |
8395 v14 = this->uClipX; | |
8396 if ( (signed int)v14 < (signed int)x ) | |
8397 v14 = x; | |
8398 v15 = this->uClipZ; | |
8399 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
8400 { | |
8401 v16 = this->uClipX; | |
8402 if ( (signed int)v16 < (signed int)x ) | |
8403 v16 = x; | |
8404 v27 = v15 - v16; | |
8405 } | |
8406 v17 = this->uClipY; | |
8407 if ( (signed int)v17 < (signed int)y ) | |
8408 v17 = y; | |
8409 v18 = this->uClipW; | |
8410 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
8411 { | |
8412 v19 = this->uClipY; | |
8413 if ( (signed int)v19 < (signed int)y ) | |
8414 v19 = y; | |
8415 v9 = v18 - v19; | |
8416 } | |
8417 } | |
8418 if ( (signed int)v9 > 0 ) | |
8419 { | |
8420 ya = v9; | |
8421 v23 = v22 - v27; | |
8422 do | |
8423 { | |
8424 if ( v27 > 0 ) | |
8425 { | |
8426 xa = v27; | |
8427 do | |
8428 { | |
8429 v20 = *v24; | |
8430 if ( v20 >= a7 && v20 <= a8 ) | |
8431 { | |
8432 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
8433 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
8434 v21 = 2 * a8 - v21 - a7; | |
8435 *v8 = a4->pPalette16[v21]; | |
8436 } | |
8437 ++v8; | |
8438 ++v24; | |
8439 --xa; | |
8440 } | |
8441 while ( xa ); | |
8442 } | |
8443 v8 += this->uTargetSurfacePitch - v27; | |
8444 v24 += v23; | |
8445 --ya; | |
8446 } | |
8447 while ( ya ); | |
8448 } | |
8449 } | |
8450 } | |
8451 | |
8452 //----- (004A63E6) -------------------------------------------------------- | |
8453 void Render::_4A63E6(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
8454 { | |
8455 Texture *v8; // eax@2 | |
8456 Texture *v9; // ebx@4 | |
8457 unsigned __int16 *v10; // esi@6 | |
8458 unsigned int v11; // edi@7 | |
8459 unsigned int v12; // eax@9 | |
8460 unsigned int v13; // eax@10 | |
8461 unsigned int v14; // edx@11 | |
8462 unsigned int v15; // eax@13 | |
8463 unsigned int v16; // edx@14 | |
8464 unsigned int v17; // edx@17 | |
8465 unsigned int v18; // eax@19 | |
8466 unsigned int v19; // edx@20 | |
8467 int v20; // eax@27 | |
8468 int v21; // edx@29 | |
8469 int v22; // [sp+Ch] [bp-Ch]@6 | |
8470 int v23; // [sp+Ch] [bp-Ch]@24 | |
8471 int v24; // [sp+10h] [bp-8h]@6 | |
8472 int v25; // [sp+14h] [bp-4h]@6 | |
8473 int i; // [sp+20h] [bp+8h]@25 | |
8474 int v27; // [sp+24h] [bp+Ch]@23 | |
8475 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
8476 | |
8477 if ( this->uNumSceneBegins ) | |
8478 { | |
8479 v8 = a4; | |
8480 if ( a4 ) | |
8481 { | |
8482 if ( a4->pPalette16 ) | |
8483 { | |
8484 v9 = a5; | |
8485 if ( a5 ) | |
8486 { | |
8487 if ( a5->pPalette16 ) | |
8488 { | |
8489 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 8490 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8491 v25 = v8->uTextureWidth; |
8492 v24 = v8->uTextureHeight; | |
8493 v22 = v8->uTextureWidth; | |
8494 if ( this->bClip ) | |
8495 { | |
8496 v11 = this->uClipX; | |
8497 if ( (signed int)a2 < (signed int)v11 ) | |
8498 { | |
8499 v28 += v11 - a2; | |
8500 v25 += a2 - v11; | |
8501 v9 = a5; | |
8502 v10 += v11 - a2; | |
8503 } | |
8504 v12 = this->uClipY; | |
8505 if ( (signed int)a3 < (signed int)v12 ) | |
8506 { | |
8507 v13 = v12 - a3; | |
8508 v9 = a5; | |
8509 v28 += v22 * v13; | |
8510 v24 += a3 - this->uClipY; | |
8511 v10 += this->uTargetSurfacePitch * v13; | |
8512 } | |
8513 v14 = this->uClipX; | |
8514 if ( (signed int)v14 < (signed int)a2 ) | |
8515 v14 = a2; | |
8516 v15 = this->uClipZ; | |
8517 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
8518 { | |
8519 v16 = this->uClipX; | |
8520 if ( (signed int)v16 < (signed int)a2 ) | |
8521 v16 = a2; | |
8522 v25 = v15 - v16; | |
8523 } | |
8524 v17 = this->uClipY; | |
8525 if ( (signed int)v17 < (signed int)a3 ) | |
8526 v17 = a3; | |
8527 v18 = this->uClipW; | |
8528 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
8529 { | |
8530 v19 = this->uClipY; | |
8531 if ( (signed int)v19 < (signed int)a3 ) | |
8532 v19 = a3; | |
8533 v24 = v18 - v19; | |
8534 } | |
8535 } | |
8536 v27 = 0; | |
8537 if ( v24 > 0 ) | |
8538 { | |
8539 v23 = v22 - v25; | |
8540 do | |
8541 { | |
8542 for ( i = 0; i < v25; ++v28 ) | |
8543 { | |
8544 if ( *v28 ) | |
8545 { | |
710 | 8546 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 8547 if ( v20 >= a7 ) |
8548 { | |
8549 if ( v20 <= a8 ) | |
8550 { | |
8551 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
8552 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
8553 v21 = 2 * a8 - v21 - a7; | |
8554 v9 = a5; | |
8555 *v10 = a5->pPalette16[v21]; | |
8556 } | |
8557 } | |
8558 } | |
8559 ++i; | |
8560 ++v10; | |
8561 } | |
8562 ++v27; | |
8563 v10 += this->uTargetSurfacePitch - v25; | |
8564 v28 += v23; | |
8565 } | |
8566 while ( v27 < v24 ); | |
8567 } | |
8568 } | |
8569 } | |
8570 } | |
8571 } | |
8572 } | |
8573 } | |
8574 | |
8575 //----- (004A6274) -------------------------------------------------------- | |
8576 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
8577 { | |
8578 Texture *pCurrentTexture; // edi@2 | |
8579 int uHeight; // ebx@4 | |
8580 unsigned __int16 *v6; // eax@4 | |
8581 unsigned int v7; // edx@5 | |
8582 unsigned int v8; // edx@6 | |
8583 unsigned int v9; // edx@7 | |
8584 unsigned int v10; // edx@8 | |
8585 unsigned int v11; // edx@9 | |
8586 unsigned int v12; // esi@12 | |
8587 unsigned int v13; // esi@15 | |
8588 unsigned int v14; // edx@17 | |
8589 unsigned int v15; // esi@18 | |
8590 unsigned __int8 *v16; // ebx@22 | |
8591 char uFlag; // zf@28 | |
8592 int v18; // [sp+10h] [bp-10h]@4 | |
8593 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
8594 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
8595 int uXa; // [sp+28h] [bp+8h]@24 | |
8596 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
8597 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
8598 | |
8599 if ( this->uNumSceneBegins ) | |
8600 { | |
8601 pCurrentTexture = pTexture; | |
8602 if ( pTexture ) | |
8603 { | |
8604 if ( pTexture->pPalette16 ) | |
8605 { | |
8606 uHeight = pTexture->uTextureHeight; | |
8607 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 8608 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8609 uWidth = pTexture->uTextureWidth; |
8610 v18 = pTexture->uTextureWidth; | |
8611 if ( this->bClip ) | |
8612 { | |
8613 v7 = this->uClipX; | |
8614 if ( (signed int)uX < (signed int)v7 ) | |
8615 { | |
8616 v8 = v7 - uX; | |
8617 v19 += v8; | |
8618 uWidth += uX - this->uClipX; | |
8619 v6 += v8; | |
8620 } | |
8621 v9 = this->uClipY; | |
8622 uHeight = pTexture->uTextureHeight; | |
8623 if ( (signed int)uY < (signed int)v9 ) | |
8624 { | |
8625 v10 = v9 - uY; | |
8626 v19 += v18 * v10; | |
8627 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
8628 pCurrentTexture = pTexture; | |
8629 v6 += this->uTargetSurfacePitch * v10; | |
8630 } | |
8631 v11 = this->uClipX; | |
8632 if ( (signed int)v11 < (signed int)uX ) | |
8633 v11 = uX; | |
8634 pTexturea = this->uClipZ; | |
8635 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
8636 { | |
8637 v12 = this->uClipX; | |
8638 if ( (signed int)v12 < (signed int)uX ) | |
8639 v12 = uX; | |
8640 uWidth = pTexturea - v12; | |
8641 } | |
8642 v13 = this->uClipY; | |
8643 if ( (signed int)v13 < (signed int)uY ) | |
8644 v13 = uY; | |
8645 v14 = this->uClipW; | |
8646 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
8647 { | |
8648 v15 = this->uClipY; | |
8649 if ( (signed int)v15 < (signed int)uY ) | |
8650 v15 = uY; | |
8651 uHeight = v14 - v15; | |
8652 } | |
8653 } | |
8654 if ( (signed int)uHeight > 0 ) | |
8655 { | |
8656 uYa = uHeight; | |
8657 v16 = v19; | |
8658 do | |
8659 { | |
8660 if ( uWidth > 0 ) | |
8661 { | |
8662 uXa = uWidth; | |
8663 do | |
8664 { | |
8665 if ( *v16 ) | |
8666 *v6 = pCurrentTexture->pPalette16[*v16]; | |
8667 ++v6; | |
8668 ++v16; | |
8669 } | |
8670 while ( uXa-- !=1 ); | |
8671 } | |
8672 v16 += v18 - uWidth; | |
8673 uFlag = uYa-- == 1; | |
8674 v6 += this->uTargetSurfacePitch - uWidth; | |
8675 } | |
8676 while ( !uFlag ); | |
8677 } | |
8678 } | |
8679 } | |
8680 } | |
8681 } | |
8682 | |
8683 //----- (004A612A) -------------------------------------------------------- | |
710 | 8684 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 8685 { |
8686 Texture *v5; // eax@2 | |
8687 unsigned int v6; // edx@3 | |
8688 int v7; // ebx@3 | |
8689 int v8; // edi@3 | |
8690 signed int v9; // eax@4 | |
8691 int v10; // eax@5 | |
8692 unsigned int v11; // esi@6 | |
8693 signed int v12; // esi@8 | |
8694 unsigned int v13; // eax@10 | |
8695 signed int v14; // esi@11 | |
8696 unsigned int v15; // esi@14 | |
8697 unsigned int v16; // eax@16 | |
8698 unsigned int v17; // ecx@17 | |
8699 int v18; // edx@23 | |
8700 int v19; // [sp+Ch] [bp-Ch]@3 | |
8701 int v20; // [sp+10h] [bp-8h]@3 | |
8702 int uOutXa; // [sp+20h] [bp+8h]@21 | |
8703 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
8704 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
8705 | |
8706 if ( this->uNumSceneBegins ) | |
8707 { | |
8708 v5 = pTexture; | |
8709 if ( pTexture ) | |
8710 { | |
8711 v6 = uOutY; | |
8712 v7 = pTexture->uTextureHeight; | |
8713 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
710 | 8714 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8715 v8 = v5->uTextureWidth; |
8716 v20 = v5->uTextureWidth; | |
8717 v19 = v5->uTextureWidth; | |
8718 if ( this->bClip ) | |
8719 { | |
8720 v9 = this->uClipX; | |
8721 if ( uOutX < v9 ) | |
8722 { | |
8723 v10 = v9 - uOutX; | |
8724 uOutYa += v10; | |
8725 v8 += uOutX - this->uClipX; | |
8726 v20 = v8; | |
8727 pZBuffer += v10; | |
8728 } | |
8729 v11 = this->uClipY; | |
8730 if ( (signed int)v6 < (signed int)v11 ) | |
8731 { | |
8732 uOutYa += v19 * (v11 - v6); | |
8733 v7 += v6 - v11; | |
8734 pZBuffer += 640 * (v11 - v6); | |
8735 v8 = v20; | |
8736 } | |
8737 v12 = this->uClipX; | |
8738 if ( v12 < uOutX ) | |
8739 v12 = uOutX; | |
8740 v13 = this->uClipZ; | |
8741 if ( v8 + v12 > (signed int)v13 ) | |
8742 { | |
8743 v14 = this->uClipX; | |
8744 if ( v14 < uOutX ) | |
8745 v14 = uOutX; | |
8746 v8 = v13 - v14; | |
8747 } | |
8748 v15 = this->uClipY; | |
8749 if ( (signed int)v15 < (signed int)v6 ) | |
8750 v15 = v6; | |
8751 v16 = this->uClipW; | |
8752 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
8753 { | |
8754 v17 = this->uClipY; | |
8755 if ( (signed int)v17 >= (signed int)v6 ) | |
8756 v6 = v17; | |
8757 v7 = v16 - v6; | |
8758 } | |
8759 } | |
8760 if ( v7 > 0 ) | |
8761 { | |
8762 uOutXa = v7; | |
8763 do | |
8764 { | |
8765 if ( v8 > 0 ) | |
8766 { | |
8767 v18 = v8; | |
8768 do | |
8769 { | |
8770 if ( *uOutYa ) | |
8771 *pZBuffer = zVal; | |
8772 ++pZBuffer; | |
8773 ++uOutYa; | |
8774 --v18; | |
8775 } | |
8776 while ( v18 ); | |
8777 } | |
8778 pZBuffer += 640 - v8; | |
8779 uOutYa += v19 - v8; | |
8780 --uOutXa; | |
8781 } | |
8782 while ( uOutXa ); | |
8783 } | |
8784 } | |
8785 } | |
8786 } | |
8787 | |
8788 //----- (004A601E) -------------------------------------------------------- | |
991 | 8789 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 8790 { |
8791 signed int v5; // edx@3 | |
8792 int v6; // ebx@3 | |
8793 int v7; // esi@3 | |
8794 void *v8; // esi@3 | |
8795 unsigned int v9; // eax@4 | |
8796 unsigned int v10; // eax@6 | |
8797 signed int v11; // edi@8 | |
8798 unsigned int v12; // eax@10 | |
8799 signed int v13; // edi@11 | |
8800 unsigned int v14; // edi@14 | |
8801 unsigned int v15; // eax@16 | |
8802 unsigned int v16; // ecx@17 | |
8803 int v17; // [sp+18h] [bp+Ch]@3 | |
8804 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
8805 | |
8806 if ( this->uNumSceneBegins && pTexture ) | |
8807 { | |
8808 v5 = a3; | |
8809 v6 = pTexture->uTextureHeight; | |
8810 v7 = 5 * a3; | |
8811 v17 = pTexture->uTextureHeight; | |
8812 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
8813 pTexturea = pTexture->uTextureWidth; | |
8814 if ( this->bClip ) | |
8815 { | |
8816 v9 = this->uClipX; | |
8817 if ( a2 < (signed int)v9 ) | |
8818 { | |
8819 pTexturea += a2 - v9; | |
8820 v8 = (char *)v8 + 4 * (v9 - a2); | |
8821 } | |
8822 v10 = this->uClipY; | |
8823 if ( v5 < (signed int)v10 ) | |
8824 { | |
8825 v17 += v5 - v10; | |
8826 v8 = (char *)v8 + 2560 * (v10 - v5); | |
8827 } | |
8828 v11 = this->uClipX; | |
8829 if ( v11 < a2 ) | |
8830 v11 = a2; | |
8831 v12 = this->uClipZ; | |
8832 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
8833 { | |
8834 v13 = this->uClipX; | |
8835 if ( v13 < a2 ) | |
8836 v13 = a2; | |
8837 pTexturea = v12 - v13; | |
8838 } | |
8839 v14 = this->uClipY; | |
8840 if ( (signed int)v14 < v5 ) | |
8841 v14 = v5; | |
8842 v6 = v17; | |
8843 v15 = this->uClipW; | |
8844 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
8845 { | |
8846 v16 = this->uClipY; | |
8847 if ( (signed int)v16 < v5 ) | |
8848 v16 = v5; | |
8849 v6 = v15 - v16; | |
8850 } | |
8851 } | |
8852 if ( v6 > 0 ) | |
8853 { | |
8854 do | |
8855 { | |
8856 if ( (signed int)pTexturea > 0 ) | |
8857 { | |
8858 memset32(v8, a5, pTexturea); | |
8859 v8 = (char *)v8 + 4 * pTexturea; | |
8860 } | |
8861 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
8862 --v6; | |
8863 } | |
8864 while ( v6 ); | |
8865 } | |
8866 } | |
8867 } | |
8868 | |
8869 //----- (004A5EB2) -------------------------------------------------------- | |
8870 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
8871 { | |
8872 Texture *v4; // edi@2 | |
8873 unsigned int v5; // ebx@4 | |
8874 unsigned __int16 *pTarget; // eax@4 | |
8875 unsigned int v7; // edx@5 | |
8876 unsigned int v8; // edx@6 | |
8877 unsigned int v9; // edx@7 | |
8878 unsigned int v10; // edx@8 | |
8879 unsigned int v11; // edx@9 | |
8880 unsigned int v12; // esi@12 | |
8881 unsigned int v13; // esi@15 | |
8882 unsigned int v14; // edx@17 | |
8883 unsigned int v15; // esi@18 | |
8884 unsigned __int8 *v16; // edx@22 | |
8885 char v17; // zf@26 | |
8886 int v18; // [sp+10h] [bp-10h]@4 | |
8887 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
8888 int v20; // [sp+1Ch] [bp-4h]@4 | |
8889 int uXa; // [sp+28h] [bp+8h]@24 | |
8890 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
8891 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
8892 | |
8893 if ( this->uNumSceneBegins ) | |
8894 { | |
8895 v4 = a4; | |
8896 if ( a4 ) | |
8897 { | |
8898 if ( a4->pPalette16 ) | |
8899 { | |
8900 v5 = a4->uTextureHeight; | |
8901 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 8902 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 8903 v20 = a4->uTextureWidth; |
8904 v18 = a4->uTextureWidth; | |
8905 if ( this->bClip ) | |
8906 { | |
8907 v7 = this->uClipX; | |
8908 if ( (signed int)uX < (signed int)v7 ) | |
8909 { | |
8910 v8 = v7 - uX; | |
8911 v19 += v8; | |
8912 v20 += uX - this->uClipX; | |
8913 pTarget += v8; | |
8914 } | |
8915 v9 = this->uClipY; | |
8916 v5 = a4->uTextureHeight; | |
8917 if ( (signed int)uY < (signed int)v9 ) | |
8918 { | |
8919 v10 = v9 - uY; | |
8920 v19 += v18 * v10; | |
8921 v5 = uY - this->uClipY + a4->uTextureHeight; | |
8922 v4 = a4; | |
8923 pTarget += this->uTargetSurfacePitch * v10; | |
8924 } | |
8925 v11 = this->uClipX; | |
8926 if ( (signed int)v11 < (signed int)uX ) | |
8927 v11 = uX; | |
8928 v23 = this->uClipZ; | |
8929 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
8930 { | |
8931 v12 = this->uClipX; | |
8932 if ( (signed int)v12 < (signed int)uX ) | |
8933 v12 = uX; | |
8934 v20 = v23 - v12; | |
8935 } | |
8936 v13 = this->uClipY; | |
8937 if ( (signed int)v13 < (signed int)uY ) | |
8938 v13 = uY; | |
8939 v14 = this->uClipW; | |
8940 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
8941 { | |
8942 v15 = this->uClipY; | |
8943 if ( (signed int)v15 < (signed int)uY ) | |
8944 v15 = uY; | |
8945 v5 = v14 - v15; | |
8946 } | |
8947 } | |
8948 if ( (signed int)v5 > 0 ) | |
8949 { | |
8950 uYa = v5; | |
8951 v16 = v19; | |
8952 do | |
8953 { | |
8954 if ( v20 > 0 ) | |
8955 { | |
8956 uXa = v20; | |
8957 do | |
8958 { | |
8959 *pTarget = v4->pPalette16[*v16]; | |
8960 ++pTarget; | |
8961 ++v16; | |
8962 --uXa; | |
8963 } | |
8964 while ( uXa ); | |
8965 } | |
8966 v16 += v18 - v20; | |
8967 v17 = uYa-- == 1; | |
8968 pTarget += this->uTargetSurfacePitch - v20; | |
8969 } | |
8970 while ( !v17 ); | |
8971 } | |
8972 } | |
8973 } | |
8974 } | |
8975 } | |
8976 | |
8977 //----- (004667E9) -------------------------------------------------------- | |
8978 void Render::ChangeBetweenWinFullscreenModes() | |
8979 { | |
8980 float v0; // ST14_4@17 | |
8981 int v4; // edx@26 | |
8982 ObjectDesc *v5; // eax@26 | |
8983 RGBTexture *v6; // esi@33 | |
8984 const char *v8; // [sp-4h] [bp-28h]@33 | |
8985 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
8986 | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8987 if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) |
0 | 8988 { |
8989 ModalWindow(pGlobalTXT_LocalizationStrings[62], 0);// "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window." | |
8990 return; | |
8991 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8992 if ( pRenderer->bWindowMode || !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
8993 { |
0 | 8994 if ( pEventTimer->bPaused ) |
8995 BYTE1(dword_6BE364_game_settings_1) |= 8u; | |
8996 else | |
8997 pEventTimer->Pause(); | |
8998 if ( pMiscTimer->bPaused ) | |
8999 BYTE1(dword_6BE364_game_settings_1) |= 0x10u; | |
9000 else | |
9001 pMiscTimer->Pause(); | |
9002 pMouse->bActive = 0; | |
9003 if ( pRenderer->pRenderD3D ) | |
9004 { | |
9005 pBitmaps_LOD->ReleaseHardwareTextures(); | |
9006 pSprites_LOD->ReleaseAll(); | |
9007 } | |
9008 if ( pRenderer->bWindowMode ) | |
9009 { | |
9010 if ( GetWindowRect(hWnd, &Rect) ) | |
9011 { | |
9012 WriteWindowsRegistryInt("window X", Rect.left); | |
9013 WriteWindowsRegistryInt("window Y", Rect.top); | |
9014 uWindowX = Rect.left; | |
9015 uWindowY = Rect.top; | |
9016 } | |
9017 SetMenu(hWnd, 0); | |
9018 SetWindowLongA(hWnd, -20, 0); | |
9019 SetWindowLongA(hWnd, -16, 0x10000000u); | |
9020 pRenderer->InitializeFullscreen(hWnd); | |
9021 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | |
9022 pGame->pGammaController->Initialize(v0); | |
9023 } | |
9024 else | |
9025 { | |
9026 ClipCursor(0); | |
9027 pRenderer->SwitchToWindow(hWnd); | |
9028 SetWindowLongA(hWnd, -16, uWindowStyle); | |
9029 SetMenu(hWnd, hOSMenu); | |
9030 } | |
9031 if ( pRenderer->pRenderD3D ) | |
9032 { | |
9033 pBitmaps_LOD->_410423_move_textures_to_device(); | |
9034 pSprites_LOD->MoveSpritesToVideoMemory(); | |
9035 } | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9036 if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits |
0 | 9037 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9038 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9039 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9040 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9041 pPaletteManager->RecalculateAll(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9042 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9043 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9044 for (int i = 0; i < pObjectList->uNumObjects; i++) |
0 | 9045 { |
9046 BYTE3(v4) = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9047 v5 = &pObjectList->pObjects[i]; |
0 | 9048 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; |
9049 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
9050 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9051 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9052 SetUserInterface(pParty->alignment, true); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9053 if ( pVideoPlayer->pVideoFrame.pPixels ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9054 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); |
0 | 9055 if ( uCurrentMenuID != 6 ) |
9056 { | |
9057 if ( uCurrentMenuID == 8 ) | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9058 dword_A74C88 = 1; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9059 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9060 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9061 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9062 if ( uCurrentMenuID ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9063 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9064 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9065 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9066 v8 = "makeme.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9067 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9068 else |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9069 { |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9070 v6 = &pTexture_PCX; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9071 pTexture_PCX.Release(); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9072 v8 = "title.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9073 if ( uCurrentMenuID ) |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9074 v8 = "lsave640.pcx"; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9075 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9076 v6->Load(v8, 0); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9077 } |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9078 } |
0 | 9079 viewparams->bRedrawGameUI = 1; |
688 | 9080 viewparams->InitGrayPalette(); |
0 | 9081 pMouse->SetCurrentCursorBitmap(); |
9082 if ( pRenderer->bWindowMode ) | |
9083 { | |
9084 InvalidateRect(0, 0, 0); | |
9085 MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | |
9086 ShowWindow(hWnd, 1); | |
9087 } | |
9088 pMouse->bActive = 1; | |
9089 if ( pVideoPlayer->AnyMovieLoaded() ) | |
898 | 9090 pVideoPlayer->SelectMovieType(); |
0 | 9091 if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) |
9092 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | |
9093 else | |
9094 pEventTimer->Resume(); | |
9095 if ( BYTE1(dword_6BE364_game_settings_1) & 0x10 ) | |
9096 BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; | |
9097 else | |
9098 pMiscTimer->Resume(); | |
9099 } | |
9100 } | |
9101 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
9102 // A74C88: using guessed type int dword_A74C88; | |
9103 | |
9104 | |
9105 //----- (004524D8) -------------------------------------------------------- | |
9106 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
9107 { | |
9108 int v11; // eax@13 | |
9109 int v12; // ecx@13 | |
9110 void *v13; // eax@13 | |
9111 unsigned __int8 v14; // zf@13 | |
9112 unsigned __int8 v15; // sf@13 | |
9113 int v16; // esi@14 | |
9114 int v17; // ecx@16 | |
9115 int v18; // esi@16 | |
9116 unsigned __int16 *v19; // eax@16 | |
9117 int v20; // edx@16 | |
9118 int v21; // ecx@16 | |
9119 int v22; // eax@16 | |
9120 int v23; // esi@16 | |
9121 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
9122 int v27; // [sp+28h] [bp-Ch]@14 | |
9123 int v28; // [sp+2Ch] [bp-8h]@13 | |
9124 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
9125 | |
9126 //v3 = this; | |
9127 //sprintf(Str1, "%s", pName); | |
9128 //v4 = uNumItems; | |
9129 if (!uNumItems) | |
9130 return nullptr; | |
9131 | |
9132 //{ | |
9133 //v5 = 0, pDesta = uNumItems; | |
9134 uint idx1 = 0, | |
9135 idx2 = uNumItems; | |
9136 while (true) | |
9137 { | |
9138 auto i = idx1 + (idx2 - idx1) / 2; | |
9139 | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1164
diff
changeset
|
9140 auto res = _stricmp(pName, pSpriteNames[i]); |
0 | 9141 if (!res) |
9142 { | |
9143 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
9144 break; | |
9145 } | |
9146 else if (res < 0) | |
9147 idx2 = idx1 + (idx2 - idx1) / 2; | |
9148 else | |
9149 idx1 = i + 1; | |
9150 | |
9151 if ( idx1 >= idx2 ) | |
9152 return false; | |
9153 } | |
9154 | |
9155 | |
9156 uint uCompressedSize = 0; | |
9157 fread(&uCompressedSize, 4, 1, pFile); | |
9158 | |
9159 auto pTex = new HWLTexture; | |
670 | 9160 fread(&pTex->uBufferWidth, 4, 1, pFile); |
9161 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
9162 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
9163 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 9164 fread(&pTex->uWidth, 4, 1, pFile); |
9165 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 9166 fread(&pTex->uAreaX, 4, 1, pFile); |
9167 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 9168 |
9169 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
9170 if (uCompressedSize) | |
9171 { | |
9172 auto pCompressedData = new char[uCompressedSize]; | |
9173 { | |
9174 fread(pCompressedData, 1, uCompressedSize, pFile); | |
9175 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
9176 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
9177 } | |
9178 delete [] pCompressedData; | |
9179 } | |
9180 else | |
9181 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
9182 | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9183 if ( field_61A94_scale_hwls_to_half ) //is it even possible to ever get here? field_61A94_scale_hwls_to_half is only set to zero |
0 | 9184 { |
9185 v11 = pTex->uHeight / 2; | |
9186 v12 = pTex->uWidth / 2; | |
9187 pTex->uHeight = v11; | |
9188 pTex->uWidth = v12; | |
9189 v13 = new unsigned __int16[v12 * v11]; | |
9190 v28 = 0; | |
9191 v14 = pTex->uHeight == 0; | |
9192 v15 = (pTex->uHeight & 0x80000000u) != 0; | |
9193 v26 = (unsigned __int16 *)v13; | |
9194 if ( !(v15 | v14) ) | |
9195 { | |
9196 v16 = pTex->uWidth; | |
9197 v27 = 1; | |
9198 do | |
9199 { | |
9200 pDestb = 0; | |
9201 if ( v16 > 0 ) | |
9202 { | |
9203 do | |
9204 { | |
9205 v17 = v16 * v27; | |
9206 v18 = v28 * v16; | |
9207 v19 = pTex->pPixels; | |
9208 v20 = pDestb + 2 * v18; | |
9209 v21 = (int)&v19[2 * (pDestb + v17)]; | |
9210 v22 = (int)&v19[2 * v20]; | |
9211 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
9212 LOWORD(v21) = *(unsigned short *)v21; | |
9213 v23 = pDestb++ + v18; | |
9214 v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
9215 v16 = pTex->uWidth; | |
9216 } | |
9217 while (pDestb < pTex->uWidth); | |
9218 } | |
9219 ++v28; | |
9220 v27 += 2; | |
9221 } | |
9222 while ( v28 < (signed int)pTex->uHeight ); | |
9223 } | |
9224 delete [] pTex->pPixels; | |
9225 pTex->pPixels = v26; | |
9226 } | |
9227 return pTex; | |
9228 //result = pTex; | |
9229 // } | |
9230 // else | |
9231 // { | |
9232 //LABEL_8: | |
9233 // return nullptr; | |
9234 // } | |
9235 } | |
9236 | |
9237 //----- (0045271F) -------------------------------------------------------- | |
9238 bool RenderHWLContainer::Release() | |
9239 { | |
9240 __int32 v4; // eax@6 | |
9241 FILE *v5; // ST24_4@6 | |
9242 FILE *File; // [sp+4h] [bp-4h]@6 | |
9243 | |
1162 | 9244 if ( this->bDumpDebug) |
0 | 9245 { |
9246 File = fopen("logd3d.txt", "w"); | |
1162 | 9247 v4 = ftell(this->pFile); |
9248 v5 = this->pFile; | |
9249 this->uDataOffset = v4; | |
9250 fwrite(&this->uNumItems, 4u, 1u, v5); | |
9251 for (int i = 0; i < this->uNumItems; i++) | |
9252 { | |
9253 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
9254 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
9255 } | |
9256 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
9257 fseek(this->pFile, 4, 0); | |
9258 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
9259 fclose(this->pFile); | |
0 | 9260 fclose(File); |
9261 } | |
9262 else | |
9263 { | |
9264 fclose(this->pFile); | |
1162 | 9265 for (int i = 0; i < this->uNumItems; i++) |
9266 { | |
9267 free(this->pSpriteNames[i]); | |
0 | 9268 } |
9269 } | |
1093 | 9270 return true; |
0 | 9271 } |
9272 | |
9273 //----- (00452347) -------------------------------------------------------- | |
9274 RenderHWLContainer::RenderHWLContainer(): | |
9275 bDumpDebug(false) | |
9276 { | |
9277 this->pFile = 0; | |
9278 uSignature = 0; | |
1164
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9279 this->uDataOffset = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9280 memset(&this->uNumItems, 0, 0x61A84u); |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9281 this->uNumItems = 0; |
6b911d7e09a5
RenderHWLContainer::RenderHWLContainer, Render::SetPixel, Render::ChangeBetweenWinFullscreenModes cleanup
Grumpy7
parents:
1162
diff
changeset
|
9282 this->field_61A94_scale_hwls_to_half = 0; |
0 | 9283 } |
9284 | |
9285 //----- (0045237F) -------------------------------------------------------- | |
9286 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
9287 { | |
9288 pFile = _wfopen(pFilename, L"rb"); | |
9289 if (!pFile) | |
9290 { | |
9291 Log::Warning(L"Failed to open file: %s", pFilename); | |
9292 return false; | |
9293 } | |
9294 | |
9295 fread(&uSignature, 1, 4, pFile); | |
9296 if (uSignature != 'TD3D') | |
9297 { | |
9298 Log::Warning(L"Invalid format: %s", pFilename); | |
9299 return false; | |
9300 } | |
9301 | |
9302 fread(&uDataOffset, 4, 1, pFile); | |
9303 fseek(pFile, uDataOffset, SEEK_SET); | |
9304 fread(&uNumItems, 4, 1, pFile); | |
9305 | |
9306 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
9307 for (uint i = 0; i < uNumItems; ++i) | |
9308 { | |
9309 pSpriteNames[i] = new char[20]; | |
9310 fread(pSpriteNames[i], 1, 20, pFile); | |
9311 } | |
9312 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
9313 | |
9314 return true; | |
9315 } | |
9316 | |
9317 //----- (004A1C1E) -------------------------------------------------------- | |
9318 void DoRenderBillboards_D3D() | |
9319 { | |
186 | 9320 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
9321 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9322 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9323 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9324 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9325 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9326 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9327 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9328 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9329 { |
1390 | 9330 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; |
9331 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
9332 } | |
9333 p->pQuads[0].pos.x = 10; | |
9334 p->pQuads[0].pos.y = 10; | |
9335 | |
9336 p->pQuads[1].pos.x = 10; | |
9337 p->pQuads[1].pos.y = 200; | |
9338 | |
9339 p->pQuads[2].pos.x = 100; | |
9340 p->pQuads[2].pos.y = 200; | |
9341 | |
9342 p->pQuads[3].pos.x = 100; | |
9343 p->pQuads[3].pos.y = 10; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9344 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9345 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9346 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9347 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9348 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9349 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9350 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 9351 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9352 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9353 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9354 }*/ |
0 | 9355 |
9356 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) | |
9357 { | |
101 | 9358 auto p = &pRenderer->pBillboardRenderListD3D[i]; |
0 | 9359 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9360 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
0 | 9361 SetBillboardBlendOptions(p->uOpacity); |
9362 | |
101 | 9363 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9364 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9365 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
1390 | 9366 p->pQuads, p->uNumVertices, |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9367 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 9368 } |
9369 | |
9370 if (pRenderer->bFogEnabled) | |
9371 { | |
9372 pRenderer->bFogEnabled = false; | |
186 | 9373 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 9374 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
9375 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
9376 } | |
186 | 9377 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
9378 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9379 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9380 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9381 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9382 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 9383 } |
9384 | |
9385 //----- (004A1DA8) -------------------------------------------------------- | |
9386 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
9387 { | |
9388 switch (a1) | |
9389 { | |
9390 case RenderBillboardD3D::Transparent: | |
9391 { | |
9392 if (pRenderer->bFogEnabled) | |
9393 { | |
9394 pRenderer->bFogEnabled = false; | |
186 | 9395 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 9396 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
9397 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
9398 } | |
9399 | |
186 | 9400 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); |
9401 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9402 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 9403 } |
9404 break; | |
9405 | |
9406 case RenderBillboardD3D::Opaque_1: | |
9407 case RenderBillboardD3D::Opaque_2: | |
9408 case RenderBillboardD3D::Opaque_3: | |
9409 { | |
9410 if (pRenderer->bUsingSpecular) | |
9411 { | |
9412 if (!pRenderer->bFogEnabled) | |
9413 { | |
9414 pRenderer->bFogEnabled = true; | |
186 | 9415 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
9416 } | |
9417 } | |
9418 | |
9419 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9420 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9421 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 9422 } |
9423 break; | |
9424 | |
9425 default: | |
9426 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
9427 assert(false); |
0 | 9428 break; |
9429 } | |
9430 } | |
1297 | 9431 //----- (0040DF3D) -------------------------------------------------------- |
9432 void __cdecl CallRenderPresent() | |
9433 { | |
9434 pRenderer->Present(); | |
9435 } | |
1390 | 9436 |
9437 | |
9438 | |
9439 //----- (0044EC20) -------------------------------------------------------- | |
9440 /*bool RenderD3D::DoesRaiseExceptions() | |
9441 { | |
9442 return true; | |
9443 }*/ |