changeset 2206:15a327be07e2

DrawSpriteObjects_ODM() cleaned
author Ritor1
date Thu, 06 Feb 2014 00:38:03 +0600
parents db94443ea4e7
children ff8920a40c21 7d5c05264a0d
files Indoor.cpp Render.cpp mm7_3.cpp
diffstat 3 files changed, 234 insertions(+), 311 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Wed Feb 05 17:24:38 2014 +0600
+++ b/Indoor.cpp	Thu Feb 06 00:38:03 2014 +0600
@@ -4450,7 +4450,7 @@
   int v57; // eax@81
   int v58; // esi@81
   int v59; // eax@90
-  BLVSector *v60; // edx@90
+  //BLVSector *v60; // edx@90
   int v61; // ecx@90
   BLVFace *face; // esi@91
   int v63; // ST34_4@98
@@ -4629,69 +4629,63 @@
       v135 = v163;
       v139 = outz;
     }
-    a5b = 0;
-    while ( !v114 )
+    
+    //while ( !v114 )
+    for ( a5b = 0; a5b < 2; a5b++ )
     {
       if ( a5b )
       {
-        v102 = v58;
-        v100 = v55;
-        v98 = v54;
+        v102 = outz;
+        v100 = pOut.y;
+        v98 = pOut.x;
       }
       else
       {
-        v102 = v57;
-        v100 = v56;
-        v98 = v51;
+        v102 = v163;
+        v100 = outy;
+        v98 = outx;
       }
       v59 = pIndoor->GetSector(v98, v100, v102);
-      v60 = pIndoor->pSectors;
-      v61 = 116 * v59;
-      sDepthb = 0;
-      for ( i = 116 * v59;
-            sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61)
-                    + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61);
-            ++sDepthb )
+      //v60 = pIndoor->pSectors;
+      //v61 = 116 * v59;
+      //i = 116 * v59;
+      //for (sDepthb = 0; *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61)
+                    //+ 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61); ++sDepthb)
+      for ( sDepthb = 0; sDepthb < pIndoor->pSectors[v59].uNumFaces; ++sDepthb )
       {
-        face = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]];
+        face = &pIndoor->pFaces[pIndoor->pSectors[v59].pFaceIDs[sDepthb]];// face = &pIndoor->pFaces[*(__int16 *)((char *)&pIndoor->pSectors->pWalls + v61)[sDepthb]]
+        v63 = fixpoint_mul(v143, face->pFacePlane_old.vNormal.x);
+        v64 = fixpoint_mul(v151, face->pFacePlane_old.vNormal.z);
+        v65 = fixpoint_mul(v147, face->pFacePlane_old.vNormal.y);
+        v20 = v63 + v64 + v65;
+        v66 = v63 + v64 + v65;
+        v107 = v63 + v64 + v65;
         if ( face->Portal()
-          || v119 > face->pBounding.x2
-          || v123 < face->pBounding.x1
-          || v127 > face->pBounding.y2
-          || v131 < face->pBounding.y1
-          || v135 > face->pBounding.z2
-          || v139 < face->pBounding.z1
-          || (v63 = fixpoint_mul(v143, face->pFacePlane_old.vNormal.x),
-              v64 = fixpoint_mul(v151, face->pFacePlane_old.vNormal.z),
-              v65 = fixpoint_mul(v147, face->pFacePlane_old.vNormal.y),
-              v20 = v63 + v64 + v65 == 0,
-              v66 = v63 + v64 + v65,
-              v107 = v63 + v64 + v65,
-              v20) )
-          goto LABEL_107;
-        //v67 = outz * face->pFacePlane_old.vNormal.z;
-        v68 = -(face->pFacePlane_old.dist + outz * face->pFacePlane_old.vNormal.z + pOut.y * face->pFacePlane_old.vNormal.y
-              + pOut.x * face->pFacePlane_old.vNormal.x);
+          || v119 > face->pBounding.x2 || v123 < face->pBounding.x1
+          || v127 > face->pBounding.y2 || v131 < face->pBounding.y1
+          || v135 > face->pBounding.z2 || v139 < face->pBounding.z1
+          || !v20 )
+          continue;
+        v68 = -(face->pFacePlane_old.dist + pOut.x * face->pFacePlane_old.vNormal.x
+                                          + pOut.y * face->pFacePlane_old.vNormal.y
+                                          + outz * face->pFacePlane_old.vNormal.z);
         if ( v66 <= 0 )
         {
-          if ( face->pFacePlane_old.dist
-             + outz * face->pFacePlane_old.vNormal.z
-             + pOut.y * face->pFacePlane_old.vNormal.y
-             + pOut.x * face->pFacePlane_old.vNormal.x < 0 )
-            goto LABEL_107;
+          if ( face->pFacePlane_old.dist + pOut.x * face->pFacePlane_old.vNormal.x
+                                         + pOut.y * face->pFacePlane_old.vNormal.y
+                                         + outz * face->pFacePlane_old.vNormal.z < 0 )
+            continue;
         }
         else
         {
-          if ( face->pFacePlane_old.dist
-             + outz * face->pFacePlane_old.vNormal.z
-             + pOut.y * face->pFacePlane_old.vNormal.y
-             + pOut.x * face->pFacePlane_old.vNormal.x > 0 )
-            goto LABEL_107;
+          if ( face->pFacePlane_old.dist + pOut.x * face->pFacePlane_old.vNormal.x
+                                         + pOut.y * face->pFacePlane_old.vNormal.y
+                                         + outz * face->pFacePlane_old.vNormal.z > 0 )
+            continue;
         }
