diff mm7_3.cpp @ 67:3b4f8bd48e3b

25.01.13 (I did sky)
author Ritor1
date Fri, 25 Jan 2013 16:48:21 +0600
parents 31feb3432bbd
children 6ef241d53522
line wrap: on
line diff
--- a/mm7_3.cpp	Wed Jan 23 17:29:00 2013 +0600
+++ b/mm7_3.cpp	Fri Jan 25 16:48:21 2013 +0600
@@ -7690,12 +7690,12 @@
 {
   int v0; // esi@2
   int v1; // eax@2
-  double v2; // st7@2
-  double v3; // st6@2
-  double v4; // st5@2
-  double v5; // st4@2
-  double v6; // st7@2
-  char *v7; // esi@3
+  //double v2; // st7@2
+  //double v3; // st6@2
+  //double v4; // st5@2
+  //double v5; // st4@2
+  //double v6; // st7@2
+  //char *v7; // esi@3
   int v8; // eax@4
   int v9; // eax@4
   int v10; // ebx@4
@@ -7707,91 +7707,75 @@
   int v16; // eax@12
   signed __int64 v17; // qtt@13
   signed int v18; // ecx@13
-  Texture *v19; // eax@15
-  double v20; // st6@15
-  double v21; // st7@15
-  double v22; // st6@15
-  unsigned __int8 v23; // sf@15
-  unsigned __int8 v24; // of@15
+  //Texture *v19; // eax@15
+  //double v20; // st6@15
+  //double v21; // st7@15
+  //double v22; // st6@15
+  //unsigned __int8 v23; // sf@15
+  //unsigned __int8 v24; // of@15
   stru148 _this; // [sp+14h] [bp-150h]@1
-  double v26; // [sp+120h] [bp-44h]@4
-  float v27; // [sp+128h] [bp-3Ch]@4
+  //double v26; // [sp+120h] [bp-44h]@4
+  //float v27; // [sp+128h] [bp-3Ch]@4
   float v28; // [sp+12Ch] [bp-38h]@2
   int v29; // [sp+130h] [bp-34h]@4
   int v30; // [sp+134h] [bp-30h]@1
-  int v31; // [sp+138h] [bp-2Ch]@2
+  //int v31; // [sp+138h] [bp-2Ch]@2
   int v32; // [sp+13Ch] [bp-28h]@6
   int v33; // [sp+140h] [bp-24h]@2
-  float v34; // [sp+144h] [bp-20h]@1
+  int v34; // [sp+144h] [bp-20h]@1
   int v35; // [sp+148h] [bp-1Ch]@4
-  double v36; // [sp+14Ch] [bp-18h]@2
+  int v36; // [sp+14Ch] [bp-18h]@2
   int v37; // [sp+154h] [bp-10h]@8
   int v38; // [sp+158h] [bp-Ch]@1
   int v39; // [sp+15Ch] [bp-8h]@4
   int v40; // [sp+160h] [bp-4h]@7
 
-  v30 = (signed __int64)((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z)
-                       / ((double)pOutdoorCamera->int_fov_rad + 8192.0)
-                       + (double)pViewport->uScreenCenterY);
-  v34 = cos((double)pIndoorCamera->sRotationX * 0.0030664064) * (double)pOutdoorCamera->shading_dist_mist;
-  v38 = (signed __int64)((double)pViewport->uScreenCenterY
-                       - (double)pOutdoorCamera->int_fov_rad
-                       / (v34 + 0.0000001)
-                       * (sin((double)pIndoorCamera->sRotationX * 0.0030664064)
-                        * (double)-pOutdoorCamera->shading_dist_mist
-                        - (double)pIndoorCamera->pos.z));
+  v30 = ((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z)
+        / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY);
+  v38 = pViewport->uScreenCenterY - 
+        pOutdoorCamera->int_fov_rad / (pOutdoorCamera->shading_dist_mist * cos(pIndoorCamera->sRotationX * 0.003066406352445483) + 0.0000001000000011686097) *
+        (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z);
   _this._48607B(&stru_8019C8);
   _this.ptr_38->_48694B();
-  _this.uTileBitmapID = LOWORD(pOutdoor->uSky_TextureID);
+  _this.uTileBitmapID = pOutdoor->uSky_TextureID;
   _this.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0);
