diff Render.cpp @ 125:b90504bbb93b

Merge
author Nomad
date Fri, 16 Nov 2012 13:58:59 +0200
parents 05b2d9653abc
children 5eb242640b6f 1d44b914b7bd
line wrap: on
line diff
--- a/Render.cpp	Fri Nov 16 13:56:53 2012 +0200
+++ b/Render.cpp	Fri Nov 16 13:58:59 2012 +0200
@@ -906,9 +906,9 @@
 //----- (0047F5C6) --------------------------------------------------------
 float Render::DrawBezierTerrain()
 {
-  __debugbreak();
-  return 0;
-  /*
+//  __debugbreak();
+ // return 0;
+  
   unsigned int v0; // ebx@1
   unsigned int v1; // edi@1
   unsigned int v2; // eax@1
@@ -988,6 +988,7 @@
   IndoorCameraD3D *v76; // ecx@184
   int v77; // ecx@184
   int v79; // ebx@185
+  int v127; // esi@185
   int v86; // edi@196
   int v87; // eax@196
   int v88; // ecx@196
@@ -1585,68 +1586,41 @@
       v77 = v73 - 2;
       if ( v73 - 2 < v75 )
       {
-        _ESI = 0;
+        v127 = 0;
         v79 = (v73 - 66) << 9;
         v116 = v77;
         v105 = v79;
         v111 = v75 - v77;
         do
         {
-          __asm { fild    [ebp+var_58] }
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fst     [ebp+var_54]
-            fstp    dword ptr [esi+eax]
-          }
-          v105 = (64 - terrain_76D9C8[v70]) << 9;
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+4]
-          }
-          v105 = pOutdoor->GetHeightOnTerrain(v116, terrain_76D9C8[v70]);
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+8]
-            fld     [ebp+var_54]
-          }
-          _EAX = ptr_801A04;
-          __asm { fstp    dword ptr [esi+eax] }
-          v105 = (63 - terrain_76D9C8[v70]) << 9;
-          _EAX = ptr_801A04;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+4]
-          }
-          v105 = pOutdoor->GetHeightOnTerrain(v116, terrain_76D9C8[v70] + 1);
-          _EAX = ptr_801A04;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+8]
-          }
+		  *(float *)&v106 = (double)v105;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.x + v127) = *(float *)&v106;
+          v105 = (64 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v127) = (double)v105;
+          v105 = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70));
+          *(float *)((char *)&ptr_801A08->vWorldPosition.z + v127) = (double)v105;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.x + v127) = *(float *)&v106;
+          v105 = (63 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v127) = (double)v105;
+          v105 = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70) + 1);
+          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v127) = (double)v105;
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
-            a1->ViewTransform(&ptr_801A08[_ESI], 1u);
-            a1->ViewTransform(&ptr_801A04[_ESI], 1u);
-            a1->Project(&ptr_801A08[_ESI], 1u, 0);
-            a1->Project(&ptr_801A04[_ESI], 1u, 0);
+            a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v127, 1);
+            a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v127, 1);
+            a1->Project((RenderVertexSoft *)(char *)ptr_801A08 + v127, 1, 0);
+            a1->Project((RenderVertexSoft *)(char *)ptr_801A04 + v127, 1, 0);
           }
           v79 += 512;
-          ++_ESI;
+          v127 += 48;
           ++v116;
           v105 = v79;
-        }
+		}
         while ( v116 < v107 );
       }
-      v103 = abs(pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v70]);
-      v104 = abs(pIndoorCamera->uMapGridCellX - terrain_76DBC8[v70]);
-      if ( pRenderer->pRenderD3D )
+	  v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v70]);
+      v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v70]);
+	  if ( pRenderer->pRenderD3D )
         Render::DrawTerrainD3D(v111, 0, (int)&v102);
       else
         Render::DrawTerrainSW(v111, 0, (int)&v102);
@@ -1675,7 +1649,7 @@
       v107 = v90 + 2;
       if ( v89 - 2 < v90 + 2 )
       {
-        _ESI = 0;
+        v86 = 0;
         v116 = v89 - 2;
         v92 = (66 - v89) << 9;
         v105 = (66 - v89) << 9;
@@ -1683,59 +1657,35 @@
         do
         {
           v93 = v116;
-          v106 = (terrain_76DBC8[v86] - 64) << 9;
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fild    [ebp+var_54]
-            fstp    dword ptr [esi+eax]
-            fild    [ebp+var_58]
-          }
-          _EAX = ptr_801A08;
-          __asm
-          {
-            fst     [ebp+var_58]
-            fstp    dword ptr [esi+eax+4]
-          }
-          v106 = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v93);
-          _EAX = ptr_801A08;
-          __asm { fild    [ebp+var_54] }
+          v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.x + v86) = (double)v106;
+          *(float *)&v105 = (double)v105;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&v105;
+          v106 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86), v93);
           v97 = v116;
-          __asm { fstp    dword ptr [esi+eax+8] }
-          v106 = (terrain_76DBC8[v86] - 63) << 9;
-          _EAX = ptr_801A04;
-          __asm
-          {
-            fild    [ebp+var_54]
-            fstp    dword ptr [esi+eax]
-            fld     [ebp+var_58]
-          }
-          _EAX = ptr_801A04;
-          __asm { fstp    dword ptr [esi+eax+4] }
-          v105 = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v97);
-          _EAX = ptr_801A04;
-          __asm
-          {
-            fild    [ebp+var_58]
-            fstp    dword ptr [esi+eax+8]
-          }
+          *(float *)((char *)&ptr_801A08->vWorldPosition.z + v86) = (double)v106;
+          v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.x + v86) = (double)v106;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&v105;
+          v105 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
+          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)v105;
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
-            a1->ViewTransform(&ptr_801A08[_ESI], 1u);
-            a1->ViewTransform(&ptr_801A04[_ESI], 1u);
-            a1->Project(&ptr_801A08[_ESI], 1u, 0);
-            a1->Project(&ptr_801A04[_ESI], 1u, 0);
+           a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1);
+           a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1);
+           a1->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0);
+           a1->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0);
           }
           v92 -= 512;
-          ++_ESI;
+          v86 += 48;
           ++v116;
           v105 = v92;
-        }
+		}
         while ( v116 < v107 );
       }
-      v103 = abs(pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]);
-      v104 = abs(pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]);
-      if ( pRenderer->pRenderD3D )
+      v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]);
+	  v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]);
+	  if ( pRenderer->pRenderD3D )
         Render::DrawTerrainD3D(v111, 1, (int)&v102);
       else
         Render::DrawTerrainSW(v111, 1, (int)&v102);
@@ -1743,7 +1693,7 @@
   }
   result = v126;
   pOutdoorCamera->field_40 = v126;
-  return result;*/
+  return result;
 }
 // 47FFC4: inconsistent fpu stack
 // 4D864C: using guessed type char byte_4D864C;