-        v69 = abs(-(face->pFacePlane_old.dist
-                  + outz * face->pFacePlane_old.vNormal.z
-                  + pOut.y * face->pFacePlane_old.vNormal.y
-                  + pOut.x * face->pFacePlane_old.vNormal.x)) >> 14;
+        v69 = abs(-(face->pFacePlane_old.dist + pOut.x * face->pFacePlane_old.vNormal.x
+                                              + pOut.y * face->pFacePlane_old.vNormal.y
+                                              + outz * face->pFacePlane_old.vNormal.z )) >> 14;
         if ( v69 <= abs(v66) )
         {
           //LODWORD(v70) = v68 << 16;
@@ -4701,30 +4695,17 @@
           v108 = fixpoint_div(v68, v107);
           if ( v108 >= 0 )
           {
-            if ( sub_4075DB(
-                   pOut.x + ((signed int)(fixpoint_mul(v108, v143) + 32768) >> 16),
-                   pOut.y + ((signed int)(fixpoint_mul(v108, v147) + 32768) >> 16),
-                   outz + ((signed int)(fixpoint_mul(v108, v151) + 32768) >> 16),
-                   face) )
+            if ( sub_4075DB(pOut.x + ((signed int)(fixpoint_mul(v108, v143) + 0x8000) >> 16),
+                            pOut.y + ((signed int)(fixpoint_mul(v108, v147) + 0x8000) >> 16),
+                              outz + ((signed int)(fixpoint_mul(v108, v151) + 0x8000) >> 16),
+                            face) )
             {
               v114 = 1;
               break;
             }
           }
         }
-        v61 = i;
-LABEL_107:
-        v60 = pIndoor->pSectors;
       }
-      ++a5b;
-      if ( a5b >= 2 )
-        break;
-      v57 = v163;
-      v56 = outy;
-      v51 = outx;
-      v58 = outz;
-      v55 = pOut.y;
-      v54 = pOut.x;
     }
     v72.z = y;
     v72.x = x;
@@ -4750,9 +4731,7 @@
     v152 = v81;
     v120 = pOut.x;
     if ( pOut.x < outx )
-    {
       v124 = outx;
-    }
     else
     {
       v120 = outx;
@@ -4778,85 +4757,68 @@
       v136 = v163;
       v140 = outz;
     }
