diff mm7_3.cpp @ 1439:468f434a8d8a

Слияние
author Ritor1
date Mon, 22 Jul 2013 18:00:58 +0600
parents bc99e1a48bea 3161094869e0
children b67a3e0d6fc3
line wrap: on
line diff
--- a/mm7_3.cpp	Mon Jul 22 18:00:34 2013 +0600
+++ b/mm7_3.cpp	Mon Jul 22 18:00:58 2013 +0600
@@ -2098,7 +2098,7 @@
 }
 
 //----- (00473893) --------------------------------------------------------
-void __cdecl ODM_ProcessPartyActions()
+void ODM_ProcessPartyActions()
 {
   //int _zero; // esi@1
   int v1; // edi@1
@@ -2283,8 +2283,7 @@
     bWaterWalk = 1;
     *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u;
     if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) &&
-		pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster-1].sMana <= 0 )
-		//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 10] <= 0 )
+		pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 )
       bWaterWalk = 0;
   }
   v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &v130, &v108, bWaterWalk);
@@ -3040,24 +3039,14 @@
 		  if ( !v107
 			&& !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
 		  {
-        
-			v90 = -1;
-			v89 = 1;
-			v88 = 804;
-			v87 = 64;
-			pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+            pAudioPlayer->PlaySound((SoundID)64, 804, 1, -1, 0, 0, 0, 0);
 		  }
 		  else
 		  {
-			v90 = -1;
-			v89 = 1;
-			v88 = 804;
-			v86 = 1;
-		//LABEL_255:
 			v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
 			v64 = WorldPosToGridCellX(pParty->vPosition.x);
-			v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86);
-			pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+			v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 1);
+			pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);
 		  }
 		}
 		else
@@ -3067,29 +3056,16 @@
 			  if ( v107
 				|| BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
 			  {
-        
-				v90 = -1;
-				v89 = 1;
-				v88 = 804;
-				v86 = 0;
 				v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
 				v64 = WorldPosToGridCellX(pParty->vPosition.x);
-				v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86);
-				pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+				v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 0);
+				pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);
 			  }
 			  else
-			  {
-				  v90 = -1;
-				  v89 = 1;
-				  v88 = 804;
-				  v87 = 103;
-			//LABEL_257:
-				  pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
-			  }
+                pAudioPlayer->PlaySound((SoundID)103, 804, 1, -1, 0, 0, 0, 0);
 			}
 			else
 			{
-		//LABEL_344:
 			  pAudioPlayer->_4AA258(804);
 			  pParty->walk_sound_timer = 64;
 			}
@@ -3152,8 +3128,7 @@
             do
             {
               v110 = (*v74)->GetMaxHealth();
-              (*v74)->ReceiveDamage(
-                (signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
+              (*v74)->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
                 DMGT_PHISYCAL);
               v75 = (*v74)->GetActualEndurance();
               v110 = 20 - (*v74)->GetParameterBonus(v75);
@@ -3854,7 +3829,6 @@
 
   return result;
 }
-// 47730C: using guessed type int __stdcall const_1(int);
 
 //----- (004775ED) --------------------------------------------------------
 int stru6_stru1_indoor_sw_billboard::_4775ED(float a2)
@@ -3899,20 +3873,20 @@
   float v39; // [sp+D0h] [bp-8h]@6
   int *v40; // [sp+D4h] [bp-4h]@2
 
-  v2 = (char *)&this->field_14[4 * this->field_10 + 20];
+  v2 = (char *)&this->field_64[4 * this->uNumVertices];
   v38 = 0;
-  *(int *)v2 = this->field_14[20];
+  *(int *)v2 = this->field_64[0];
   v2 += 4;
-  *(int *)v2 = this->field_14[21];
+  *(int *)v2 = this->field_64[1];
   v2 += 4;
-  *(int *)v2 = this->field_14[22];
-  *((int *)v2 + 1) = this->field_14[23];
-  v3 = this->field_10;
+  *(int *)v2 = this->field_64[2];
+  *((int *)v2 + 1) = this->field_64[3];
+  v3 = this->uNumVertices;
   v35 = this;
   if ( v3 > 0 )
   {
-    v40 = &this->field_14[40];
-    v4 = (char *)&this->field_14[23] + 3;
+    v40 = &this->field_64[20];
+    v4 = (char *)&this->field_64[3] + 3;
     v34 = v3;
     while ( 1 )
     {
@@ -3998,9 +3972,7 @@
     goto LABEL_10;
   }
 LABEL_12:
-  result = v38;
-  this->field_10 = v38;
-  return result;
+  return this->uNumVertices = v38;
 }
 
 //----- (00477927) --------------------------------------------------------
@@ -4046,20 +4018,20 @@
   float v39; // [sp+D0h] [bp-8h]@6
   int *v40; // [sp+D4h] [bp-4h]@2
 
-  v2 = (char *)&this->field_14[4 * this->field_10 + 20];
+  v2 = (char *)&this->field_64[4 * this->uNumVertices];
   v38 = 0;
-  *(int *)v2 = this->field_14[20];
+  *(int *)v2 = this->field_64[0];
   v2 += 4;
-  *(int *)v2 = this->field_14[21];
+  *(int *)v2 = this->field_64[1];
   v2 += 4;
-  *(int *)v2 = this->field_14[22];
-  *((int *)v2 + 1) = this->field_14[23];
-  v3 = this->field_10;
+  *(int *)v2 = this->field_64[2];
+  *((int *)v2 + 1) = this->field_64[3];
+  v3 = this->uNumVertices;
   v35 = this;
   if ( v3 > 0 )
   {
-    v40 = &this->field_14[40];
-    v4 = (char *)&this->field_14[23] + 3;
+    v40 = &this->field_64[20];
+    v4 = (char *)&this->field_64[3] + 3;
     v34 = v3;
     while ( 1 )
     {
@@ -4145,9 +4117,7 @@
     goto LABEL_10;
   }
 LABEL_12:
-  result = v38;
-  this->field_10 = v38;
-  return result;
+  return this->uNumVertices = v38;
 }
 
 //----- (00477C61) --------------------------------------------------------
@@ -4199,7 +4169,7 @@
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     v2 = 0;
-    if ( this->field_10 > 0 )
+    if ( this->uNumVertices > 0 )
     {
       v3 = (int)&this->field_14[1];
       do
@@ -4252,7 +4222,7 @@
         *(float *)(v3 + 80) = v11;
         v3 += 16;
       }
-      while ( v2 < this->field_10 );
+      while ( v2 < this->uNumVertices );
     }
   }
   else
@@ -4298,7 +4268,7 @@
     }
     while ( v31 );
   }
-  this->field_10 = 3;
+  this->uNumVertices = 3;
   return 1;
 }
 
@@ -4330,7 +4300,7 @@
     v10 = (double)pOutdoorCamera->shading_dist_mist;
     v3 = 8.0;
   }
-  v4 = a1->field_10;
+  v4 = a1->uNumVertices;
   if ( v4 <= 0 )
     goto LABEL_16;
   v5 = (char *)&a1->field_14[20];
@@ -4353,15 +4323,15 @@
     if ( v9 )
     {
       v2->_477927(v10);
-      return v2->field_10 != 0;
+      return v2->uNumVertices != 0;
     }
 LABEL_16:
     memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
-    return v2->field_10 != 0;
+    return v2->uNumVertices != 0;
   }
   v7 = v3;
   _4775ED(v7);
-  return v2->field_10 != 0;
+  return v2->uNumVertices != 0;
 }
 
 //----- (0047802A) --------------------------------------------------------
@@ -4378,7 +4348,7 @@
   v16 = 0;
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
-	for(int i = 0; i < a1->field_10; i++)
+	for(int i = 0; i < a1->uNumVertices; i++)
     {
 		v6 = (double)pBLVRenderParams->field_40 * 0.000015258789 / a1->field_B4[i*4];
 		if ( pRenderer->pRenderD3D )
@@ -4409,7 +4379,7 @@
   }
   else
   {
-	for(int i = 0; i < a1->field_10; i++)
+	for(int i = 0; i < a1->uNumVertices; i++)
     {
 		v12 = (double)pOutdoorCamera->int_fov_rad / a1->field_B4[i*4];
 		a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1];
@@ -4446,14 +4416,14 @@
 //----- (0047840D) --------------------------------------------------------
 char Render::DrawBuildingsD3D()
 {
-  IndoorCameraD3D *v0; // eax@3
+  //IndoorCameraD3D *v0; // eax@3
   char result; // al@3
   BSPModel *v2; // ebx@4
   int v3; // eax@6
   ODMFace *pFace; // esi@6
   Vec3_int_ *v5; // ecx@8
   int v6; // eax@8
-  stru148 *v7; // ebx@8
+  struct Polygon *v7; // ebx@8
   LightmapBuilder *v8; // eax@8
   int v9; // ecx@8
   char v10; // zf@8
@@ -4477,9 +4447,9 @@
   int v26; // eax@57
   int v27; // eax@57
   int v28; // eax@58
-  int v29; // edx@58
-  double v30; // st7@59
-  LightmapBuilder *v31; // edi@63
+  //int v29; // edx@58
+  //double v30; // st7@59
+  //LightmapBuilder *v31; // edi@63
   signed int v32; // eax@73
   int v33; // eax@78
   unsigned int v34; // eax@80
@@ -4487,16 +4457,16 @@
   int v36; // [sp-14h] [bp-6Ch]@69
   RenderVertexSoft *v37; // [sp-10h] [bp-68h]@69
   int v38; // [sp-Ch] [bp-64h]@69
-  LightmapBuilder *v39; // [sp-8h] [bp-60h]@2
+  //LightmapBuilder *v39; // [sp-8h] [bp-60h]@2
   int v40; // [sp-4h] [bp-5Ch]@2
-  std::string *v41; // [sp+Ch] [bp-4Ch]@2
+  //std::string *v41; // [sp+Ch] [bp-4Ch]@2
   int v41b;
   int v42; // [sp+10h] [bp-48h]@6
   LightmapBuilder *pLightmapBuilder; // [sp+14h] [bp-44h]@8
   float v44; // [sp+18h] [bp-40h]@10
   float v45; // [sp+1Ch] [bp-3Ch]@10
   ODMFace *v46; // [sp+20h] [bp-38h]@6
-  IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3
+  //IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3
   unsigned int v48; // [sp+28h] [bp-30h]@8
   int v49; // [sp+2Ch] [bp-2Ch]@10
   int v50; // [sp+30h] [bp-28h]@34
@@ -4512,12 +4482,11 @@
 
   if ( !pRenderer->pRenderD3D )
   {
-          MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0);
-  }
+    MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0);
+  }
+
   unused = 0;
-  v0 = pGame->pIndoorCameraD3D;
   a1 = 0;
-  v47 = v0;
   result = LOBYTE(pOutdoor->pBModels);
   v41b = pOutdoor->uNumBModels;
   if ( (signed int)pOutdoor->uNumBModels > 0 )
@@ -4553,10 +4522,11 @@
 	  v5 = v2->pVertices.pVertices;
       v6 = pFace->pVertexIDs[0];
       v53 = 0;
-      v7 = &array_77EC08[pOutdoorCamera->numStru148s];
+      v7 = &array_77EC08[pOutdoorCamera->uNumPolygons];
 	  //v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8);
       v8 = (LightmapBuilder *)v5[v6].z;
-      *(int *)&v7->flags = 0;
+      v7->flags = 0;
+      v7->field_32 = 0;
       pLightmapBuilder = v8;
       v9 = pFace->uTextureID;
       v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0;
@@ -4695,7 +4665,7 @@
 		  if ( *(float *)&pLightmapBuilder == v23->vWorldPosition.z )
             ++v53;
           //v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u);
-		  v47->ViewTransform(v23, 1u);
+		  pGame->pIndoorCameraD3D->ViewTransform(v23, 1u);
 		  if ( v23->vWorldViewPosition.x < 8.0 || (double)pOutdoorCamera->shading_dist_mist < v23->vWorldViewPosition.x )
           {
             if ( v23->vWorldViewPosition.x >= 8.0 )
@@ -4705,7 +4675,7 @@
           }
           else
           {
-            v47->Project(v23, 1u, 0);
+            pGame->pIndoorCameraD3D->Project(v23, 1u, 0);
           }
           ++v23;// += 48;
           --v51;
@@ -4735,9 +4705,9 @@
         v7->dimming_level = 0;
       if ( v7->dimming_level > 31 )
         v7->dimming_level = 31;
-      if ( pOutdoorCamera->numStru148s >= 1999 + 5000)
+      if ( pOutdoorCamera->uNumPolygons >= 1999 + 5000)
         return result;
-      ++pOutdoorCamera->numStru148s;
+      ++pOutdoorCamera->uNumPolygons;
       ++pOutdoorCamera->field_44;
       if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) )
       {
@@ -4750,19 +4720,12 @@
         v27 = 8 * (v25 | (v26 << 6));
         LOBYTE(v27) = v27 | 6;
         v7->field_50 = v27;
-        if ( v18 > 0 )
+
+        for (v28 = 0; v28 < v18; ++v28)
         {
-          v28 = 0;
-          v29 = v18;
-          do
-          {
-            v30 = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001);
             memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28]));
-            ++v28;
-            --v29;
-            array_50A2B0[v28 + 49]._rhw = v30;
-          }
-          while ( v29 );
+            array_50AC10[v28]._rhw = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001);
+
           pFace = v46;
         }
 
@@ -4778,20 +4741,18 @@
         }*/
 
         v40 = (int)pFace;
-        pLightmapBuilder = pGame->pLightmapBuilder;
-        v31 = pLightmapBuilder;
-        pLightmapBuilder->ApplyLights_OutdoorFace(pFace);
+        pGame->pLightmapBuilder->ApplyLights_OutdoorFace(pFace);
         pDecalBuilder->ApplyDecals_OutdoorFace(pFace);
-        v31->std__vector_000004_size = 0;
-        LOBYTE(v31) = 0;
+        pGame->pLightmapBuilder->std__vector_000004_size = 0;
+
+        int v31 = 0;
         if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
         {
-          v31 = (LightmapBuilder *)(v50 ? 3 : v49 != 0 ? 5 : 0);
+          v31 = v50 ? 3 : v49 != 0 ? 5 : 0;
 		  static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, &v56->pVertices);
           if ( pDecalBuilder->uNumDecals > 0 )
           {
             v40 = -1;
-            v39 = v31;
             v38 = 0;
             v37 = array_50AC10;
             v36 = uNumVertices;
@@ -4806,7 +4767,7 @@
           }
         }
         if ( stru_F8AD28.uNumLightsApplied > 0 )
-          pLightmapBuilder->ApplyLights(
+          pGame->pLightmapBuilder->ApplyLights(
             &stru_F8AD28,
             &static_RenderBuildingsD3D_stru_73C834,
             uNumVertices,
@@ -4845,7 +4806,7 @@
         }
         goto LABEL_85;
       }
-      --pOutdoorCamera->numStru148s;
+      --pOutdoorCamera->uNumPolygons;
       --pOutdoorCamera->field_44;
 LABEL_85:
       v54 = (Vec3_int_ *)((char *)v54 + 1);
@@ -4860,414 +4821,6 @@
 }
 // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag;
 
