changeset 1427:1987f2cca08f

m
author Ritor1
date Thu, 01 Aug 2013 09:26:05 +0600
parents 5930342f092b
children 50d1412cd2c0
files Outdoor_stuff.h Render.cpp Render.h _deleted.cpp mm7_3.cpp
diffstat 5 files changed, 137 insertions(+), 158 deletions(-) [+]
line wrap: on
line diff
--- a/Outdoor_stuff.h	Tue Jul 30 15:14:46 2013 +0600
+++ b/Outdoor_stuff.h	Thu Aug 01 09:26:05 2013 +0600
@@ -19,7 +19,7 @@
   void DrawBorderTiles();
   //void _48276F_sr();
   void _normalize_v_18();
-  void _48607B(struct stru149 *a2);
+  void Create_48607B(struct stru149 *a2);
 
   float field_0;
   float field_4;
@@ -70,7 +70,7 @@
 {
   int _48616B(int a2, int a3, int a4, int a5, int a6, int a7);
   int _48653D(int a2, int a3, int a4, int a5, int a6, int a7);
-  int sky_48694B();
+  void Inverse_sky_48694B();
 
   int field_0_party_dir_x;
   int field_4_party_dir_y;
--- a/Render.cpp	Tue Jul 30 15:14:46 2013 +0600
+++ b/Render.cpp	Thu Aug 01 09:26:05 2013 +0600
@@ -209,27 +209,10 @@
   return result;
 }
 
-
 void Render::RenderTerrainD3D() // New function
 {
-  char result; // al@3
   int v6; // ecx@8
- struct Polygon *pTile; // ebx@8
- struct Polygon *v16;
-  unsigned int v18; // edi@22
-  int v35; // edi@63
-  int v37; // eax@73
-  int v39; // eax@80
-  char v40; // [sp-18h] [bp-70h]@2
-  int v41; // [sp-14h] [bp-6Ch]@2
-  int v42; // [sp-10h] [bp-68h]@2
-  int v43; // [sp-Ch] [bp-64h]@2
-  const char *v44; // [sp-8h] [bp-60h]@2
-  int v45; // [sp-4h] [bp-5Ch]@2
-  int v56;
-  int v57; // [sp+38h] [bp-20h]@36
-  int v64; // [sp+57h] [bp-1h]@2
-  int v62;
+  struct Polygon *pTilePolygon; // ebx@8
 
   //warning: the game uses CW culling by default, ccw is incosistent
   pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW);
@@ -271,20 +254,20 @@
   {
     for (unsigned int x = 0; x < 127; ++x)
     {
-      pTile = &array_77EC08[pOutdoorCamera->uNumPolygons];
-      pTile->flags = 0;
-      pTile->field_32 = 0;
-      pTile->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z);
-      pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTile->uTileBitmapID];
-      if (pTile->uTileBitmapID == 0xFFFF)
+      pTilePolygon = &array_77EC08[pOutdoorCamera->uNumPolygons];
+      pTilePolygon->flags = 0;
+      pTilePolygon->field_32 = 0;
+      pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z);
+      pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID];
+      if (pTilePolygon->uTileBitmapID == 0xFFFF)
         continue;
 
       //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z);
-      pTile->flags = pOutdoor->GetSomeOtherTileInfo(x, z);
-      pTile->field_32 = 0;
-      pTile->field_59 = 1;
-      pTile->sTextureDeltaU = 0;
-      pTile->sTextureDeltaV = 0;
+      pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z);
+      pTilePolygon->field_32 = 0;
+      pTilePolygon->field_59 = 1;
+      pTilePolygon->sTextureDeltaU = 0;
+      pTilePolygon->sTextureDeltaV = 0;
 //  x,z         x+1,z
 //  .____________.
 //  |            |
@@ -309,9 +292,9 @@
       //v58 = 0;
       //if (v58 == 4) // if all y == first y;  primitive in xz plane 
         //pTile->field_32 |= 0x0001;
-      pTile->pODMFace = nullptr;
-      pTile->uNumVertices = 4;
-      pTile->field_59 = 5;
+      pTilePolygon->pODMFace = nullptr;
+      pTilePolygon->uNumVertices = 4;
+      pTilePolygon->field_59 = 5;
 
 //shading (затенение)----------------------------------------------------------------------------
       //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1];
@@ -322,17 +305,17 @@
       float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) -
                   (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) -
                   (norm->z * (float)pOutdoor->vSunlight.z / 65536.0));
-      pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);
+      pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);
 //-----------------------------------------------------------------------------------------------
 
       ++pOutdoorCamera->uNumPolygons;
       ++pOutdoorCamera->field_44;
       assert(pOutdoorCamera->uNumPolygons < 20000);
 