-    a5c = 0;
-    while ( 1 )
+    //while ( 1 )
+    for ( a5c = 0; a5c < 2; a5c++ )
     {
       if ( v113 )
         return !v114 || !v113;
       if ( a5c )
       {
-        v103 = v86;
-        v101 = v83;
-        v99 = v82;
+        v103 = outz;
+        v101 = pOut.y;
+        v99 = pOut.x;
       }
       else
       {
-        v103 = v85;
-        v101 = v84;
-        v99 = v79;
+        v103 = v163;
+        v101 = outy;
+        v99 = outx;
       }
       v87 = pIndoor->GetSector(v99, v101, v103);
-      v88 = pIndoor->pSectors;
-      v89 = 116 * v87;
-      v162 = 0;
-      v112 = v89;
-      if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89)
-         + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 )
-        break;
-LABEL_148:
-      ++a5c;
-      if ( a5c >= 2 )
-        return !v114 || !v113;
-      v85 = v163;
-      v84 = outy;
-      v79 = outx;
-      v86 = outz;
-      v83 = pOut.y;
-      v82 = pOut.x;
-    }
-    while ( 1 )
+      //v88 = pIndoor->pSectors;
+      //v89 = 116 * v87;
+      
+      //v112 = v89;
+      //if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89)
+         //+ 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 )
+   //{
+    //while ( 1 )
+    for ( v162 = 0; v162 < pIndoor->pSectors[v87].uNumFaces; v162++)
     {
-      face = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]];
+      face = &pIndoor->pFaces[pIndoor->pSectors[v87].pFaceIDs[v162]];
+      yb = fixpoint_mul(v144, face->pFacePlane_old.vNormal.x);
+      v_4b = fixpoint_mul(v148, face->pFacePlane_old.vNormal.y);
+      vf = fixpoint_mul(v152, face->pFacePlane_old.vNormal.z);
+      v20 = yb + vf + v_4b;
+      v91 = yb + vf + v_4b;
+      vc = yb + vf + v_4b;
       if ( face->Portal()
-        || v120 > face->pBounding.x2
-        || v124 < face->pBounding.x1
-        || v128 > face->pBounding.y2
-        || v132 < face->pBounding.y1
-        || v136 > face->pBounding.z2
-        || v140 < face->pBounding.z1
-        || (yb = fixpoint_mul(v144, face->pFacePlane_old.vNormal.x),
-            v_4b = fixpoint_mul(v148, face->pFacePlane_old.vNormal.y),
-            vf = fixpoint_mul(v152, face->pFacePlane_old.vNormal.z),
-            v20 = yb + vf + v_4b == 0,
-            v91 = yb + vf + v_4b,
-            vc = yb + vf + v_4b,
-            v20) )
-        goto LABEL_145;
-      v92 = outz * face->pFacePlane_old.vNormal.z;
-      v93 = -(face->pFacePlane_old.dist
-            + v92
-            + pOut.y * face->pFacePlane_old.vNormal.y
-            + pOut.x * face->pFacePlane_old.vNormal.x);
+        || v120 > face->pBounding.x2 || v124 < face->pBounding.x1
+        || v128 > face->pBounding.y2 || v132 < face->pBounding.y1
+        || v136 > face->pBounding.z2 || v140 < face->pBounding.z1
+        || !v20 )
+        continue;
+      //v92 = outz * face->pFacePlane_old.vNormal.z;
+      v93 = -(face->pFacePlane_old.dist + pOut.x * face->pFacePlane_old.vNormal.x
+                                        + pOut.y * face->pFacePlane_old.vNormal.y
+                                        + outz * face->pFacePlane_old.vNormal.z);
       if ( v91 <= 0 )
       {
-        if ( face->pFacePlane_old.dist
-           + v92
-           + pOut.y * face->pFacePlane_old.vNormal.y
-           + pOut.x * face->pFacePlane_old.vNormal.x < 0 )
-          goto LABEL_145;
+        if ( face->pFacePlane_old.dist + pOut.x * face->pFacePlane_old.vNormal.x
+                                       + pOut.y * face->pFacePlane_old.vNormal.y
+                                       + outz * face->pFacePlane_old.vNormal.z < 0 )
+          continue;
       }
       else
       {
-        if ( face->pFacePlane_old.dist
-           + v92
-           + pOut.y * face->pFacePlane_old.vNormal.y
-           + pOut.x * face->pFacePlane_old.vNormal.x > 0 )
-          goto LABEL_145;
+        if ( face->pFacePlane_old.dist + pOut.x * face->pFacePlane_old.vNormal.x
+                                       + pOut.y * face->pFacePlane_old.vNormal.y
+                                       + outz * face->pFacePlane_old.vNormal.z > 0 )
+          continue;
       }
