comparison Render.cpp @ 1644:dbd6f940f26c

Fixed Celestia sky a bit.
author Nomad
date Tue, 17 Sep 2013 21:41:39 +0200
parents 8971dc85b8fb
children a7eebb6ee7a2
comparison
equal deleted inserted replaced
1642:8971dc85b8fb 1644:dbd6f940f26c
5006 5006
5007 //----- (00479A53) -------------------------------------------------------- 5007 //----- (00479A53) --------------------------------------------------------
5008 void Render::DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID) 5008 void Render::DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID)
5009 { 5009 {
5010 BLVFace *pFace; // esi@1 5010 BLVFace *pFace; // esi@1
5011 unsigned int v3; // edi@1 5011 //unsigned int v3; // edi@1
5012 PolygonType v4; // al@1 5012 //PolygonType v4; // al@1
5013 double v5; // st7@3 5013 double v5; // st7@3
5014 signed __int64 v6; // qax@3 5014 signed __int64 v6; // qax@3
5015 PolygonType v7; // cl@3 5015 //PolygonType v7; // cl@3
5016 int v8; // esi@7 5016 //int v8; // esi@7
5017 int v9; // eax@7 5017 //int v9; // eax@7
5018 unsigned int v10; // eax@7 5018 //unsigned int v10; // eax@7
5019 double v11; // st6@7 5019 //double v11; // st6@7
5020 int v12; // edx@7 5020 int v12; // edx@7
5021 int v13; // eax@7 5021 int v13; // eax@7
5022 char *v14; // esi@8 5022 //char *v14; // esi@8
5023 void *v15; // ecx@9 5023 void *v15; // ecx@9
5024 int v16; // eax@9 5024 //int v16; // eax@9
5025 int v17; // edi@9 5025 int v17; // edi@9
5026 double v18; // st7@9 5026 double v18; // st7@9
5027 signed int v19; // ebx@9 5027 signed int v19; // ebx@9
5028 void *v20; // ecx@9 5028 void *v20; // ecx@9
5029 int v21; // ebx@11 5029 int v21; // ebx@11
5057 RenderVertexSoft *v49; // ebx@41 5057 RenderVertexSoft *v49; // ebx@41
5058 void *v50; // edi@43 5058 void *v50; // edi@43
5059 double v51; // st7@46 5059 double v51; // st7@46
5060 RenderVertexSoft *v52; // edx@46 5060 RenderVertexSoft *v52; // edx@46
5061 void *v53; // edi@48 5061 void *v53; // edi@48
5062 char *v54; // ebx@52 5062 //char *v54; // ebx@52
5063 unsigned int v55; // eax@53 5063 //unsigned int v55; // eax@53
5064 unsigned int v56; // eax@55 5064 //unsigned int v56; // eax@55
5065 int v57; // ST10_4@55 5065 //int v57; // ST10_4@55
5066 Texture *v58; // eax@55 5066 //Texture *v58; // eax@55
5067 signed int v59; // [sp-4h] [bp-178h]@17 5067 signed int v59; // [sp-4h] [bp-178h]@17
5068 struct Polygon *v60; // [sp+0h] [bp-174h]@17 5068 struct Polygon *v60; // [sp+0h] [bp-174h]@17
5069 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 5069 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17
5070 struct Polygon v62; // [sp+14h] [bp-160h]@6 5070 struct Polygon v62; // [sp+14h] [bp-160h]@6
5071 unsigned int v63; // [sp+120h] [bp-54h]@7 5071 unsigned int v63; // [sp+120h] [bp-54h]@7
5072 double v64; // [sp+124h] [bp-50h]@7 5072 //double v64; // [sp+124h] [bp-50h]@7
5073 unsigned int v65; // [sp+128h] [bp-4Ch]@1 5073 unsigned int v65; // [sp+128h] [bp-4Ch]@1
5074 unsigned int v66; // [sp+12Ch] [bp-48h]@7 5074 unsigned int v66; // [sp+12Ch] [bp-48h]@7
5075 float v67; // [sp+130h] [bp-44h]@7 5075 float v67; // [sp+130h] [bp-44h]@7
5076 __int64 v68; // [sp+134h] [bp-40h]@3 5076 //__int64 v68; // [sp+134h] [bp-40h]@3
5077 __int64 v69; // [sp+13Ch] [bp-38h]@3 5077 __int64 v69; // [sp+13Ch] [bp-38h]@3
5078 int v70; // [sp+144h] [bp-30h]@3 5078 int v70; // [sp+144h] [bp-30h]@3
5079 int X; // [sp+148h] [bp-2Ch]@9 5079 int X; // [sp+148h] [bp-2Ch]@9
5080 int v72; // [sp+14Ch] [bp-28h]@7 5080 int v72; // [sp+14Ch] [bp-28h]@7
5081 float v73; // [sp+150h] [bp-24h]@16 5081 float v73; // [sp+150h] [bp-24h]@16
5086 int v78; // [sp+164h] [bp-10h]@7 5086 int v78; // [sp+164h] [bp-10h]@7
5087 void *v79; // [sp+168h] [bp-Ch]@9 5087 void *v79; // [sp+168h] [bp-Ch]@9
5088 float v80; // [sp+16Ch] [bp-8h]@3 5088 float v80; // [sp+16Ch] [bp-8h]@3
5089 const void *v81; // [sp+170h] [bp-4h]@7 5089 const void *v81; // [sp+170h] [bp-4h]@7
5090 5090
5091 __debugbreak();
5092
5093 pFace = &pIndoor->pFaces[uFaceID]; 5091 pFace = &pIndoor->pFaces[uFaceID];
5094 v65 = uFaceID; 5092 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor)
5095 v3 = uNumVertices; 5093 {
5096 v4 = pFace->uPolygonType; 5094 int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x;
5097 if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor ) 5095 int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y;
5098 { 5096 for (uint i = 0; i < uNumVertices; ++i)
5099 if ( (signed int)uNumVertices > 0 ) 5097 {
5100 { 5098 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f;
5101 v54 = (char *)&array_507D30[0].u; 5099 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f;
5102 LODWORD(v80) = uNumVertices; 5100 }
5103 do 5101 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0);
5104 {
5105 v69 = (GetTickCount() >> 5) - pGame->pIndoorCameraD3D->vPartyPos.x;
5106 *(float *)v54 = (double)v69 + *(float *)v54;
5107 *(float *)v54 = *(float *)v54 * 0.25;
5108 v55 = GetTickCount();
5109 v54 += 48;
5110 v44 = LODWORD(v80)-- == 1;
5111 v68 = pGame->pIndoorCameraD3D->vPartyPos.y + (v55 >> 5);
5112 *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25;
5113 }
5114 while ( !v44 );
5115 uFaceID = v65;
5116 }
5117 v56 = 8 * uFaceID;
5118 LOBYTE(v56) = PID(OBJECT_BModel,uFaceID);
5119 v57 = v56;
5120 v58 = pFace->GetTexture();
5121 pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0);
5122 return; 5102 return;
5123 } 5103 }
5124 HIDWORD(v69) = pGame->pIndoorCameraD3D->sRotationX; 5104
5125 HIDWORD(v68) = pGame->pIndoorCameraD3D->vPartyPos.z;
5126 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY; 5105 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY;
5127 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z) 5106 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)
5128 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) 5107 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0)
5129 * 65536.0) 5108 * 65536.0)
5130 + *(float *)&v74); 5109 + *(float *)&v74);
5131 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064; 5110 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;
5132 *(float *)&v75 = v5; 5111 *(float *)&v75 = v5;
5133 v80 = cos(v5) * 16192.0;
5134 v6 = (signed __int64)(*(float *)&v74 5112 v6 = (signed __int64)(*(float *)&v74
5135 - (double)pBLVRenderParams->fov_rad_fixpoint 5113 - (double)pBLVRenderParams->fov_rad_fixpoint
5136 / ((v80 + 0.0000001) 5114 / ((cos(v5) * 16192.0 + 0.0000001)
5137 * 65535.0) 5115 * 65535.0)
5138 * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68))); 5116 * (sin(*(float *)&v75) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
5139 v7 = pFace->uPolygonType; 5117
5140 if ( v7 == 4 || v7 == 3 ) 5118
5141 v70 = v6;
5142 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); 5119 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0);
5143 v62.Create_48607B(&stru_8019C8); 5120 v62.Create_48607B(&stru_8019C8);
5144 v62.uTileBitmapID = pFace->uBitmapID; 5121 v62.uTileBitmapID = pFace->uBitmapID;
5145 v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0); 5122
5123 v62.pTexture = pBitmaps_LOD->GetTexture(v62.uTileBitmapID);
5146 if ( !v62.pTexture ) 5124 if ( !v62.pTexture )
5147 return; 5125 return;
5148 v8 = pGame->pIndoorCameraD3D->sRotationX; 5126
5149 v62.dimming_level = 0; 5127 v62.dimming_level = 0;
5150 v62.uNumVertices = v3; 5128 v62.uNumVertices = uNumVertices;
5151 v9 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
5152 v62.v_18.y = 0; 5129 v62.v_18.y = 0;
5153 v62.v_18.x = -v9; 5130 v62.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
5154 v62.v_18.z = -stru_5C6E00->Cos(v8 + 16); 5131 v62.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
5155 v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX; 5132 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices]));
5156 memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3])); 5133 v62.field_24 = 0x2000000;
5157 LODWORD(v80) = v10; 5134
5158 v62.field_24 = 33554432; 5135 extern float _calc_fov(int viewport_width, int angle_degree);
5159 v64 = (double)(signed int)v10 * 0.5; 5136 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5;
5160 v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); 5137 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
5161 LODWORD(v80) = v62.pTexture->uTextureWidth; 5138 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74);
5162 v11 = 1.0 / (double)SLODWORD(v80);
5163 LODWORD(v80) = v62.pTexture->uTextureHeight;
5164 v12 = v62.pTexture->uWidthMinus1; 5139 v12 = v62.pTexture->uWidthMinus1;
5165 v13 = v62.pTexture->uHeightMinus1; 5140 v13 = v62.pTexture->uHeightMinus1;
5166 v67 = v11; 5141 v67 = 1.0 / (double)v62.pTexture->uTextureWidth;
5167 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; 5142 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
5168 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; 5143 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
5169 v78 = 0; 5144 v78 = 0;
5170 v81 = 0; 5145 v81 = 0;
5171 *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80); 5146 float v68 = 1.0 / (double)v62.pTexture->uTextureHeight;
5172 if ( (signed int)v62.uNumVertices <= 0 ) 5147 if ( (signed int)v62.uNumVertices <= 0 )
5173 { 5148 {
5174 LABEL_17: 5149 LABEL_17:
5175 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; 5150 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID];
5176 v27 = pRenderer; 5151 v27 = pRenderer;
5177 v60 = &v62; 5152 v60 = &v62;
5178 v59 = v62.uNumVertices; 5153 v59 = v62.uNumVertices;
5179 goto LABEL_18; 5154 goto LABEL_18;
5180 } 5155 }
5181 v14 = (char *)&array_507D30[0].vWorldViewProjY; 5156
5157 //v14 = (char *)&array_507D30[0].vWorldViewProjY;
5158 int _507D30_idx = 0;
5182 while ( 2 ) 5159 while ( 2 )
5183 { 5160 {
5184 v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14)); 5161 v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY));
5185 LODWORD(v80) = v62.ptr_38->field_14; 5162 v77 = (unsigned __int64)(v62.ptr_38->field_14 * (signed __int64)(signed int)v15) >> 16;
5186 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; 5163 v74 = v77 + v62.ptr_38->field_C;
5187 v16 = v77 + v62.ptr_38->field_C;
5188 v77 = (int)v15; 5164 v77 = (int)v15;
5189 v74 = v16; 5165 v77 = (unsigned __int64)(v62.ptr_38->field_20 * (signed __int64)(signed int)v15) >> 16;
5190 LODWORD(v80) = v62.ptr_38->field_20;
5191 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
5192 v79 = v15; 5166 v79 = v15;
5193 v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18); 5167 v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18);
5194 LODWORD(v80) = v62.v_18.z;
5195 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16); 5168 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16);
5196 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1)); 5169 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX);
5197 v18 = *(float *)v14 - 1.0; 5170 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0;
5198 v19 = -v62.field_24; 5171 v19 = -v62.field_24;
5199 v77 = -v62.field_24; 5172 v77 = -v62.field_24;
5200 X = (int)((char *)v79 + v62.v_18.x); 5173 X = (int)((char *)v79 + v62.v_18.x);
5201 LODWORD(v76) = (signed __int64)v18; 5174 LODWORD(v76) = (signed __int64)v18;
5202 v20 = (void *)(v72 * (v70 - LODWORD(v76))); 5175 v20 = (void *)(v72 * (v70 - LODWORD(v76)));
5211 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) 5184 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
5212 break; 5185 break;
5213 v19 = v77; 5186 v19 = v77;
5214 v20 = v79; 5187 v20 = v79;
5215 LABEL_14: 5188 LABEL_14:
5216 LODWORD(v80) = v62.v_18.z;
5217 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16); 5189 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16);
5218 v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16; 5190 v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16;
5219 --LODWORD(v76); 5191 --LODWORD(v76);
5220 v20 = (char *)v20 + v72; 5192 v20 = (char *)v20 + v72;
5221 X = v22 + v62.v_18.x; 5193 X = v22 + v62.v_18.x;
5225 { 5197 {
5226 LODWORD(v23) = v77 << 16; 5198 LODWORD(v23) = v77 << 16;
5227 HIDWORD(v23) = v77 >> 16; 5199 HIDWORD(v23) = v77 >> 16;
5228 v79 = (void *)(v23 / X); 5200 v79 = (void *)(v23 / X);
5229 v77 = v17; 5201 v77 = v17;
5230 LODWORD(v80) = v62.ptr_38->field_10;
5231 v77 = v17; 5202 v77 = v17;
5232 LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16); 5203 LODWORD(v76) = v74 + ((unsigned __int64)(v62.ptr_38->field_10 * (signed __int64)v17) >> 16);
5233 LODWORD(v80) = v62.ptr_38->field_1C; 5204 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v62.ptr_38->field_1C * (signed __int64)v17) >> 16));
5234 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16));
5235 v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16; 5205 v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16;
5236 LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16; 5206 LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16;
5237 v14 += 48; 5207 //v14 += 48;
5238 LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4); 5208 LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4);
5239 v81 = (char *)v81 + 1; 5209 v81 = (char *)v81 + 1;
5240 v24 = (double)SLODWORD(v80) * 0.000015259022; 5210 v24 = (double)SLODWORD(v80) * 0.000015259022;
5241 LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4); 5211 LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4);
5242 v26 = __OFSUB__((int)v81, v62.uNumVertices); 5212 v26 = __OFSUB__((int)v81, v62.uNumVertices);
5243 v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0; 5213 v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0;
5244 *((float *)v14 - 10) = v24 * v67; 5214 array_507D30[_507D30_idx].u = v24 * v67;
5245 *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1); 5215 array_507D30[_507D30_idx].v = (double)SLODWORD(v80) * 0.000015259022 * v68;
5246 *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79; 5216 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79;
5217 _507D30_idx++;
5247 if ( !(v25 ^ v26) ) 5218 if ( !(v25 ^ v26) )
5248 goto LABEL_17; 5219 goto LABEL_17;
5249 continue; 5220 continue;
5250 } 5221 }
5251 break; 5222 break;
5367 v78 = v66 + ((signed int)v74 >> 4); 5338 v78 = v66 + ((signed int)v74 >> 4);
5368 v44 = HIDWORD(v69)-- == 1; 5339 v44 = HIDWORD(v69)-- == 1;
5369 v45 = (double)v78 * 0.000015259022; 5340 v45 = (double)v78 * 0.000015259022;
5370 v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4); 5341 v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4);
5371 *((float *)v34 - 10) = v45 * v67; 5342 *((float *)v34 - 10) = v45 * v67;
5372 *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1); 5343 *((float *)v34 - 9) = (double)v78 * 0.000015259022 * v68;
5373 v46 = (double)(signed int)v79; 5344 v46 = (double)(signed int)v79;
5374 *((float *)v34 - 16) = 0.000015258789 * v46; 5345 *((float *)v34 - 16) = 0.000015258789 * v46;
5375 *((float *)v34 - 11) = 65536.0 / v46; 5346 *((float *)v34 - 11) = 65536.0 / v46;
5376 } 5347 }
5377 while ( !v44 ); 5348 while ( !v44 );