comparison Render.cpp @ 45:bcc051713d20

BLV render & seffects
author Nomad
date Mon, 22 Oct 2012 20:45:14 +0200
parents 484492a6dd28
children 79a30ee1ecdb
comparison
equal deleted inserted replaced
43:484492a6dd28 45:bcc051713d20
61 61
62 62
63 63
64 64
65 65
66 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1);
66 67
67 68
68 /* 384 */ 69 /* 384 */
69 #pragma pack(push, 1) 70 #pragma pack(push, 1)
70 struct PCXHeader_1 71 struct PCXHeader_1
171 172
172 173
173 //----- (00440CB8) -------------------------------------------------------- 174 //----- (00440CB8) --------------------------------------------------------
174 void Render::DrawBillboardList_BLV() 175 void Render::DrawBillboardList_BLV()
175 { 176 {
176 int v0; // ebx@1
177 char *v1; // esi@2
178 __int16 v2; // ax@3 177 __int16 v2; // ax@3
179 unsigned __int16 *v3; // eax@6
180 char v4; // zf@6
181 int v5; // eax@11 178 int v5; // eax@11
182 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 179 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1
183 180
184 soft_billboard.uParentBillboardID = -1; 181 soft_billboard.uParentBillboardID = -1;
185 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; 182 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget;
187 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; 184 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch;
188 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; 185 soft_billboard.uViewportX = pBLVRenderParams->uViewportX;
189 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; 186 soft_billboard.uViewportY = pBLVRenderParams->uViewportY;
190 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; 187 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1;
191 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; 188 soft_billboard.uViewportW = pBLVRenderParams->uViewportW;
192 v0 = 0; 189
193 pOutdoorCamera->field_3C = uNumBillboardsToDraw; 190 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw;
194 if ( (signed int)uNumBillboardsToDraw > 0 ) 191
195 { 192 for (uint i = 0; i < uNumBillboardsToDraw; ++i)
196 v1 = (char *)&pBillboardRenderList[0].field_28; 193 {
197 do 194 auto p = pBillboardRenderList + i;
198 { 195
199 soft_billboard.field_8 = *((short *)v1 - 1); 196 soft_billboard.uScreenSpaceX = p->uScreenSpaceX;
200 soft_billboard.uParentBillboardID = v0; 197 soft_billboard.uParentBillboardID = i;
201 soft_billboard.field_C = *(short *)v1; 198 soft_billboard.uScreenSpaceY = p->uScreenSpaceY;
202 soft_billboard.field_10 = *((int *)v1 - 10); 199 soft_billboard.field_10 = p->field_0;
203 soft_billboard.field_14 = *((int *)v1 - 9); 200 soft_billboard.field_14 = p->field_4;
204 soft_billboard.field_28 = *((int *)v1 - 6); 201 soft_billboard.sZValue = p->sZValue;
205 soft_billboard.uFlags = *((short *)v1 - 5); 202 soft_billboard.uFlags = p->field_1E;
206 soft_billboard.uTintColor = *((int *)v1 + 1); 203 soft_billboard.uTintColor = p->uTintColor;
207 v2 = *((short *)v1 - 8); 204 v2 = p->uHwSpriteID;
208 if ( v2 != -1 ) 205 if ( v2 != -1 )
209 { 206 {
210 if ( pRenderer->pRenderD3D ) 207 if ( pRenderer->pRenderD3D )
211 { 208 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->uPaletteSubindex);
212 pRenderer->_4A43B1(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], *((short *)v1 + 1));
213 }
214 else 209 else
215 { 210 {
216 v3 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), *((short *)v1 + 1), 1); 211 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->uPaletteSubindex, 1);
217 v4 = (*(v1 - 9) & 1) == 0; 212 if (p->field_1E & 0x0100)
218 soft_billboard.pPalette = v3; 213 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette];
219 if ( !v4 )
220 soft_billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)];
221 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) 214 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 )
222 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); 215 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1);
223 v5 = *((short *)v1 - 8); 216 v5 = p->uHwSpriteID;
224 if ( v5 >= 0 ) 217 if ( v5 >= 0 )
225 pSprites_LOD->pSpriteHeaders[v5]._4ACC38(&soft_billboard, 1); 218 pSprites_LOD->pSpriteHeaders[v5]._4ACC38(&soft_billboard, 1);
226 } 219 }
227 } 220 }
228 ++v0;
229 v1 += 52;
230 }
231 while ( v0 < (signed int)uNumBillboardsToDraw );
232 } 221 }
233 } 222 }
234 223
235 224
236 225
2902 billboard.uViewportX = pViewport->uViewportX; 2891 billboard.uViewportX = pViewport->uViewportX;
2903 billboard.uViewportY = pViewport->uViewportY; 2892 billboard.uViewportY = pViewport->uViewportY;
2904 billboard.uViewportZ = pViewport->uViewportZ - 1; 2893 billboard.uViewportZ = pViewport->uViewportZ - 1;
2905 billboard.uViewportW = pViewport->uViewportW; 2894 billboard.uViewportW = pViewport->uViewportW;
2906 v0 = 0; 2895 v0 = 0;
2907 pOutdoorCamera->field_3C = uNumBillboardsToDraw; 2896 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw;
2908 v16 = 0; 2897 v16 = 0;
2909 if ( (signed int)uNumBillboardsToDraw > 0 ) 2898 if ( (signed int)uNumBillboardsToDraw > 0 )
2910 { 2899 {
2911 v17 = 0; 2900 v17 = 0;
2912 v1 = (char *)&pBillboardRenderList[0].field_28; 2901 v1 = (char *)&pBillboardRenderList[0].uScreenSpaceY;
2913 do 2902 do
2914 { 2903 {
2915 billboard.field_8 = *((short *)v1 - 1); 2904 billboard.uScreenSpaceX = *((short *)v1 - 1);
2916 v2 = *((short *)v1 - 5); 2905 v2 = *((short *)v1 - 5);
2917 billboard.field_C = *(short *)v1; 2906 billboard.uScreenSpaceY = *(short *)v1;
2918 v3 = *((int *)v1 - 10); 2907 v3 = *((int *)v1 - 10);
2919 billboard.uParentBillboardID = v0; 2908 billboard.uParentBillboardID = v0;
2920 v4 = *((int *)v1 + 1); 2909 v4 = *((int *)v1 + 1);
2921 billboard.field_10 = v3; 2910 billboard.field_10 = v3;
2922 v5 = *((int *)v1 - 9); 2911 v5 = *((int *)v1 - 9);
2923 billboard.uTintColor = v4; 2912 billboard.uTintColor = v4;
2924 v6 = *((short *)v1 - 8); 2913 v6 = *((short *)v1 - 8);
2925 billboard.field_14 = v5; 2914 billboard.field_14 = v5;
2926 v7 = *((int *)v1 - 6); 2915 v7 = *((int *)v1 - 6);
2927 billboard.field_28 = *((int *)v1 - 6); 2916 billboard.sZValue = *((int *)v1 - 6);
2928 billboard.uFlags = v2; 2917 billboard.uFlags = v2;
2929 if ( v6 != -1 ) 2918 if ( v6 != -1 )
2930 { 2919 {
2931 v8 = *((short *)v1 + 1); 2920 v8 = *((short *)v1 + 1);
2932 if ( pRenderer->pRenderD3D ) 2921 if ( pRenderer->pRenderD3D )
2933 { 2922 {
2934 billboard.field_28 = v7; 2923 billboard.sZValue = v7;
2935 billboard.uFlags = v2; 2924 billboard.uFlags = v2;
2936 pRenderer->TransformBillboard( 2925 pRenderer->TransformBillboard(
2937 &billboard, 2926 &billboard,
2938 &pSprites_LOD->pHardwareSprites[v6], 2927 &pSprites_LOD->pHardwareSprites[v6],
2939 v8, 2928 v8,
3139 v3->field_0 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; 3128 v3->field_0 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16;
3140 v26 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; 3129 v26 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16;
3141 v3->pSpriteFrame = v28; 3130 v3->pSpriteFrame = v28;
3142 v3->field_4 = v26; 3131 v3->field_4 = v26;
3143 v3->field_1E = v46; 3132 v3->field_1E = v46;
3144 v3->field_20 = x; 3133 v3->some_x = x;
3145 v3->field_22 = y; 3134 v3->some_y = y;
3146 v3->field_24 = z; 3135 v3->some_z = z;
3147 v3->field_26 = v35; 3136 v3->uScreenSpaceX = v35;
3148 v3->field_28 = v32; 3137 v3->uScreenSpaceY = v32;
3149 HIWORD(v26) = HIWORD(v42); 3138 HIWORD(v26) = HIWORD(v42);
3150 LOWORD(v26) = 0; 3139 LOWORD(v26) = 0;
3151 v27 = (*(v0 - 2) & 0x20) == 0; 3140 v27 = (*(v0 - 2) & 0x20) == 0;
3152 v3->sZValue = v26 + (8 * v41 | 2); 3141 v3->sZValue = v26 + (8 * v41 | 2);
3153 v3->field_2A = 0; 3142 v3->uPaletteSubindex = 0;
3154 v3->field_2C_prolly_tint = 0; 3143 v3->uTintColor = 0;
3155 if ( !v27 ) 3144 if ( !v27 )
3156 { 3145 {
3157 if ( !pRenderer->pRenderD3D ) 3146 if ( !pRenderer->pRenderD3D )
3158 v3->sZValue = 0; 3147 v3->sZValue = 0;
3159 } 3148 }
3571 v27->uHwSpriteID = *v37; 3560 v27->uHwSpriteID = *v37;
3572 v28 = v9->uPaletteIndex; 3561 v28 = v9->uPaletteIndex;
3573 v27->field_0 = v26; 3562 v27->field_0 = v26;
3574 v27->field_4 = v26; 3563 v27->field_4 = v26;
3575 v29 = v38; 3564 v29 = v38;
3576 v27->field_26 = v25; 3565 v27->uScreenSpaceX = v25;
3577 HIBYTE(v29) |= 2u; 3566 HIBYTE(v29) |= 2u;
3578 v27->uPalette = v28; 3567 v27->uPalette = v28;
3579 v27->field_1E = v29; 3568 v27->field_1E = v29;
3580 v27->field_20 = x; 3569 v27->some_x = x;
3581 v27->field_22 = y; 3570 v27->some_y = y;
3582 v27->field_24 = v36; 3571 v27->some_z = v36;
3583 v27->field_28 = v40; 3572 v27->uScreenSpaceY = v40;
3584 HIWORD(v30) = HIWORD(v39); 3573 HIWORD(v30) = HIWORD(v39);
3585 v31 = 8 * v35 | 5; 3574 v31 = 8 * v35 | 5;
3586 LOWORD(v30) = 0; 3575 LOWORD(v30) = 0;
3587 v27->uIndoorSectorID = 0; 3576 v27->uIndoorSectorID = 0;
3588 v27->sZValue = v30 + v31; 3577 v27->sZValue = v30 + v31;
3589 v27->field_2A = 0; 3578 v27->uPaletteSubindex = 0;
3590 v27->pSpriteFrame = v9; 3579 v27->pSpriteFrame = v9;
3591 v27->field_2C_prolly_tint = 0; 3580 v27->uTintColor = 0;
3592 } 3581 }
3593 } 3582 }
3594 goto LABEL_38; 3583 goto LABEL_38;
3595 } 3584 }
3596 } 3585 }
3625 local_0.z = (double)*((signed int *)v0 + 1); 3614 local_0.z = (double)*((signed int *)v0 + 1);
3626 local_0.flt_10 = 0.0; 3615 local_0.flt_10 = 0.0;
3627 local_0.flt_14 = 0.0; 3616 local_0.flt_14 = 0.0;
3628 local_0.flt_18 = 0.0; 3617 local_0.flt_18 = 0.0;
3629 local_0.flt_28 = 1.0; 3618 local_0.flt_28 = 1.0;
3630 local_0.field_20 = (rand() & 0x80) + 128; 3619 local_0.timeToLive = (rand() & 0x80) + 128;
3631 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); 3620 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01");
3632 pGame->pParticleEngine->AddParticle(&local_0); 3621 pGame->pParticleEngine->AddParticle(&local_0);
3633 } 3622 }
3634 } 3623 }
3635 LABEL_38: 3624 LABEL_38:
4509 { 4498 {
4510 v35 = *(int *)v34; 4499 v35 = *(int *)v34;
4511 *(int *)v34 = 0; 4500 *(int *)v34 = 0;
4512 v34 += 32; 4501 v34 += 32;
4513 --v33; 4502 --v33;
4514 *((int *)v34 - 9) = LODWORD(pRenderer->uFogColor) | v35 & 0xFF000000; 4503 *((int *)v34 - 9) = pRenderer->uFogColor | v35 & 0xFF000000;
4515 } 4504 }
4516 while ( v33 ); 4505 while ( v33 );
4517 } 4506 }
4518 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); 4507 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
4519 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6)); 4508 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6));
4622 v1->bRequiredTextureStagesAvailable = 0; 4611 v1->bRequiredTextureStagesAvailable = 0;
4623 v1->bTinting = 1; 4612 v1->bTinting = 1;
4624 LOBYTE(v1->field_103668) = 0; 4613 LOBYTE(v1->field_103668) = 0;
4625 v1->field_1036B8 = 0; 4614 v1->field_1036B8 = 0;
4626 v1->_gpu_memory_used = 0; 4615 v1->_gpu_memory_used = 0;
4616 uNumBillboardsToDraw = 0;
4627 } 4617 }
4628 4618
4629 bool Render::Initialize(bool bWindowed, uint uDefaultDevice, 4619 bool Render::Initialize(bool bWindowed, uint uDefaultDevice,
4630 bool bColoredLights, uint uDetailLevel, uint bTinting) 4620 bool bColoredLights, uint uDetailLevel, uint bTinting)
4631 { 4621 {
7193 } 7183 }
7194 7184
7195 //----- (004A1FE1) -------------------------------------------------------- 7185 //----- (004A1FE1) --------------------------------------------------------
7196 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() 7186 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene()
7197 { 7187 {
7198 char v1; // zf@1 7188 --uNumD3DSceneBegins;
7199 7189 if (uNumD3DSceneBegins)
7200 v1 = this->uNumD3DSceneBegins-- == 1; 7190 return;
7201 if ( v1 ) 7191
7202 { 7192 if (pRenderD3D)
7203 if ( this->pRenderD3D ) 7193 {
7204 { 7194 pGame->draw_debug_outlines();
7205 pGame->draw_debug_outlines(); 7195 DoRenderBillboards_D3D();
7206 DoRenderBillboards_D3D(); 7196 pGame->pStru6Instance->RenderSpecialEffects();
7207 pGame->pStru6Instance->RenderSpecialEffects(); 7197 pRenderD3D->pDevice->EndScene();
7208 pRenderD3D->pDevice->EndScene(); 7198 }
7209 } 7199 else
7210 else 7200 pGame->pStru6Instance->RenderSpecialEffects();
7211 {
7212 pGame->pStru6Instance->RenderSpecialEffects();
7213 }
7214 }
7215 } 7201 }
7216 7202
7217 7203
7218 7204
7219 //----- (004A2031) -------------------------------------------------------- 7205 //----- (004A2031) --------------------------------------------------------
7477 { 7463 {
7478 v39 = *(int *)v38; 7464 v39 = *(int *)v38;
7479 *(int *)v38 = 0; 7465 *(int *)v38 = 0;
7480 v38 += 32; 7466 v38 += 32;
7481 --v37; 7467 --v37;
7482 *((int *)v38 - 9) = LODWORD(pRenderer->uFogColor) | v39 & 0xFF000000; 7468 *((int *)v38 - 9) = pRenderer->uFogColor | v39 & 0xFF000000;
7483 } 7469 }
7484 while ( v37 ); 7470 while ( v37 );
7485 } 7471 }
7486 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); 7472 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
7487 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6u)); 7473 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6u));
7864 } 7850 }
7865 // 4D864C: using guessed type char byte_4D864C; 7851 // 4D864C: using guessed type char byte_4D864C;
7866 7852
7867 7853
7868 //----- (004A43B1) -------------------------------------------------------- 7854 //----- (004A43B1) --------------------------------------------------------
7869 void Render::_4A43B1(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int a4) 7855 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int uPaletteSubindex)
7870 { 7856 {
7871 RenderBillboardTransform_local0 *v4; // ebx@2 7857 RenderBillboardTransform_local0 *v4; // ebx@2
7872 double v5; // st7@2 7858 double v5; // st7@2
7873 float v6; // ST08_4@2 7859 float v6; // ST08_4@2
7874 unsigned int v7; // eax@2 7860 unsigned int v7; // eax@2
7901 7887
7902 v26 = this; 7888 v26 = this;
7903 if ( this->uNumD3DSceneBegins ) 7889 if ( this->uNumD3DSceneBegins )
7904 { 7890 {
7905 v4 = pSoftBillboard; 7891 v4 = pSoftBillboard;
7906 v5 = (double)HIWORD(pSoftBillboard->field_28); 7892 v5 = (double)HIWORD(pSoftBillboard->sZValue);
7907 pSoftBillboarda = v5; 7893 pSoftBillboarda = v5;
7908 v6 = v5; 7894 v6 = v5;
7909 v7 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v6)); 7895 v7 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v6));
7910 v8 = a4; 7896 v8 = uPaletteSubindex;
7911 v9 = v7; 7897 v9 = v7;
7912 v28 = a4 & 0xFF000000; 7898 v28 = uPaletteSubindex & 0xFF000000;
7913 if ( a4 & 0xFF000000 ) 7899 if ( uPaletteSubindex & 0xFF000000 )
7914 pBillboardRenderListD3D[v9].bOpaque = 3; 7900 pBillboardRenderListD3D[v9].uOpacity = RenderBillboardD3D::Opaque_3;
7915 else 7901 else
7916 pBillboardRenderListD3D[v9].bOpaque = 0; 7902 pBillboardRenderListD3D[v9].uOpacity = RenderBillboardD3D::Transparent;
7917 v10 = a3; 7903 v10 = a3;
7918 pBillboardRenderListD3D[v9].field_90 = v4->field_44; 7904 pBillboardRenderListD3D[v9].field_90 = v4->field_44;
7919 pBillboardRenderListD3D[v9].field_94 = v4->field_28; 7905 pBillboardRenderListD3D[v9].sZValue = v4->sZValue;
7920 pBillboardRenderListD3D[v9].uParentBillboardID = v4->uParentBillboardID; 7906 pBillboardRenderListD3D[v9].uParentBillboardID = v4->uParentBillboardID;
7921 v25 = v4->field_8; 7907 v25 = v4->uScreenSpaceX;
7922 v24 = v4->field_C; 7908 v24 = v4->uScreenSpaceY;
7923 a1 = (double)(v4->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_10); 7909 a1 = (double)(v4->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_10);
7924 v29 = (double)(v4->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_14); 7910 v29 = (double)(v4->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_14);
7925 v31 = (double)((v10->uBufferWidth >> 1) - v10->uAreaX); 7911 v31 = (double)((v10->uBufferWidth >> 1) - v10->uAreaX);
7926 v27 = (double)(v10->uBufferHeight - v10->uAreaY); 7912 v27 = (double)(v10->uBufferHeight - v10->uAreaY);
7927 if ( v4->uFlags & 4 ) 7913 if ( v4->uFlags & 4 )
7954 v18 = (double)(v10->uBufferHeight - v10->uAreaY - v10->uAreaHeight); 7940 v18 = (double)(v10->uBufferHeight - v10->uAreaY - v10->uAreaHeight);
7955 if ( v4->uFlags & 4 ) 7941 if ( v4->uFlags & 4 )
7956 v17 = v17 * -1.0; 7942 v17 = v17 * -1.0;
7957 pBillboardRenderListD3D[v9].pQuards[1].specular = 0; 7943 pBillboardRenderListD3D[v9].pQuards[1].specular = 0;
7958 pBillboardRenderListD3D[v9].pQuards[1].diffuse = v12; 7944 pBillboardRenderListD3D[v9].pQuards[1].diffuse = v12;
7959 *(float *)(v9 * 156 + 15684320) = v13 - v17 * a1; 7945 pBillboardRenderListD3D[v9].pQuards[1].pos.x = v13 - v17 * a1;
7960 *(float *)(v9 * 156 + 15684324) = v32 - v18 * v29; 7946 pBillboardRenderListD3D[v9].pQuards[1].pos.y = v32 - v18 * v29;
7961 *(float *)(v9 * 156 + 15684328) = v15; 7947 pBillboardRenderListD3D[v9].pQuards[1].pos.z = v15;
7962 *(float *)(v9 * 156 + 15684332) = v16; 7948 pBillboardRenderListD3D[v9].pQuards[1].rhw = v16;
7963 *(float *)(v9 * 156 + 15684344) = 0.0; 7949 pBillboardRenderListD3D[v9].pQuards[1].texcoord.x = 0.0;
7964 *(float *)(v9 * 156 + 15684348) = 1.0; 7950 pBillboardRenderListD3D[v9].pQuards[1].texcoord.y = 1.0;
7965 v19 = v10->uBufferHeight - v10->uAreaY - v10->uAreaHeight; 7951 v19 = v10->uBufferHeight - v10->uAreaY - v10->uAreaHeight;
7966 v20 = (double)(v10->uAreaX + v10->uAreaWidth + (v10->uBufferWidth >> 1) - v10->uBufferWidth); 7952 v20 = (double)(v10->uAreaX + v10->uAreaWidth + (v10->uBufferWidth >> 1) - v10->uBufferWidth);
7967 if ( v4->uFlags & 4 ) 7953 if ( v4->uFlags & 4 )
7968 v20 = v20 * -1.0; 7954 v20 = v20 * -1.0;
7969 pBillboardRenderListD3D[v9].pQuards[2].specular = 0; 7955 pBillboardRenderListD3D[v9].pQuards[2].specular = 0;
7970 pBillboardRenderListD3D[v9].pQuards[2].diffuse = v12; 7956 pBillboardRenderListD3D[v9].pQuards[2].diffuse = v12;
7971 *(float *)(v9 * 156 + 15684352) = v20 * a1 + v13; 7957 pBillboardRenderListD3D[v9].pQuards[2].pos.x = v20 * a1 + v13;
7972 *(float *)(v9 * 156 + 15684356) = v32 - (double)v19 * v29; 7958 pBillboardRenderListD3D[v9].pQuards[2].pos.y = v32 - (double)v19 * v29;
7973 *(float *)(v9 * 156 + 15684360) = v15; 7959 pBillboardRenderListD3D[v9].pQuards[2].pos.z = v15;
7974 *(float *)(v9 * 156 + 15684364) = v16; 7960 pBillboardRenderListD3D[v9].pQuards[2].rhw = v16;
7975 *(float *)(v9 * 156 + 15684376) = 1.0; 7961 pBillboardRenderListD3D[v9].pQuards[2].texcoord.x = 1.0;
7976 *(float *)(v9 * 156 + 15684380) = 1.0; 7962 pBillboardRenderListD3D[v9].pQuards[2].texcoord.y = 1.0;
7977 v21 = v10->uBufferHeight - v10->uAreaY; 7963 v21 = v10->uBufferHeight - v10->uAreaY;
7978 v22 = (double)(v10->uAreaX + v10->uAreaWidth + (v10->uBufferWidth >> 1) - v10->uBufferWidth); 7964 v22 = (double)(v10->uAreaX + v10->uAreaWidth + (v10->uBufferWidth >> 1) - v10->uBufferWidth);
7979 if ( v4->uFlags & 4 ) 7965 if ( v4->uFlags & 4 )
7980 v22 = v22 * -1.0; 7966 v22 = v22 * -1.0;
7981 pBillboardRenderListD3D[v9].pQuards[3].specular = 0; 7967 pBillboardRenderListD3D[v9].pQuards[3].specular = 0;
7982 pBillboardRenderListD3D[v9].pQuards[3].diffuse = v12; 7968 pBillboardRenderListD3D[v9].pQuards[3].diffuse = v12;
7983 *(float *)(v9 * 156 + 15684384) = v22 * a1 + v13; 7969 pBillboardRenderListD3D[v9].pQuards[3].pos.x = v22 * a1 + v13;
7984 *(float *)(v9 * 156 + 15684388) = v32 - (double)v21 * v29; 7970 pBillboardRenderListD3D[v9].pQuards[3].pos.y = v32 - (double)v21 * v29;
7985 *(float *)(v9 * 156 + 15684392) = v15; 7971 pBillboardRenderListD3D[v9].pQuards[3].pos.z = v15;
7986 *(float *)(v9 * 156 + 15684396) = v16; 7972 pBillboardRenderListD3D[v9].pQuards[3].rhw = v16;
7987 *(float *)(v9 * 156 + 15684408) = 1.0; 7973 pBillboardRenderListD3D[v9].pQuards[3].texcoord.x = 1.0;
7988 *(float *)(v9 * 156 + 15684412) = 0.0; 7974 pBillboardRenderListD3D[v9].pQuards[3].texcoord.y = 0.0;
7989 v23 = v10->pTexture; 7975 v23 = v10->pTexture;
7990 pBillboardRenderListD3D[v9].uNumVertices = 4; 7976 pBillboardRenderListD3D[v9].uNumVertices = 4;
7991 *(float *)(v9 * 156 + 15684416) = pSoftBillboarda; 7977 pBillboardRenderListD3D[v9].flt_88 = pSoftBillboarda;
7992 pBillboardRenderListD3D[v9].pTexture = v23; 7978 pBillboardRenderListD3D[v9].pTexture = v23;
7993 } 7979 }
7994 } 7980 }
7995 7981
7996 7982
8041 double v45; // st6@3 8027 double v45; // st6@3
8042 float v46; // eax@3 8028 float v46; // eax@3
8043 8029
8044 if ( this->uNumD3DSceneBegins ) 8030 if ( this->uNumD3DSceneBegins )
8045 { 8031 {
8046 if ( HIWORD(a2->field_28) ) 8032 if ( HIWORD(a2->sZValue) )
8047 { 8033 {
8048 v5 = (double)HIWORD(a2->field_28); 8034 v5 = (double)HIWORD(a2->sZValue);
8049 v6 = v5; 8035 v6 = v5;
8050 v7 = v5; 8036 v7 = v5;
8051 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); 8037 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7));
8052 pBillboardRenderListD3D[v8].bOpaque = 1; 8038 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1;
8053 pBillboardRenderListD3D[v8].field_90 = a2->field_44; 8039 pBillboardRenderListD3D[v8].field_90 = a2->field_44;
8054 pBillboardRenderListD3D[v8].field_94 = a2->field_28; 8040 pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
8055 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; 8041 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID;
8056 v9 = a2->field_8; 8042 v9 = a2->uScreenSpaceX;
8057 v10 = a2->field_C; 8043 v10 = a2->uScreenSpaceY;
8058 v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10); 8044 v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10);
8059 v12 = (double)v9; 8045 v12 = (double)v9;
8060 v13 = v12; 8046 v13 = v12;
8061 v14 = (double)(v10 - 12); 8047 v14 = (double)(v10 - 12);
8062 v15 = v14; 8048 v15 = v14;
8075 * v11 + v13; 8061 * v11 + v13;
8076 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 8062 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17
8077 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 8063 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16
8078 - 12.0) 8064 - 12.0)
8079 * v11 8065 * v11
8080 + (double)a2->field_C; 8066 + (double)a2->uScreenSpaceY;
8081 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; 8067 pBillboardRenderListD3D[v8].pQuards[0].specular = 0;
8082 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; 8068 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse;
8083 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22; 8069 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22;
8084 pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (v6 * 0.061758894); 8070 pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (v6 * 0.061758894);
8085 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / v6; 8071 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / v6;
8086 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; 8072 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0;
8087 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; 8073 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0;
8088 v23 = (double)(a2->field_8 - 12) - v13; 8074 v31 = (double)(a2->uScreenSpaceX + 12) - v13;
8089 v24 = (double)a2->field_C - v15; 8075 v32 = (double)a2->uScreenSpaceY - v15;
8090 v25 = stru_5C6E00->SinCos(angle); 8076 v25 = stru_5C6E00->SinCos(angle);
8091 v26 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); 8077 v26 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
8092 v27 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); 8078 v27 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
8093 v28 = stru_5C6E00->SinCos(angle); 8079 v28 = stru_5C6E00->SinCos(angle);
8094 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 8080 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022
8100 * v11 + v13; 8086 * v11 + v13;
8101 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v24 8087 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v24
8102 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v23 8088 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v23
8103 - 12.0) 8089 - 12.0)
8104 * v11 8090 * v11
8105 + (double)a2->field_C; 8091 + (double)a2->uScreenSpaceY;
8106 pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z; 8092 pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z;
8107 v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw; 8093 v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw;
8108 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29; 8094 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29;
8109 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; 8095 pBillboardRenderListD3D[v8].pQuards[1].specular = 0;
8110 pBillboardRenderListD3D[v8].pQuards[1].rhw = v30; 8096 pBillboardRenderListD3D[v8].pQuards[1].rhw = v30;
8111 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; 8097 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse;
8112 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; 8098 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0;
8113 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; 8099 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0;
8114 v31 = (double)(a2->field_8 + 12) - v13; 8100 v23 = (double)(a2->uScreenSpaceX - 12) - v13;
8115 v32 = (double)a2->field_C - v15; 8101 v24 = (double)a2->uScreenSpaceY - v15;
8116 v33 = stru_5C6E00->SinCos(angle); 8102 v33 = stru_5C6E00->SinCos(angle);
8117 v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); 8103 v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
8118 v35 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); 8104 v35 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
8119 v36 = stru_5C6E00->SinCos(angle); 8105 v36 = stru_5C6E00->SinCos(angle);
8120 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 8106 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022
8127 v37 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; 8113 v37 = pBillboardRenderListD3D[v8].pQuards[0].pos.z;
8128 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v32 8114 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v32
8129 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v31 8115 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v31
8130 - 12.0) 8116 - 12.0)
8131 * v11 8117 * v11
8132 + (double)a2->field_C; 8118 + (double)a2->uScreenSpaceY;
8133 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; 8119 pBillboardRenderListD3D[v8].pQuards[2].specular = 0;
8134 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37; 8120 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37;
8135 pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; 8121 pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw;
8136 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; 8122 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse;
8137 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38; 8123 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38;
8138 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; 8124 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0;
8139 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; 8125 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0;
8140 v39 = (double)(a2->field_8 + 12) - v13; 8126 v39 = (double)(a2->uScreenSpaceX + 12) - v13;
8141 v40 = (double)(a2->field_C - 25) - v15; 8127 v40 = (double)(a2->uScreenSpaceY - 25) - v15;
8142 v41 = stru_5C6E00->SinCos(angle); 8128 v41 = stru_5C6E00->SinCos(angle);
8143 v42 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); 8129 v42 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
8144 v43 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); 8130 v43 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
8145 v44 = stru_5C6E00->SinCos(angle); 8131 v44 = stru_5C6E00->SinCos(angle);
8146 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 8132 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022
8152 * v11 + v13; 8138 * v11 + v13;
8153 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 8139 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40
8154 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 8140 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39
8155 - 12.0) 8141 - 12.0)
8156 * v11 8142 * v11
8157 + (double)a2->field_C; 8143 + (double)a2->uScreenSpaceY;
8158 v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; 8144 v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z;
8159 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; 8145 pBillboardRenderListD3D[v8].pQuards[3].specular = 0;
8160 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46; 8146 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46;
8161 pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; 8147 pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw;
8162 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; 8148 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse;
8217 signed int v45; // eax@2 8203 signed int v45; // eax@2
8218 double v46; // st6@2 8204 double v46; // st6@2
8219 8205
8220 if ( this->uNumD3DSceneBegins ) 8206 if ( this->uNumD3DSceneBegins )
8221 { 8207 {
8222 v5 = (double)HIWORD(a2->field_28); 8208 v5 = (double)HIWORD(a2->sZValue);
8223 v6 = v5; 8209 v6 = v5;
8224 v7 = v5; 8210 v7 = v5;
8225 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); 8211 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7));
8226 pBillboardRenderListD3D[v8].bOpaque = 1; 8212 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1;
8227 pBillboardRenderListD3D[v8].field_90 = a2->field_44; 8213 pBillboardRenderListD3D[v8].field_90 = a2->field_44;
8228 pBillboardRenderListD3D[v8].field_94 = a2->field_28; 8214 pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
8229 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; 8215 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID;
8230 v9 = a2->field_8; 8216 v9 = a2->uScreenSpaceX;
8231 v10 = a2->field_C; 8217 v10 = a2->uScreenSpaceY;
8232 v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10); 8218 v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10);
8233 v12 = (double)v9; 8219 v12 = (double)v9;
8234 v13 = v12; 8220 v13 = v12;
8235 v14 = (double)(v10 - 12); 8221 v14 = (double)(v10 - 12);
8236 v15 = v14; 8222 v15 = v14;
8250 * v11 + v13; 8236 * v11 + v13;
8251 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 8237 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17
8252 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 8238 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16
8253 - 12.0) 8239 - 12.0)
8254 * v11 8240 * v11
8255 + (double)a2->field_C; 8241 + (double)a2->uScreenSpaceY;
8256 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; 8242 pBillboardRenderListD3D[v8].pQuards[0].specular = 0;
8257 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; 8243 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse;
8258 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23; 8244 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23;
8259 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); 8245 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist);
8260 pBillboardRenderListD3D[v8].pQuards[0].pos.z = v24; 8246 pBillboardRenderListD3D[v8].pQuards[0].pos.z = v24;
8261 v25 = 1.0 / v6; 8247 v25 = 1.0 / v6;
8262 pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; 8248 pBillboardRenderListD3D[v8].pQuards[0].rhw = v25;
8263 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; 8249 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0;
8264 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; 8250 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0;
8265 v26 = (double)(a2->field_8 - 12) - v13; 8251 v26 = (double)(a2->uScreenSpaceX - 12) - v13;
8266 v27 = (double)a2->field_C - v15; 8252 v27 = (double)a2->uScreenSpaceY - v15;
8267 v28 = stru_5C6E00->SinCos(angle); 8253 v28 = stru_5C6E00->SinCos(angle);
8268 v29 = stru_5C6E00->SinCos(v19); 8254 v29 = stru_5C6E00->SinCos(v19);
8269 v30 = stru_5C6E00->SinCos(v19); 8255 v30 = stru_5C6E00->SinCos(v19);
8270 v31 = stru_5C6E00->SinCos(angle); 8256 v31 = stru_5C6E00->SinCos(angle);
8271 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 8257 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022
8277 * v11 + v13; 8263 * v11 + v13;
8278 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 8264 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27
8279 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 8265 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26
8280 - 12.0) 8266 - 12.0)
8281 * v11 8267 * v11
8282 + (double)a2->field_C; 8268 + (double)a2->uScreenSpaceY;
8283 pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24; 8269 pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24;
8284 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32; 8270 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32;
8285 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; 8271 pBillboardRenderListD3D[v8].pQuards[1].specular = 0;
8286 pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; 8272 pBillboardRenderListD3D[v8].pQuards[1].rhw = v25;
8287 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; 8273 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse;
8288 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; 8274 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0;
8289 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; 8275 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0;
8290 v33 = (double)(a2->field_8 + 12) - v13; 8276 v33 = (double)(a2->uScreenSpaceX + 12) - v13;
8291 v34 = (double)a2->field_C - v15; 8277 v34 = (double)a2->uScreenSpaceY - v15;
8292 v35 = stru_5C6E00->SinCos(angle); 8278 v35 = stru_5C6E00->SinCos(angle);
8293 v36 = stru_5C6E00->SinCos(v19); 8279 v36 = stru_5C6E00->SinCos(v19);
8294 v37 = stru_5C6E00->SinCos(v19); 8280 v37 = stru_5C6E00->SinCos(v19);
8295 v38 = stru_5C6E00->SinCos(angle); 8281 v38 = stru_5C6E00->SinCos(angle);
8296 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 8282 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022
8302 * v11 + v13; 8288 * v11 + v13;
8303 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 8289 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34
8304 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 8290 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33
8305 - 12.0) 8291 - 12.0)
8306 * v11 8292 * v11
8307 + (double)a2->field_C; 8293 + (double)a2->uScreenSpaceY;
8308 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; 8294 pBillboardRenderListD3D[v8].pQuards[2].specular = 0;
8309 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24; 8295 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24;
8310 pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; 8296 pBillboardRenderListD3D[v8].pQuards[2].rhw = v25;
8311 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; 8297 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse;
8312 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39; 8298 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39;
8313 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; 8299 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0;
8314 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; 8300 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0;
8315 v40 = (double)(a2->field_8 + 12) - v13; 8301 v40 = (double)(a2->uScreenSpaceX + 12) - v13;
8316 v41 = (double)(a2->field_C - 25) - v15; 8302 v41 = (double)(a2->uScreenSpaceY - 25) - v15;
8317 v42 = stru_5C6E00->SinCos(angle); 8303 v42 = stru_5C6E00->SinCos(angle);
8318 v43 = stru_5C6E00->SinCos(v19); 8304 v43 = stru_5C6E00->SinCos(v19);
8319 v44 = stru_5C6E00->SinCos(v19); 8305 v44 = stru_5C6E00->SinCos(v19);
8320 v45 = stru_5C6E00->SinCos(angle); 8306 v45 = stru_5C6E00->SinCos(angle);
8321 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 8307 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022
8327 * v11 + v13; 8313 * v11 + v13;
8328 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 8314 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41
8329 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 8315 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40
8330 - 12.0) 8316 - 12.0)
8331 * v11 8317 * v11
8332 + (double)a2->field_C; 8318 + (double)a2->uScreenSpaceY;
8333 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; 8319 pBillboardRenderListD3D[v8].pQuards[3].specular = 0;
8334 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24; 8320 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24;
8335 pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; 8321 pBillboardRenderListD3D[v8].pQuards[3].rhw = v25;
8336 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; 8322 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse;
8337 pBillboardRenderListD3D[v8].pTexture = a3; 8323 pBillboardRenderListD3D[v8].pTexture = a3;
8381 auto a1 = this; 8367 auto a1 = this;
8382 a3 = a1; 8368 a3 = a1;
8383 if ( a1->uNumD3DSceneBegins ) 8369 if ( a1->uNumD3DSceneBegins )
8384 { 8370 {
8385 v5 = a2; 8371 v5 = a2;
8386 v6 = (double)HIWORD(a2->field_28); 8372 v6 = (double)HIWORD(a2->sZValue);
8387 v31 = v6; 8373 v31 = v6;
8388 v7 = v6; 8374 v7 = v6;
8389 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); 8375 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7));
8390 if ( BYTE3(v5->uTintColor) ) 8376 if ( BYTE3(v5->uTintColor) )
8391 pBillboardRenderListD3D[v8].bOpaque = 3; 8377 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3;
8392 else 8378 else
8393 pBillboardRenderListD3D[v8].bOpaque = 0; 8379 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent;
8394 v9 = pSprite; 8380 v9 = pSprite;
8395 pBillboardRenderListD3D[v8].field_90 = v5->field_44; 8381 pBillboardRenderListD3D[v8].field_90 = v5->field_44;
8396 pBillboardRenderListD3D[v8].field_94 = v5->field_28; 8382 pBillboardRenderListD3D[v8].sZValue = v5->sZValue;
8397 pBillboardRenderListD3D[v8].uParentBillboardID = v5->uParentBillboardID; 8383 pBillboardRenderListD3D[v8].uParentBillboardID = v5->uParentBillboardID;
8398 v24 = v5->field_8; 8384 v24 = v5->uScreenSpaceX;
8399 v23 = v5->field_C; 8385 v23 = v5->uScreenSpaceY;
8400 v30 = (double)(v5->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_10); 8386 v30 = (double)(v5->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_10);
8401 v29 = (double)(v5->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_14); 8387 v29 = (double)(v5->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_14);
8402 pSpritea = (double)((v9->uBufferWidth >> 1) - v9->uAreaX); 8388 pSpritea = (double)((v9->uBufferWidth >> 1) - v9->uAreaX);
8403 v26 = (double)(v9->uBufferHeight - v9->uAreaY); 8389 v26 = (double)(v9->uBufferHeight - v9->uAreaY);
8404 if ( v5->uFlags & 4 ) 8390 if ( v5->uFlags & 4 )
8479 } 8465 }
8480 } 8466 }
8481 8467
8482 8468
8483 //----- (004A48E4) -------------------------------------------------------- 8469 //----- (004A48E4) --------------------------------------------------------
8484 int Render::_4A48E4(int a2, int a3, int a4, int a5, int a6) 8470 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6)
8485 { 8471 {
8486 int v6; // ecx@1 8472 int v6; // ecx@1
8487 int v7; // ebx@1 8473 int v7; // ebx@1
8488 int v8; // ecx@1 8474 int v8; // ecx@1
8489 int v9; // edx@1 8475 int v9; // edx@1
8496 int v16; // [sp+18h] [bp-4h]@1 8482 int v16; // [sp+18h] [bp-4h]@1
8497 int v17; // [sp+24h] [bp+8h]@1 8483 int v17; // [sp+24h] [bp+8h]@1
8498 unsigned int v18; // [sp+28h] [bp+Ch]@1 8484 unsigned int v18; // [sp+28h] [bp+Ch]@1
8499 int v19; // [sp+34h] [bp+18h]@1 8485 int v19; // [sp+34h] [bp+18h]@1
8500 8486
8501 v6 = a2; 8487 v6 = screenSpaceX;
8502 v7 = (a6 >> 1) + a3; 8488 v7 = (a6 >> 1) + screenSpaceY;
8503 v17 = 0; 8489 v17 = 0;
8504 v15 = 0; 8490 v15 = 0;
8505 v8 = (a6 >> 1) + v6; 8491 v8 = (a6 >> 1) + v6;
8506 v14 = (a6 >> 1) * (a6 >> 1); 8492 v14 = (a6 >> 1) * (a6 >> 1);
8507 v9 = 2 * (a6 >> 1); 8493 v9 = 2 * (a6 >> 1);
8508 v10 = (a6 >> 1) * ((a6 >> 1) - 1); 8494 v10 = (a6 >> 1) * ((a6 >> 1) - 1);
8509 x = v8 - (a6 >> 1); 8495 x = v8 - (a6 >> 1);
8510 v16 = (a6 >> 1) + a3 - v8; 8496 v16 = (a6 >> 1) + screenSpaceY - v8;
8511 v19 = a6 >> 1; 8497 v19 = a6 >> 1;
8512 v13 = v9; 8498 v13 = v9;
8513 v18 = v8; 8499 v18 = v8;
8514 do 8500 do
8515 { 8501 {
8516 sub_4A46E6(x, v16 + v18, a4, 2 * v19, a5); 8502 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor);
8517 if ( v15 ) 8503 if ( v15 )
8518 sub_4A46E6(x, v17 + v7, a4, 2 * v19, a5); 8504 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor);
8519 v14 -= v15; 8505 v14 -= v15;
8520 if ( v14 <= v10 ) 8506 if ( v14 <= v10 )
8521 { 8507 {
8522 if ( v19 != v17 ) 8508 if ( v19 != v17 )
8523 { 8509 {
8524 sub_4A46E6(v18, v16 + x, a4, 2 * v17, a5); 8510 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor);
8525 sub_4A46E6(v18, v19 + v7, a4, 2 * v17, a5); 8511 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor);
8526 } 8512 }
8527 --v19; 8513 --v19;
8528 v13 -= 2; 8514 v13 -= 2;
8529 ++x; 8515 ++x;
8530 v10 -= v13; 8516 v10 -= v13;
8711 } 8697 }
8712 v5 = Billboard_ProbablyAddToListAndSortByZOrder(v14); 8698 v5 = Billboard_ProbablyAddToListAndSortByZOrder(v14);
8713 v6 = 0; 8699 v6 = 0;
8714 pBillboardRenderListD3D[v5].field_90 = 0; 8700 pBillboardRenderListD3D[v5].field_90 = 0;
8715 pBillboardRenderListD3D[v5].uParentBillboardID = -1; 8701 pBillboardRenderListD3D[v5].uParentBillboardID = -1;
8716 pBillboardRenderListD3D[v5].bOpaque = 2; 8702 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2;
8717 if ( a1->field_10 > 0 ) 8703 if ( a1->field_10 > 0 )
8718 { 8704 {
8719 v7 = (char *)&a1->field_14[62]; 8705 v7 = (char *)&a1->field_14[62];
8720 v8 = (char *)&pBillboardRenderListD3D[v5].pQuards[0].pos.z; 8706 v8 = (char *)&pBillboardRenderListD3D[v5].pQuards[0].pos.z;
8721 do 8707 do
8753 8739
8754 8740
8755 //----- (004A4DE1) -------------------------------------------------------- 8741 //----- (004A4DE1) --------------------------------------------------------
8756 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) 8742 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture)
8757 { 8743 {
8758 //const char *v5; // ebx@1
8759 //Render *v6; // edi@1
8760 //HWLTexture *pHWLTexture; // esi@1
8761 //signed int result; // eax@1
8762 //IDirectDrawSurface **v9; // ebx@9
8763 //IDirectDrawSurface4 *v10; // edi@11
8764 //int v11; // ebx@11
8765 HRESULT v12; // eax@14 8744 HRESULT v12; // eax@14
8766 unsigned __int16 *v13; // ecx@19 8745 unsigned __int16 *v13; // ecx@19
8767 unsigned __int16 *v14; // eax@19 8746 unsigned __int16 *v14; // eax@19
8768 DWORD v15; // edx@20 8747 DWORD v15; // edx@20
8769 HRESULT v16; // eax@23 8748 HRESULT v16; // eax@23
8770 stru350 Dst; // [sp+Ch] [bp-F8h]@12 8749 stru350 Dst; // [sp+Ch] [bp-F8h]@12
8771 //DDSURFACEDESC2 desc; // [sp+6Ch] [bp-98h]@13
8772 //DDSCAPS2 v19; // [sp+E8h] [bp-1Ch]@13
8773 //int v20; // [sp+100h] [bp-4h]@12
8774 8750
8775 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); 8751 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps);
8776 if ( pHWLTexture ) 8752 if ( pHWLTexture )
8777 { 8753 {
8778 bMipMaps = !strncmp(pName, "HDWTR", 5); 8754 bMipMaps = !strncmp(pName, "HDWTR", 5);
11268 } 11244 }
11269 fread(pSpriteOffsets, 4, uNumItems, pFile); 11245 fread(pSpriteOffsets, 4, uNumItems, pFile);
11270 11246
11271 return true; 11247 return true;
11272 } 11248 }
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258 //----- (004A1C1E) --------------------------------------------------------
11259 void DoRenderBillboards_D3D()
11260 {
11261 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u));
11262 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
11263 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
11264 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
11265
11266 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i)
11267 {
11268 auto p = pRenderer->pBillboardRenderListD3D + i;
11269
11270 if (p->uOpacity != RenderBillboardD3D::InvalidOpacity)
11271 SetBillboardBlendOptions(p->uOpacity);
11272
11273 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture));
11274 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
11275 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
11276 p->pQuards,
11277 p->uNumVertices,
11278 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS));
11279 }
11280
11281 if (pRenderer->bFogEnabled)
11282 {
11283 pRenderer->bFogEnabled = false;
11284 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1));
11285 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
11286 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
11287 }
11288 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2));
11289 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
11290 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
11291 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
11292 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
11293 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
11294 }
11295
11296
11297
11298
11299
11300 //----- (004A1DA8) --------------------------------------------------------
11301 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1)
11302 {
11303 switch (a1)
11304 {
11305 case RenderBillboardD3D::Transparent:
11306 {
11307 if (pRenderer->bFogEnabled)
11308 {
11309 pRenderer->bFogEnabled = false;
11310 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
11311 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
11312 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
11313 }
11314
11315 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5));
11316 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u));
11317 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1));
11318 }
11319 break;
11320
11321 case RenderBillboardD3D::Opaque_1:
11322 case RenderBillboardD3D::Opaque_2:
11323 case RenderBillboardD3D::Opaque_3:
11324 {
11325 if (pRenderer->bUsingSpecular)
11326 {
11327 if (!pRenderer->bFogEnabled)
11328 {
11329 pRenderer->bFogEnabled = true;
11330 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
11331 }
11332 }
11333
11334 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
11335 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
11336 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
11337 }
11338 break;
11339
11340 default:
11341 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1);
11342 break;
11343 }
11344 }
11345