-      v_4c = abs(-(face->pFacePlane_old.dist
-                 + v92
-                 + pOut.y * face->pFacePlane_old.vNormal.y
-                 + pOut.x * face->pFacePlane_old.vNormal.x)) >> 14;
+      v_4c = abs(-(face->pFacePlane_old.dist + pOut.x * face->pFacePlane_old.vNormal.x
+                                             + pOut.y * face->pFacePlane_old.vNormal.y
+                                             + outz * face->pFacePlane_old.vNormal.z)) >> 14;
       if ( v_4c <= abs(v91) )
       {
         //LODWORD(v94) = v93 << 16;
@@ -4866,24 +4828,17 @@
         vd = fixpoint_div(v93, vc);
         if ( vd >= 0 )
         {
-          if ( sub_4075DB(
-                 pOut.x + ((signed int)(fixpoint_mul(vd, v144) + 32768) >> 16),
-                 pOut.y + ((signed int)(fixpoint_mul(vd, v148) + 32768) >> 16),
-                 outz + ((signed int)(fixpoint_mul(vd, v152) + 32768) >> 16),
-                 face) )
+          if ( sub_4075DB(pOut.x + ((signed int)(fixpoint_mul(vd, v144) + 0x8000) >> 16),
+                          pOut.y + ((signed int)(fixpoint_mul(vd, v148) + 0x8000) >> 16),
+                            outz + ((signed int)(fixpoint_mul(vd, v152) + 0x8000) >> 16),
+                          face) )
           {
             v113 = 1;
-            goto LABEL_148;
+            break;
           }
         }
       }
-      v89 = v112;
-LABEL_145:
-      v88 = pIndoor->pSectors;
-      ++v162;
-      if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89)
-                 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) )
-        goto LABEL_148;
+      }
     }
   }
   else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