-//----- (004789DE) --------------------------------------------------------
-BSPModel *Render::DrawBuildingsSW()
-{
-  BSPModel *result; // eax@1
-  BSPModel *v1; // ebx@2
-  int v2; // eax@4
-  ODMFace *v3; // edi@4
-  int v4; // ecx@6
-  int v5; // eax@6
-  int v6; // ecx@6
-  int v7; // ecx@6
-  double v8; // st7@7
-  char *v9; // ebx@7
-  int v10; // eax@9
-  double v11; // st7@9
-  stru148 *v12; // ebx@19
-  double v13; // st7@21
-  double v14; // ST4C_8@23
-  int v15; // eax@23
-  int v16; // eax@27
-  int v17; // ecx@29
-  unsigned __int8 v18; // sf@29
-  unsigned __int8 v19; // of@29
-  int v20; // ecx@30
-  int v21; // eax@31
-  int v22; // eax@31
-  int v23; // eax@35
-  int v24; // eax@39
-  Texture *v25; // eax@43
-  int v26; // esi@43
-  signed int v27; // ecx@43
-  double v28; // st6@43
-  double v29; // st5@43
-  unsigned short *v30; // edx@44
-  int v31; // eax@44
-  double v32; // st4@45
-  int v33; // ecx@45
-  char v34; // zf@45
-  BSPVertexBuffer *v35; // eax@50
-  unsigned int v36; // eax@53
-  signed int v37; // esi@53
-  int v38; // eax@54
-  signed int v39; // edx@55
-  char *v40; // ecx@56
-  double v41; // ST1C_8@57
-  double v42; // ST24_8@57
-  signed int v43; // eax@60
-  signed int v44; // esi@60
-  int v45; // eax@61
-  signed int v46; // edx@62
-  char *v47; // ecx@63
-  double v48; // ST34_8@64
-  double v49; // ST44_8@64
-  int v50; // eax@66
-  signed int v51; // ecx@67
-  char *v52; // edx@68
-  double v53; // ST3C_8@69
-  double v54; // ST2C_8@69
-  float v55; // [sp+44h] [bp-7Ch]@50
-  float v56; // [sp+48h] [bp-78h]@50
-  float v57; // [sp+4Ch] [bp-74h]@50
-  float v58; // [sp+50h] [bp-70h]@64
-  int v59; // [sp+54h] [bp-6Ch]@64
-  int v60; // [sp+58h] [bp-68h]@69
-  float v61; // [sp+5Ch] [bp-64h]@64
-  float v62; // [sp+60h] [bp-60h]@69
-  float v63; // [sp+64h] [bp-5Ch]@57
-  float v64; // [sp+68h] [bp-58h]@57
-  int v65; // [sp+6Ch] [bp-54h]@64
-  int v66; // [sp+70h] [bp-50h]@1
-  int v67; // [sp+74h] [bp-4Ch]@6
-  int v68; // [sp+78h] [bp-48h]@4
-  int v69; // [sp+7Ch] [bp-44h]@57
-  int v70; // [sp+80h] [bp-40h]@69
-  int v71; // [sp+84h] [bp-3Ch]@23
-  float v72; // [sp+88h] [bp-38h]@69
-  int v73; // [sp+8Ch] [bp-34h]@57
-  int v74; // [sp+90h] [bp-30h]@6
-  int v75; // [sp+94h] [bp-2Ch]@6
-  ODMFace *v76; // [sp+98h] [bp-28h]@4
-  int v77; // [sp+9Ch] [bp-24h]@6
-  BSPModel *v78; // [sp+A0h] [bp-20h]@2
-  int v79; // [sp+A4h] [bp-1Ch]@4
-  int a1; // [sp+A8h] [bp-18h]@1
-  unsigned short *v81; // [sp+ACh] [bp-14h]@7
-  int v82; // [sp+B0h] [bp-10h]@6
-  int v83; // [sp+B4h] [bp-Ch]@6
-  signed int v84; // [sp+B8h] [bp-8h]@7
-  int a2; // [sp+BCh] [bp-4h]@1
-
-  a2 = 0;
-  a1 = 0;
-  result = (BSPModel *)pOutdoor->pBModels;
-  v66 = pOutdoor->uNumBModels;
-  if ( (signed int)pOutdoor->uNumBModels > 0 )
-  {
-    v1 = pOutdoor->pBModels;
-    v78 = pOutdoor->pBModels;
-    while ( 1 )
-    {
-      if ( IsBModelVisible(a1, &a2) )
-      {
-		v1->field_40 |= 1u;
-        v2 = v1->uNumFaces;
-        v3 = v1->pFaces;
-        v74 = 0;
-        v76 = v3;
-        v68 = v2;
-        if ( v2 > 0 )
-          break;
-      }
-LABEL_73:
-      ++a1;
-      ++v1;
-      result = (BSPModel *)a1;
-      v78 = v1;
-      if ( a1 >= v66 )
-        return result;
-    }
-    while ( 1 )
-    {
-	  if ( !v3->Invisible() )
-      {
-        v4 = 3 * v3->pVertexIDs[0];
-        v5 = (int)((char *)v1 - 8);
-        v67 = (int)((char *)v1 - 8);
-        v6 = *(_DWORD *)(*(&v1->uNumConvexFaces - 2) + 4 * v4 + 8) + 4;
-        v82 = 0;
-        v83 = v6;
-        v74 = 0;
-        v7 = v3->uNumVertices;
-        v75 = 0;
-        v77 = v7;
-        if ( v7 > 0 )
-        {
-          v8 = (double)v83;
-          v9 = (char *)&array_73D150[0].vWorldViewPosition;
-		  v81 = v3->pVertexIDs;
-          v83 = v7;
-          *(float *)&v84 = v8;
-          while ( 1 )
-          {
-            v10 = *(int *)(v5 + 4) + 12 * *(short *)v81;
-            *((float *)v9 - 3) = (double)*(signed int *)v10 + 4.0;
-            *((float *)v9 - 2) = (double)*(signed int *)(v10 + 4) + 4.0;
-            v11 = (double)*(signed int *)(v10 + 8) + 4.0;
-            *((float *)v9 - 1) = v11;
-            if ( *(float *)&v84 == v11 )
-              ++v82;
-            pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)(v9 - 12), 1u);
-            if ( *(float *)v9 < 8.0 || (double)pOutdoorCamera->shading_dist_mist < *(float *)v9 )
-            {
-              if ( *(float *)v9 >= 8.0 )
-                v75 = 1;
-              else
-                v74 = 1;
-            }
-            else
-            {
-              pGame->pIndoorCameraD3D->Project((RenderVertexSoft *)(v9 - 12), 1u, 0);
-            }
-            v81 += 2;
-            v9 += 48;
-            --v83;
-            if ( !v83 )
-              break;
-            v5 = v67;
-          }
-          v7 = v77;
-        }
-        v12 = &array_77EC08[pOutdoorCamera->numStru148s];
-        *(int *)&v12->flags = 0;
-        if ( v82 == v7 )
-          *(int *)&v12->flags = 65536;
-        v12->pODMFace = v3;
-        v12->uNumVertices = v7;
-        v12->field_59 = 5;
-        v84 = v3->pFacePlane.vNormal.x;
-        v83 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.x) >> 16;
-        v82 = -pOutdoor->vSunlight.y;
-        v84 = v3->pFacePlane.vNormal.y;
-        v82 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.y) >> 16;
-        v81 = (unsigned __int16 *)-pOutdoor->vSunlight.z;
-        v84 = v3->pFacePlane.vNormal.z;
-        v81 = (unsigned __int16 *)((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
-        v84 = v83 + v82 + ((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
-        v13 = (double)v84 * 0.000015258789;
-        if ( v13 < 0.0 )
-          v13 = 0.0;
-        *(float *)&v84 = v13 * 31.0;
-        v14 = *(float *)&v84 + 6.7553994e15;
-        v71 = LODWORD(v14);
-        v15 = (int)&v12->dimming_level;
-        v12->dimming_level = 31 - LOBYTE(v14);
-        if ( (char)(31 - LOBYTE(v14)) < 0 )
-          *(char *)v15 = 0;
-        if ( *(char *)v15 > 31 )
-          *(char *)v15 = 31;
-        v16 = v3->uTextureID;
-        if ( BYTE1(v3->uAttributes) & 0x40 )
-          v16 = pTextureFrameTable->GetFrameTexture(v16, pEventTimer->uTotalGameTimeElapsed);
-        v17 = v16;
-        result = (BSPModel *)&pBitmaps_LOD->pTextures[v16];
-        v19 = __OFSUB__(pOutdoorCamera->numStru148s, 1999);
-        v18 = pOutdoorCamera->numStru148s - 1999 < 0;
-        v12->pTexture = (Texture *)(v17 != -1 ? (int)result : 0);
-        if ( !(v18 ^ v19) )
-          return result;
-        ++pOutdoorCamera->numStru148s;
-        ++pOutdoorCamera->field_44;
-        if ( !ODMFace::IsBackfaceCulled(v3, array_73D150, v12) )
-        {
-LABEL_71:
-          --pOutdoorCamera->numStru148s;
-          --pOutdoorCamera->field_44;
-          goto LABEL_72;
-        }
-        LOBYTE(v20) = v79;
-        v21 = a1;
-        v3->bVisible = 1;
-        v12->uBModelFaceID = v20;
-        LOWORD(v20) = (unsigned __int8)v20;
-        v12->uBModelID = v21;
-        v22 = 8 * (v20 | (v21 << 6));
-        LOBYTE(v22) = v22 | 6;
-        v12->field_50 = v22;
-        if ( v3->uAttributes & 0x10 )
-          *(int *)&v12->flags |= 2u;
-        if ( BYTE2(v3->uAttributes) & 0x40 )
-          HIBYTE(v12->flags) |= 4u;
-        v23 = v3->uAttributes;
-        if ( v23 & 4 )
-        {
-          HIBYTE(v12->flags) |= 4u;
-        }
-        else
-        {
-          if ( v23 & 0x20 )
-            HIBYTE(v12->flags) |= 8u;
-        }
-        v24 = v3->uAttributes;
-        if ( BYTE1(v24) & 8 )
-        {
-          HIBYTE(v12->flags) |= 0x20u;
-        }
-        else
-        {
-          if ( v24 & 0x40 )
-            HIBYTE(v12->flags) |= 0x10u;
-        }
-        v25 = v12->pTexture;
-        v26 = v77;
-        v27 = v25->uTextureWidth;
-        v84 = v25->uTextureHeight;
-        v28 = 1.0 / (double)v27;
-        v29 = 1.0 / (double)v84;
-        if ( v77 > 0 )
-        {
-		  v30 = v3->pTextureVIDs;
-          v31 = 0;
-          v83 = v77;
-          do
-          {
-            v32 = 1.0 / (*(float *)(v31 * 48 + 7590236) + 0.0000001);
-            memcpy(&array_50AC10[v31], &array_73D150[v31], sizeof(array_50AC10[v31]));
-            ++v31;
-            array_50A2B0[v31 + 49]._rhw = v32;
-            v84 = v12->sTextureDeltaU + *(short *)(v30 - 40);
-            array_50A2B0[v31 + 49].u = (double)v84 * v28;
-            v33 = v12->sTextureDeltaV + *(short *)v30;
-            v30 += 2;
-            v34 = v83-- == 1;
-            v84 = v33;
-            array_50A2B0[v31 + 49].v = (double)v33 * v29;
-          }
-          while ( !v34 );
-          v3 = v76;
-          v26 = v77;
-        }
-        
-        static stru154 static_sub_004789DE_stru_73C818; // idb
-        /*static bool __init_flag = false;
-        if (!__init_flag)
-        {
-          __init_flag = true;
-
-          static_sub_004789DE_byte_73C830__init_flag |= 1u;
-          stru154::stru154(&static_sub_004789DE_stru_73C818);
-        }*/
-
-        pGame->pLightmapBuilder->ApplyLights_OutdoorFace((ODMFace *)v3);
-        if ( stru_F8AD28.uNumLightsApplied <= 0 )
-        {
-          v12->field_108 = 0;
-        }
-        else
-        {
-          v35 = (BSPVertexBuffer *)(v78 - 2);
-          v12->field_108 = 1;
-
-          static_sub_004789DE_stru_73C818.GetFacePlaneAndClassify((ODMFace *)v3, v35);
-          v55 = static_sub_004789DE_stru_73C818.face_plane.vNormal.x;
-          v56 = static_sub_004789DE_stru_73C818.face_plane.vNormal.y;
-          v57 = static_sub_004789DE_stru_73C818.face_plane.vNormal.z;
-          pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, v26, (Vec3_float_ *)&v55);
-        }
-        if ( v74 )
-        {
-          v36 = sr_4250FE(v26);
-          v37 = v36;
-          if ( !v36 || (OutdoorCamera::Project(v36), v38 = sr_4254D2(v37), (v12->uNumVertices = v38) == 0) )
-            goto LABEL_71;
-          v12->_48276F_sr();
-          v39 = 0;
-          if ( (signed int)v12->uNumVertices > 0 )
-          {
-            v40 = (char *)&array_508690[0].vWorldViewProjY;
-            do
-            {
-              LODWORD(v64) = *((int *)v40 - 1);
-              v41 = v64 + 6.7553994e15;
-              v69 = LODWORD(v41);
-              dword_50B638[v39] = LODWORD(v41);
-              LODWORD(v63) = *(int *)v40;
-              v42 = v63 + 6.7553994e15;
-              v73 = LODWORD(v42);
-              v40 += 48;
-              dword_50B570[v39++] = LODWORD(v42);
-            }
-            while ( v39 < (signed int)v12->uNumVertices );
-          }
-        }
-        else
-        {
-          if ( v75 )
-          {
-            v43 = sr_4252E8(v26);
-            v44 = v43;
-            if ( !v43 || (OutdoorCamera::Project(v43), v45 = sr_4254D2(v44), (v12->uNumVertices = v45) == 0) )
-              goto LABEL_71;
-            v12->_48276F_sr();
-            v46 = 0;
-            if ( (signed int)v12->uNumVertices > 0 )
-            {
-              v47 = (char *)&array_508690[0].vWorldViewProjY;
-              do
-              {
-                LODWORD(v61) = *((int *)v47 - 1);
-                v48 = v61 + 6.7553994e15;
-                v65 = LODWORD(v48);
-                dword_50B638[v46] = LODWORD(v48);
-                LODWORD(v58) = *(int *)v47;
-                v49 = v58 + 6.7553994e15;
-                v59 = LODWORD(v49);
-                v47 += 48;
-                dword_50B570[v46++] = LODWORD(v49);
-              }
-              while ( v46 < (signed int)v12->uNumVertices );
-            }
-          }
-          else
-          {
-            v50 = sr_4254D2(v26);
-            v12->uNumVertices = v50;
-            if ( !v50 )
-              goto LABEL_71;
-            sr_sub_4829B9(
-              &array_73D150[v3->uGradientVertex1],
-              &array_73D150[v3->uGradientVertex2],
-              &array_73D150[v3->uGradientVertex3],
-              v12,
-              0);
-            v51 = 0;
-            if ( (signed int)v12->uNumVertices > 0 )
-            {
-              v52 = (char *)&array_508690[0].vWorldViewProjY;
-              do
-              {
-                LODWORD(v62) = *((int *)v52 - 1);
-                v53 = v62 + 6.7553994e15;
-                v60 = LODWORD(v53);
-                dword_50B638[v51] = LODWORD(v53);
-                LODWORD(v72) = *(int *)v52;
-                v54 = v72 + 6.7553994e15;
-                v70 = LODWORD(v54);
-                v52 += 48;
-                dword_50B570[v51++] = LODWORD(v54);
-              }
-              while ( v51 < (signed int)v12->uNumVertices );
-            }
-          }
-        }
-        sr_sub_486B4E_push_outdoor_edges(array_508690, dword_50B638.data(), dword_50B570.data(), v12);
-      }
-LABEL_72:
-      ++v79;
-      v1 = v78;
-      ++v3;
-      v76 = v3;
-      if ( v79 >= v68 )
-        goto LABEL_73;
-    }
-  }
-  return result;
-}
-// 50B570: using guessed type int dword_50B570[];
-// 50B638: using guessed type int dword_50B638[];
-// 73C830: using guessed type char static_sub_004789DE_byte_73C830__init_flag;
 
 //----- (00479089) --------------------------------------------------------
 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable)
@@ -5339,9 +4892,8 @@
 }
 
 //----- (00479295) --------------------------------------------------------
-int stru148::_479295()
+int Polygon::_479295()
 {
-  stru148 *v1; // edi@1
   ODMFace *v2; // esi@1
   int v3; // ecx@4
   int v4; // eax@4
@@ -5352,7 +4904,6 @@
   Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8
   int v11; // [sp+18h] [bp-4h]@4
 
-  v1 = this;
   v2 = this->pODMFace;
   if ( !v2->pFacePlane.vNormal.z )
   {
@@ -5379,105 +4930,14 @@
   v5 = -65536;
 LABEL_5:
   v6 = v11;
-  v1->sTextureDeltaU = v2->sTextureDeltaU;
+  sTextureDeltaU = v2->sTextureDeltaU;
   v7 = v3;
-  v8 = v1->ptr_38;
-  v1->sTextureDeltaV = v2->sTextureDeltaV;
+  v8 = ptr_38;
+  sTextureDeltaV = v2->sTextureDeltaV;
   v8->_48616B(v4, v7, 0, 0, v5, v6);
   return 1;
 }
 
-//----- (00479332) --------------------------------------------------------
-int Render::OnOutdoorRedrawSW()
-{
-  signed int result; // eax@1
-  unsigned int v1; // edi@1
-  char *v2; // esi@2
-  char v3; // cl@3
-  double v4; // st7@4
-  float v5; // ST34_4@6
-  double v6; // ST24_8@6
-  int v7; // eax@6
-  unsigned int v8; // eax@11
-  signed int v9; // eax@13
-  Vec3_float_ *v10; // eax@14
-  double v11; // st7@17
-  float v12; // ST34_4@19
-  double v13; // ST1C_8@19
-  float v14; // [sp+4h] [bp-34h]@1
-  float v15; // [sp+8h] [bp-30h]@1
-  float v16; // [sp+Ch] [bp-2Ch]@1
-
-  v14 = (double)pOutdoor->vSunlight.x / 65536.0;
-  result = 0;
-  v1 = (unsigned int)&array_77EC08[pOutdoorCamera->numStru148s];
-  v15 = (double)pOutdoor->vSunlight.y / 65536.0;
-  v16 = (double)pOutdoor->vSunlight.z / 65536.0;
-  if ( v1 > (unsigned int)array_77EC08.data() )
-  {
-    v2 = (char *)&array_77EC08[0].pODMFace;
-    while ( 1 )
-    {
-      v3 = v2[5];
-      if ( v3 == 5 )
-        break;
-      if ( v3 == 1 )
-      {
-        v9 = pTerrainNormalIndices[((*((int *)v2 - 9) >> 15) & 1)
-                                 + 2 * ((unsigned __int8)v2[9] + ((unsigned __int8)v2[8] << 7))];
-        if ( v9 > (signed int)(uNumTerrainNormals - 1) )
-          v10 = 0;
-        else
-          v10 = &pTerrainNormals[v9];
-        if ( v10 )
-        {
-          v11 = -(v16 * v10->z + v15 * v10->y + v14 * v10->x);
-          if ( v11 < 0.0 )
-            v11 = 0.0;
-          v12 = v11 * 31.0;
-          v13 = v12 + 6.7553994e15;
-          v2[4] = 31 - LOBYTE(v13);
-        }
-        else
-        {
-          v2[4] = 0;
-        }
-        if ( v2[4] < 0 )
-          v2[4] = 0;
-        goto LABEL_23;
-      }
-LABEL_24:
-      v2 += 268;
-      if ( (unsigned int)(v2 - 84) >= v1 )
-        return result;
-    }
-    v4 = (double)(signed int)(((unsigned __int64)(**(int **)v2 * (signed __int64)-pOutdoor->vSunlight.x) >> 16)
-                            + ((unsigned __int64)(*(int *)(*(int *)v2 + 4) * (signed __int64)-pOutdoor->vSunlight.y) >> 16)
-                            + ((unsigned __int64)(*(int *)(*(int *)v2 + 8) * (signed __int64)-pOutdoor->vSunlight.z) >> 16))
-       * 0.000015258789;
-    if ( v4 < 0.0 )
-      v4 = 0.0;
-    v5 = v4 * 31.0;
-    v6 = v5 + 6.7553994e15;
-    v7 = (int)(v2 + 4);
-    v2[4] = 31 - LOBYTE(v6);
-    if ( (char)(31 - LOBYTE(v6)) < 0 )
-      *(char *)v7 = 0;
-    if ( *(char *)v7 > 31 )
-      *(char *)v7 = 31;
-    if ( *(char *)(*(int *)v2 + 29) & 0x40 )
-    {
-      v8 = pTextureFrameTable->GetFrameTexture(
-             *((short *)v2 - 4),
-             pEventTimer->uTotalGameTimeElapsed);
-      *((int *)v2 - 6) = v8 != -1 ? (int)&pBitmaps_LOD->pTextures[v8] : 0;
-    }
-LABEL_23:
-    result = 1;
-    goto LABEL_24;
-  }
-  return result;
-}
 
 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr)
 {
@@ -5969,7 +5429,7 @@
   int v16; // eax@12
   signed __int64 v17; // qtt@13
   signed int pShading; // ecx@13
-  stru148 pSky; // [sp+14h] [bp-150h]@1
+  struct Polygon pSky; // [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
@@ -6032,7 +5492,7 @@
   //--------------------------------------------------------------------------
 
   //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;
@@ -6142,431 +5602,6 @@
   //}
 }
 