-  if ( _this.pTexture )
-  {
-    v0 = pIndoorCamera->sRotationX;
-    _this.field_58 = 0;
-    _this.uNumVertices = 4;
-    _this.v_18.x = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi + 16);
-    _this.v_18.y = 0;
-    v1 = stru_5C6E00->SinCos(v0 + 16);
-    v2 = (double)(signed int)pViewport->uViewportX;
-    _this.v_18.z = -v1;
-    array_50AC10[0].vWorldViewProjX = v2;
-    v3 = (double)(signed int)pViewport->uViewportY;
-    array_50AC10[0].vWorldViewProjY = v3;
-    array_50AC10[1].vWorldViewProjX = v2;
-    v4 = (double)v38;
-    _this.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
-    _this.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
-    v28 = v4;
-    array_50AC10[1].vWorldViewProjY = v4;
-    v5 = (double)(signed int)pViewport->uViewportZ;
-    array_50AC10[2].vWorldViewProjX = v5;
-    v38 = pViewport->uViewportZ - pViewport->uViewportX;
-    _this.field_24 = 0x2000000u;
-    array_50AC10[2].vWorldViewProjY = v4;
-    array_50AC10[3].vWorldViewProjX = v5;
-    array_50AC10[3].vWorldViewProjY = v3;
-    v36 = (double)(pViewport->uViewportZ - pViewport->uViewportX) * 0.5;
-    v6 = tan(0.6457717418670654);
-    v31 = 0;
-    v33 = 65536 / (signed int)(signed __int64)(v36 / v6 + 0.5);
-    if ( (signed int)_this.uNumVertices <= 0 )
-      goto LABEL_16;
-    v7 = (char *)&array_50AC10[0].vWorldViewProjY;
-    while ( 1 )
-    {
-      LODWORD(v27) = *(int *)v7;
-      v26 = v27 + 6.7553994e15;
-      v29 = LODWORD(v26);
-      v38 = _this.ptr_38->field_14;
-      v39 = (unsigned __int64)(v38 * (signed __int64)(v33 * (v30 - LODWORD(v26)))) >> 16;
-      v8 = v39 + _this.ptr_38->field_C;
-      v39 = v33 * (v30 - LODWORD(v26));
-      v35 = v8;
-      v38 = _this.ptr_38->field_20;
-      v39 = (unsigned __int64)(v38 * (signed __int64)(v33 * (v30 - LODWORD(v26)))) >> 16;
-      HIDWORD(v36) = v39 + _this.ptr_38->field_18;
-      v38 = _this.v_18.z;
-      v9 = (unsigned __int64)(_this.v_18.z * (signed __int64)(v33 * (v30 - LODWORD(v26)))) >> 16;
+  if (pOutdoor->uSky_TextureID == -1)
+    return;
+  _this.field_58 = 0;
+  _this.uNumVertices = 4;
+  _this.v_18.x = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi + 16);
+  _this.v_18.y = 0;
+  _this.v_18.z = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX + 16);
+  _this.field_24 = 0x2000000;
+
+  _this.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
+  _this.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
+
+  array_50AC10[0].vWorldViewProjX = pViewport->uViewportX;
+  array_50AC10[0].vWorldViewProjY = pViewport->uViewportY;
+
+  array_50AC10[1].vWorldViewProjX = pViewport->uViewportX;
+  array_50AC10[1].vWorldViewProjY = v38;
+
+  array_50AC10[2].vWorldViewProjX = pViewport->uViewportZ;
+  array_50AC10[2].vWorldViewProjY = pViewport->uViewportY;
+
+  array_50AC10[3].vWorldViewProjX = pViewport->uViewportZ;
+  array_50AC10[3].vWorldViewProjY = v38;
+
+  v36 = (double)(pViewport->uViewportZ - pViewport->uViewportX) * 0.5;
+  v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5);
+
+  for (int i = 0; i < _this.uNumVertices; ++i)
+  {
+     v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);
+     v39 = (unsigned __int64)(_this.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;
+     v8 = v39 + _this.ptr_38->field_C;
+
+     v39 = (unsigned __int64)(_this.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;
+     v36 = v39 + _this.ptr_38->field_18;
+
+      v9 = (unsigned __int64)(_this.v_18.z * v33 * (v30 - v29)) / 65536;
       v10 = _this.v_18.x + v9;
       v39 = _this.v_18.x + v9;
       if ( _this.v_18.x + v9 > 0 )
@@ -7799,11 +7783,11 @@
         v10 = 0;
         v39 = 0;
       }
-      v11 = (signed __int64)*((float *)v7 - 1);
+      v11 = (signed __int64)array_50AC10[i].vWorldViewProjX;
       v38 = v10;
-      v12 = *(float *)v7 - 1.0;
+      v12 = array_50AC10[i].vWorldViewProjY - 1.0;
       v13 = v33 * (pViewport->uScreenCenterX - v11);
-      LODWORD(v34) = -_this.field_24;
+      v34 = -_this.field_24;
       v32 = (signed __int64)v12;
       v14 = v33 * (v30 - v32);
       while ( 1 )
@@ -7811,9 +7795,9 @@
         v40 = v14;
         if ( !v10 )
           goto LABEL_12;
-        v37 = abs(SLODWORD(v34) >> 14);
+        v37 = abs(v34 >> 14);
         v15 = abs(v10);
-        if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportY )
+        if ( v37 <= v15 || v32 <= pViewport->uViewportY )
         {
           if ( v39 <= 0 )
             break;
@@ -7827,57 +7811,49 @@
         v10 = _this.v_18.x + v16;
         v39 = _this.v_18.x + v16;
         v38 = _this.v_18.x + v16;
-      }
-      LODWORD(v17) = LODWORD(v34) << 16;
-      HIDWORD(v17) = SLODWORD(v34) >> 16;
-      v40 = v17 / v38;
+        break;
+      }
+      LODWORD(v17) = v34 << 16;
+      HIDWORD(v17) = v34 >> 16;
       v18 = v17 / v38;
       if ( v18 < 0 )
         v18 = pOutdoorCamera->shading_dist_mist;