@@ -4979,9 +4934,9 @@
             v110 = fixpoint_div(v23, v109);
             if ( v110 >= 0 )
             {
-              if ( sub_4077F1(pOut.x + ((signed int)(fixpoint_mul(v110, v125) + 32768) >> 16),
-                              pOut.y + ((signed int)(fixpoint_mul(v110, v121) + 32768) >> 16),
-                                outz + ((signed int)(fixpoint_mul(v110, v117) + 32768) >> 16),
+              if ( sub_4077F1(pOut.x + ((signed int)(fixpoint_mul(v110, v125) + 0x8000) >> 16),
+                              pOut.y + ((signed int)(fixpoint_mul(v110, v121) + 0x8000) >> 16),
+                                outz + ((signed int)(fixpoint_mul(v110, v117) + 0x8000) >> 16),
                               odm_face,
                               &pOutdoor->pBModels[model_id].pVertices) )
               {
@@ -5087,9 +5042,9 @@
             vb = fixpoint_div(v42, va);
             if ( vb >= 0 )
             {
-              if ( sub_4077F1(pOut.x + ((signed int)(fixpoint_mul(vb, v126) + 32768) >> 16),
-                              pOut.y + ((signed int)(fixpoint_mul(vb, v122) + 32768) >> 16),
-                                outz + ((signed int)(fixpoint_mul(vb, v118) + 32768) >> 16),
+              if ( sub_4077F1(pOut.x + ((signed int)(fixpoint_mul(vb, v126) + 0x8000) >> 16),
+                              pOut.y + ((signed int)(fixpoint_mul(vb, v122) + 0x8000) >> 16),
+                                outz + ((signed int)(fixpoint_mul(vb, v118) + 0x8000) >> 16),
                               odm_face,
                               &pOutdoor->pBModels[model_id].pVertices) )
               {
--- a/Render.cpp	Wed Feb 05 17:24:38 2014 +0600
+++ b/Render.cpp	Thu Feb 06 00:38:03 2014 +0600
@@ -464,48 +464,18 @@
 //----- (0047AF11) --------------------------------------------------------
 void Render::DrawSpriteObjects_ODM()
 {
-  //char *v0; // edi@2
-  //ObjectDesc *v1; // ebx@4
-  __int16 v2; // cx@5
-  RenderBillboard *v3; // esi@10
-  SpriteFrame *v4; // eax@10
-  //SpriteFrame *v5; // ebx@10
+  SpriteFrame *frame; // eax@10
   unsigned int v6; // eax@10
-  //int v7; // ecx@10
-  //int v8; // edx@10
   int v9; // ecx@10
-  unsigned __int16 v10; // ax@10
-  //int *v11; // eax@14
-  int v12; // eax@22
-  int v13; // ST3C_4@23
-  int v14; // eax@23
-  int v15; // ecx@23
-  int v16; // ebx@23
   int v17; // ecx@25
   int v18; // eax@25
-  int v19; // ST40_4@26
-  int v20; // ecx@26
-  int v21; // ST44_4@28
   int v22; // ST3C_4@29
   signed __int64 v23; // qtt@30
-  int v24; // ebx@30
-  int v25; // ST3C_4@30
   int v26; // eax@31
   char v27; // zf@31
-  //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10
-  //__int16 a5; // [sp+10h] [bp-30h]@10
   int v30; // [sp+14h] [bp-2Ch]@23
-  int v31; // [sp+14h] [bp-2Ch]@29
-  __int16 v32; // [sp+14h] [bp-2Ch]@30
-  int v33; // [sp+18h] [bp-28h]@23
-  int v34; // [sp+18h] [bp-28h]@26
-  int v35; // [sp+18h] [bp-28h]@30
-  int v36; // [sp+1Ch] [bp-24h]@10
   int v37; // [sp+1Ch] [bp-24h]@23
   int a6; // [sp+20h] [bp-20h]@10
-  int a6a; // [sp+20h] [bp-20h]@23
-  int v40; // [sp+24h] [bp-1Ch]@25
-  //signed int v41; // [sp+28h] [bp-18h]@1
   int v42; // [sp+2Ch] [bp-14h]@23
   int y; // [sp+30h] [bp-10h]@10
   int x; // [sp+34h] [bp-Ch]@10
@@ -532,136 +502,133 @@
         //if ( !(v1->uFlags & 1) )
         //{
           //v2 = *((short *)v0 - 14)
-    v2 = object->uType;
-    if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) )
+    //v2 = object->uType;
+    if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600)
+       || pGame->pStru6Instance->_4A81CA(object) )
     {
             //a5 = *(short *)v0;
       x = object->vPosition.x;
       y = object->vPosition.y;
       z = object->vPosition.z;
-      v3 = &pBillboardRenderList[::uNumBillboardsToDraw];
-      v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID);
-      //v5 = v4;
-      //v28 = v4;
-      v36 = v4->uFlags;
-      a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier;
+      frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID);
+      a6 = frame->uGlowRadius * object->field_22_glow_radius_multiplier;
       v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
       //LOWORD(v7) = object->uFacing;
       //v8 = v36;
-            v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7;
-            v10 = v4->pHwSpriteIDs[v9];
-            v3->uHwSpriteID = v10;
-            if ( v36 & 0x20 )
-            {
-              //v8 = v36;
-              z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1;
-            }
-            v46 = 0;
-            if ( v36 & 2 )
-              v46 = 2;
-            //v11 = (int *)(256 << v9);
-            if ( (256 << v9) & v36 )
-              v46 |= 4u;
-            if ( v36 & 0x40000 )
-              v46 |= 0x40u;
-            if ( v36 & 0x20000 )
-              LOBYTE(v46) = v46 | 0x80;
-            if ( a6 )
-            {
-              //LOBYTE(v11) = _4E94D3_light_type;
-              pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type);
-            }
-            v12 = (x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
-            if (pGame->pIndoorCameraD3D->sRotationX)
-            {
-              v13 = (y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
-              v30 = ((unsigned __int64)(v12 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16)
-                  + ((unsigned __int64)(v13 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16);
-              v37 = (unsigned __int64)(v12 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
-              a6a = (unsigned __int64)(v13 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16;
-              v33 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
-              v14 = (unsigned __int64)(v30 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16;
-              v15 = (unsigned __int64)(v33 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16;
-              v16 = v15 + v14;
-              v42 = v15 + v14;
-              if ( v15 + v14 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 )
-              {
-                v17 = a6a - v37;
-                v40 = a6a - v37;
-                v18 = ((unsigned __int64)(v33 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16)
-                    - ((unsigned __int64)(v30 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16);
-                goto LABEL_29;
-              }
-            }
-            else
+      v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7;
+      pBillboardRenderList[::uNumBillboardsToDraw].uHwSpriteID = frame->pHwSpriteIDs[v9];
+      if ( frame->uFlags & 0x20 )
+      {
+        //v8 = v36;
+        z -= fixpoint_mul(frame->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)frame->pHwSpriteIDs[v9]].uHeight) / 2;
+      }
+      v46 = 0;
+      if ( frame->uFlags & 2 )
+        v46 = 2;
+      //v11 = (int *)(256 << v9);
+      if ( (256 << v9) & frame->uFlags )
+        v46 |= 4u;
+      if ( frame->uFlags & 0x40000 )
+        v46 |= 0x40u;
+      if ( frame->uFlags & 0x20000 )
+        LOBYTE(v46) = v46 | 0x80;
+      if ( a6 )
+      {
+        //LOBYTE(v11) = _4E94D3_light_type;
+        pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type);
+      }
+      if (pGame->pIndoorCameraD3D->sRotationX)
+      {
+        v30 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y)
+            + fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y);
+        v37 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_sine_y);
+        v42 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x)
+            + fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_cosine_x);
+        if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 )
+        {
+          v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - v37;
+          v18 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x)
+              - fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_sine_x);
+          if ( abs(v42) >= abs(v17) )
+          {
+            LODWORD(v23) = 0;
+            HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad);
+
+            object->uAttributes |= 1;
+            pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex;
+            pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID;
+            pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
+            pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame;
+            pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
+            pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46;
+            pBillboardRenderList[::uNumBillboardsToDraw].world_x = x;
+            pBillboardRenderList[::uNumBillboardsToDraw].world_y = y;
+            pBillboardRenderList[::uNumBillboardsToDraw].world_z = z;
+            pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16);
+            pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16);
+            HIWORD(v26) = HIWORD(v42);
+            LOWORD(v26) = 0;
+            pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i));
+            pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
+            pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
+            if ( !(object->uAttributes & 0x20) )
             {
-              v34 = (y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
-              v19 = (unsigned __int64)(v12 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16;
-              v20 = (unsigned __int64)(v34 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
-              v16 = v20 + v19;
-              v42 = v20 + v19;
-              if ( v20 + v19 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 )
-              {
-                v21 = (unsigned __int64)(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16) * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
-                v17 = ((unsigned __int64)(v34 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - v21;
-                v40 = ((unsigned __int64)(v34 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - v21;
-                v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
-LABEL_29:
-                v31 = v18;
-                v22 = abs(v17);
-                if ( abs(v16) >= v22 )
-                {
-                  LODWORD(v23) = 0;
-                  HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad);
-                  v24 = v23 / v42;
-                  v25 = v23 / v42;
-                  LODWORD(v23) = 0;
-                  HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad);
-                  v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16);
-                  v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16);
-
-                  //if (::uNumBillboardsToDraw >= 500)
-                  //  return;
-                  assert(::uNumBillboardsToDraw < 500);
-                  ++::uNumBillboardsToDraw;
-                  ++uNumSpritesDrawnThisFrame;
-
-                  object->uAttributes |= 1;
-                  v3->uPalette = v4->uPaletteIndex;
-                  v3->uIndoorSectorID = object->uSectorID;
-                  v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16;
-                  v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16;
-                  v3->pSpriteFrame = v4;
-                  v3->_screenspace_y_scaler_packedfloat = v26;
-                  v3->field_1E = v46;
-                  v3->world_x = x;
-                  v3->world_y = y;
-                  v3->world_z = z;
-                  v3->uScreenSpaceX = v35;
-                  v3->uScreenSpaceY = v32;
-                  HIWORD(v26) = HIWORD(v42);
-                  LOWORD(v26) = 0;
-                  v27 = (object->uAttributes & 0x20) == 0;
-                  v3->sZValue = v26 + (PID(OBJECT_Item,i));
-                  v3->dimming_level = 0;
-                  v3->sTintColor = 0;
-                  if ( !v27 )
-                  {
-                    if ( !pRenderer->pRenderD3D )
-                      v3->sZValue = 0;
-                  }
-                }
-                goto LABEL_34;
-              }
+              if ( !pRenderer->pRenderD3D )
+                pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0;
             }
+            //if (::uNumBillboardsToDraw >= 500)
+            //  return;
+            assert(::uNumBillboardsToDraw < 500);
+            ++::uNumBillboardsToDraw;
+            ++uNumSpritesDrawnThisFrame;
           }
-        //}
-LABEL_34:
-      ;
-      //++v41;
-      //v0 += 112;
-    //}
-    //while ( v41 < (signed int)uNumSpriteObjects );
+        }
+      }
+      else
+      {
+        v42 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y)
+            + fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y);
+        if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 )
+        {
+          v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y)
+              - fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y);
+          v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
+          if ( abs(v42) >= abs(v17) )
+          {
+            LODWORD(v23) = 0;
+            HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad);
+
+            object->uAttributes |= 1;
+            pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex;
+            pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID;
+            pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
+            pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame;
+            pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
+            pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46;
+            pBillboardRenderList[::uNumBillboardsToDraw].world_x = x;
+            pBillboardRenderList[::uNumBillboardsToDraw].world_y = y;
+            pBillboardRenderList[::uNumBillboardsToDraw].world_z = z;
+            pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16);
+            pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16);
+            HIWORD(v26) = HIWORD(v42);
+            LOWORD(v26) = 0;
+            pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i));
+            pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
+            pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
+            if ( !(object->uAttributes & 0x20) )
+            {
+              if ( !pRenderer->pRenderD3D )
+                pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0;
+            }
+            //if (::uNumBillboardsToDraw >= 500)
+            //  return;
+            assert(::uNumBillboardsToDraw < 500);
+            ++::uNumBillboardsToDraw;
+            ++uNumSpritesDrawnThisFrame;
+          }
+        }
+      }
+    }
   }
 }
 