-//----- (00479A53) --------------------------------------------------------
-void __fastcall _479A53_draw_some_blv_poly(unsigned int uNumVertices, unsigned int uFaceID)
-{
-  BLVFace *pFace; // esi@1
-  unsigned int v3; // edi@1
-  PolygonType v4; // al@1
-  double v5; // st7@3
-  signed __int64 v6; // qax@3
-  PolygonType v7; // cl@3
-  int v8; // esi@7
-  int v9; // eax@7
-  unsigned int v10; // eax@7
-  double v11; // st6@7
-  int v12; // edx@7
-  int v13; // eax@7
-  char *v14; // esi@8
-  void *v15; // ecx@9
-  int v16; // eax@9
-  int v17; // edi@9
-  double v18; // st7@9
-  signed int v19; // ebx@9
-  void *v20; // ecx@9
-  int v21; // ebx@11
-  int v22; // eax@14
-  signed __int64 v23; // qtt@16
-  double v24; // st7@16
-  unsigned __int8 v25; // sf@16
-  unsigned __int8 v26; // of@16
-  Render *v27; // ecx@17
-  double v28; // st7@20
-  char *v29; // ebx@20
-  char *v30; // edx@20
-  unsigned __int8 v31; // c0@21
-  unsigned __int8 v32; // c3@21
-  double v33; // st6@23
-  char *v34; // esi@30
-  const void *v35; // ecx@31
-  int v36; // eax@31
-  const void *v37; // edi@31
-  signed __int64 v38; // qax@31
-  int v39; // ecx@31
-  int v40; // ebx@33
-  int v41; // eax@36
-  signed __int64 v42; // qtt@39
-  int v43; // eax@39
-  char v44; // zf@39
-  double v45; // st7@39
-  double v46; // st7@39
-  unsigned int v47; // edx@40
-  double v48; // st7@41
-  RenderVertexSoft *v49; // ebx@41
-  void *v50; // edi@43
-  double v51; // st7@46
-  RenderVertexSoft *v52; // edx@46
-  void *v53; // edi@48
-  char *v54; // ebx@52
-  unsigned int v55; // eax@53
-  unsigned int v56; // eax@55
-  int v57; // ST10_4@55
-  Texture *v58; // eax@55
-  signed int v59; // [sp-4h] [bp-178h]@17
-  stru148 *v60; // [sp+0h] [bp-174h]@17
-  IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17
-  stru148 v62; // [sp+14h] [bp-160h]@6
-  unsigned int v63; // [sp+120h] [bp-54h]@7
-  double v64; // [sp+124h] [bp-50h]@7
-  unsigned int v65; // [sp+128h] [bp-4Ch]@1
-  unsigned int v66; // [sp+12Ch] [bp-48h]@7
-  float v67; // [sp+130h] [bp-44h]@7
-  __int64 v68; // [sp+134h] [bp-40h]@3
-  __int64 v69; // [sp+13Ch] [bp-38h]@3
-  int v70; // [sp+144h] [bp-30h]@3
-  int X; // [sp+148h] [bp-2Ch]@9
-  int v72; // [sp+14Ch] [bp-28h]@7
-  float v73; // [sp+150h] [bp-24h]@16
-  unsigned int v74; // [sp+154h] [bp-20h]@3
-  RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3
-  float v76; // [sp+15Ch] [bp-18h]@9
-  int v77; // [sp+160h] [bp-14h]@9
-  int v78; // [sp+164h] [bp-10h]@7
-  void *v79; // [sp+168h] [bp-Ch]@9
-  float v80; // [sp+16Ch] [bp-8h]@3
-  const void *v81; // [sp+170h] [bp-4h]@7
-
-  __debugbreak();
-
-  pFace = &pIndoor->pFaces[uFaceID];
-  v65 = uFaceID;
-  v3 = uNumVertices;
-  v4 = pFace->uPolygonType;
-  if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor )
-  {
-    if ( (signed int)uNumVertices > 0 )
-    {
-      v54 = (char *)&array_507D30[0].u;
-      LODWORD(v80) = uNumVertices;
-      do
-      {
-        v69 = (GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x;
-        *(float *)v54 = (double)v69 + *(float *)v54;
-        *(float *)v54 = *(float *)v54 * 0.25;
-        v55 = GetTickCount();
-        v54 += 48;
-        v44 = LODWORD(v80)-- == 1;
-        v68 = pBLVRenderParams->vPartyPos.y + (v55 >> 5);
-        *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25;
-      }
-      while ( !v44 );
-      uFaceID = v65;
-    }
-    v56 = 8 * uFaceID;
-    LOBYTE(v56) = PID(OBJECT_BModel,uFaceID);
-    v57 = v56;
-    v58 = pFace->GetTexture();
-    pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0);
-    return;
-  }
-  HIDWORD(v69) = pIndoorCamera->sRotationX;
-  HIDWORD(v68) = pIndoorCamera->pos.z;
-  *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY;
-  v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z)
-                       / (((double)pBLVRenderParams->field_40 + 16192.0)
-                        * 65536.0)
-                       + *(float *)&v74);
-  v5 = (double)pIndoorCamera->sRotationX * 0.0030664064;
-  *(float *)&v75 = v5;
-  v80 = cos(v5) * 16192.0;
-  v6 = (signed __int64)(*(float *)&v74
-                      - (double)pBLVRenderParams->field_40
-                      / ((v80 + 0.0000001)
-                       * 65535.0)
-                      * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68)));
-  v7 = pFace->uPolygonType;
-  if ( v7 == 4 || v7 == 3 )
-    v70 = v6;
-  stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0);
-  v62._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 )
-    return;
-  v8 = pBLVRenderParams->sPartyRotX;
-  v62.dimming_level = 0;
-  v62.uNumVertices = v3;
-  v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX + 16);
-  v62.v_18.y = 0;
-  v62.v_18.x = -v9;
-  v62.v_18.z = -stru_5C6E00->Cos(v8 + 16);
-  v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX;
-  memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3]));
-  LODWORD(v80) = v10;
-  v62.field_24 = 33554432;
-  v64 = (double)(signed int)v10 * 0.5;
-  v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
-  LODWORD(v80) = v62.pTexture->uTextureWidth;
-  v11 = 1.0 / (double)SLODWORD(v80);
-  LODWORD(v80) = v62.pTexture->uTextureHeight;
-  v12 = v62.pTexture->uWidthMinus1;
-  v13 = v62.pTexture->uHeightMinus1;
-  v67 = v11;
-  v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
-  v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
-  v78 = 0;
-  v81 = 0;
-  *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80);
-  if ( (signed int)v62.uNumVertices <= 0 )
-  {
-LABEL_17:
-    v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID];
-    v27 = pRenderer;
-    v60 = &v62;
-    v59 = v62.uNumVertices;
-    goto LABEL_18;
-  }
-  v14 = (char *)&array_507D30[0].vWorldViewProjY;
-  while ( 2 )
-  {
-    v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14));
-    LODWORD(v80) = v62.ptr_38->field_14;
-    v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
-    v16 = v77 + v62.ptr_38->field_C;
-    v77 = (int)v15;
-    v74 = v16;
-    LODWORD(v80) = v62.ptr_38->field_20;
-    v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
-    v79 = v15;
-    v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18);
-    LODWORD(v80) = v62.v_18.z;
-    v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16);
-    v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1));
-    v18 = *(float *)v14 - 1.0;
-    v19 = -v62.field_24;
-    v77 = -v62.field_24;
-    X = (int)((char *)v79 + v62.v_18.x);
-    LODWORD(v76) = (signed __int64)v18;
-    v20 = (void *)(v72 * (v70 - LODWORD(v76)));
-    while ( 1 )
-    {
-      v79 = v20;
-      if ( !X )
-        goto LABEL_14;
-      v21 = abs(v19 >> 14);
-      if ( v21 <= abs(X) )
-        break;
-      if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
-        break;
-      v19 = v77;
-      v20 = v79;
-LABEL_14:
-      LODWORD(v80) = v62.v_18.z;
-      v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16);
-      v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16;
-      --LODWORD(v76);
-      v20 = (char *)v20 + v72;
-      X = v22 + v62.v_18.x;
-      v78 = 1;
-    }
-    if ( !v78 )
-    {
-      LODWORD(v23) = v77 << 16;
-      HIDWORD(v23) = v77 >> 16;
-      v79 = (void *)(v23 / X);
-      v77 = v17;
-      LODWORD(v80) = v62.ptr_38->field_10;
-      v77 = v17;
-      LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16);
-      LODWORD(v80) = v62.ptr_38->field_1C;
-      v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16));
-      v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16;
-      LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16;
-      v14 += 48;
-      LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4);
-      v81 = (char *)v81 + 1;
-      v24 = (double)SLODWORD(v80) * 0.000015259022;
-      LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4);
-      v26 = __OFSUB__((int)v81, v62.uNumVertices);
-      v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0;
-      *((float *)v14 - 10) = v24 * v67;
-      *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1);
-      *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79;
-      if ( !(v25 ^ v26) )
-        goto LABEL_17;
-      continue;
-    }
-    break;
-  }
-  LODWORD(v73) = 0;
-  v80 = v76;
-  if ( (signed int)v62.uNumVertices > 0 )
-  {
-    v28 = (double)SLODWORD(v76);
-    LODWORD(v76) = (int)(char *)array_50AC10 + 28;
-    v29 = (char *)&array_50AC10[0].vWorldViewProjX;
-    v30 = (char *)&array_507D30[1].vWorldViewProjY;
-    v79 = array_50AC10;
-    v81 = array_507D30;
-    v78 = v62.uNumVertices;
-    do
-    {
-      v31 = v28 < *((float *)v30 - 12);
-      v32 = v28 == *((float *)v30 - 12);
-      ++LODWORD(v73);
-      memcpy(v79, v81, 0x30u);
-      v79 = (char *)v79 + 48;
-      LODWORD(v76) += 48;
-      v29 += 48;
-      if ( v31 | v32 || v28 >= *(float *)v30 )
-      {
-        if ( v28 >= *((float *)v30 - 12) || v28 <= *(float *)v30 )
-          goto LABEL_28;
-        v33 = (*((float *)v30 - 1) - *((float *)v30 - 13)) * v28 / (*(float *)v30 - *((float *)v30 - 12))
-            + *((float *)v30 - 1);
-      }
-      else
-      {
-        v33 = (*((float *)v30 - 13) - *((float *)v30 - 1)) * v28 / (*((float *)v30 - 12) - *(float *)v30)
-            + *((float *)v30 - 13);
-      }
-      *(float *)v29 = v33;
-      v79 = (char *)v79 + 48;
-      v29 += 48;
-      ++LODWORD(v73);
-      *(unsigned int *)LODWORD(v76) = v28;
-      LODWORD(v76) += 48;
-LABEL_28:
-      v81 = (char *)v81 + 48;
-      v30 += 48;
-      --v78;
-    }
-    while ( v78 );
-  }
-  if ( SLODWORD(v73) <= 0 )
-    goto LABEL_40;
-  v34 = (char *)&array_50AC10[0].vWorldViewProjY;
-  v65 = v77 >> 14;
-  HIDWORD(v69) = LODWORD(v73);
-  do
-  {
-    v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34));
-    v78 = v62.ptr_38->field_14;
-    v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
-    v36 = (int)((char *)v81 + v62.ptr_38->field_C);
-    v81 = v35;
-    v74 = v36;
-    v78 = v62.ptr_38->field_20;
-    v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
-    v78 = (int)v35;
-    v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18);
-    v81 = (const void *)v62.v_18.z;
-    v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16;
-    v37 = (const void *)(v72
-                       * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1)));
-    v38 = (signed __int64)(*(float *)v34 - 1.0);
-    v81 = 0;
-    LODWORD(v76) = v38;
-    v39 = v72 * (v70 - v38);
-    while ( 1 )
-    {
-      v78 = v39;
-      if ( !X )
-        goto LABEL_36;
-      v40 = abs(X);
-      if ( abs((signed __int64)v65) <= v40 )
-        break;
-      if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
-        break;
-      v39 = v78;
-LABEL_36:
-      v78 = v62.v_18.z;
-      v41 = (unsigned __int64)(v62.v_18.z * (signed __int64)v39) >> 16;
-      --LODWORD(v76);
-      v39 += v72;
-      X = v41 + v62.v_18.x;
-      v81 = (const void *)1;
-    }
-    if ( v81 )
-    {
-      v79 = (void *)v62.v_18.z;
-      v78 = 2 * LODWORD(v76);
-      v81 = (const void *)((unsigned __int64)(v62.v_18.z
-                                            * (signed __int64)(signed int)(signed __int64)(((double)v70
-                                                                                          - ((double)(2 * LODWORD(v76))
-                                                                                           - *(float *)v34))
-                                                                                         * (double)v72)) >> 16);
-      X = (int)((char *)v81 + v62.v_18.x);
-    }
-    LODWORD(v42) = v77 << 16;
-    HIDWORD(v42) = v77 >> 16;
-    v79 = (void *)(v42 / X);
-    v81 = v37;
-    v78 = v62.ptr_38->field_10;
-    v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
-    v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
-    v74 = (unsigned int)v37;
-    LODWORD(v76) = v43;
-    v78 = v62.ptr_38->field_1C;
-    v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16));
-    v74 = (unsigned __int64)(v43 * v42 / X) >> 16;
-    v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16);
-    v34 += 48;
-    v78 = v66 + ((signed int)v74 >> 4);
-    v44 = HIDWORD(v69)-- == 1;
-    v45 = (double)v78 * 0.000015259022;
-    v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4);
-    *((float *)v34 - 10) = v45 * v67;
-    *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1);
-    v46 = (double)(signed int)v79;
-    *((float *)v34 - 16) = 0.000015258789 * v46;
-    *((float *)v34 - 11) = 65536.0 / v46;
-  }
-  while ( !v44 );
-LABEL_40:
-  v47 = 0;
-  if ( SLODWORD(v73) > 0 )
-  {
-    v48 = (double)SLODWORD(v80);
-    v75 = array_507D30;
-    v49 = array_50AC10;
-    HIDWORD(v69) = LODWORD(v73);
-    do
-    {
-      if ( v48 >= v49->vWorldViewProjY )
-      {
-        v50 = v75;
-        ++v47;
-        ++v75;
-        memcpy(v50, v49, 0x30u);
-      }
-      ++v49;
-      --HIDWORD(v69);
-    }
-    while ( HIDWORD(v69) );
-  }
-  v62.uNumVertices = v47;
-  pRenderer->_4A2ED5(v47, &v62, pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]);
-  *(float *)&v74 = 0.0;
-  if ( SLODWORD(v73) > 0 )
-  {
-    v51 = (double)SLODWORD(v80);
-    v75 = array_507D30;
-    v52 = array_50AC10;
-    v80 = v73;
-    do
-    {
-      if ( v51 <= v52->vWorldViewProjY )
-      {
-        v53 = v75;
-        ++v74;
-        ++v75;
-        memcpy(v53, v52, 0x30u);
-      }
-      ++v52;
-      --LODWORD(v80);
-    }
-    while ( v80 != 0.0 );
-  }
-  v62.uNumVertices = v74;
-  v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID];
-  v60 = &v62;
-  v59 = v74;
-  v27 = pRenderer;
-LABEL_18:
-  v27->_4A2ED5(v59, v60, v61);
-}
-
 //----- (0047A384) --------------------------------------------------------
 void ODM_LoadAndInitialize(const char *pLevelFilename, OutdoorCamera *thisa)
 {
@@ -6811,322 +5846,6 @@
   v7 = 0;
   return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1);
 }
-// 6BE030: using guessed type int day_attrib;
-// 6BE040: using guessed type int day_fogrange_1;
-// 6BE044: using guessed type int day_fogrange_2;
-
-//----- (0047BEB1) --------------------------------------------------------
-int __fastcall sr_sub_47BEB1(signed int a1, stru148 *a2, int terrain_gamma, int a4, int *a5, int *a6, int a7, int a8)
-{
-  stru148 *v8; // ebx@1
-  signed int v9; // edx@1
-  int v10; // eax@5
-  signed int v11; // eax@9
-  signed int v12; // eax@15
-  signed __int64 v13; // qtt@21
-  int *v14; // ecx@30
-  int *v15; // edi@30
-  int v16; // ebx@32
-  signed __int64 v17; // qtt@37
-  double v18; // ST10_8@37
-  double v19; // ST10_8@38
-  int v20; // edi@39
-  int result; // eax@46
-  int *v22; // eax@48
-  signed int v23; // edx@51
-  signed __int64 v24; // qtt@51
-  int v25; // ecx@51
-  signed int v26; // [sp+14h] [bp-4h]@1
-  float v27; // [sp+28h] [bp+10h]@37
-  float v28; // [sp+28h] [bp+10h]@38
-  int v29; // [sp+2Ch] [bp+14h]@37
-
-  v8 = a2;
-  v9 = a1;
-  v26 = a1;
-  if ( pParty->armageddon_timer )
-  {
-    *a5 = -1;
-    *a6 = -1;
-    *(char *)a7 = 1;
-LABEL_46:
-    result = a8;
-    *(char *)a8 = 0;
-    return result;
-  }
-  if ( a1 < 0 )
-  {
-    v26 = v8->field_34 << 16;
-    v9 = v8->field_34 << 16;
-  }
-  v10 = pWeather->bNight;
-  if ( bUnderwater == 1 )
-    v10 = 0;
-  if ( !v10 )
-  {
-    if ( !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater )
-    {
-      v14 = a5;
-      v15 = a6;
-      if ( !v9 )
-      {
-        *a5 = 31;
-        *a6 = -1;
-      }
-      v16 = v8->dimming_level - terrain_gamma;
-      if ( v16 >= 0 )
-      {
-        if ( v16 > 27 )
-          v16 = 27;
-      }
-      else
-      {
-        v16 = 0;
-      }
-      *a6 = 27;
-      if ( a4 )
-      {
-        v28 = pOutdoor->fFogDensity * 27.0;
-        v19 = v28 + 6.7553994e15;
-        v29 = LODWORD(v19);
-      }
-      else
-      {
-        LODWORD(v17) = v9 << 16;
-        HIDWORD(v17) = v9 >> 16;
-        v27 = (double)(signed int)(((unsigned __int64)(v17 / (pOutdoorCamera->shading_dist_shade << 16) * (31 - *a6)) >> 16)
-                                 + *a6)
-            * pOutdoor->fFogDensity;
-        v18 = v27 + 6.7553994e15;
-        v29 = LODWORD(v18);
-      }
-      *v14 = v16 + v29;
-      v20 = *v15;
-      if ( v16 + v29 > v20 )
-        *v14 = v20;
-      if ( *v14 < v16 )
-        *v14 = v16;
-      if ( *v14 > pOutdoor->max_terrain_dimming_level )
-        *v14 = pOutdoor->max_terrain_dimming_level;
-      goto LABEL_45;
-    }
-    if ( v9 >= day_fogrange_1 << 16 )
-    {
-      if ( v9 <= day_fogrange_2 << 16 )
-      {
-        v23 = v9 - (day_fogrange_1 << 16);
-        LODWORD(v24) = v23 << 16;
-        HIDWORD(v24) = v23 >> 16;
-        v25 = (unsigned __int64)(27 * v24 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16;
-        v22 = a5;
-        *a5 = v25;
-        if ( v25 > 27 )
-          goto LABEL_54;
-        v9 = v26;
-      }
-      else
-      {
-        v22 = a5;
-        *a5 = 27;
-      }
-    }
-    else
-    {
-      v22 = a5;
-      *a5 = 0;
-    }
-    if ( v9 )
-    {
-LABEL_55:
-      if ( a4 )
-        *v22 = 31;
-      *a6 = 31;
-      *(char *)a7 = 0;
-      goto LABEL_59;
-    }
-LABEL_54:
-    *v22 = 27;
-    goto LABEL_55;
-  }
-  if ( v10 == 1 )
-  {
-    v11 = 1;
-    if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x10 )
-    {
-      v12 = 0;
-    }
-    else
-    {
-      if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 )
-      {
-        if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime <= 0 )
-          v11 = 0;
-        else
-          v11 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower;
-      }
-      v12 = v11 << 26;
-    }
-    if ( a4 )
-      goto LABEL_24;
-    if ( v9 <= v12 )
-    {
-      if ( v9 > 0 )
-      {
-        LODWORD(v13) = v9 << 16;
-        HIDWORD(v13) = v9 >> 16;
-        v9 = v26;
-        *a5 = (unsigned __int64)(27 * v13 / v12) >> 16;
-      }
-      if ( *a5 > 27 )
-        goto LABEL_24;
-    }
-    else
-    {
-      *a5 = 27;
-    }
-    if ( v9 )
-    {
-LABEL_25:
-      if ( v8->field_32 & 4 )
-        *a5 = 27;
-      *a6 = 27;
-LABEL_45:
-      *(char *)a7 = 0;
-      goto LABEL_46;
-    }
-LABEL_24:
-    *a5 = 27;
-    goto LABEL_25;
-  }
-  *a5 = -1;
-  *a6 = -1;
-  *(char *)a7 = 1;
-LABEL_59:
-  result = a8;
-  *(char *)a8 = 1;
-  return result;
-}
-
-//----- (0047C178) --------------------------------------------------------
-void *__fastcall sr_sub_47C178(signed int a1, stru148 *a2, int terrain_gamma, int a4)
-{
-  stru148 *v4; // esi@1
-  void *result; // eax@2
-  int v6; // [sp+4h] [bp-8h]@3
-  int v7; // [sp+8h] [bp-4h]@3
-
-  v4 = a2;
-  if ( pParty->armageddon_timer )
-  {
-    result = PaletteManager::Get(a2->pTexture->palette_id2);
-  }
-  else
-  {
-    sr_sub_47BEB1(a1, a2, terrain_gamma, a4, &v6, &v7, (int)((char *)&terrain_gamma + 3), (int)((char *)&a4 + 3));
-    result = sr_sub_47C1CA(v4, SBYTE3(a4), v6, v7);
-  }
-  return result;
-}
-
-//----- (0047C1CA) --------------------------------------------------------
-void *__fastcall sr_sub_47C1CA(stru148 *a1, char a2, int a3, signed int a4)
-{
-  stru148 *v4; // esi@1
-  void *result; // eax@2
-  int v6; // edx@3
-  int v7; // ecx@8
-  int a3a; // [sp+4h] [bp-8h]@1
-  char v9; // [sp+8h] [bp-4h]@1
-
-  v9 = a2;
-  v4 = a1;
-  a3a = 1;
-  if ( pParty->armageddon_timer )
-  {
-    result = PaletteManager::Get(a1->pTexture->palette_id2);
-  }
-  else
-  {
-    v6 = pGame->_44EC23(a1, &a3a, a4);
-    if ( v6 == -1 )
-      v6 = a3;
-    if ( v9 == 1 )
-    {
-      if ( v6 != -1 || a4 != -1 )
-      {
-        v7 = v4->pTexture->palette_id2;
-      }
-      else
-      {
-        v6 = 0;
-        v7 = 0;
-      }
-      result = PaletteManager::Get_Mist_or_Red_LUT(v7, v6, a3a);
-    }
-    else
-    {
-      result = PaletteManager::Get_Dark_or_Red_LUT(v4->pTexture->palette_id2, v6, a3a);
-    }
-  }
-  return result;
-}
-
-//----- (0047C24C) --------------------------------------------------------
-unsigned __int16 *__fastcall sr_sub_47C24C_get_palette(BLVFace *a1, int a2, int a3, char a4)
-{
-  int v4; // esi@1
-  int v5; // eax@2
-  int a3a; // [sp+4h] [bp-4h]@1
-
-  v4 = a2;
-  a3a = 1;
-  if ( a4 )
-  {
-    v5 = pGame->_44ED0A(a1, &a3a, 31);
-    if ( v5 != -1 )
-      a3 = v5;
-  }
-  return PaletteManager::Get_Dark_or_Red_LUT(v4, a3, a3a);
-}
-
-//----- (0047C28C) --------------------------------------------------------
-char *__fastcall sr_sub_47C28C_get_palette(stru148 *a1, char a2, signed int a3, signed int a4)
-{
-  stru148 *v4; // esi@1
-  char *result; // eax@2
-  signed int v6; // eax@3
-  int v7; // ecx@8
-  int a2a; // [sp+4h] [bp-8h]@1
-  char v9; // [sp+8h] [bp-4h]@1
-
-  v9 = a2;
-  v4 = a1;
-  a2a = 1;
-  if ( pParty->armageddon_timer )
-  {
-    result = (char *)pPaletteManager->field_199600_palettes[a1->pTexture->palette_id2];
-  }
-  else
-  {
-    v6 = pGame->_44EC23(a1, &a2a, a4);
-    if ( v6 != -1 )
-      a3 = v6;
-    if ( v9 == 1 )
-    {
-      if ( a3 != -1 || a4 != -1 )
-        v7 = v4->pTexture->palette_id2;
-      else
-        v7 = 0;
-      result = (char *)PaletteManager::_47C30E_get_palette(v7, a2a);
-    }
-    else
-    {
-      result = (char *)PaletteManager::_47C33F_get_palette(v4->pTexture->palette_id2, a2a);
-    }
-  }
-  return result;
-}
-// 4D864C: using guessed type char byte_4D864C;
 
 //----- (0047C370) --------------------------------------------------------
 unsigned int __cdecl GetLevelFogColor()
@@ -7445,7 +6164,7 @@
 }
 
 //----- (004811A3) --------------------------------------------------------
-void stru148::DrawBorderTiles()
+void Polygon::DrawBorderTiles()
 {
   //__debugbreak();
 
@@ -7457,52 +6176,15 @@
   //pRenderer->DrawTerrainPolygon(uNumVertices, this, pBitmaps_LOD->pHardwareTextures[uTileBitmapID], true, true);
 }
 
-//----- (00481DB2) --------------------------------------------------------
-char __fastcall sr_sub_481DB2(RenderVertexSoft *a1, signed int a2, stru148 *a3)
-{
-  int v3; // eax@2
-  int v4; // esi@2
-  signed int v5; // esi@2
-  char *v6; // edi@3
-  double v7; // ST14_8@4
-  double v8; // ST0C_8@4
-  char result; // al@5
-
-  if ( a2 >= 3 )
-  {
-    v3 = a3->uTileBitmapID;
-    v4 = a3->uTileBitmapID;
-    a3->ptr_38 = &stru_8019C8;
-    a3->pTexture = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0);
-    v5 = 0;
-    if ( (signed int)a3->uNumVertices > 0 )
-    {
-      v6 = (char *)&array_508690[0].vWorldViewProjY;
-      do
-      {
-        v7 = *((float *)v6 - 1) + 6.7553994e15;
-        dword_50B638[v5] = LODWORD(v7);
-        v8 = *(float *)v6 + 6.7553994e15;
-        v6 += 48;
-        dword_50B570[v5++] = LODWORD(v8);
-      }
-      while ( v5 < (signed int)a3->uNumVertices );
-    }
-    result = sr_sub_486B4E_push_outdoor_edges(a1, dword_50B638.data(), dword_50B570.data(), a3);
-  }
-  return result;
-}
-// 50B570: using guessed type int dword_50B570[];
-// 50B638: using guessed type int dword_50B638[];
 
 //----- (00481EB7) --------------------------------------------------------