-      v40 = v13;
-      v37 = _this.ptr_38->field_10;
-      v40 = v13;
-      v37 = v35 + ((unsigned __int64)(v37 * (signed __int64)v13) >> 16);
-      v35 = _this.ptr_38->field_1C;
-      HIDWORD(v36) += (unsigned __int64)(v35 * (signed __int64)v13) >> 16;
-      v35 = 224 * pMiscTimer->uTotalGameTimeElapsed
-          + ((signed int)((unsigned __int64)(v37 * (signed __int64)v18) >> 16) >> 3);
-      v40 = (unsigned __int64)(SHIDWORD(v36) * (signed __int64)v18) >> 16;
-      v19 = _this.pTexture;
-      HIDWORD(v36) = _this.pTexture->uTextureWidth;
-      v7 += 48;
-      v20 = (double)SHIDWORD(v36) * 65536.0;
-      HIDWORD(v36) = 224 * pMiscTimer->uTotalGameTimeElapsed + (v40 >> 3);
-      ++v31;
-      *((float *)v7 - 10) = (double)v35 / v20;
-      v21 = (double)SHIDWORD(v36);
-      HIDWORD(v36) = v19->uTextureHeight;
-      v22 = (double)SHIDWORD(v36);
-      HIDWORD(v36) = v18 >> 16;
-      v24 = _this.uNumVertices > v31;
-      v23 = ((v31 - _this.uNumVertices) & 0x80000000u) != 0;
-      *((float *)v7 - 9) = v21 / (v22 * 65536.0);
-      *((float *)v7 - 16) = (double)pOutdoorCamera->shading_dist_mist;
-      *((float *)v7 - 11) = 1.0 / (double)SHIDWORD(v36);
-      if ( !(v23 ^ v24) )
-      {
-LABEL_16:
-        pRenderer->DrawFan(
-          _this.uNumVertices,
-          &_this,
-          pBitmaps_LOD->pHardwareTextures[(signed __int16)_this.uTileBitmapID]);
-        array_50AC10[0].vWorldViewProjY = v28;
-        array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
-        array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
-        array_50AC10[3].vWorldViewProjY = v28;
-        pRenderer->DrawFan(
-          _this.uNumVertices,
-          &_this,
-          pBitmaps_LOD->pHardwareTextures[(signed __int16)_this.uTileBitmapID]);
+
+      v37 += ((unsigned __int64)(_this.ptr_38->field_10 * v13) >> 16);
+      v36 += ((unsigned __int64)(_this.ptr_38->field_1C * v13) >> 16);
+      v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v37 * v18) >> 16) / 8;
+      v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v36 * v18) >> 16) / 8;
+
+      array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+      array_50AC10[i].flt_20 = 1.0 / (double)(v17 / 65536);
+      array_50AC10[i].u = (double)v35 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth);
+      array_50AC10[i].v = (double)v36 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth);
+    }
+
+     float t = (GetTickCount() % 96000) / 96000.0f;
+
+ array_50AC10[0].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+ array_50AC10[0].flt_20 = 1;
+ array_50AC10[0].u = 0;
+ array_50AC10[0].v = 0 + t;
+
+ array_50AC10[1].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+ array_50AC10[1].flt_20 = 1;
+ array_50AC10[1].u = 0;
+ array_50AC10[1].v = 1 + t;
+ 
+ array_50AC10[2].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+ array_50AC10[2].flt_20 = 1;
+ array_50AC10[2].u = 1;
+ array_50AC10[2].v = 0 + t;
+
+ array_50AC10[3].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+ array_50AC10[3].flt_20 = 1;
+ array_50AC10[3].u = 1;
+ array_50AC10[3].v = 1 + t;
+ pRenderer->DrawStrip(_this.uNumVertices, &_this,
+          pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]);//problem
         return;
-      }
-    }
-  }
 }
 
 
@@ -9128,16 +9104,16 @@
 
 
 //----- (0047F44B) --------------------------------------------------------
-int __stdcall WorldPosToGridCellX(signed int a1)
-{
-  return (a1 >> 9) + 64;
+unsigned int __stdcall WorldPosToGridCellX(signed int sWorldPosX)
+{
+  return (sWorldPosX / 512) + 64;
 }
 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
 
 //----- (0047F458) --------------------------------------------------------
-int __stdcall WorldPosToGridCellZ(signed int a1)
-{
-  return 64 - (a1 >> 9);
+unsigned int __stdcall WorldPosToGridCellZ(signed int sWorldPosZ)
+{
+  return 64 - (sWorldPosZ / 512);
 }
 
 //----- (0047F469) --------------------------------------------------------