-      pTile->uBModelID = 0;
-      pTile->uBModelFaceID = 0;
-      pTile->field_50 = (8 * (0 | (0 << 6))) | 6;
-      for (unsigned int k = 0; k < pTile->uNumVertices; ++k)
+      pTilePolygon->uBModelID = 0;
+      pTilePolygon->uBModelFaceID = 0;
+      pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6;
+      for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k)
       {
         memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
         array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
@@ -340,27 +323,27 @@
 
 // check the transparency and texture (tiles) mapping (проверка прозрачности и наложение текстур (тайлов))----------------------
       bool transparent = false;
-      if ( !( pTile->flags & 1 ) ) // не поддерживается TextureFrameTable
-      {
-        if ( /*pTile->flags & 2 && */pTile->uTileBitmapID == pRenderer->hd_water_tile_id)
+      if ( !( pTilePolygon->flags & 1 ) ) // не поддерживается TextureFrameTable
+      {
+        if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id)
         {
           //transparent = false;
           v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
         }
         else
         {
-          v6 = pTile->uTileBitmapID;
-          if ( !_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5) )
+          v6 = pTilePolygon->uTileBitmapID;
+          if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) )
             transparent = true;
         }
 
       assert(v6 < 1000); // many random crashes here
 
       // for all shore tiles - draw a tile water under them since they're half-empty
-      if (!_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5))  // all shore tile filenames are wtrdrXXX
-        pTile->DrawBorderTiles();
-
-      pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v6], transparent, true);
+      if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5))  // all shore tile filenames are wtrdrXXX
+        pTilePolygon->DrawBorderTiles();
+
+      pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true);
       }
       //else //здесь уже пограничные тайлы воды
         //pTile->DrawBorderTiles();
@@ -4947,11 +4930,9 @@
 // 4D864C: using guessed type char byte_4D864C;
 
 //----- (004A2DA3) --------------------------------------------------------
-void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *a3, IDirect3DTexture2 *pTexture)
+void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture)
 {
   int v7; // eax@7
-  float v13; // ST3C_4@8
-  int i;
 
   if ( !this->uNumD3DSceneBegins )
     return;
@@ -4964,7 +4945,7 @@
       this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
       this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
     }
-    for ( i = 0; i < uNumVertices; ++i )
+    for ( uint i = 0; i < uNumVertices; ++i )
     {
       pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX;
       pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY;
@@ -4974,10 +4955,7 @@
       pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0);
       v7 = 0;
       if (this->bUsingSpecular)
-      {
-        v13 = array_50AC10[i].vWorldViewPosition.x;
-        v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13);
-      }
+        v7 = sub_47C3D7_get_fog_related_stuff(0, 1, array_50AC10[i].vWorldViewPosition.x);
       pVertices[i].specular = v7;
       pVertices[i].texcoord.x = array_50AC10[i].u;
       pVertices[i].texcoord.y = array_50AC10[i].v;
@@ -5169,7 +5147,7 @@
   if ( v7 == 4 || v7 == 3 )
     v70 = v6;
   stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0);
-  v62._48607B(&stru_8019C8);
+  v62.Create_48607B(&stru_8019C8);
   v62.uTileBitmapID = pFace->uBitmapID;
   v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
   if ( !v62.pTexture )
--- a/Render.h	Tue Jul 30 15:14:46 2013 +0600
+++ b/Render.h	Thu Aug 01 09:26:05 2013 +0600
@@ -320,7 +320,7 @@
   unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6);
   void DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture);
   void DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders);
-  void DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *a3, IDirect3DTexture2 *pTexture);
+  void DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture);
   void _4A2ED5(signed int a2, struct Polygon *a3, IDirect3DTexture2 *pHwTex);
   void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, struct Texture *pTex, int uPackedID, unsigned int uColor, int a8);
   void DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID);
--- a/_deleted.cpp	Tue Jul 30 15:14:46 2013 +0600
+++ b/_deleted.cpp	Thu Aug 01 09:26:05 2013 +0600
@@ -2119,8 +2119,8 @@
   if (pOutdoorCamera->uNumPolygons >= 1999)
     return;
 
-  array_77EC08[1999]._48607B(&stru_8019C8);
-  array_77EC08[1999].ptr_38->sky_48694B();
+  array_77EC08[1999].Create_48607B(&stru_8019C8);
+  array_77EC08[1999].ptr_38->Inverse_sky_48694B();
 
   if (pOutdoor->uMainTile_BitmapID == -1)
   {
@@ -2142,8 +2142,8 @@
                        + (double)pViewport->uScreenCenterY);
   cos((double)pIndoorCamera->sRotationX * 0.0030664064);
   sin((double)pIndoorCamera->sRotationX * 0.0030664064);