-void __cdecl ResetStru148s()
+void __cdecl ResetPolygons()
 {
   int v0; // ecx@1
   char *v1; // eax@2
 
-  v0 = pOutdoorCamera->numStru148s;
-  if ( pOutdoorCamera->numStru148s > 0 )
+  v0 = pOutdoorCamera->uNumPolygons;
+  if ( pOutdoorCamera->uNumPolygons > 0 )
   {
     v1 = (char *)&array_77EC08[0].prolly_tail;
     do
@@ -7521,7 +6203,7 @@
 void __cdecl sub_481ED9_MessWithOutdoorCamera()
 {
   stru_8019C8._48616B(65536, 0, 0, 0, 65536, 0);
-  pOutdoorCamera->numStru148s = 0;
+  pOutdoorCamera->uNumPolygons = 0;
   pOutdoorCamera->uNumEdges = 0;
   pOutdoorCamera->uNumSpans = 0;
   pOutdoorCamera->uNumSurfs = 0;
@@ -7561,7 +6243,7 @@
 }
 
 //----- (00481FC9) --------------------------------------------------------
-int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4)//Rotate camera
+int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera
 {
   float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14;
 
@@ -7761,2602 +6443,18 @@
     return y_x1z1;
 }
 
-//----- (0048276F) --------------------------------------------------------
-void stru148::_48276F_sr()
-{
-  unsigned int v1; // ebx@1
-  float v2; // edx@2
-  double v3; // st7@2
-  char *v4; // ecx@3
-  float v5; // eax@5
-  float v6; // eax@7
-  float v7; // eax@9
-  float v8; // ecx@13
-  int i; // eax@16
-  int v10; // edx@20
-  RenderVertexSoft *v11; // ecx@22
-  RenderVertexSoft *v12; // edx@22
-  RenderVertexSoft *v13; // esi@22
-  int v14; // ebx@26
-  RenderVertexSoft *v15; // ebx@27
-  double v16; // st6@28
-  double v17; // st5@28
-  double v18; // st4@28
-  int v19; // [sp+4h] [bp-2Ch]@20
-  int v20; // [sp+8h] [bp-28h]@22
-  int v21; // [sp+Ch] [bp-24h]@22
-  stru148 *v22; // [sp+10h] [bp-20h]@1
-  float v23; // [sp+14h] [bp-1Ch]@11
-  float v24; // [sp+18h] [bp-18h]@7
-  float v25; // [sp+1Ch] [bp-14h]@5
-  float v26; // [sp+20h] [bp-10h]@2
-  float v27; // [sp+24h] [bp-Ch]@2
-  float v28; // [sp+28h] [bp-8h]@2
-  float v29; // [sp+2Ch] [bp-4h]@9
-
-  v1 = this->uNumVertices;
-  v22 = this;
-  if ( (signed int)v1 >= 3 )
-  {
-    LODWORD(v2) = 0;
-    v26 = 10000.0;
-    v28 = 10000.0;
-    v3 = -10000.0;
-    v27 = -10000.0;
-    if ( (signed int)v1 > 0 )
-    {
-      v4 = (char *)&array_508690[0].vWorldViewProjY;
-      do
-      {
-        if ( *((float *)v4 - 1) < (double)v26 )
-        {
-          LODWORD(v5) = *((int *)v4 - 1);
-          v25 = v2;
-          v26 = v5;
-        }
-        if ( *((float *)v4 - 1) > (double)v27 )
-        {
-          LODWORD(v6) = *((int *)v4 - 1);
-          v24 = v2;
-          v27 = v6;
-        }
-        if ( *(float *)v4 < (double)v28 )
-        {
-          LODWORD(v7) = *(int *)v4;
-          v29 = v2;
-          v28 = v7;
-        }
-        if ( v3 < *(float *)v4 )
-        {
-          v3 = *(float *)v4;
-          v23 = v2;
-        }
-        ++LODWORD(v2);
-        v4 += 48;
-      }
-      while ( SLODWORD(v2) < (signed int)v1 );
-    }
-    v8 = v29;
-    if ( LODWORD(v29) == LODWORD(v25) || LODWORD(v29) == LODWORD(v24) )
-      v8 = v23;
-    v29 = 0.0;
-    for ( i = 0; i < (signed int)v1; ++i )
-    {
-      if ( i == LODWORD(v25) || i == LODWORD(v24) || i == LODWORD(v8) )
-      {
-        v10 = LODWORD(v29)++;
-        *(&v19 + v10) = i;
-      }
-    }
-    v11 = &array_508690[v19];
-    v12 = &array_508690[v20];
-    v13 = &array_508690[v21];
-    if ( LODWORD(v29) != 3 )
-    {
-      v11 = array_508690;
-      v13 = (RenderVertexSoft *)((char *)array_508690 + 16 * (3 * v1 - 3));
-      v12 = &array_508690[1];
-      v28 = array_508690[1].vWorldPosition.x - array_508690[0].vWorldPosition.x;
-      v27 = array_508690[1].vWorldPosition.y - array_508690[0].vWorldPosition.y;
-      v29 = array_508690[1].vWorldPosition.z - array_508690[0].vWorldPosition.z;
-      v26 = v13->vWorldPosition.x - array_508690[0].vWorldPosition.x;
-      v25 = v13->vWorldPosition.y - array_508690[0].vWorldPosition.y;
-      v24 = v13->vWorldPosition.z - array_508690[0].vWorldPosition.z;
-      if ( v24 * v27 - v25 * v29 == 0.0 )
-      {
-        if ( v26 * v29 - v24 * v28 == 0.0 )
-        {
-          if ( v25 * v28 - v26 * v27 == 0.0 )
-          {
-            v14 = v1 - 2;
-            LODWORD(v26) = v14;
-            if ( v14 >= 2 )
-            {
-              v15 = &array_508690[v14];
-              do
-              {
-                v16 = v15->vWorldPosition.x - array_508690[0].vWorldPosition.x;
-                v17 = v15->vWorldPosition.y - array_508690[0].vWorldPosition.y;
-                v18 = v15->vWorldPosition.z - array_508690[0].vWorldPosition.z;
-                v13 = v15;
-                if ( v27 * v18 - v17 * v29 != 0.0 )
-                  break;
-                if ( v16 * v29 - v18 * v28 != 0.0 )
-                  break;
-                if ( v28 * v17 - v16 * v27 != 0.0 )
-                  break;
-                --LODWORD(v26);
-                --v15;
-              }
-              while ( SLODWORD(v26) >= 2 );
-            }
-          }
-        }
-      }
-    }
-    sr_sub_4829B9(v11, v12, v13, v22, 1);
-  }
-}
-
-//----- (004829B9) --------------------------------------------------------
-stru148 *__fastcall sr_sub_4829B9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4, int a5)
-{
-  double v5; // st7@1
-  RenderVertexSoft *v6; // esi@1
-  double v7; // st6@1
-  stru148 *result; // eax@3
-  double v9; // st6@3
-  double v10; // st5@3
-  float v11; // ST0C_4@3
-  float v12; // ST04_4@3
-  double v13; // st4@3
-  float v14; // [sp+8h] [bp-Ch]@1
-  float v15; // [sp+10h] [bp-4h]@1
-  float v16; // [sp+1Ch] [bp+8h]@1
-  float v17; // [sp+1Ch] [bp+8h]@3
-
-  v5 = a2->vWorldViewProjX - a1->vWorldViewProjX;
-  v6 = a3;
-  v16 = a3->vWorldViewProjY - a1->vWorldViewProjY;
-  v15 = a2->vWorldViewProjY - a1->vWorldViewProjY;
-  v14 = v6->vWorldViewProjX - a1->vWorldViewProjX;
-  v7 = v16 * v5 - v14 * v15;
-  if ( v7 == 0.0 )
-    v7 = 0.0000001;
-  result = a4;
-  v9 = 1.0 / v7;
-  v10 = 1.0 / a1->vWorldViewPosition.x;
-  v11 = 1.0 / a2->vWorldViewPosition.x - v10;
-  v12 = 1.0 / v6->vWorldViewPosition.x - v10;
-  v13 = (v11 * v16 - v12 * v15) * v9;
-  v17 = (v11 * v14 - v12 * v5) * -v9;
-  a4->field_C = a1->vWorldViewProjX;
-  a4->field_10 = a1->vWorldViewProjY;
-  a4->field_0 = v10;
-  a4->field_8 = v17;
-  a4->field_4 = v13;
-  return result;
-}
-
 //----- (00482A90) --------------------------------------------------------
 signed int __cdecl const_1_0()
 {
   return 1;
 }
 