--- a/mm7_3.cpp	Wed Feb 05 17:24:38 2014 +0600
+++ b/mm7_3.cpp	Thu Feb 06 00:38:03 2014 +0600
@@ -1565,7 +1565,7 @@
 int stru6_stru1_indoor_sw_billboard::_4775ED(float a2)
 {
   char *v2; // edi@1
-  int v3; // eax@1
+  //int v3; // eax@1
   char *v4; // edx@2
   char *v5; // esi@3
   double v6; // st7@6
@@ -1613,22 +1613,23 @@
   v2 += 4;
   *(int *)v2 = this->field_64[2];
   *((int *)v2 + 1) = this->field_64[3];
-  v3 = this->uNumVertices;
+  //v3 = this->uNumVertices;
   v35 = this;
-  if ( v3 > 0 )
+  if ( this->uNumVertices > 0 )
   {
     v40 = &this->field_64[20];
     v4 = (char *)&this->field_64[3] + 3;
-    v34 = v3;
-    while ( 1 )
+    
+    //while ( 1 )
+	for ( v34 = this->uNumVertices; v34; --v34 )
     {
       v5 = v4 - 15;
       if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 )
 	  {
         v4 += 16;
-		--v34;
-		if ( !v34 )
-		  return this->uNumVertices = v38;
+		//--v34;
+		//if ( !v34 )
+		  //return this->uNumVertices = v38;
 		continue;
 	  }
       if ( *(float *)v5 <= (double)a2 )
@@ -1701,9 +1702,9 @@
       *v27 = *(int *)v28;
       v27[1] = *(int *)(v28 + 4);
       v4 += 16;
-      --v34;
-      if ( !v34 )
-          return this->uNumVertices = v38;
+      //--v34;
+      //if ( !v34 )
+          //return this->uNumVertices = v38;
     }
   }
   return this->uNumVertices = v38;
@@ -2141,7 +2142,7 @@
   stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX);
   v17 = v3 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) + v4 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
   if (pGame->pIndoorCameraD3D->sRotationX)
-    v17 = (unsigned __int64)(v17 * (signed __int64)stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX)) >> 16;
+    v17 = fixpoint_mul(v17, stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX));
   v19 = v4 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) - v3 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
   v9 = int_get_vector_length(abs(v3), abs(v4), 0);
   //v10 = v14 * 188;
@@ -2150,9 +2151,9 @@
   if ( v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256 )
     *reachable = true;
   if ( v19 >= 0 )
-    v11 = ((unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)v17) >> 16) - ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16);
+    v11 = fixpoint_mul(stru_5C6E00->Sin(angle), v17) - fixpoint_mul(stru_5C6E00->Cos(angle), v19);
   else
-    v11 = ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16) + ((unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)v17) >> 16);
+    v11 = fixpoint_mul(stru_5C6E00->Cos(angle), v19) + fixpoint_mul(stru_5C6E00->Sin(angle), v17);
   v12 = v11 >> 16;
   if ( v9 <= pODMRenderParams->shading_dist_mist + 2048 )
   {