-  array_77EC08[1999]._48607B(&stru_8019C8);
-  array_77EC08[1999].ptr_38->sky_48694B();
+  array_77EC08[1999].Create_48607B(&stru_8019C8);
+  array_77EC08[1999].ptr_38->Inverse_sky_48694B();
 
   if (pOutdoor->uSky_TextureID == -1)
   {
--- a/mm7_3.cpp	Tue Jul 30 15:14:46 2013 +0600
+++ b/mm7_3.cpp	Thu Aug 01 09:26:05 2013 +0600
@@ -5361,14 +5361,12 @@
   int v9; // eax@4
   int v10; // ebx@4
   signed __int64 v11; // qax@6
-  //double v12; // st7@6
   int v13; // edi@6
   int v14; // ecx@6
-  //int v15; // eax@8
   int v16; // eax@12
-  signed __int64 v17; // qtt@13
+  //signed __int64 v17; // qtt@13
   signed int pShading; // ecx@13
-  struct Polygon pSky; // [sp+14h] [bp-150h]@1
+  struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1
   float v28; // [sp+12Ch] [bp-38h]@2
   int v29; // [sp+130h] [bp-34h]@4
   int v30; // [sp+134h] [bp-30h]@1
@@ -5376,11 +5374,11 @@
   int v33; // [sp+140h] [bp-24h]@2
   int v34; // [sp+144h] [bp-20h]@1
   int v35; // [sp+148h] [bp-1Ch]@4
-  int v36; // [sp+14Ch] [bp-18h]@2
+  int screen_center_x; // [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
+  //int v40; // [sp+160h] [bp-4h]@7
   
   extern bool new_sky;
   if (new_sky)
@@ -5390,48 +5388,59 @@
   }
 
   v30 = ((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z)
-        / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY);
+        / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY);//184 изменяется при подъёме на высоту
   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);
-
-  pSky._48607B(&stru_8019C8);
-  pSky.ptr_38->sky_48694B();
-  pSky.uTileBitmapID = pOutdoor->uSky_TextureID;//номер текстуры
-  pSky.pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? &pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID] : 0);//текстура неба
+       (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z);//61 / 184 / 310 изменяется при наклоне камеры
+
+  pSkyPolygon.Create_48607B(&stru_8019C8);
+  pSkyPolygon.ptr_38->Inverse_sky_48694B();//maybe creating skydome(возможно создание купола неба)
+  pSkyPolygon.uTileBitmapID = pOutdoor->uSky_TextureID;//номер текстуры
+  pSkyPolygon.pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? &pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID] : 0);//текстура неба
   if (pOutdoor->uSky_TextureID == -1)
     return;
 
-  pSky.dimming_level = 0;//затемнение
-  pSky.uNumVertices = 4;//количество вершин
-
-  //centering(центруем)---------------------------------------------------------------
-  pSky.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);//-3216
-  pSky.v_18.y = 0;
-  pSky.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);//-65457
-  //---------------------------------------------------------------------------
-
-  pSky.field_24 = 0x2000000;
-
-  pSky.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
-  pSky.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
+  pSkyPolygon.dimming_level = 0;//затемнение
+  pSkyPolygon.uNumVertices = 4;//количество вершин
+
+  //centering(центруем)--наклон камеры ----------------------------------------//
+  pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);//-3216, вверх: -28020, вниз: 22078
+  pSkyPolygon.v_18.y = 0;
+  pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);//-65457, вверх: -59244, вниз: -61705
+  //---------------------------------------------------------------------------//
+
+  pSkyPolygon.field_24 = 0x2000000;
+
+  pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//60928
+  pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
   
   //sky position(положение неба)----------------------------------------------
-  array_50AC10[0].vWorldViewProjX = pViewport->uViewportTL_X;
-  array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y;
-
-  array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X;
-  array_50AC10[1].vWorldViewProjY = v38;
-
-  array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X;
-  array_50AC10[2].vWorldViewProjY = v38;
-
-  array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X;
-  array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y;
+  //                X
+  // 0._____________________________.3
+  //  |8,8                    468,8 |
+  //  |                             |
+  //  |                             |
+  // Y|                             |
+  //  |                             |
+  //  |8,?                    468,? |
+  // 1._____________________________.2
+  // 
+
+  array_50AC10[0].vWorldViewProjX = pViewport->uViewportTL_X;//8
+  array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y;//8
+
+  array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X;//8
+  array_50AC10[1].vWorldViewProjY = v38;//61 / 184 / 310
+
+  array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X;//468
+  array_50AC10[2].vWorldViewProjY = v38;//61 / 184 / 310
+
+  array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X;//468
+  array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y;//8
   //--------------------------------------------------------------------------
 
   //pParty->sRotationY / 2048.0f
-  // move sky(двидение неба)--------------include-----------------------------
+  // move sky(движение неба)--------------include(вставка)---------------------
     float t = (GetTickCount() % 96000) / 96000.0f;
     array_50AC10[0].u = t - pParty->sRotationY / 1024.0f;
     array_50AC10[0].v = t - pParty->sRotationX / 512.0f;
@@ -5444,25 +5453,31 @@
 
     array_50AC10[3].u = 1 + t - pParty->sRotationY / 1024.0f;
     array_50AC10[3].v = t - pParty->sRotationX / 512.0f;
-  //--------------------------------------------------------------------------
+  //--------------------------------------------------------------------------//
 
   //rotate skydome(вращение купола неба)--------------------------------------
-  v36 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5;//центр экрана 230
-  v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5);//214
-
-  for (uint i = 0; i < pSky.uNumVertices; ++i)
+  // В игре принята своя система измерения углов. Полный угол в 2П радиан соответствует 65536 еденицам. Значению угла 0 соответствует 
+  // направление на восток, значению 16384(0х4000) - на север и т.д..
+
+  //нахождение вектора взгляда------------------------------------------------
+  //положение камеры----------------------------------------------------------
+  screen_center_x = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;//центр экрана по X = 230
+  v33 = 65536 / (signed int)(screen_center_x / tan(0.6457717418670654) + 0.5);//360 : (расстояние от экрана до камеры в пикселях) = 214
+  //--------------------------------------------------------------------------
+
+  for (uint i = 0; i < pSkyPolygon.uNumVertices; ++i)
   {
     v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);//8
-    v39 = (unsigned __int64)(pSky.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0
-    v8 = v39 + pSky.ptr_38->field_C;//0
-
-    v39 = (unsigned __int64)(pSky.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;//0
-    v36 = v39 + pSky.ptr_38->field_18;//65536
-
-    v9 = (unsigned __int64)(pSky.v_18.z * v33 * (v30 - v29)) / 65536;//27917
-    v10 = pSky.v_18.x + v9;//24701
-    v39 = pSky.v_18.x + v9;//24701
-    if ( pSky.v_18.x + v9 > 0 )
+    v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0
+    v8 = v39 + pSkyPolygon.ptr_38->field_C;//0
+
+    v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;//0
+    screen_center_x = v39 + pSkyPolygon.ptr_38->field_18;//65536
+
+    v9 = (unsigned __int64)(pSkyPolygon.v_18.z * v33 * (v30 - v29)) / 65536;//27917
+    v10 = pSkyPolygon.v_18.x + v9;//24701
+    v39 = pSkyPolygon.v_18.x + v9;//24701
+    if ( pSkyPolygon.v_18.x + v9 > 0 )
     {
       v10 = 0;
       v39 = 0;
@@ -5471,73 +5486,71 @@
     v38 = v10;
     //v12 = array_50AC10[i].vWorldViewProjY - 1.0;
     v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX);
-    v34 = -pSky.field_24;
+    v34 = -pSkyPolygon.field_24;
     v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0;
     v14 = v33 * (v30 - v32);
 
     while ( 1 )
     {
-      v40 = v14;
+      //v40 = v14;
       if ( !v10 )
       {
-        v37 = pSky.v_18.z;
-        v16 = (unsigned __int64)(pSky.v_18.z * (signed __int64)v14) >> 16;
+        v37 = pSkyPolygon.v_18.z;
+        v16 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v14) >> 16;
         --v32;
         v14 += v33;
-        v10 = pSky.v_18.x + v16;
-        v39 = pSky.v_18.x + v16;
-        v38 = pSky.v_18.x + v16;
+        v10 = pSkyPolygon.v_18.x + v16;
+        v39 = pSkyPolygon.v_18.x + v16;
+        v38 = pSkyPolygon.v_18.x + v16;
         break;
       }
-      v37 = abs(v34 >> 14);
+      v37 = abs(v34 >> 14);//2048
       if ( abs(v34 >> 14) <= abs(v10) || v32 <= pViewport->uViewportTL_Y )
       {
         if ( v39 <= 0 )
           break;
       }
-      v14 = v40;
-      v37 = pSky.v_18.z;
-      v16 = (unsigned __int64)(pSky.v_18.z * v14) >> 16;
+      //v14 = v40;
+      v37 = pSkyPolygon.v_18.z;
+      v16 = (unsigned __int64)(pSkyPolygon.v_18.z * v14) >> 16;
       --v32;
       v14 += v33;
-      v10 = pSky.v_18.x + v16;
-      v39 = pSky.v_18.x + v16;
-      v38 = pSky.v_18.x + v16;
+      v10 = pSkyPolygon.v_18.x + v16;
+      v39 = pSkyPolygon.v_18.x + v16;
+      v38 = pSkyPolygon.v_18.x + v16;
       break;
     }
 
-    LODWORD(v17) = v34 << 16;
-    HIDWORD(v17) = v34 >> 16;
-    pShading = v17 / v38;
+    pShading = fixpoint_div(v34, v38);
     if ( pShading < 0 )
       pShading = pOutdoorCamera->shading_dist_mist;
 
-    v37 += ((unsigned __int64)(pSky.ptr_38->field_10 * v13) >> 16);
-    v36 += ((unsigned __int64)(pSky.ptr_38->field_1C * v13) >> 16);
+    v37 += ((unsigned __int64)(pSkyPolygon.ptr_38->field_10 * v13) >> 16);
+    screen_center_x += ((unsigned __int64)(pSkyPolygon.ptr_38->field_1C * v13) >> 16);
     v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v37, pShading) / 8;