-//----- (00482A94) --------------------------------------------------------
-int sr_sub_482A94(Span *_this)
-{
-  stru315 *v1; // ebp@0
-  Span *v2; // edi@1
-  stru148 *v3; // esi@1
-  int v4; // ecx@1
-  stru149 *v5; // eax@1
-  stru149 *v6; // eax@1
-  int v7; // edx@1
-  int v8; // eax@1
-  int v9; // ecx@1
-  int v10; // edx@1
-  int v11; // ebx@1
-  int v12; // eax@1
-  signed int v13; // ebx@1
-  int v14; // ebx@2
-  signed __int64 v15; // qtt@3
-  stru149 *v16; // eax@3
-  signed int v17; // ebx@3
-  Texture *v18; // eax@14
-  unsigned __int16 *v19; // eax@15
-  stru149 *v20; // eax@21
-  signed int v21; // eax@21
-  int v22; // eax@21
-  int v23; // ecx@21
-  Texture *v24; // edx@21
-  signed int v25; // eax@21
-  signed int v27; // [sp-4h] [bp-A4h]@8
-  int v28; // [sp+Ch] [bp-94h]@1
-  int v29; // [sp+10h] [bp-90h]@1
-  stru316 a2; // [sp+14h] [bp-8Ch]@21
-  stru315 a1; // [sp+3Ch] [bp-64h]@1
-  int v32; // [sp+80h] [bp-20h]@1
-  int v33; // [sp+84h] [bp-1Ch]@1
-  int v34; // [sp+88h] [bp-18h]@1
-  int v35; // [sp+8Ch] [bp-14h]@1
-  int v36; // [sp+90h] [bp-10h]@1
-  int v37; // [sp+94h] [bp-Ch]@1
-  int v38; // [sp+98h] [bp-8h]@1
-  int X; // [sp+9Ch] [bp-4h]@1
-
-  v2 = _this;
-  v3 = _this->pParent;
-  v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
-  v5 = v3->ptr_38;
-  v38 = v4;
-  v37 = v5->field_14;
-  v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16;
-  v6 = v3->ptr_38;
-  v7 = v38 + v6->field_C;
-  v37 = v6->field_20;
-  v33 = v7;
-  v8 = ((unsigned __int64)(v37 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
-  v38 = v4;
-  v34 = v8;
-  v37 = v3->v_18.z;
-  v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16;
-  v9 = v3->v_18.x;
-  v28 = v3->sTextureDeltaU << 16;
-  v35 = v3->sTextureDeltaV << 16;
-  v10 = v2->field_8;
-  v29 = pOutdoorCamera->camera_rotation_y_int_sine;
-  v32 = pOutdoorCamera->camera_rotation_y_int_cosine;
-  a1.field_28 = v2->field_C;
-  v11 = v3->field_24;
-  v37 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v10);
-  v12 = v3->v_18.y;
-  v13 = -v11;
-  v36 = v13;
-  X = ((unsigned __int64)(v37 * (signed __int64)v12) >> 16) + v38 + v9;
-  if ( !X || (v14 = abs(v13 >> 14), v14 > abs(X)) )
-    return 0;
-  LODWORD(v15) = v36 << 16;
-  HIDWORD(v15) = v36 >> 16;
-  v38 = v15 / X;
-  v16 = v3->ptr_38;
-  X = v37;
-  v36 = v16->field_10;
-  X = v37;
-  v36 = v33 + ((unsigned __int64)(v36 * (signed __int64)v37) >> 16);
-  v33 = v3->ptr_38->field_1C;
-  X = (unsigned __int64)(v33 * (signed __int64)v37) >> 16;
-  v34 += (unsigned __int64)(v33 * (signed __int64)v37) >> 16;
-  v17 = 2;
-  a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
-  if ( v38 >= mipmapping_building_mm1 << 16 )
-  {
-    if ( v38 >= mipmapping_building_mm2 << 16 )
-    {
-      if ( v38 >= mipmapping_building_mm3 << 16 )
-      {
-        if ( bUseLoResSprites )
-          goto LABEL_12;
-        v27 = 3;
-      }
-      else
-      {
-        v27 = 2;
-      }
-      v17 = v27;
-      goto LABEL_12;
-    }
-    v17 = 1;
-  }
-  else
-  {
-    v17 = 0;
-  }
-LABEL_12:
-  if ( v17 < (signed int)v3->ptr_48 )
-    v17 = (signed int)v3->ptr_48;
-  v18 = v3->pTexture;
-  if ( v17 )
-  {
-    if ( v17 == 1 )
-    {
-      v19 = (unsigned __int16 *)v18->pLevelOfDetail1;
-    }
-    else
-    {
-      if ( v17 == 2 )
-        v19 = (unsigned __int16 *)v18->pLevelOfDetail2;
-      else
-        v19 = (unsigned __int16 *)v18->pLevelOfDetail3;
-    }
-  }
-  else
-  {
-    v19 = (unsigned __int16 *)v18->pLevelOfDetail0_prolly_alpha_mask;
-  }
-  a1.pTextureLOD = v19;
-  X = (unsigned __int64)(v36 * (signed __int64)v38) >> 16;
-  v20 = v3->ptr_38;
-  X = v38;
-  a1.field_30 = v28 + ((unsigned __int64)(v36 * (signed __int64)v38) >> 16) - v20->field_24;
-  X = (unsigned __int64)(v34 * (signed __int64)v38) >> 16;
-  v21 = X - v3->ptr_38->field_28 - v35;
-  a1.field_30 >>= v17 + bUseLoResSprites;
-  a1.field_2C = v21 >> (v17 + bUseLoResSprites);
-  v35 = pOutdoorCamera->int_fov_rad_inv;
-  v37 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v38) >> 16) >> (v17 + bUseLoResSprites);
-  a1.field_4 = (unsigned __int64)(v37 * (signed __int64)v29) >> 16;
-  X = (unsigned __int64)(v37 * (signed __int64)v32) >> 16;
-  a1.field_0 = -(signed int)((unsigned __int64)(v37 * (signed __int64)v32) >> 16);
-  v22 = v2->field_A;
-  a1.pColorBuffer = &pRenderer->pTargetSurface[v2->field_8 + pRenderer->uTargetSurfacePitch * v2->field_A];
-  HIWORD(v23) = HIWORD(v38);
-  a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v2->field_8 + 640 * v22];
-  LOWORD(v23) = 0;
-  a1.field_24 = v23 | v3->field_50;
-  v24 = v3->pTexture;
-  v32 = (signed int)v24->uTextureWidth >> v17;
-  v25 = (signed int)v24->uTextureHeight >> v17;
-  a1.field_10 = v17 - v24->uWidthLn2 + 16;
-  a1.field_C = v32 - 1;
-  a1.field_8 = (v25 << 16) - 65536;
-  a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v38, v3, pOutdoorCamera->building_gamme, 1u, 1);
-  if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-    sr_sub_485975(&a1, (stru315 *)&a2);
-  else
-    sr_sub_4D6FB0(v1);
-  return 1;
-}
-
-//----- (00482E07) --------------------------------------------------------
-signed int __fastcall sr_sub_482E07(Span *ecx0, unsigned __int16 *pRenderTarget)
-{
-  stru315 *v2; // ebp@0
-  stru148 *v3; // esi@1
-  int v4; // edi@1
-  int v5; // edi@1
-  stru149 *v6; // eax@1
-  stru149 *v7; // eax@1
-  int v8; // edx@1
-  int v9; // eax@1
-  int v10; // edi@1
-  int v11; // eax@1
-  unsigned __int64 v12; // qax@1
-  int v13; // eax@1
-  signed __int64 v14; // qtt@3
-  int v15; // ebx@4
-  signed __int64 v16; // qtt@5
-  int v17; // eax@5
-  unsigned __int16 *v18; // eax@7
-  Texture *v19; // eax@8
-  Texture *v20; // eax@10
-  Texture *v21; // eax@12
-  Texture *v22; // eax@14
-  int v23; // ecx@17
-  Texture *v24; // ebx@17
-  signed int v25; // edx@17
-  signed int v26; // eax@17
-  char v27; // bl@17
-  stru149 *v28; // eax@18
-  stru149 *v29; // eax@18
-  int v30; // eax@18
-  int v31; // eax@18
-  unsigned int v32; // edx@18
-  int v33; // edi@21
-  signed __int64 v34; // qtt@22
-  signed int v35; // ecx@22
-  int v36; // eax@24
-  stru149 *v37; // eax@24
-  int v38; // edi@24
-  int v39; // eax@24
-  int v40; // edi@35
-  signed __int64 v41; // qtt@36
-  int v42; // edx@36
-  stru149 *v43; // eax@36
-  int v44; // edi@36
-  int v45; // eax@36
-  Span *v46; // edi@44
-  stru149 *v47; // eax@44
-  stru149 *v48; // eax@44
-  int v49; // eax@44
-  int v50; // ecx@44
-  unsigned int v51; // edx@44
-  int v52; // edi@46
-  signed __int64 v53; // qtt@47
-  unsigned int v54; // ecx@47
-  int v55; // eax@49
-  stru149 *v56; // eax@49
-  int v57; // edi@49
-  int v58; // eax@49
-  int v59; // edi@60
-  signed __int64 v60; // qtt@61
-  int v61; // edx@61
-  stru149 *v62; // eax@61
-  int v63; // edi@61
-  int v64; // eax@61
-  int v66; // [sp+Ch] [bp-B8h]@1
-  int v67; // [sp+10h] [bp-B4h]@1
-  int v68; // [sp+14h] [bp-B0h]@1
-  int v69; // [sp+18h] [bp-ACh]@1
-  int v70; // [sp+1Ch] [bp-A8h]@5
-  int v71; // [sp+20h] [bp-A4h]@1
-  signed int v72; // [sp+24h] [bp-A0h]@1
-  stru316 a2; // [sp+28h] [bp-9Ch]@18
-  int v74; // [sp+50h] [bp-74h]@17
-  stru315 a1; // [sp+54h] [bp-70h]@5
-  Span *v76; // [sp+98h] [bp-2Ch]@1
-  unsigned __int16 *v77; // [sp+9Ch] [bp-28h]@1
-  int v78; // [sp+A0h] [bp-24h]@17
-  int v79; // [sp+A4h] [bp-20h]@3
-  int v80; // [sp+A8h] [bp-1Ch]@3
-  int v81; // [sp+ACh] [bp-18h]@1
-  int X; // [sp+B0h] [bp-14h]@2
-  int v83; // [sp+B4h] [bp-10h]@1
-  int v84; // [sp+B8h] [bp-Ch]@1
-  int v85; // [sp+BCh] [bp-8h]@1
-  int v86; // [sp+C0h] [bp-4h]@18
-
-  v85 = ecx0->field_C;
-  v3 = ecx0->pParent;
-  v4 = pViewport->uScreenCenterY - ecx0->field_A;
-  v77 = pRenderTarget;
-  v5 = pOutdoorCamera->int_fov_rad_inv * v4;
-  v6 = v3->ptr_38;
-  v76 = ecx0;
-  v81 = v5;
-  v83 = v6->field_14;
-  v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16;
-  v7 = v3->ptr_38;
-  v8 = v81 + v7->field_C;
-  v83 = v7->field_20;
-  v67 = v8;
-  v9 = ((unsigned __int64)(v83 * (signed __int64)v5) >> 16) + v3->ptr_38->field_18;
-  v81 = v5;
-  v71 = v9;
-  v83 = v3->v_18.z;
-  v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16;
-  v68 = v3->sTextureDeltaU << 16;
-  v69 = v3->sTextureDeltaV << 16;
-  v72 = -v3->field_24;
-  v10 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - ecx0->field_8);
-  v11 = v3->v_18.y;
-  v66 = v81 + v3->v_18.x;
-  v83 = v10;
-  v12 = v10 * (signed __int64)v11;
-  v81 = v12 >> 16;
-  v13 = v66 + (v12 >> 16);
-  v84 = v13;
-  if ( !v13
-    || (X = v72 >> 15, v83 = abs(v13), abs(v72 >> 15) >= v83)
-    || (LODWORD(v14) = v72 << 16,
-        HIDWORD(v14) = v72 >> 16,
-        v79 = v14 / v84,
-        v80 = v10 - v85 * pOutdoorCamera->int_fov_rad_inv,
-        v81 = (unsigned __int64)(v80 * (signed __int64)v3->v_18.y) >> 16,
-        (v84 = v66 + v81) == 0)
-    || (v15 = abs(v66 + v81), abs(X) >= v15) )
-    return 0;
-  LODWORD(v16) = v72 << 16;
-  HIDWORD(v16) = v72 >> 16;
-  v70 = v16 / v84;
-  v17 = v16 / v84;
-  a1.field_24 = v79;
-  if ( v79 >= v17 )
-    a1.field_24 = v17;
-  v18 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
-  a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
-  v84 = 2;
-  if ( a1.field_24 >= mipmapping_building_mm1 << 16 )
-  {
-    if ( a1.field_24 >= mipmapping_building_mm2 << 16 )
-    {
-      if ( a1.field_24 >= mipmapping_building_mm3 << 16 )
-      {
-        if ( bUseLoResSprites )
-          goto LABEL_16;
-        v22 = v3->pTexture;
-        v84 = 3;
-        v18 = (unsigned __int16 *)v22->pLevelOfDetail3;
-      }
-      else
-      {
-        v21 = v3->pTexture;
-        v84 = 2;
-        v18 = (unsigned __int16 *)v21->pLevelOfDetail2;
-      }
-    }
-    else
-    {
-      v20 = v3->pTexture;
-      v84 = 1;
-      v18 = (unsigned __int16 *)v20->pLevelOfDetail1;
-    }
-  }
-  else
-  {
-    v19 = v3->pTexture;
-    v84 = 0;
-    v18 = (unsigned __int16 *)v19->pLevelOfDetail0_prolly_alpha_mask;
-  }
-  a1.pTextureLOD = v18;
-LABEL_16:
-  if ( v18 )
-  {
-    v23 = v3->field_5A;
-    v83 = v3->field_52;
-    v24 = v3->pTexture;
-    v74 = v23;
-    v78 = v85 >> v23;
-    v25 = v24->uTextureWidth;
-    v81 = v85 - (v85 >> v23 << v23);
-    v26 = (signed int)v24->uTextureHeight >> v84;
-    a1.field_10 = v84 - v24->uWidthLn2 + 16;
-    v27 = v84 + bUseLoResSprites;
-    a1.field_8 = (v26 << 16) - 65536;
-    a1.field_C = (v25 >> v84) - 1;
-    if ( v79 >= v70 )
-    {
-      v46 = v76;
-      a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v70, v3, pOutdoorCamera->building_gamme, 0, 1);
-      v47 = v3->ptr_38;
-      v79 = v80;
-      v86 = v47->field_10;
-      v79 = v80;
-      v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16);
-      v86 = v3->ptr_38->field_1C;
-      v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16);
-      v79 = (unsigned __int64)(v84 * (signed __int64)v70) >> 16;
-      v48 = v3->ptr_38;
-      v79 = v70;
-      a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v70) >> 16) - v48->field_24;
-      v79 = (unsigned __int64)(v86 * (signed __int64)v70) >> 16;
-      v49 = ((unsigned __int64)(v86 * (signed __int64)v70) >> 16) - v3->ptr_38->field_28;
-      a1.field_30 >>= v27;
-      a1.field_2C = (v69 + v49) >> v27;
-      a1.field_14 = dword_80AA20 >> v27;
-      a1.field_18 = dword_80AA1C >> v27;
-      a1.field_1C = dword_80AA18 >> v27;
-      v50 = v46->field_8;
-      a1.field_20 = dword_80AA14 >> v27;
-      v51 = v50 + pRenderer->uTargetSurfacePitch * v46->field_A;
-      a1.pDepthBuffer = (unsigned int *)(&pRenderer->pActiveZBuffer[640 * v46->field_A - 1] + v85 + v50);
-      a1.pColorBuffer = &v77[v85 - 1] + v51;
-      v80 += pOutdoorCamera->int_fov_rad_inv << v74;
-      if ( v78 > 0 )
-      {
-        do
-        {
-          v77 = (unsigned __int16 *)v3->v_18.y;
-          v86 = (unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16;
-          v84 = v66 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16);
-          if ( v66 + (unsigned int)((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16)
-            && (v52 = abs((signed __int64)v66 + ((__int64)((signed int)v77 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v52) )
-          {
-            LODWORD(v53) = v72 << 16;
-            HIDWORD(v53) = v72 >> 16;
-            v86 = v53 / v84;
-            v54 = v53 / v84;
-            v84 = v53 / v84;
-          }
-          else
-          {
-            v84 = 0x40000000u;
-            v54 = 0x40000000u;
-          }
-          HIWORD(v55) = HIWORD(v54);
-          LOWORD(v55) = 0;
-          a1.field_24 = v3->field_50 | v55;
-          v77 = (unsigned __int16 *)v3->ptr_38->field_10;
-          v77 = (unsigned __int16 *)(v67 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16));
-          v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16;
-          v56 = v3->ptr_38;
-          v57 = ((unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16) - v56->field_24;
-          v77 = (unsigned __int16 *)v56->field_1C;
-          v77 = (unsigned __int16 *)(v71 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16));
-          v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16;
-          v58 = (((v69 + v86 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74;
-          a1.field_4 = (((v68 + v57) >> v27) - a1.field_30) >> v74;
-          a1.field_0 = v58;
-          a1.field_28 = v83;
-          if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-          {
-            if ( v3->pODMFace->uPolygonType == 1 )
-              sr_sub_485BAE(&a1, &a2);
-            else
-              sr_sub_485AFF(&a1, &a2);
-          }
-          else
-          {
-            if ( v3->pODMFace->uPolygonType == 1 )
-              sr_sub_4D71F8(&a1);
-            else
-              sr_sub_4D714C(&a1);
-          }
-          a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(
-                                                      &a2,
-                                                      v76,
-                                                      v84,
-                                                      v3,
-                                                      pOutdoorCamera->building_gamme,
-                                                      0,
-                                                      0);
-          v80 += pOutdoorCamera->int_fov_rad_inv << v74;
-          --v78;
-        }
-        while ( v78 );
-      }
-      if ( !v81 )
-        return 1;
-      v83 = v3->v_18.y;
-      v86 = (unsigned __int64)(v83 * (signed __int64)v80) >> 16;
-      v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
-      if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) )
-      {
-        v59 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16));
-        if ( abs(X) < v59 )
-        {
-          LODWORD(v60) = v72 << 16;
-          HIDWORD(v60) = v72 >> 16;
-          v86 = v60 / v84;
-          HIWORD(v61) = (unsigned int)(v60 / v84) >> 16;
-          LOWORD(v61) = 0;
-          a1.field_24 = v61 | v3->field_50;
-          v83 = v3->ptr_38->field_10;
-          v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
-          v86 = (unsigned __int64)(v83 * v60 / v84) >> 16;
-          v62 = v3->ptr_38;
-          v63 = ((unsigned __int64)(v83 * v60 / v84) >> 16) - v62->field_24;
-          v83 = v62->field_1C;
-          v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
-          v86 = (unsigned __int64)(v83 * v60 / v84) >> 16;
-          v64 = (((signed int)(v69 + ((unsigned __int64)(v83 * v60 / v84) >> 16) - v3->ptr_38->field_28) >> v27)
-               - a1.field_2C) >> v74;
-          a1.field_4 = (((v68 + v63) >> v27) - a1.field_30) >> v74;
-          a1.field_0 = v64;
-          a1.field_28 = v81;
-          if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-          {
-            if ( v3->pODMFace->uPolygonType == 1 )
-              sr_sub_485BAE(&a1, &a2);
-            else
-              sr_sub_485AFF(&a1, &a2);
-          }
-          else
-          {
-            if ( v3->pODMFace->uPolygonType == 1 )
-              sr_sub_4D71F8(&a1);
-            else
-              sr_sub_4D714C(&a1);
-          }
-          return 1;
-        }
-      }
-    }
-    else
-    {
-      a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v79, v3, pOutdoorCamera->building_gamme, 1u, 1);
-      v28 = v3->ptr_38;
-      v85 = v10;
-      v86 = v28->field_10;
-      v85 = v10;
-      v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16);
-      v86 = v3->ptr_38->field_1C;
-      v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16);
-      v85 = (unsigned __int64)(v84 * (signed __int64)v79) >> 16;
-      v29 = v3->ptr_38;
-      v85 = v79;
-      a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v79) >> 16) - v29->field_24;
-      v85 = (unsigned __int64)(v86 * (signed __int64)v79) >> 16;
-      v30 = ((unsigned __int64)(v86 * (signed __int64)v79) >> 16) - v3->ptr_38->field_28;
-      a1.field_30 >>= v27;
-      a1.field_2C = (v69 + v30) >> v27;
-      a1.field_14 = dword_80AA20 >> v27;
-      a1.field_18 = dword_80AA1C >> v27;
-      a1.field_1C = dword_80AA18 >> v27;
-      a1.field_20 = dword_80AA14 >> v27;
-      v31 = v76->field_A;
-      v32 = pRenderer->uTargetSurfacePitch * v76->field_A;
-      v86 = v76->field_8;
-      a1.pColorBuffer = &v77[v86 + v32];
-      a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v86 + 640 * v31];
-      v80 = v10 - (pOutdoorCamera->int_fov_rad_inv << v74);
-      if ( v78 > 0 )
-      {
-        v86 = v78;
-        do
-        {
-          v78 = v3->v_18.y;
-          v85 = (unsigned __int64)(v78 * (signed __int64)v80) >> 16;
-          v84 = v66 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
-          if ( v66 + (unsigned int)((unsigned __int64)(v78 * (signed __int64)v80) >> 16)
-            && (v33 = abs((signed __int64)v66 + ((__int64)(v78 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v33) )
-          {
-            LODWORD(v34) = v72 << 16;
-            HIDWORD(v34) = v72 >> 16;
-            v85 = v34 / v84;
-            v35 = v34 / v84;
-            v84 = v34 / v84;
-          }
-          else
-          {
-            v84 = 1073741824;
-            v35 = 1073741824;
-          }
-          HIWORD(v36) = HIWORD(v35);
-          LOWORD(v36) = 0;
-          a1.field_24 = v3->field_50 | v36;
-          v78 = v3->ptr_38->field_10;
-          v78 = v67 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
-          v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16;
-          v37 = v3->ptr_38;
-          v38 = ((unsigned __int64)(v78 * (signed __int64)v35) >> 16) - v37->field_24;
-          v78 = v37->field_1C;
-          v78 = v71 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
-          v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16;
-          v39 = (((v69 + v85 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74;
-          a1.field_4 = (((v68 + v38) >> v27) - a1.field_30) >> v74;
-          a1.field_0 = v39;
-          a1.field_28 = v83;
-          if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-          {
-            if ( v3->pODMFace->uPolygonType == 1 )
-              sr_sub_485A24(&a1, (stru315 *)&a2);
-            else
-              sr_sub_485975(&a1, (stru315 *)&a2);
-          }
-          else
-          {
-            if ( v3->pODMFace->uPolygonType == 1 )
-              sr_sub_4D705A(v2);
-            else
-              sr_sub_4D6FB0(v2);
-          }
-          a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(
-                                                      &a2,
-                                                      v76,
-                                                      v84,
-                                                      v3,
-                                                      pOutdoorCamera->building_gamme,
-                                                      1u,
-                                                      0);
-          v80 -= pOutdoorCamera->int_fov_rad_inv << v74;
-          --v86;
-        }
-        while ( v86 );
-      }
-      if ( !v81 )
-        return 1;
-      v83 = v3->v_18.y;
-      v76 = (Span *)((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
-      v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
-      if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) )
-      {
-        v40 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16));
-        if ( abs(X) < v40 )
-        {
-          LODWORD(v41) = v72 << 16;
-          HIDWORD(v41) = v72 >> 16;
-          X = v41 / v84;
-          HIWORD(v42) = (unsigned int)(v41 / v84) >> 16;
-          LOWORD(v42) = 0;
-          a1.field_24 = v42 | v3->field_50;
-          v83 = v3->ptr_38->field_10;
-          v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
-          X = (unsigned __int64)(v83 * v41 / v84) >> 16;
-          v43 = v3->ptr_38;
-          v44 = ((unsigned __int64)(v83 * v41 / v84) >> 16) - v43->field_24;
-          v83 = v43->field_1C;
-          v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
-          X = (unsigned __int64)(v83 * v41 / v84) >> 16;
-          v45 = (((signed int)(v69 + ((unsigned __int64)(v83 * v41 / v84) >> 16) - v3->ptr_38->field_28) >> v27)
-               - a1.field_2C) >> v74;
-          a1.field_4 = (((v68 + v44) >> v27) - a1.field_30) >> v74;
-          a1.field_0 = v45;
-          a1.field_28 = v81;
-          if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-          {
-            if ( v3->pODMFace->uPolygonType == 1 )
-              sr_sub_485A24(&a1, (stru315 *)&a2);
-            else
-              sr_sub_485975(&a1, (stru315 *)&a2);
-          }
-          else
-          {
-            if ( v3->pODMFace->uPolygonType == 1 )
-              sr_sub_4D705A(v2);
-            else
-              sr_sub_4D6FB0(v2);
-          }
-          return 1;
-        }
-      }
-    }
-  }
-  return 0;
-}
-
-//----- (004839BD) --------------------------------------------------------
-signed int __fastcall sr_sub_4839BD(Span *ecx0, unsigned __int16 *pTargetSurface)
-{
-  stru315 *v2; // ebp@0
-  int v3; // eax@1
-  int v4; // edi@1
-  stru148 *v5; // esi@1
-  unsigned int v6; // ebx@1
-  int v7; // ecx@1
-  int v8; // ebx@1
-  int v9; // ecx@1
-  int v10; // eax@1
-  stru149 *v11; // eax@1
-  int v12; // edx@1
-  int v13; // eax@1
-  int v14; // edi@1
-  int v15; // ecx@1
-  int v16; // eax@1
-  signed int v17; // edi@1
-  int v18; // edi@2
-  signed __int64 v19; // qtt@3
-  int v20; // edi@3
-  unsigned __int16 *v21; // eax@3
-  Texture *v22; // eax@4
-  Texture *v23; // eax@6
-  Texture *v24; // eax@8
-  Texture *v25; // eax@10
-  stru149 *v26; // eax@13
-  int v27; // edi@13
-  signed int v28; // edx@13
-  Texture *v29; // ebx@13
-  int v30; // edi@13
-  signed int v31; // edx@13
-  signed int v32; // eax@13
-  signed int v33; // eax@13
-  int v34; // ebx@13
-  int v35; // eax@15
-  int v36; // ebx@15
-  int v37; // eax@16
-  signed __int64 v38; // qtt@17
-  int v39; // ecx@17
-  int v40; // eax@19
-  stru149 *v41; // eax@21
-  int v42; // ebx@21
-  int v43; // ebx@21
-  int v44; // eax@21
-  char v45; // zf@25
-  int v46; // eax@28
-  int v47; // eax@28
-  int v48; // ebx@28
-  int v49; // eax@29
-  signed __int64 v50; // qtt@30
-  int v51; // ecx@30
-  int v52; // eax@30
-  int v53; // edx@31
-  stru149 *v54; // eax@33
-  int v55; // ebx@33
-  signed int v56; // ebx@33
-  int v57; // eax@33
-  unsigned __int64 v58; // qax@33
-  int v60; // [sp+Ch] [bp-BCh]@1
-  Span *v61; // [sp+10h] [bp-B8h]@1
-  int v62; // [sp+14h] [bp-B4h]@2
-  int v63; // [sp+18h] [bp-B0h]@1
-  stru315 a1; // [sp+1Ch] [bp-ACh]@1
-  stru316 a2; // [sp+60h] [bp-68h]@13
-  int v66; // [sp+88h] [bp-40h]@13
-  int v67; // [sp+8Ch] [bp-3Ch]@1
-  int v68; // [sp+90h] [bp-38h]@13
-  int v69; // [sp+94h] [bp-34h]@3
-  int v70; // [sp+98h] [bp-30h]@1
-  int v71; // [sp+9Ch] [bp-2Ch]@1
-  int v72; // [sp+A0h] [bp-28h]@1
-  int v73; // [sp+A4h] [bp-24h]@13
-  int v74; // [sp+A8h] [bp-20h]@1
-  int v75; // [sp+ACh] [bp-1Ch]@3
-  int v76; // [sp+B0h] [bp-18h]@1
-  int v77; // [sp+B4h] [bp-14h]@1
-  int X; // [sp+B8h] [bp-10h]@1
-  int v79; // [sp+BCh] [bp-Ch]@21
-  int v80; // [sp+C0h] [bp-8h]@13
-  unsigned int v81; // [sp+C4h] [bp-4h]@1
-
-  v3 = ecx0->field_A;
-  v4 = ecx0->field_8;
-  v5 = ecx0->pParent;
-  v6 = v4 + pRenderer->uTargetSurfacePitch * ecx0->field_A;
-  v61 = ecx0;
-  v7 = ecx0->field_C;
-  a1.pColorBuffer = &pTargetSurface[v6];
-  v74 = v7;
-  a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v4 + 640 * v3];
-  v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4);
-  v9 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v3);
-  v10 = v5->ptr_38->field_14;
-  v76 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4);
-  v72 = v10;
-  v81 = (unsigned __int64)(v10 * (signed __int64)v9) >> 16;
-  v11 = v5->ptr_38;
-  v12 = v81 + v11->field_C;
-  v72 = v11->field_20;
-  v67 = v12;
-  v13 = ((unsigned __int64)(v72 * (signed __int64)v9) >> 16) + v5->ptr_38->field_18;
-  v81 = v9;
-  v70 = v13;
-  v72 = v5->v_18.z;
-  v81 = (unsigned __int64)(v72 * (signed __int64)v9) >> 16;
-  v14 = v5->field_24;
-  v15 = v81 + v5->v_18.x;
-  v71 = v5->sTextureDeltaU << 16;
-  v63 = v5->sTextureDeltaV << 16;
-  v16 = v5->v_18.y;
-  v17 = -v14;
-  v60 = v15;
-  v77 = v17;
-  v81 = (unsigned __int64)(v76 * (signed __int64)v16) >> 16;
-  X = v81 + v15;
-  if ( !(v81 + v15) || (v62 = v17 >> 14, v18 = abs(v17 >> 14), v18 > abs(X)) )
-    return 0;
-  LODWORD(v19) = v77 << 16;
-  HIDWORD(v19) = v77 >> 16;
-  v69 = v19 / X;
-  v20 = v19 / X;
-  v21 = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
-  a1.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
-  v75 = 2;
-  if ( v20 >= mipmapping_building_mm1 << 16 )
-  {
-    if ( v20 >= mipmapping_building_mm2 << 16 )
-    {
-      if ( v20 >= mipmapping_building_mm3 << 16 )
-      {
-        if ( bUseLoResSprites )
-          goto LABEL_12;
-        v25 = v5->pTexture;
-        v75 = 3;
-        v21 = (unsigned __int16 *)v25->pLevelOfDetail3;
-      }
-      else
-      {
-        v24 = v5->pTexture;
-        v75 = 2;
-        v21 = (unsigned __int16 *)v24->pLevelOfDetail2;
-      }
-    }
-    else
-    {
-      v23 = v5->pTexture;
-      v75 = 1;
-      v21 = (unsigned __int16 *)v23->pLevelOfDetail1;
-    }
-  }
-  else
-  {
-    v22 = v5->pTexture;
-    v75 = 0;
-    v21 = (unsigned __int16 *)v22->pLevelOfDetail0_prolly_alpha_mask;
-  }
-  a1.pTextureLOD = v21;
-LABEL_12:
-  if ( v21 )
-  {
-    a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, v20, v5, pOutdoorCamera->building_gamme, 1u, 1);
-    a1.field_28 = 16;
-    v66 = v74 >> 4;
-    v81 = v8;
-    v26 = v5->ptr_38;
-    v72 = v74 - 16 * (v74 >> 4);
-    v76 = v26->field_10;
-    v81 = v8;
-    v74 = v67 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16);
-    v76 = v5->ptr_38->field_1C;
-    v76 = v70 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16);
-    v81 = (unsigned __int64)(v74 * (signed __int64)v20) >> 16;
-    v27 = ((unsigned __int64)(v74 * (signed __int64)v20) >> 16) - v5->ptr_38->field_24;
-    v81 = (unsigned __int64)(v76 * (signed __int64)v69) >> 16;
-    v28 = v63 + ((unsigned __int64)(v76 * (signed __int64)v69) >> 16) - v5->ptr_38->field_28;
-    v76 = v75 + bUseLoResSprites;
-    v73 = v8 - 16 * pOutdoorCamera->int_fov_rad_inv;
-    v29 = v5->pTexture;
-    v30 = (v71 + v27) >> v76;
-    v31 = v28 >> v76;
-    v32 = (signed int)v29->uTextureWidth >> v75;
-    v74 = (signed __int16)v75;
-    v68 = v31;
-    v80 = v32;
-    v33 = (signed int)v29->uTextureHeight >> v75;
-    v34 = v75 - v29->uWidthLn2;
-    a1.field_8 = (v33 << 16) - 65536;
-    v81 = 2 * pMiscTimer->uTotalGameTimeElapsed;
-    a1.field_10 = v34 + 16;
-    a1.field_C = v80 - 1;
-    if ( v66 > 0 )
-    {
-      v74 = v66;
-      v66 = 12 - v75;
-      do
-      {
-        v80 = v5->v_18.y;
-        v35 = (unsigned __int64)(v80 * (signed __int64)v73) >> 16;
-        v36 = v35 + v60;
-        X = v35 + v60;
-        if ( v35 + v60 && (v80 = abs(v62), v37 = abs(v36), v80 <= v37) )
-        {
-          LODWORD(v38) = v77 << 16;
-          HIDWORD(v38) = v77 >> 16;
-          v80 = v38 / X;
-          v39 = v38 / X;
-          X = v38 / X;
-        }
-        else
-        {
-          X = 0x40000000u;
-          v39 = 0x40000000u;
-        }
-        HIWORD(v40) = HIWORD(v39);
-        if ( v39 <= v69 )
-          HIWORD(v40) = HIWORD(v69);
-        LOWORD(v40) = 0;
-        a1.field_24 = v5->field_50 | v40;
-        v79 = v5->ptr_38->field_10;
-        v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
-        v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16;
-        v41 = v5->ptr_38;
-        v42 = ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v41->field_24;
-        v79 = v41->field_1C;
-        v79 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
-        v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16;
-        v43 = (v71 + v42) >> v76;
-        v79 = (signed int)(v63 + ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v5->ptr_38->field_28) >> v76;
-        a1.field_4 = (v43 - v30) >> 4;
-        a1.field_0 = (v79 - v68) >> 4;
-        a1.field_30 = v30 + 4 * stru_5C6E00->Cos(v81 + (v68 >> v66));
-        v44 = stru_5C6E00->Sin(v81 + (v30 >> v66));
-        a1.field_2C = v68 + 4 * v44;
-        if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-          sr_sub_485975(&a1, (stru315 *)&a2);
-        else
-          sr_sub_4D6FB0(v2);
-        a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, X, v5, pOutdoorCamera->building_gamme, 1u, 0);
-        v73 -= 16 * pOutdoorCamera->int_fov_rad_inv;
-        v45 = v74-- == 1;
-        a1.field_28 = 16;
-        v30 = v43;
-        v68 = v79;
-      }
-      while ( !v45 );
-      v31 = v79;
-    }
-    if ( !v72 )
-      return 1;
-    v66 = 12 - v75;
-    a1.field_30 = v30 + 4 * stru_5C6E00->Cos(v81 + (v31 >> (12 - v75)));
-    v46 = stru_5C6E00->Sin(v81 + (v30 >> v66));
-    a1.field_2C = v68 + 4 * v46;
-    v79 = v5->v_18.y;
-    v80 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
-    v47 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
-    v48 = v47 + v60;
-    X = v47 + v60;
-    if ( v47 + v60 )
-    {
-      v79 = abs(v62);
-      v49 = abs(v48);
-      if ( v79 <= v49 )
-      {
-        LODWORD(v50) = v77 << 16;
-        HIDWORD(v50) = v77 >> 16;
-        v77 = v50 / X;
-        v51 = v50 / X;
-        HIWORD(v52) = HIWORD(v69);
-        if ( v51 <= v69 )
-        {
-          LOWORD(v52) = 0;
-          a1.field_24 = v52 | v5->field_50;
-        }
-        else
-        {
-          HIWORD(v53) = HIWORD(v51);
-          LOWORD(v53) = 0;
-          a1.field_24 = v53 | v5->field_50;
-        }
-        v79 = v5->ptr_38->field_10;
-        v77 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
-        v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
-        v67 = (unsigned __int64)(v79 * (signed __int64)v51) >> 16;
-        v54 = v5->ptr_38;
-        v55 = v67 - v54->field_24;
-        v79 = v54->field_1C;
-        v56 = v71 + v55;
-        v71 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
-        v57 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
-        v79 = v57;
-        v58 = v57 * (signed __int64)v51;
-        v70 = v58 >> 16;
-        LODWORD(v58) = (signed int)(v63 + (v58 >> 16) - v5->ptr_38->field_28) >> v76;
-        a1.field_4 = ((v56 >> v76) - v30) >> 4;
-        a1.field_0 = ((signed int)v58 - v68) >> 4;
-        a1.field_28 = v72;
-        if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-          sr_sub_485975(&a1, (stru315 *)&a2);
-        else
-          sr_sub_4D6FB0(v2);
-        return 1;
-      }
-    }
-  }
-  return 0;
-}
-// 4D864C: using guessed type char byte_4D864C;
-// 6BE0E4: using guessed type int mipmapping_building_mm1;
-// 6BE0E8: using guessed type int mipmapping_building_mm2;
-// 6BE0EC: using guessed type int mipmapping_building_mm3;
-
-//----- (0048408A) --------------------------------------------------------
-signed int sr_sub_48408A_prolly_odm_water_no_waves(Span *_this)
-{
-  stru315 *v1; // ebp@0
-  Span *v2; // edi@1
-  stru148 *v3; // esi@1
-  int v4; // ecx@1
-  stru149 *v5; // eax@1
-  stru149 *v6; // eax@1
-  int v7; // edx@1
-  int v8; // eax@1
-  int v9; // ebx@1
-  int v10; // eax@1
-  int v11; // ecx@1
-  int v12; // eax@1
-  int v13; // ecx@1
-  int v14; // eax@1
-  signed int v15; // ecx@1
-  int v16; // ebx@1
-  signed __int64 v17; // qtt@3
-  stru149 *v18; // eax@3
-  int v19; // ebx@3
-  Texture *v20; // eax@4
-  unsigned __int16 *v21; // eax@4
-  Texture *v22; // eax@6
-  Texture *v23; // ecx@8
-  Texture *v24; // eax@10
-  stru149 *v25; // eax@12
-  signed int v26; // eax@12
-  int v27; // ecx@12
-  int v28; // eax@14
-  int v29; // edx@14
-  int v30; // ecx@14
-  Texture *v31; // esi@14
-  int v32; // edx@14
-  int v33; // eax@14
-  int v35; // [sp+Ch] [bp-8Ch]@1
-  int v36; // [sp+10h] [bp-88h]@1
-  stru316 a2; // [sp+14h] [bp-84h]@14
-  stru315 a1; // [sp+3Ch] [bp-5Ch]@1
-  int v39; // [sp+80h] [bp-18h]@1
-  int v40; // [sp+84h] [bp-14h]@1
-  int v41; // [sp+88h] [bp-10h]@1
-  int v42; // [sp+8Ch] [bp-Ch]@1
-  int v43; // [sp+90h] [bp-8h]@2
-  int v44; // [sp+94h] [bp-4h]@1
-
-  v2 = _this;
-  v3 = _this->pParent;
-  v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
-  v5 = v3->ptr_38;
-  v44 = v4;
-  v42 = v5->field_14;
-  v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16;
-  v6 = v3->ptr_38;
-  v7 = v44 + v6->field_C;
-  v42 = v6->field_20;
-  v39 = v7;
-  v8 = ((unsigned __int64)(v42 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
-  v44 = v4;
-  v41 = v8;
-  v42 = v3->v_18.z;
-  v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16;
-  v9 = v44 + v3->v_18.x;
-  v35 = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
-  v10 = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
-  v11 = v2->field_8;
-  v36 = v10;
-  a1.field_28 = v2->field_C;
-  v12 = pViewport->uScreenCenterX - v11;
-  v13 = v3->field_24;
-  v42 = pOutdoorCamera->int_fov_rad_inv * v12;
-  v14 = v3->v_18.y;
-  v15 = -v13;
-  v40 = v15;
-  v16 = ((unsigned __int64)(v42 * (signed __int64)v14) >> 16) + v9;
-  v44 = v16;
-  if ( !v16 || (v43 = abs(v15 >> 14), v43 > abs(v16)) )
-    return 0;
-  LODWORD(v17) = v40 << 16;
-  HIDWORD(v17) = v40 >> 16;
-  v43 = v17 / v44;
-  v18 = v3->ptr_38;
-  v44 = v42;
-  v40 = v18->field_10;
-  v44 = v42;
-  v40 = v39 + ((unsigned __int64)(v40 * (signed __int64)v42) >> 16);
-  v39 = v3->ptr_38->field_1C;
-  v44 = (unsigned __int64)(v39 * (signed __int64)v42) >> 16;
-  v19 = v43;
-  v41 += (unsigned __int64)(v39 * (signed __int64)v42) >> 16;
-  a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
-  v44 = 2;
-  if ( v43 < mipmapping_terrain_mm1 << 16 )
-  {
-    v20 = v3->pTexture;
-    v44 = 0;
-    v21 = (unsigned __int16 *)v20->pLevelOfDetail0_prolly_alpha_mask;
-LABEL_11:
-    a1.pTextureLOD = v21;
-    goto LABEL_12;
-  }
-  if ( v43 < mipmapping_terrain_mm2 << 16 )
-  {
-    v22 = v3->pTexture;
-    v44 = 1;
-    v21 = (unsigned __int16 *)v22->pLevelOfDetail1;
-    goto LABEL_11;
-  }
-  if ( v43 >= mipmapping_terrain_mm3 << 16 )
-  {
-    if ( !bUseLoResSprites )
-    {
-      v24 = v3->pTexture;
-      v44 = 3;
-      v21 = (unsigned __int16 *)v24->pLevelOfDetail3;
-      goto LABEL_11;
-    }
-  }
-  else
-  {
-    v23 = v3->pTexture;
-    v44 = 2;
-    a1.pTextureLOD = (unsigned __int16 *)v23->pLevelOfDetail2;
-  }
-LABEL_12:
-  v43 = (unsigned __int64)(v40 * (signed __int64)v43) >> 16;
-  v25 = v3->ptr_38;
-  v43 = v19;
-  a1.field_30 = ((unsigned __int64)(v40 * (signed __int64)v19) >> 16) - v25->field_24;
-  v43 = (unsigned __int64)(v41 * (signed __int64)v19) >> 16;
-  v26 = ((unsigned __int64)(v41 * (signed __int64)v19) >> 16) - v3->ptr_38->field_28;
-  v27 = bUseLoResSprites + v44 + 2;
-  a1.field_30 >>= v27;
-  v41 = bUseLoResSprites + v44 + 2;
-  a1.field_2C = v26 >> v27;
-  if ( byte_80AA10 )
-  {
-    a1.field_14 = dword_80AA20 >> v27;
-    a1.field_18 = dword_80AA1C >> v27;
-    a1.field_1C = dword_80AA18 >> v27;
-    a1.field_20 = dword_80AA14 >> v27;
-  }
-  v41 = pOutdoorCamera->int_fov_rad_inv;
-  v42 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v19) >> 16) >> v27;
-  a1.field_4 = (unsigned __int64)(v42 * (signed __int64)v35) >> 16;
-  v43 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16;
-  a1.field_0 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16;
-  a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v19, v3, pOutdoorCamera->terrain_gamma, 1u, 1);
-  LOWORD(v19) = 0;
-  v28 = v2->field_A;
-  v29 = v2->field_A;
-  a1.field_24 = v19;
-  v30 = v2->field_8;
-  a1.pColorBuffer = &pRenderer->pTargetSurface[v30 + pRenderer->uTargetSurfacePitch * v29];
-  a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v30 + 640 * v28];
-  v31 = v3->pTexture;
-  v32 = ((signed int)v31->uTextureWidth >> v44) - 1;
-  v33 = ((signed int)v31->uTextureHeight >> v44 << 16) - 65536;
-  a1.field_10 = v44 - v31->uWidthLn2 + 16;
-  a1.field_C = v32;
-  a1.field_8 = v33;
-  if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-  {
-    if ( byte_80AA10 )
-      sr_sub_485A24(&a1, (stru315 *)&a2);
-    else
-      sr_sub_485975(&a1, (stru315 *)&a2);
-  }
-  else
-  {
-    if ( byte_80AA10 )
-      sr_sub_4D705A(v1);
-    else
-      sr_sub_4D6FB0(v1);
-  }
-  return 1;
-}
-
-//----- (00484442) --------------------------------------------------------
-signed int sr_sub_484442(Span *_this)
-{
-  int v1; // ebp@0
-  Span *v2; // edi@1
-  stru148 *v3; // esi@1
-  int v4; // ecx@1
-  stru149 *v5; // eax@1
-  stru149 *v6; // eax@1
-  int v7; // edx@1
-  int v8; // eax@1
-  int v9; // ebx@1
-  int v10; // eax@1
-  int v11; // ecx@1
-  int v12; // eax@1
-  int v13; // ecx@1
-  signed int v14; // ecx@1
-  int v15; // ebx@1
-  signed __int64 v16; // qtt@3
-  int v17; // ecx@3
-  int v18; // ebx@3
-  int v19; // eax@3
-  signed int v20; // ebx@3
-  unsigned __int16 *v21; // eax@4
-  stru149 *v22; // eax@12
-  signed int v23; // eax@12
-  int v24; // ecx@12
-  int v25; // ecx@14
-  unsigned int *v26; // eax@14
-  Texture *v27; // esi@14
-  signed int v28; // edi@14
-  signed int v29; // eax@14
-  signed int v31; // [sp+Ch] [bp-90h]@1
-  int v32; // [sp+10h] [bp-8Ch]@1
-  int v33; // [sp+14h] [bp-88h]@1
-  stru316 v34; // [sp+18h] [bp-84h]@14
-  stru315 v35; // [sp+40h] [bp-5Ch]@1
-  int v36; // [sp+84h] [bp-18h]@1
-  int v37; // [sp+88h] [bp-14h]@1
-  int v38; // [sp+8Ch] [bp-10h]@1
-  int v39; // [sp+90h] [bp-Ch]@1
-  int v40; // [sp+94h] [bp-8h]@1
-  int v41; // [sp+98h] [bp-4h]@1
-
-  v2 = _this;
-  v3 = _this->pParent;
-  v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
-  v5 = v3->ptr_38;
-  v40 = v4;
-  v39 = v5->field_14;
-  v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16;
-  v6 = v3->ptr_38;
-  v7 = v40 + v6->field_C;
-  v39 = v6->field_20;
-  v36 = v7;
-  v8 = ((unsigned __int64)(v39 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
-  v40 = v4;
-  v38 = v8;
-  v39 = v3->v_18.z;
-  v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16;
-  v9 = v40 + v3->v_18.x;
-  v32 = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
-  v10 = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
-  v11 = v2->field_8;
-  v33 = v10;
-  v35.field_28 = v2->field_C;
-  v12 = pViewport->uScreenCenterX - v11;
-  v13 = v3->field_24;
-  v41 = pOutdoorCamera->int_fov_rad_inv * v12;
-  v14 = -v13;
-  v31 = v14;
-  v15 = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * v12 * (signed __int64)v3->v_18.y) >> 16) + v9;
-  v37 = v15;
-  if ( !v15 || (v39 = abs(v14 >> 14), v39 > abs(v15)) )
-    return 0;
-  LODWORD(v16) = v31 << 16;
-  HIDWORD(v16) = v31 >> 16;
-  v40 = v16 / v37;
-  v17 = v16 / v37;
-  v18 = v41;
-  HIWORD(v19) = (unsigned int)(v16 / v37) >> 16;
-  LOWORD(v19) = 0;
-  v35.field_24 = v19;
-  v37 = v36 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v41) >> 16);
-  v36 = v3->ptr_38->field_1C;
-  v41 = (unsigned __int64)(v36 * (signed __int64)v41) >> 16;
-  v38 += (unsigned __int64)(v36 * (signed __int64)v18) >> 16;
-  v20 = 2;
-  v35.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
-  if ( v17 < mipmapping_terrain_mm1 << 16 )
-  {
-    v20 = 0;
-    v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail0_prolly_alpha_mask;
-LABEL_11:
-    v35.pTextureLOD = v21;
-    goto LABEL_12;
-  }
-  if ( v17 < mipmapping_terrain_mm2 << 16 )
-  {
-    v20 = 1;
-    v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail1;
-    goto LABEL_11;
-  }
-  if ( v17 < mipmapping_terrain_mm3 << 16 )
-  {
-    v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
-    goto LABEL_11;
-  }
-  if ( !bUseLoResSprites )
-  {
-    v20 = 3;
-    v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail3;
-    goto LABEL_11;
-  }
-LABEL_12:
-  v41 = (unsigned __int64)(v37 * (signed __int64)v17) >> 16;
-  v22 = v3->ptr_38;
-  v41 = v17;
-  v35.field_30 = ((unsigned __int64)(v37 * (signed __int64)v17) >> 16) - v22->field_24;
-  v23 = ((unsigned __int64)(v38 * (signed __int64)v17) >> 16) - v3->ptr_38->field_28;
-  v24 = bUseLoResSprites + v20 + 2;
-  v35.field_30 >>= v24;
-  v38 = bUseLoResSprites + v20 + 2;
-  v35.field_2C = v23 >> v24;
-  if ( byte_80AA10 )
-  {
-    v35.field_14 = dword_80AA20 >> v24;
-    v35.field_18 = dword_80AA1C >> v24;
-    v35.field_1C = dword_80AA18 >> v24;
-    v35.field_20 = dword_80AA14 >> v24;
-  }
-  v38 = pOutdoorCamera->int_fov_rad_inv;
-  v39 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v40) >> 16) >> v24;
-  v35.field_4 = (unsigned __int64)(v39 * (signed __int64)v32) >> 16;
-  v41 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16;
-  v35.field_0 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16;
-  v35.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&v34, v2, v40, v3, pOutdoorCamera->terrain_gamma, 1u, 1);
-  v25 = v2->field_8;
-  v26 = (unsigned int *)&pRenderer->pActiveZBuffer[v25 + 640 * v2->field_A];
-  v35.pColorBuffer = &pRenderer->pTargetSurface[v25 + pRenderer->uTargetSurfacePitch * v2->field_A];
-  v35.pDepthBuffer = v26;
-  v27 = v3->pTexture;
-  v28 = (signed int)v27->uTextureWidth >> v20;
-  v29 = (signed int)v27->uTextureHeight >> v20;
-  v35.field_10 = v20 - v27->uWidthLn2 + 16;
-  v35.field_C = v28 - 1;
-  v35.field_8 = (v29 << 16) - 65536;
-  if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-  {
-    if ( byte_80AA10 )
-      sr_sub_485D3E(&v35, &v34);
-    else
-      sr_sub_485C89(&v35, &v34);
-  }
-  else
-  {
-    if ( byte_80AA10 )
-      sr_sub_4D72EC(v1);
-    else
-      sr_sub_4D73DF(v1);
-  }
-  return 1;
-}
-
-//----- (004847EB) --------------------------------------------------------
-int sr_sub_4847EB(Span *_this)
-{
-  stru315 *v1; // ebp@0
-  int v2; // ebx@1
-  int v3; // edx@1
-  stru148 *v4; // esi@1
-  int v5; // eax@1
-  signed int v6; // eax@3
-  int v7; // edi@3
-  stru149 *v8; // eax@3
-  stru149 *v9; // eax@3
-  int v10; // edx@3
-  int v11; // eax@3
-  signed int v12; // ebx@3
-  int v13; // ebx@4
-  signed __int64 v14; // qtt@5
-  int v15; // eax@5
-  signed int v16; // ebx@5
-  unsigned __int16 *v17; // ecx@6
-  stru149 *v18; // eax@14
-  stru149 *v19; // eax@14
-  signed int v20; // eax@14
-  int v21; // ecx@14
-  Texture *v22; // edx@16
-  signed int v23; // eax@16
-  int v24; // ebx@16
-  int v25; // edi@17
-  int v26; // ebx@17
-  int v27; // eax@17
-  int v28; // edi@17
-  int v29; // eax@18
-  signed __int64 v30; // qtt@19
-  int v31; // ecx@19
-  int v32; // eax@19
-  stru149 *v33; // eax@21
-  signed int v34; // edi@21
-  int v35; // ebx@21
-  signed int v36; // edi@21
-  signed __int64 v37; // qtt@21
-  signed int v38; // ebx@21
-  int v39; // ebx@29
-  int v40; // eax@32
-  unsigned __int64 v41; // qax@32
-  int v42; // edi@32
-  int v43; // eax@33
-  signed __int64 v44; // qtt@34
-  int v45; // ecx@34
-  int v46; // eax@34
-  stru149 *v47; // eax@36
-  signed int v48; // edi@36
-  int v49; // eax@36
-  int v50; // eax@47
-  unsigned __int64 v51; // qax@47
-  int v52; // edi@47
-  int v53; // eax@48
-  signed __int64 v54; // qtt@49
-  int v55; // ecx@49
-  int v56; // eax@49
-  stru149 *v57; // eax@51
-  signed int v58; // edi@51
-  int v59; // eax@51
-  Span *v61; // [sp+Ch] [bp-B0h]@1
-  int v62; // [sp+10h] [bp-ACh]@3
-  int v63; // [sp+14h] [bp-A8h]@3
-  int v64; // [sp+18h] [bp-A4h]@3
-  int v65; // [sp+1Ch] [bp-A0h]@3
-  signed int v66; // [sp+20h] [bp-9Ch]@3
-  signed int v67; // [sp+24h] [bp-98h]@3
-  int v68; // [sp+28h] [bp-94h]@1
-  char v69; // [sp+2Ch] [bp-90h]@1
-  stru315 sr; // [sp+30h] [bp-8Ch]@1
-  stru316 sr2; // [sp+74h] [bp-48h]@14
-  int v72; // [sp+9Ch] [bp-20h]@5
-  int v73; // [sp+A0h] [bp-1Ch]@1
-  int v74; // [sp+A4h] [bp-18h]@3
-  int v75; // [sp+A8h] [bp-14h]@21
-  int v76; // [sp+ACh] [bp-10h]@1
-  int v77; // [sp+B0h] [bp-Ch]@14
-  int v78; // [sp+B4h] [bp-8h]@3
-  int v79; // [sp+B8h] [bp-4h]@3
-
-  v2 = _this->field_A;
-  v3 = _this->field_8;
-  v4 = _this->pParent;
-  v73 = 0;
-  v61 = _this;
-  sr.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2];
-  v76 = v3;
-  v5 = _this->field_C;
-  sr.pColorBuffer = &pRenderer->pTargetSurface[v3 + pRenderer->uTargetSurfacePitch * v2];
-  v68 = texmapping_terrain_subdivsize;
-  v69 = texmapping_terrain_subdivpow2;
-  if ( v5 >= texmapping_terrain_subdivsize )
-    v73 = texmapping_terrain_subdivsize - (v3 & (texmapping_terrain_subdivsize - 1));
-  v6 = v5 - v73;
-  v67 = v6 >> texmapping_terrain_subdivpow2;
-  v62 = v6 - (v6 >> texmapping_terrain_subdivpow2 << texmapping_terrain_subdivpow2);
-  v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76);
-  v8 = v4->ptr_38;
-  v79 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76);
-  v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
-  v76 = v8->field_14;
-  v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16;
-  v9 = v4->ptr_38;
-  v10 = v78 + v9->field_C;
-  v76 = v9->field_20;
-  v65 = v10;
-  v11 = ((unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16)
-      + v4->ptr_38->field_18;
-  v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
-  v64 = v11;
-  v76 = v4->v_18.z;
-  v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16;
-  v12 = -v4->field_24;
-  v63 = v78 + v4->v_18.x;
-  v66 = -v4->field_24;
-  v78 = (unsigned __int64)(v79 * (signed __int64)v4->v_18.y) >> 16;
-  v74 = v78 + v63;
-  if ( !(v78 + v63) || (v76 = v12 >> 14, v13 = abs(v12 >> 14), v13 > abs(v74)) )
-    return 0;
-  LODWORD(v14) = v66 << 16;
-  HIDWORD(v14) = v66 >> 16;
-  v72 = v14 / v74;
-  sr.pTextureLOD = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2;
-  v15 = v14 / v74;
-  v16 = 2;
-  if ( v15 >= mipmapping_terrain_mm1 << 16 )
-  {
-    if ( v15 >= mipmapping_terrain_mm2 << 16 )
-    {
-      if ( v15 >= mipmapping_terrain_mm3 << 16 )
-      {
-        if ( bUseLoResSprites )
-          goto LABEL_14;
-        v16 = 3;
-        v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail3;
-      }
-      else
-      {
-        v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2;
-      }
-    }
-    else
-    {
-      v16 = 1;
-      v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail1;
-    }
-  }
-  else
-  {
-    v16 = 0;
-    v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0_prolly_alpha_mask;
-  }
-  sr.pTextureLOD = v17;
-LABEL_14:
-  sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v15, v4, pOutdoorCamera->terrain_gamma, 1u, 1);
-  v18 = v4->ptr_38;
-  v78 = v7;
-  v79 = v18->field_10;
-  v78 = v7;
-  v77 = v65 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16);
-  v79 = v4->ptr_38->field_1C;
-  v79 = v64 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16);
-  v78 = (unsigned __int64)(v77 * (signed __int64)v72) >> 16;
-  v19 = v4->ptr_38;
-  v78 = v72;
-  sr.field_30 = ((unsigned __int64)(v77 * (signed __int64)v72) >> 16) - v19->field_24;
-  v78 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16;
-  v20 = ((unsigned __int64)(v79 * (signed __int64)v72) >> 16) - v4->ptr_38->field_28;
-  v21 = bUseLoResSprites + v16 + 2;
-  sr.field_30 >>= v21;
-  v78 = bUseLoResSprites + v16 + 2;
-  sr.field_2C = v20 >> v21;
-  if ( byte_80AA10 )
-  {
-    sr.field_14 = dword_80AA20 >> v21;
-    sr.field_18 = dword_80AA1C >> v21;
-    sr.field_1C = dword_80AA18 >> v21;
-    sr.field_20 = dword_80AA14 >> v21;
-  }
-  v22 = v4->pTexture;
-  v79 = (signed int)v22->uTextureWidth >> v16;
-  v23 = (signed int)v22->uTextureHeight >> v16;
-  v24 = v16 - v22->uWidthLn2 + 16;
-  sr.field_8 = (v23 << 16) - 65536;
-  sr.field_10 = v24;
-  sr.field_C = v79 - 1;
-  if ( v73 )
-  {
-    v25 = v7 - v73 * pOutdoorCamera->int_fov_rad_inv;
-    v26 = v25;
-    v77 = v4->v_18.y;
-    v79 = v25;
-    v27 = (unsigned __int64)(v77 * (signed __int64)v25) >> 16;
-    v28 = v27 + v63;
-    v74 = v27 + v63;
-    if ( !(v27 + v63) || (v77 = abs(v76), v29 = abs(v28), v77 > v29) )
-      return 0;
-    LODWORD(v30) = v66 << 16;
-    HIDWORD(v30) = v66 >> 16;
-    v77 = v30 / v74;
-    v31 = v30 / v74;
-    HIWORD(v32) = HIWORD(v72);
-    if ( v72 <= v31 )
-      HIWORD(v32) = HIWORD(v31);
-    LOWORD(v32) = 0;
-    v77 = v26;
-    sr.field_24 = v32;
-    v74 = v4->ptr_38->field_10;
-    v74 = v65 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16);
-    v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16;
-    v33 = v4->ptr_38;
-    v77 = v26;
-    v34 = ((unsigned __int64)(v74 * (signed __int64)v31) >> 16) - v33->field_24;
-    v74 = v33->field_1C;
-    v74 = v64 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16);
-    v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16;
-    v35 = (v77 - v4->ptr_38->field_28) >> v78;
-    v74 = v73 << 16;
-    v36 = (v34 >> v78) - sr.field_30;
-    LODWORD(v37) = v36 << 16;
-    HIDWORD(v37) = v36 >> 16;
-    v38 = v35 - sr.field_2C;
-    sr.field_4 = v37 / (v73 << 16);
-    v75 = v73 << 16;
-    LODWORD(v37) = v38 << 16;
-    HIDWORD(v37) = v38 >> 16;
-    v77 = v37 / (v73 << 16);
-    sr.field_0 = v37 / (v73 << 16);
-    sr.field_28 = v73;
-    if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-    {
-      if ( byte_80AA10 )
-        sr_sub_485A24(&sr, (stru315 *)&sr2);
-      else
-        sr_sub_485975(&sr, (stru315 *)&sr2);
-    }
-    else
-    {
-      if ( byte_80AA10 )
-        sr_sub_4D705A(v1);
-      else
-        sr_sub_4D6FB0(v1);
-    }
-    v39 = v79 - (pOutdoorCamera->int_fov_rad_inv << v69);
-  }
-  else
-  {
-    v79 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69);
-    v39 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69);
-  }
-  sr.field_28 = v68;
-  while ( v67 > 0 )
-  {
-    v40 = v4->v_18.y;
-    --v67;
-    v75 = v40;
-    v41 = v40 * (signed __int64)v39;
-    v79 = v41 >> 16;
-    LODWORD(v41) = v41 >> 16;
-    v42 = v41 + v63;
-    v74 = v41 + v63;
-    if ( !((int)v41 + v63) || (v75 = abs(v76), v43 = abs(v42), v75 > v43) )
-      return 0;
-    LODWORD(v44) = v66 << 16;
-    HIDWORD(v44) = v66 >> 16;
-    v73 = v44 / v74;
-    v45 = v44 / v74;
-    HIWORD(v46) = HIWORD(v72);
-    if ( v72 <= v45 )
-      HIWORD(v46) = HIWORD(v45);
-    LOWORD(v46) = 0;
-    v79 = v39;
-    sr.field_24 = v46;
-    v75 = v4->ptr_38->field_10;
-    v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
-    v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16;
-    v47 = v4->ptr_38;
-    v79 = v39;
-    v48 = ((unsigned __int64)(v75 * (signed __int64)v45) >> 16) - v47->field_24;
-    v75 = v47->field_1C;
-    v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
-    v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16;
-    v49 = (((v79 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69;
-    sr.field_4 = ((v48 >> v78) - sr.field_30) >> v69;
-    sr.field_0 = v49;
-    if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-    {
-      if ( byte_80AA10 )
-        sr_sub_485A24(&sr, (stru315 *)&sr2);
-      else
-        sr_sub_485975(&sr, (stru315 *)&sr2);
-    }
-    else
-    {
-      if ( byte_80AA10 )
-        sr_sub_4D705A(v1);
-      else
-        sr_sub_4D6FB0(v1);
-    }
-    sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v73, v4, pOutdoorCamera->terrain_gamma, 1u, 0);
-    sr.field_28 = v68;
-    v39 -= pOutdoorCamera->int_fov_rad_inv << v69;
-  }
-  if ( !v62 )
-    return 1;
-  v50 = v4->v_18.y;
-  v75 = v50;
-  v51 = v50 * (signed __int64)v39;
-  v79 = v51 >> 16;
-  LODWORD(v51) = v51 >> 16;
-  v52 = v51 + v63;
-  v74 = v51 + v63;
-  if ( (int)v51 + v63 )
-  {
-    v75 = abs(v76);
-    v53 = abs(v52);
-    if ( v75 <= v53 )
-    {
-      LODWORD(v54) = v66 << 16;
-      HIDWORD(v54) = v66 >> 16;
-      v76 = v54 / v74;
-      v55 = v54 / v74;
-      HIWORD(v56) = HIWORD(v72);
-      if ( v72 <= v55 )
-        HIWORD(v56) = HIWORD(v55);
-      LOWORD(v56) = 0;
-      v76 = v39;
-      sr.field_24 = v56;
-      v75 = v4->ptr_38->field_10;
-      v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
-      v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16;
-      v57 = v4->ptr_38;
-      v76 = v39;
-      v58 = ((unsigned __int64)(v75 * (signed __int64)v55) >> 16) - v57->field_24;
-      v75 = v57->field_1C;
-      v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
-      v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16;
-      v59 = (((v76 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69;
-      sr.field_4 = ((v58 >> v78) - sr.field_30) >> v69;
-      sr.field_0 = v59;
-      sr.field_28 = v62;
-      if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-      {
-        if ( byte_80AA10 )
-          sr_sub_485A24(&sr, (stru315 *)&sr2);
-        else
-          sr_sub_485975(&sr, (stru315 *)&sr2);
-      }
-      else
-      {
-        if ( byte_80AA10 )
-          sr_sub_4D705A(v1);
-        else
-          sr_sub_4D6FB0(v1);
-      }
-      return 1;
-    }
-  }
-  return 0;
-}
-// 4D864C: using guessed type char byte_4D864C;
-// 6BE050: using guessed type int texmapping_terrain_subdivsize;
-// 6BE054: using guessed type int texmapping_terrain_subdivpow2;
-// 6BE0F0: using guessed type int mipmapping_terrain_mm1;
-// 6BE0F4: using guessed type int mipmapping_terrain_mm2;
-// 6BE0F8: using guessed type int mipmapping_terrain_mm3;
-// 80AA10: using guessed type char byte_80AA10;
-// 80AA14: using guessed type int dword_80AA14;
-// 80AA18: using guessed type int dword_80AA18;
-// 80AA1C: using guessed type int dword_80AA1C;
-// 80AA20: using guessed type int dword_80AA20;
-
-//----- (00485407) --------------------------------------------------------
-signed int __fastcall sr_sub_485407_prolly_odm_water_wavy(Span *a1)
-{
-  stru315 *v1; // ebp@0
-  int v2; // eax@1
-  int v3; // edx@1
-  unsigned int v4; // edi@1
-  stru148 *v5; // esi@1
-  int v6; // ecx@1
-  int v7; // ebx@1
-  int v8; // ecx@1
-  stru149 *v9; // eax@1
-  stru149 *v10; // eax@1
-  int v11; // edx@1
-  int v12; // eax@1
-  int v13; // eax@1
-  int v14; // ecx@1
-  signed int v15; // edi@1
-  int v16; // edi@2
-  signed __int64 v17; // qtt@3
-  int v18; // edi@3
-  int v19; // eax@3
-  unsigned __int8 *pLOD; // eax@3
-  Texture *v21; // eax@4
-  Texture *v22; // eax@6
-  Texture *v23; // eax@8
-  Texture *v24; // eax@10
-  stru149 *v25; // eax@13
-  stru149 *v26; // eax@13
-  signed int v27; // ebx@13
-  stru149 *v28; // eax@13
-  Texture *v29; // esi@13
-  signed int v30; // ebx@13
-  signed int v31; // edi@13
-  signed int v32; // edx@13
-  signed int v33; // eax@13
-  int v34; // esi@13
-  int v35; // eax@13
-  unsigned __int64 v36; // qax@13
-  int v37; // eax@13
-  unsigned __int64 v38; // qax@13
-  char v39; // cl@14
-  stru316 a2; // [sp+Ch] [bp-90h]@13
-  stru315 a1a; // [sp+34h] [bp-68h]@1
-  Span *v43; // [sp+78h] [bp-24h]@1
-  int v44; // [sp+7Ch] [bp-20h]@1
-  int v45; // [sp+80h] [bp-1Ch]@1
-  int v46; // [sp+84h] [bp-18h]@1
-  Span *v47; // [sp+88h] [bp-14h]@1
-  int v48; // [sp+8Ch] [bp-10h]@1
-  int v49; // [sp+90h] [bp-Ch]@3
-  int i; // [sp+94h] [bp-8h]@3
-  int X; // [sp+98h] [bp-4h]@1
-
-  v2 = a1->field_A;
-  v3 = a1->field_8;
-  v4 = v3 + pRenderer->uTargetSurfacePitch * a1->field_A;
-  v5 = a1->pParent;
-  v43 = a1;
-  v6 = a1->field_C;
-  a1a.pColorBuffer = &pRenderer->pTargetSurface[v4];
-  v46 = v6;
-  v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v3);
-  v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
-  a1a.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2];
-  v9 = v5->ptr_38;
-  v47 = (Span *)v7;
-  X = v8;
-  v48 = v9->field_14;
-  X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16;
-  v10 = v5->ptr_38;
-  v11 = X + v10->field_C;
-  v48 = v10->field_20;
-  v44 = v11;
-  v12 = ((unsigned __int64)(v48 * (signed __int64)v8) >> 16) + v5->ptr_38->field_18;
-  X = v8;
-  v45 = v12;
-  v48 = v5->v_18.z;
-  X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16;
-  v13 = v5->v_18.y;
-  v14 = X + v5->v_18.x;
-  v15 = -v5->field_24;
-  v48 = -v5->field_24;
-  X = ((unsigned __int64)(v7 * (signed __int64)v13) >> 16) + v14;
-  if ( !X || (v16 = abs(v15 >> 14), v16 > abs(X)) )
-    return 0;
-  LODWORD(v17) = v48 << 16;
-  HIDWORD(v17) = v48 >> 16;
-  i = v17 / X;
-  v18 = v17 / X;
-  HIWORD(v19) = (unsigned int)(v17 / X) >> 16;
-  LOWORD(v19) = 0;
-  a1a.field_24 = v19;
-  pLOD = v5->pTexture->pLevelOfDetail2;
-  a1a.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
-  v49 = 2;
-  if ( v18 >= mipmapping_terrain_mm1 << 16 )
-  {
-    if ( v18 >= mipmapping_terrain_mm2 << 16 )
-    {
-      if ( v18 >= mipmapping_terrain_mm3 << 16 )
-      {
-        if ( bUseLoResSprites )
-          goto LABEL_12;
-        v24 = v5->pTexture;
-        v49 = 3;
-        pLOD = v24->pLevelOfDetail3;
-      }
-      else
-      {
-        v23 = v5->pTexture;
-        v49 = 2;
-        pLOD = v23->pLevelOfDetail2;
-      }
-    }
-    else
-    {
-      v22 = v5->pTexture;
-      v49 = 1;
-      pLOD = v22->pLevelOfDetail1;
-    }
-  }
-  else
-  {
-    v21 = v5->pTexture;
-    v49 = 0;
-    pLOD = v21->pLevelOfDetail0_prolly_alpha_mask;
-  }
-  a1a.pTextureLOD = (unsigned __int16 *)pLOD;
-LABEL_12:
-  if ( !pLOD )
-    return 0;
-  a1a.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v43, v18, v5, pOutdoorCamera->terrain_gamma, 1u, 1);
-  a1a.field_28 = 16;
-  v43 = (Span *)(v46 >> 4);
-  X = v7;
-  v25 = v5->ptr_38;
-  v48 = v46 - 16 * (v46 >> 4);
-  v46 = v25->field_10;
-  X = v7;
-  v46 = v44 + ((unsigned __int64)(v46 * (signed __int64)v7) >> 16);
-  v44 = v5->ptr_38->field_1C;
-  v45 += (unsigned __int64)(v44 * (signed __int64)v7) >> 16;
-  X = (unsigned __int64)(v46 * (signed __int64)v18) >> 16;
-  v26 = v5->ptr_38;
-  X = v18;
-  v27 = ((unsigned __int64)(v46 * (signed __int64)v18) >> 16) - v26->field_24;
-  X = (unsigned __int64)(v45 * (signed __int64)v18) >> 16;
-  v28 = v5->ptr_38;
-  v29 = v5->pTexture;
-  v44 = bUseLoResSprites + v49 + 2;
-  v30 = v27 >> v44;
-  v31 = (signed int)(((unsigned __int64)(v45 * (signed __int64)v18) >> 16) - v28->field_28) >> v44;
-  v32 = (signed int)v29->uTextureWidth >> v49;
-  v33 = (signed int)v29->uTextureHeight >> v49;
-  v34 = v49 - v29->uWidthLn2;
-  a1a.field_8 = (v33 << 16) - 65536;
-  X = 2 * pMiscTimer->uTotalGameTimeElapsed;
-  v45 = pOutdoorCamera->int_fov_rad_inv;
-  a1a.field_10 = v34 + 16;
-  a1a.field_C = v32 - 1;
-  i = (unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)i) >> 16;
-  v47 = (Span *)(i >> v44);
-  v35 = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
-  v36 = (signed int)v47 * (signed __int64)v35;
-  i = v36 >> 16;
-  a1a.field_4 = v36 >> 16;
-  v37 = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
-  v38 = (signed int)v47 * (signed __int64)v37;
-  i = v38 >> 16;
-  a1a.field_0 = v38 >> 16;
-  if ( (signed int)v43 > 0 )
-  {
-    v47 = v43;
-    v39 = 12 - v49;
-    for ( i = 12 - v49; ; v39 = i )
-    {
-      a1a.field_30 = v30 + 4 * stru_5C6E00->Cos(X + (v31 >> v39));
-      a1a.field_2C = v31 + 4 * stru_5C6E00->Sin(X + (v30 >> i));
-      if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-        sr_sub_485975(&a1a, (stru315 *)&a2);
-      else
-        sr_sub_4D6FB0(v1);
-      a1a.field_28 = 16;
-      v30 += 16 * a1a.field_4;
-      v31 += 16 * a1a.field_0;
-      v47 = (Span *)((char *)v47 - 1);
-      if ( !v47 )
-        break;
-    }
-  }
-  if ( v48 )
-  {
-    i = 12 - v49;
-    a1a.field_30 = v30 + 4 * stru_5C6E00->Cos(X + (v31 >> (12 - v49)));
-    a1a.field_2C = v31 + 4 * stru_5C6E00->Sin(X + (v30 >> i));
-    a1a.field_28 = v48;
-    if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
-      sr_sub_485975(&a1a, (stru315 *)&a2);
-    else
-      sr_sub_4D6FB0(v1);
-  }
-  return 1;
-}
-
-//----- (0048585C) --------------------------------------------------------
-signed int __fastcall sr_sub_48585C_mb_DrawSpan(Span *a1, unsigned __int16 *pRenderTarget, int a4)
-{
-  Span *v3; // esi@1
-  stru148 *v4; // edi@1
-  int v5; // ebx@2
-  signed __int64 v6; // qtt@3
-  int v7; // ebx@3
-  signed int v8; // ecx@3
-  void *v9; // eax@5
-  int v10; // ecx@5
-  unsigned __int16 *pPixels; // [sp+Ch] [bp-14h]@1
-  signed int v13; // [sp+10h] [bp-10h]@1
-  int X; // [sp+18h] [bp-8h]@1
-
-  v3 = a1;
-  pPixels = pRenderTarget;
-  v4 = a1->pParent;
-  v13 = -v4->field_24;
-  X = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv
-                        * (pViewport->uScreenCenterX - (signed int)a1->field_8)
-                        * (signed __int64)v4->v_18.y) >> 16)
-    + ((unsigned __int64)(v4->v_18.z
-                        * (signed __int64)(pOutdoorCamera->int_fov_rad_inv
-                                         * (pViewport->uScreenCenterY - (signed int)a1->field_A))) >> 16)
-    + v4->v_18.x;
-  if ( X && (v5 = abs(-v4->field_24 >> 14), v5 <= abs(X)) )
-  {
-    LODWORD(v6) = v13 << 16;
-    HIDWORD(v6) = v13 >> 16;
-    v7 = v6 / X;
-    v8 = v6 / X;
-  }
-  else
-  {
-    v7 = pOutdoorCamera->shading_dist_mist << 16;
-    v8 = pOutdoorCamera->shading_dist_mist << 16;
-  }
-  v9 = sr_sub_47C178(v8, v4, pOutdoorCamera->terrain_gamma, a4);
-  fill_pixels_fast(*((short *)v9 + v4->pTexture->uDecompressedSize), pPixels, v3->field_C);
-  HIWORD(v10) = HIWORD(v7);
-  LOWORD(v10) = 0;
-  j_memset32(v10, &pRenderer->pActiveZBuffer[v3->field_8 + 640 * v3->field_A], v3->field_C);
-  return 1;
-}
-
-//----- (00485975) --------------------------------------------------------
-stru315 *__fastcall sr_sub_485975(stru315 *a1, stru315 *a2)
-{
-  stru315 *result; // eax@1
-  int i; // ecx@1
-  int v4; // esi@2
-  int v5; // esi@2
-  int v6; // ecx@2
-  int v7; // esi@3
-  int v8; // edi@3
-  int v9; // ebx@3
-  int v10; // ecx@8
-  unsigned __int16 *v11; // esi@10
-  unsigned int *v12; // ecx@12
-  int v13; // esi@12
-  int v14; // [sp+0h] [bp-4h]@2
-
-  result = a1;
-  for ( i = a1->field_28; i; i = result->field_28 )
-  {
-    v4 = result->field_8 & result->field_2C;
-    result->field_28 = i - 1;
-    v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
-    v6 = *((char *)result->pTextureLOD + v5);
-    v14 = *((char *)result->pTextureLOD + v5);
-    if ( a2->field_20 )
-    {
-      v7 = HIWORD(a2->field_10);
-      v8 = a2->field_C;
-      v9 = v7;
-      if ( v7 >= v8 )
-        v9 = a2->field_C;
-      if ( a2->field_8 - v9 <= 0 )
-      {
-        v10 = 0;
-      }
-      else
-      {
-        if ( v7 >= v8 )
-          v7 = a2->field_C;
-        v10 = a2->field_8 - v7;
-      }
-      v11 = (unsigned __int16 *)a2->field_24;
-      v6 = v14 + (v10 << 8);
-    }
-    else
-    {
-      v11 = result->field_34_palette;
-    }
-    *result->pColorBuffer = v11[v6];
-    v12 = result->pDepthBuffer;
-    v13 = result->field_24;
-    ++result->pColorBuffer;
-    *v12 = v13;
-    ++result->pDepthBuffer;
-    a2->field_10 += a2->field_18;
-    result->field_30 += result->field_4;
-    result->field_2C += result->field_0;
-  }
-  --result->field_28;
-  return result;
-}
-
-//----- (00485A24) --------------------------------------------------------
-stru315 *__fastcall sr_sub_485A24(stru315 *a1, stru315 *a2)
-{
-  stru315 *result; // eax@1
-  int i; // ecx@1
-  int v4; // ecx@2
-  int v5; // ecx@4
-  int v6; // ecx@6
-  int v7; // ecx@8
-  int v8; // esi@10
-  int v9; // ecx@10
-  int v10; // esi@11
-  int v11; // edi@11
-  int v12; // ebx@11
-  int v13; // ecx@16
-  unsigned __int16 *v14; // esi@18
-  unsigned int *v15; // ecx@20
-  int v16; // esi@20
-  int v17; // [sp+0h] [bp-4h]@10
-
-  result = a1;
-  for ( i = a1->field_28; i; i = result->field_28 )
-  {
-    result->field_28 = i - 1;
-    v4 = result->field_18;
-    if ( result->field_30 > v4 )
-      result->field_30 = v4;
-    v5 = result->field_20;
-    if ( result->field_2C > v5 )
-      result->field_2C = v5;
-    v6 = result->field_14;
-    if ( result->field_30 < v6 )
-      result->field_30 = v6;
-    v7 = result->field_1C;
-    if ( result->field_2C < v7 )
-      result->field_2C = v7;
-    v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
-    v9 = *((char *)result->pTextureLOD + v8);
-    v17 = *((char *)result->pTextureLOD + v8);
-    if ( a2->field_20 )
-    {
-      v10 = HIWORD(a2->field_10);
-      v11 = a2->field_C;
-      v12 = v10;
-      if ( v10 >= v11 )
-        v12 = a2->field_C;
-      if ( a2->field_8 - v12 <= 0 )
-      {
-        v13 = 0;
-      }
-      else
-      {
-        if ( v10 >= v11 )
-          v10 = a2->field_C;
-        v13 = a2->field_8 - v10;
-      }
-      v14 = (unsigned __int16 *)a2->field_24;
-      v9 = v17 + (v13 << 8);
-    }
-    else
-    {
-      v14 = result->field_34_palette;
-    }
-    *result->pColorBuffer = v14[v9];
-    v15 = result->pDepthBuffer;
-    v16 = result->field_24;
-    ++result->pColorBuffer;
-    *v15 = v16;
-    ++result->pDepthBuffer;
-    a2->field_10 += a2->field_18;
-    result->field_30 += result->field_4;
-    result->field_2C += result->field_0;
-  }
-  --result->field_28;
-  return result;
-}
-
-//----- (00485AFF) --------------------------------------------------------
-stru315 *__fastcall sr_sub_485AFF(stru315 *a1, stru316 *a2)
-{
-  stru315 *result; // eax@1
-  int i; // ecx@1
-  int v4; // esi@2
-  int v5; // esi@2
-  int v6; // ecx@2
-  int v7; // esi@3
-  int v8; // edi@3
-  int v9; // ebx@3
-  int v10; // ecx@8
-  unsigned __int16 *v11; // esi@10
-  unsigned int *v12; // ecx@12
-  int v13; // esi@12
-  int v14; // [sp+0h] [bp-4h]@2
-
-  result = a1;
-  for ( i = a1->field_28; i; i = result->field_28 )
-  {
-    v4 = result->field_8 & result->field_2C;
-    result->field_28 = i - 1;
-    v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
-    v6 = *((char *)result->pTextureLOD + v5);
-    v14 = *((char *)result->pTextureLOD + v5);
-    if ( a2->field_20 )
-    {
-      v7 = HIWORD(a2->field_14);
-      v8 = a2->field_C;
-      v9 = v7;
-      if ( v7 >= v8 )
-        v9 = a2->field_C;
-      if ( a2->field_8 - v9 <= 0 )
-      {
-        v10 = 0;
-      }
-      else
-      {
-        if ( v7 >= v8 )
-          v7 = a2->field_C;
-        v10 = a2->field_8 - v7;
-      }
-      v11 = a2->field_24_palette;
-      v6 = v14 + (v10 << 8);
-    }
-    else
-    {
-      v11 = result->field_34_palette;
-    }
-    *result->pColorBuffer = v11[v6];
-    v12 = result->pDepthBuffer;
-    v13 = result->field_24;
-    --result->pColorBuffer;
-    *v12 = v13;
-    --result->pDepthBuffer;
-    a2->field_14 -= a2->field_18;
-    result->field_30 += result->field_4;
-    result->field_2C += result->field_0;
-  }
-  --result->field_28;
-  return result;
-}
-
-//----- (00485BAE) --------------------------------------------------------
-stru315 *__fastcall sr_sub_485BAE(stru315 *a1, stru316 *a2)
-{
-  stru315 *result; // eax@1
-  int i; // ecx@1
-  int v4; // ecx@2
-  int v5; // ecx@4
-  int v6; // ecx@6
-  int v7; // ecx@8
-  int v8; // esi@10
-  int v9; // ecx@10
-  int v10; // esi@11
-  int v11; // edi@11
-  int v12; // ebx@11
-  int v13; // ecx@16
-  unsigned __int16 *v14; // esi@18
-  unsigned int *v15; // ecx@20
-  int v16; // esi@20
-  int v17; // [sp+0h] [bp-4h]@10
-
-  result = a1;
-  for ( i = a1->field_28; i; i = result->field_28 )
-  {
-    result->field_28 = i - 1;
-    v4 = result->field_18;
-    if ( result->field_30 > v4 )
-      result->field_30 = v4;
-    v5 = result->field_20;
-    if ( result->field_2C > v5 )
-      result->field_2C = v5;
-    v6 = result->field_14;
-    if ( result->field_30 < v6 )
-      result->field_30 = v6;
-    v7 = result->field_1C;
-    if ( result->field_2C < v7 )
-      result->field_2C = v7;
-    v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
-    v9 = *((char *)result->pTextureLOD + v8);
-    v17 = *((char *)result->pTextureLOD + v8);
-    if ( a2->field_20 )
-    {
-      v10 = HIWORD(a2->field_14);
-      v11 = a2->field_C;
-      v12 = v10;
-      if ( v10 >= v11 )
-        v12 = a2->field_C;
-      if ( a2->field_8 - v12 <= 0 )
-      {
-        v13 = 0;
-      }
-      else
-      {
-        if ( v10 >= v11 )
-          v10 = a2->field_C;
-        v13 = a2->field_8 - v10;
-      }
-      v14 = a2->field_24_palette;
-      v9 = v17 + (v13 << 8);
-    }
-    else
-    {
-      v14 = result->field_34_palette;
-    }
-    *result->pColorBuffer = v14[v9];
-    v15 = result->pDepthBuffer;
-    v16 = result->field_24;
-    --result->pColorBuffer;
-    *v15 = v16;
-    --result->pDepthBuffer;
-    a2->field_14 -= a2->field_18;
-    result->field_30 += result->field_4;
-    result->field_2C += result->field_0;
-  }
-  --result->field_28;
-  return result;
-}
-
-//----- (00485C89) --------------------------------------------------------
-stru315 *__fastcall sr_sub_485C89(stru315 *a1, stru316 *a2)
-{
-  stru315 *result; // eax@1
-  int i; // ecx@1
-  int v4; // esi@2
-  int v5; // esi@2
-  int v6; // ecx@2
-  int v7; // esi@4
-  int v8; // edi@4
-  int v9; // ecx@9
-  unsigned __int16 *v10; // esi@11
-  unsigned int *v11; // ecx@14
-  int v12; // esi@14
-  int v13; // [sp+0h] [bp-4h]@2
-
-  result = a1;
-  for ( i = a1->field_28; i; i = result->field_28 )
-  {
-    v4 = result->field_8 & result->field_2C;
-    result->field_28 = i - 1;
-    v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
-    v6 = *((char *)result->pTextureLOD + v5);
-    v13 = *((char *)result->pTextureLOD + v5);
-    if ( *((char *)result->pTextureLOD + v5) )
-    {
-      if ( a2->field_20 )
-      {
-        v7 = HIWORD(a2->field_10);
-        v8 = v7;
-        if ( v7 >= a2->field_C )
-          v8 = a2->field_C;
-        if ( a2->field_8 - v8 <= 0 )
-        {
-          v9 = 0;
-        }
-        else
-        {
-          if ( v7 >= a2->field_C )
-            v7 = a2->field_C;
-          v9 = a2->field_8 - v7;
-        }
-        v10 = a2->field_24_palette;
-        v6 = v13 + (v9 << 8);
-      }
-      else
-      {
-        v10 = result->field_34_palette;
-      }
-      *result->pColorBuffer = v10[v6];
-    }
-    v11 = result->pDepthBuffer;
-    v12 = result->field_24;
-    ++result->pColorBuffer;
-    *v11 = v12;
-    ++result->pDepthBuffer;
-    a2->field_10 += a2->field_18;
-    result->field_30 += result->field_4;
-    result->field_2C += result->field_0;
-  }
-  --result->field_28;
-  return result;
-}
-
-//----- (00485D3E) --------------------------------------------------------
-stru315 *__fastcall sr_sub_485D3E(stru315 *a1, stru316 *a2)
-{
-  stru315 *result; // eax@1
-  int i; // ecx@1
-  int v4; // ecx@2
-  int v5; // ecx@4
-  int v6; // ecx@6
-  int v7; // ecx@8
-  int v8; // esi@10
-  int v9; // ecx@10
-  int v10; // esi@12
-  int v11; // edi@12
-  int v12; // ecx@17
-  unsigned __int16 *v13; // esi@19
-  unsigned int *v14; // ecx@22
-  int v15; // esi@22
-  int v16; // [sp+0h] [bp-4h]@10
-
-  result = a1;
-  for ( i = a1->field_28; i; i = result->field_28 )
-  {
-    result->field_28 = i - 1;
-    v4 = result->field_18;
-    if ( result->field_30 > v4 )
-      result->field_30 = v4;
-    v5 = result->field_20;
-    if ( result->field_2C > v5 )
-      result->field_2C = v5;
-    v6 = result->field_14;
-    if ( result->field_30 < v6 )
-      result->field_30 = v6;
-    v7 = result->field_1C;
-    if ( result->field_2C < v7 )
-      result->field_2C = v7;
-    v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
-    v9 = *((char *)result->pTextureLOD + v8);
-    v16 = *((char *)result->pTextureLOD + v8);
-    if ( *((char *)result->pTextureLOD + v8) )
-    {
-      if ( a2->field_20 )
-      {
-        v10 = HIWORD(a2->field_10);
-        v11 = v10;
-        if ( v10 >= a2->field_C )
-          v11 = a2->field_C;
-        if ( a2->field_8 - v11 <= 0 )
-        {
-          v12 = 0;
-        }
-        else
-        {
-          if ( v10 >= a2->field_C )
-            v10 = a2->field_C;
-          v12 = a2->field_8 - v10;
-        }
-        v13 = a2->field_24_palette;
-        v9 = v16 + (v12 << 8);
-      }
-      else
-      {
-        v13 = result->field_34_palette;
-      }
-      *result->pColorBuffer = v13[v9];
-    }
-    v14 = result->pDepthBuffer;
-    v15 = result->field_24;
-    ++result->pColorBuffer;
-    *v14 = v15;
-    ++result->pDepthBuffer;
-    a2->field_10 += a2->field_18;
-    result->field_30 += result->field_4;
-    result->field_2C += result->field_0;
-  }
-  --result->field_28;
-  return result;
-}
-
-//----- (00485E1F) --------------------------------------------------------
-void *__fastcall sr_sub_485E1F(stru316 *a1, Span *a2, int a3, stru148 *a4, int a5, unsigned __int8 a6, char a7)
-{
-  stru316 *v7; // esi@1
-  signed int *v8; // edi@1
-  signed int *v9; // ebx@1
-  char v10; // zf@1
-  int v11; // eax@1
-  Span *v12; // ecx@3
-  double v13; // ST24_8@3
-  double v14; // ST24_8@3
-  int v15; // eax@3
-  signed int v16; // ST14_4@4
-  char v17; // dl@4
-  signed int v18; // ST10_4@4
-  void *v19; // eax@4
-  signed int v20; // ST14_4@5
-  char v21; // dl@5
-  int v22; // ST10_4@5
-  signed int v23; // ST14_4@6
-  char v24; // dl@6
-  Span *v26; // [sp+10h] [bp-8h]@1
-  char v27; // [sp+16h] [bp-2h]@1
-  char v28; // [sp+17h] [bp-1h]@1
-  float v29; // [sp+30h] [bp+18h]@3
-  float v30; // [sp+30h] [bp+18h]@3
-
-  v7 = a1;
-  v26 = a2;
-  v8 = &a1->field_C;
-  v9 = &a1->field_8;
-  v10 = a1->field_0 == 0;
-  v27 = a1->field_4 != 0;
-  v28 = !v10;
-  sr_sub_47BEB1(a3, a4, a5, 0, &a1->field_8, &a1->field_C, (int)&v27, (int)&v28);
-  v7->field_24_palette = (unsigned __int16 *)sr_sub_47C28C_get_palette(a4, v28, *v9, *v8);
-  v11 = a4->field_108;
-  v7->field_20 = v11;
-  if ( v11 )
-  {
-    if ( a7 )
-    {
-      v12 = v26;
-      v29 = v26->field_10 * 31.0;
-      v13 = v29 + 6.7553994e15;
-      v7->field_10 = LODWORD(v13) << 16;
-      v30 = v12->field_14 * 31.0;
-      v14 = v30 + 6.7553994e15;
-      v15 = v7->field_10;
-      v7->field_14 = LODWORD(v14) << 16;
-      v7->field_18 = -((v15 - (LODWORD(v14) << 16)) / v12->field_C);
-    }
-    v16 = *v8;
-    v17 = v28;
-    v18 = *v9;
-    v7->field_1C = a6;
-    v19 = sr_sub_47C28C_get_palette(a4, v17, v18, v16);
-  }
-  else
-  {
-    v20 = *v8;
-    v21 = v28;
-    v7->field_10 = 0;
-    v7->field_14 = 0;
-    v22 = *v9;
-    v7->field_18 = 0;
-    v7->field_1C = 0;
-    v19 = sr_sub_47C1CA(a4, v21, v22, v20);
-  }
-  v23 = *v8;
-  v24 = v28;
-  v7->field_24_palette = (unsigned __int16 *)v19;
-  return sr_sub_47C1CA(a4, v24, *v9, v23);
-}
+
+
+
 
 //----- (00485F53) --------------------------------------------------------