@@ -1854,7 +1804,7 @@
   int sY; // [sp+B0h] [bp-20h]@6
   RenderVertexSoft *a2; // [sp+B4h] [bp-1Ch]@3
   unsigned int a5; // [sp+B8h] [bp-18h]@21
-  RenderVertexSoft *_ECX; // [sp+BCh] [bp-14h]@6
+  RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6
   Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17
   RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6
   RenderVertexSoft *a8; // [sp+C8h] [bp-8h]@6
@@ -1889,32 +1839,29 @@
       v6 = abs(v83);
       --X;
       v93 = &stru_76E5C8[(v5 << 7) + v6];
-      if ( !v93->field_0
-        || ((v7 = v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = &pVerticesSR_801A10[v7],
-                                                                      v10 = &pVerticesSR_806210[v7 + 1]) : (v9 = &pVerticesSR_806210[v7 + 1], v10 = &pVerticesSR_801A10[v7]),
+      if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7),
+                                                                      v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)),
             ((a8 = v9,
-              pVertices = &pVerticesSR_801A10[v7 + 1],
+              pVertices = &pVerticesSR_801A10[1] + v7,
               v11 = v8->vWorldPosition.x,
-              _ECX = v10,
-              v12 = v11 + 6.7553994e15,
+              v101 = v10,
+              v12 = v11 + 6.755399441055744e15,
               sX = LODWORD(v12),
-              v13 = v8->vWorldPosition.y + 6.7553994e15,
+              v13 = v8->vWorldPosition.y + 6.755399441055744e15,
               sY = LODWORD(v13),
               thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5,
-              v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(thisd + 6.7553994e15)),
+              v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(thisd + 6.755399441055744e15)),
               v15 = v9->vWorldPosition.y + v8->vWorldPosition.y,
               v89 = v14,
               thise = v15 * 0.5,
-              _this = (LightmapBuilder *)WorldPosToGridCellZ(COERCE_UNSIGNED_INT64(thise + 6.7553994e15)),
+              _this = (LightmapBuilder *)WorldPosToGridCellZ(COERCE_UNSIGNED_INT64(thise + 6.755399441055744e15)),
               WorldPosToGridCellX(sX),
               WorldPosToGridCellZ(sY),
               !byte_4D864C)
           || !(pGame->uFlags & 0x80))
-         && !sub_481EFA(v8, v9, _ECX, pVertices, 1)) )
+         && !sub_481EFA(v8, v9, v101, pVertices, 1)) )
         goto LABEL_162;
-      if ( v8->vWorldPosition.z != v9->vWorldPosition.z
-        || v9->vWorldPosition.z != pVertices->vWorldPosition.z
-        || pVertices->vWorldPosition.z != _ECX->vWorldPosition.z )
+      if ( v8->vWorldPosition.z != v9->vWorldPosition.z || v9->vWorldPosition.z != pVertices->vWorldPosition.z || pVertices->vWorldPosition.z != v101->vWorldPosition.z )
         break;
       v16 = &array_77EC08[pOutdoorCamera->numStru148s];
       v17 = pOutdoor->GetTileTexture(sX, sY);
@@ -1940,13 +1887,13 @@
         v99 = v23;
         thisf = 20.0 - (-v24 - v91 * v23->y - v90 * v23->x) * 20.0;
         v25 = thisf + 6.7553994e15;
-        v27 = __OFSUB__(pOutdoorCamera->numStru148s, 1999);
+        v27 = pOutdoorCamera->numStru148s > 1999;
         v26 = pOutdoorCamera->numStru148s - 1999 < 0;
         v16->field_58 = LOBYTE(v25);
         if ( !(v26 ^ v27) )
           return;
         ++pOutdoorCamera->numStru148s;
-        if ( !sub_481FC9(v8, a8, _ECX, v16) )
+        if ( !sub_481FC9(v8, a8, v101, v16) )
           goto LABEL_126;
         v28 = 1.0 / (a2->vWorldViewPosition.x + 0.0000001);
         memcpy(array_50AC10, a2, 0x30u);
@@ -1963,8 +1910,8 @@
         array_50AC10[2].flt_20 = 1.0 / v30;
         array_50AC10[2].u = 1.0;
         array_50AC10[2].v = 1.0;
-        v31 = _ECX->vWorldViewPosition.x + 0.0000001;
-        memcpy(&array_50AC10[3], _ECX, sizeof(array_50AC10[3]));
+        v31 = v101->vWorldViewPosition.x + 0.0000001;
+        memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3]));
         array_50AC10[3].flt_20 = 1.0 / v31;
         array_50AC10[3].u = 1.0;
         array_50AC10[3].v = 0.0;
@@ -1992,12 +1939,12 @@
         }
         this_3 = a2->vWorldViewPosition.x < 8.0
               || a8->vWorldViewPosition.x < 8.0
-              || _ECX->vWorldViewPosition.x < 8.0
+              || v101->vWorldViewPosition.x < 8.0
               || pVertices->vWorldViewPosition.x < 8.0;
         v32 = (double)pOutdoorCamera->shading_dist_mist;
         v108 = v32 < a2->vWorldViewPosition.x
             || v32 < a8->vWorldViewPosition.x
-            || v32 < _ECX->vWorldViewPosition.x
+            || v32 < v101->vWorldViewPosition.x
             || v32 < pVertices->vWorldViewPosition.x;
         LOBYTE(v33) = 0;
         pGame->pLightmapBuilder->std__vector_000004_size = 0;
@@ -2238,7 +2185,7 @@
     if ( pOutdoorCamera->numStru148s >= 1999 )
       return;
     ++pOutdoorCamera->numStru148s;
-    if ( !sub_481FC9(_ECX, a2, pVertices, v59) )
+    if ( !sub_481FC9(v101, a2, pVertices, v59) )
     {
 LABEL_126:
       --pOutdoorCamera->numStru148s;
@@ -2254,8 +2201,8 @@
     array_50AC10[1].flt_20 = 1.0 / v67;
     array_50AC10[1].u = 1.0;
     array_50AC10[1].v = 1.0;
-    v68 = _ECX->vWorldViewPosition.x + 0.0000001;
-    memcpy(&array_50AC10[2], _ECX, sizeof(array_50AC10[2]));
+    v68 = v101->vWorldViewPosition.x + 0.0000001;
+    memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2]));
     array_50AC10[2].flt_20 = 1.0 / v68;
     array_50AC10[2].u = 1.0;
     array_50AC10[2].v = 0.0;
@@ -2283,9 +2230,9 @@
     }
     this_3b = a2->vWorldViewPosition.x < 8.0
            || pVertices->vWorldViewPosition.x < 8.0
-           || _ECX->vWorldViewPosition.x < 8.0;
+           || v101->vWorldViewPosition.x < 8.0;
     v69 = (double)pOutdoorCamera->shading_dist_mist;
-    v108 = v69 < a2->vWorldViewPosition.x || v69 < pVertices->vWorldViewPosition.x || v69 < _ECX->vWorldViewPosition.x;
+    v108 = v69 < a2->vWorldViewPosition.x || v69 < pVertices->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x;
     LOBYTE(v70) = 0;
     v96->std__vector_000004_size = 0;
     if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
@@ -7140,7 +7087,7 @@
 //----- (004A2031) --------------------------------------------------------
 unsigned int Render::GetActorTintColor(float a2, int a3, int a4, int a5, RenderBillboard *a6)
 {
-  return GetActorTintColor(a3, a4, a2, a5, a6);
+  return ::GetActorTintColor(a3, a4, a2, a5, a6);
 }