-    v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v36, pShading) / 8;
+    screen_center_x = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(screen_center_x, pShading) / 8;
 
     //array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
     //array_50AC10[i].vWorldPosition.x = v36 / (pSky.pTexture->uTextureHeight * 65536.0);
     //array_50AC10[i].vWorldPosition.y = 1.0 / (pOutdoorCamera->shading_dist_mist >> 16);
     //array_50AC10[i].vWorldPosition.z = v35 / (pSky.pTexture->uTextureWidth * 65536.0);
-    //array_50AC10[i]._rhw = 1.0f / (v18 >> 16);
-    //array_50AC10[i].u = (double)v35 / (65536.0 * pSky.pTexture->uTextureWidth);
-    //array_50AC10[i].v = (double)v36 / (65536.0 * pSky.pTexture->uTextureHeight);
+    //array_50AC10[i]._rhw = 1.0f / (pShading >> 16);
+    //array_50AC10[i].u = (double)v35 / (65536.0 * pSkyPolygon.pTexture->uTextureWidth);
+    //array_50AC10[i].v = (double)screen_center_x / (65536.0 * pSkyPolygon.pTexture->uTextureHeight);
   //-----------------------------------------------------------------------------------------
 
     array_50AC10[i]._rhw = 1.0f;
   }
   //if ( i  == _this.uNumVertices - 1 )
   //{
-    pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]);
+    pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]);
 
     array_50AC10[0].vWorldViewProjY = v38;
     array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
     array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
     array_50AC10[3].vWorldViewProjY = v38;
 
-    pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]);
+    pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]);
   //}
 }
 
@@ -6195,7 +6208,7 @@
 }
 
 //----- (0048607B) --------------------------------------------------------
-void Polygon::_48607B(stru149 *a2)
+void Polygon::Create_48607B(stru149 *a2)
 {
   this->pTexture = 0;
   this->ptr_38 = a2;
@@ -6337,29 +6350,17 @@
 }
 
 //----- (0048694B) --------------------------------------------------------
-int stru149::sky_48694B()
+void stru149::Inverse_sky_48694B()
 {
-  int v1; // eax@1
-  int v2; // ST04_4@1
-  int v3; // ST00_4@1
-  int v4; // eax@1
-  int v5; // ST0C_4@1
-  int result; // eax@1
-
-  v1 = this->field_C;
   this->field_18 = -this->field_18;
   this->field_1C = -this->field_1C;
   this->field_20 = -this->field_20;
-  v2 = (unsigned __int64)(v1 * (signed __int64)this->field_0_party_dir_x) >> 16;
-  v3 = this->field_18;
-  v4 = this->field_0_party_dir_x;
-  this->field_24 = v2
+  this->field_24 = ((unsigned __int64)(this->field_C * (signed __int64)this->field_0_party_dir_x) >> 16)
                  + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16)
                  + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
-  v5 = (unsigned __int64)(v3 * (signed __int64)v4) >> 16;
-  result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16;
-  this->field_28 = v5 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
-  return result;
+  this->field_28 = ((unsigned __int64)(this->field_18 * (signed __int64)this->field_0_party_dir_x) >> 16)
+                 + ((unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16)
+                 + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
 }
 
 //----- (0044100D) --------------------------------------------------------