-void __thiscall sub_485F53(Vec2_int_ *v)
+void __thiscall sr_485F53(Vec2_int_ *v)
 {
   ++v->y;
   if ( v->y > 1000 )
@@ -10364,16 +6462,16 @@
 }
 
 //----- (0048607B) --------------------------------------------------------
-void stru148::_48607B(stru149 *a2)
+void Polygon::_48607B(stru149 *a2)
 {
   this->pTexture = 0;
   this->ptr_38 = a2;
 }
 
 //----- (00486089) --------------------------------------------------------
-void stru148::_486089_normalize_v_18()
+void Polygon::_486089_normalize_v_18()
 {
-  //stru148 *v1; // esi@1
+  //Polygon *v1; // esi@1
   double v2; // st7@1
   double v3; // st6@1
   float v4; // ST18_4@2
@@ -10528,236 +6626,31 @@
 }
 
 //----- (0048694B) --------------------------------------------------------
-void stru149::sky_48694B()
+int stru149::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;
-  this->field_24 = (unsigned __int64)(this->field_C * (signed __int64)this->field_0_party_dir_x) >> 16
+  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
                  + ((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);
-  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);
+  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;
 }
 
-//----- (00486B4E) --------------------------------------------------------
-char __fastcall sr_sub_486B4E_push_outdoor_edges(RenderVertexSoft *a1, int *a2, int *a3, stru148 *a4)//maybe DrawPolygonSW
-{
-  stru148 *v4; // esi@1
-  RenderVertexSoft *v5; // edi@1
-  char v6; // zf@1
-  unsigned int v7; // eax@3
-  int v8; // ebx@3
-  int *v9; // ecx@7
-  int v10; // ebx@8
-  int v11; // eax@10
-  double v12; // st7@14
-  int *v13; // edx@14
-  double v14; // st6@14
-  double v15; // st7@16
-  int v16; // edi@16
-  double v17; // st7@16
-  double v18; // st7@16
-  int v19; // edi@18
-  double v20; // st7@18
-  double v21; // st7@18
-  Edge *i; // edx@20
-  double v23; // st7@28
-  Edge *v24; // eax@28
-  std::string v26; // [sp-18h] [bp-98h]@2
-  const char *v27; // [sp-8h] [bp-88h]@2
-  int v28; // [sp-4h] [bp-84h]@2
-  double v29; // [sp+Ch] [bp-74h]@28
-  double v30; // [sp+14h] [bp-6Ch]@28
-  double v31; // [sp+1Ch] [bp-64h]@20
-  double v32; // [sp+24h] [bp-5Ch]@16
-  double v33; // [sp+2Ch] [bp-54h]@14
-  unsigned int v34; // [sp+34h] [bp-4Ch]@2
-  unsigned __int64 v35; // [sp+38h] [bp-48h]@28
-  int v36; // [sp+40h] [bp-40h]@28
-  int v37; // [sp+44h] [bp-3Ch]@20
-  float v38; // [sp+48h] [bp-38h]@18
-  int v39; // [sp+4Ch] [bp-34h]@16
-  int v40; // [sp+50h] [bp-30h]@14
-  int v41; // [sp+54h] [bp-2Ch]@3
-  RenderVertexSoft *v42; // [sp+58h] [bp-28h]@1
-  int v43; // [sp+5Ch] [bp-24h]@14
-  int v44; // [sp+60h] [bp-20h]@6
-  int v45; // [sp+64h] [bp-1Ch]@6
-  unsigned int v46; // [sp+68h] [bp-18h]@7
-  int *v47; // [sp+6Ch] [bp-14h]@1
-  int v48; // [sp+70h] [bp-10h]@7
-  float *v49; // [sp+74h] [bp-Ch]@7
-  float v50; // [sp+78h] [bp-8h]@10
-  float v51; // [sp+7Ch] [bp-4h]@14
-
-  v4 = a4;
-  v5 = a1;
-  v47 = a2;
-  v6 = (HIBYTE(a4->flags) & 0x40) == 0;
-  v42 = a1;
-  if ( !v6 )
-  {
-          MessageBoxW(nullptr, L"The Texture Frame Table is not a supported feature.", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odspan.cpp:162", 0);
-  }
-  LOBYTE(v7) = v4->field_108;
-  v8 = v4->uNumVertices;
-  v4->field_108 = 0;
-  BYTE3(a4) = v7;
-  v41 = v8;
-  if ( v8 > 0 )
-  {
-    if ( (signed int)pOutdoorCamera->uNumSurfs < 1999 )
-    {
-      v7 = pOutdoorCamera->uNumEdges;
-      if ( (signed int)pOutdoorCamera->uNumEdges < 5979 )
-      {
-        v4->uEdgeList1Size = 0;
-        v4->uEdgeList2Size = 0;
-        v45 = -1;
-        v34 = v7;
-        v28 = v8;
-        v27 = (const char *)v5;
-        v44 = 10000;
-        pGame->pLightmapBuilder->_45CB89(v5, v8);
-        if ( v8 > 0 )
-        {
-          v9 = a3;
-          v48 = 1;
-          v49 = &v5->flt_2C;
-          v46 = (char *)v47 - (char *)a3;
-          do
-          {
-            v10 = v48;
-            ++pOutdoorCamera->uNumEdges;
-            if ( v48 >= v41 )
-              v10 = 0;
-            v11 = *v9;
-            LODWORD(v50) = *v9;
-            if ( SLODWORD(v50) > v45 )
-              v45 = v11;
-            if ( v11 < v44 )
-              v44 = v11;
-            v12 = (double)SLODWORD(v50);
-            v13 = &a3[v10];
-            v51 = v12;
-            v14 = (double)*v13;
-            v50 = v14;
-            *(float *)&v40 = v14 - v12;
-            v33 = *(float *)&v40 + 6.7553994e15;
-            v43 = LODWORD(v33);
-            if ( LODWORD(v33) )
-            {
-              if ( SLODWORD(v33) >= 0 )
-              {
-                v19 = (int)((char *)v9 + v46);
-                ptr_80C978_Edges->field_8 = 1;
-                LODWORD(v38) = (int)&v47[v10];
-                v40 = *(unsigned int *)LODWORD(v38) - *(int *)v19;
-                v6 = BYTE3(a4) == 0;
-                v20 = (double)v40;
-                v40 = *v13 - *v9;
-                v21 = v20 / (double)v40;
-                ptr_80C978_Edges->field_4 = v21;
-                ptr_80C978_Edges->field_0 = (v51 - (double)*v9) * v21 + (double)*(signed int *)v19;
-                if ( !v6 )
-                {
-                  ptr_80C978_Edges->field_1C = *v49;
-                  ptr_80C978_Edges->field_20 = v42[v10].flt_2C;
-                  ptr_80C978_Edges->field_24 = (double)*(signed int *)v19;
-                  ptr_80C978_Edges->field_28 = (double)(signed int)*(unsigned int *)LODWORD(v38);
-                  ptr_80C978_Edges->field_2C = (double)*v9;
-                  ptr_80C978_Edges->field_30 = (double)*v13;
-                  v4->pEdgeList1[v4->uEdgeList1Size++] = ptr_80C978_Edges;
-                }
-              }
-              else
-              {
-                v32 = v51 + 6.7553994e15;
-                v39 = LODWORD(v32);
-                v51 = v50;
-                v15 = (double)SLODWORD(v32);
-                ptr_80C978_Edges->field_8 = 0;
-                v16 = (int)&v47[v10];
-                v50 = v15;
-                v40 = *(int *)((char *)v9 + v46) - *(int *)v16;
-                v6 = BYTE3(a4) == 0;
-                v17 = (double)v40;
-                v40 = *v9 - *v13;
-                v18 = v17 / (double)v40;
-                ptr_80C978_Edges->field_4 = v18;
-                ptr_80C978_Edges->field_0 = (v51 - (double)*v13) * v18 + (double)*(signed int *)v16;
-                if ( !v6 )
-                {
-                  ptr_80C978_Edges->field_1C = v42[v10].flt_2C;
-                  ptr_80C978_Edges->field_20 = *v49;
-                  ptr_80C978_Edges->field_24 = (double)*(signed int *)v16;
-                  ptr_80C978_Edges->field_28 = (double)*(int *)((char *)v9 + v46);
-                  ptr_80C978_Edges->field_2C = (double)*v13;
-                  ptr_80C978_Edges->field_30 = (double)*v9;
-                  v4->pEdgeList2[v4->uEdgeList2Size++] = ptr_80C978_Edges;
-                }
-              }
-              v31 = v51 + 6.7553994e15;
-              v37 = LODWORD(v31);
-              for ( i = &pNewEdges[LODWORD(v31)]; i->pNext->field_0 < (double)ptr_80C978_Edges->field_0; i = i->pNext )
-                ;
-              if ( i->field_0 != ptr_80C978_Edges->field_0 || i->field_8 || ptr_80C978_Edges->field_8 != 1 )
-              {
-                ptr_80C978_Edges->pNext = i->pNext;
-                i->pNext = ptr_80C978_Edges;
-              }
-              else
-              {
-                ptr_80C978_Edges->pNext = i;
-                i->pPrev->pNext = ptr_80C978_Edges;
-              }
-              v23 = v50 - 1.0;
-              *(float *)&v40 = v23;
-              v38 = v23;
-              v30 = v38 + 6.7553994e15;
-              v36 = LODWORD(v30);
-              ptr_80C978_Edges->ptr_18 = ptr_80CA10[LODWORD(v30)];
-              v29 = *(float *)&v40 + 6.7553994e15;
-              v35 = __PAIR__(v40, LODWORD(v29));
-              v24 = ptr_80C978_Edges;
-              ptr_80CA10[LODWORD(v29)] = ptr_80C978_Edges;
-              v24->pSurf = ptr_80C97C_Surfs;
-              if ( ptr_80C978_Edges < &pEdges[5999] )
-                ++ptr_80C978_Edges;
-            }
-            ++v48;
-            v49 += 12;
-            ++v9;
-          }
-          while ( v48 - 1 < v41 );
-        }
-        LOBYTE(v7) = v34;
-        if ( pOutdoorCamera->uNumEdges != v34 )
-        {
-          v4->ptr_48 = 0;
-          ptr_80C97C_Surfs->field_22 = 0;
-          ptr_80C97C_Surfs->pParent = v4;
-          ptr_80C97C_Surfs->field_4 = v4->field_4;
-          ptr_80C97C_Surfs->field_8 = v4->field_8;
-          ptr_80C97C_Surfs->field_0 = v4->field_0;
-          ptr_80C97C_Surfs->field_C = v4->field_C;
-          ptr_80C97C_Surfs->field_10 = v4->field_10;
-          LOBYTE(v7) = (char)pSurfs + 28;
-          if ( ptr_80C97C_Surfs < &pSurfs[1999] )
-          {
-            ++ptr_80C97C_Surfs;
-            ++pOutdoorCamera->uNumSurfs;
-          }
-          if ( BYTE3(a4) )
-            v4->field_108 = 1;
-        }
-      }
-    }
-  }
-  return v7;
-}
 
 //----- (00440DF5) --------------------------------------------------------
 int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr)