diff mm7_1.cpp @ 1143:ed6a9efc6c90

sub_424829 little clean
author Ritor1
date Sun, 02 Jun 2013 00:43:36 +0600
parents e7871ca07661
children 29a8defbad9e 908c00615587
line wrap: on
line diff
--- a/mm7_1.cpp	Sat Jun 01 20:09:26 2013 +0600
+++ b/mm7_1.cpp	Sun Jun 02 00:43:36 2013 +0600
@@ -2225,44 +2225,44 @@
 }
 
 //----- (00424829) --------------------------------------------------------
-bool sub_424829(int a1, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int a4)
+bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID)
 {
-  int v4; // edi@1
-  BspRenderer_stru2 *v5; // ebx@1
+  //int v4; // edi@1
+  //BspRenderer_stru2 *v5; // ebx@1
   int v6; // eax@3
   int v7; // esi@5
   int v8; // edx@5
-  int v9; // ecx@6
+  //int v9; // ecx@6
   int v10; // eax@12
   int v11; // edi@13
-  int v12; // edx@18
+  //int v12; // edx@18
   int v13; // eax@22
-  int v14; // edi@28
+  //int v14; // edi@28
   int v15; // ecx@29
   int v16; // edi@30
-  int v17; // edx@35
+  //int v17; // edx@35
   int v18; // eax@39
   int v19; // eax@44
   int v20; // ecx@44
-  int v21; // edi@45
+  //int v21; // edi@45
   int v22; // edi@46
   __int16 *v23; // ecx@47
   int v24; // edx@48
   int v25; // eax@50
   int v26; // eax@55
   signed int v27; // edi@55
-  int v28; // edx@56
+  //int v28; // edx@56
   int v29; // edx@57
   int v30; // eax@59
   int v31; // eax@64
   signed int v32; // edi@64
-  int v33; // edx@65
+  //int v33; // edx@65
   __int16 *v34; // eax@66
   __int16 v35; // dx@66
   __int16 v36; // dx@67
   __int16 v37; // di@67
   __int16 v38; // dx@67
-  BspRenderer_stru2 *v39; // ecx@69
+  //BspRenderer_stru2 *v39; // ecx@69
   int v40; // edx@69
   int v41; // edi@70
   __int16 *v42; // eax@76
@@ -2274,7 +2274,7 @@
   int v49; // esi@93
   __int16 *v50; // ecx@94
   int v51; // eax@95
-  int v52; // eax@97
+  //int v52; // eax@97
   int v53; // [sp+Ch] [bp-34h]@44
   int v54; // [sp+10h] [bp-30h]@0
   int v55; // [sp+14h] [bp-2Ch]@12
@@ -2282,7 +2282,7 @@
   __int16 *v57; // [sp+14h] [bp-2Ch]@76
   __int16 *v58; // [sp+14h] [bp-2Ch]@81
   __int16 *v59; // [sp+14h] [bp-2Ch]@87
-  BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1
+  //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1
   int v61; // [sp+1Ch] [bp-24h]@29
   int v62; // [sp+20h] [bp-20h]@0
   signed int v63; // [sp+24h] [bp-1Ch]@3
@@ -2296,29 +2296,34 @@
   int v71; // [sp+34h] [bp-Ch]@75
   int v72; // [sp+34h] [bp-Ch]@80
   int v73; // [sp+38h] [bp-8h]@11
-  int v74; // [sp+3Ch] [bp-4h]@1
+  //int v74; // [sp+3Ch] [bp-4h]@1
   int a3a; // [sp+48h] [bp+8h]@76
   int a3b; // [sp+48h] [bp+8h]@87
 
   //try graphic engine with function returning 1 always, and without
-  return 1;
-  v4 = a1;
-  v5 = a2;
-  v74 = a1;
-  v60 = a2;
-  if ( !a1
-    || (!stru_50B700.field_0 ? (v64 = -1, v6 = 1, v63 = 1) : (v6 = 1, v63 = -1, v64 = 1),
-        v7 = stru_50B700._screen_space_y[0],
-        v65 = 0,
-        v8 = stru_50B700._screen_space_y[0],
-        a1 <= v6) )
-    return 0;
-  do
+  //return true;
+  if ( !pNumVertices )
+    return false;
+  v7 = stru_50B700._screen_space_y[0];
+  v65 = 0;
+  v8 = stru_50B700._screen_space_y[0];
+  if ( !stru_50B700.field_0 )
   {
-    v9 = stru_50B700._screen_space_y[v6];
-    if ( v9 >= v7 )
+    v63 = 1;
+    v64 = -1;
+  }
+  else 
+  {
+    v63 = -1;
+    v64 = 1;
+  }
+  if ( pNumVertices <= 1 )
+    return false;
+  for ( v6 = 1; v6 < pNumVertices; ++v6 )
+  {
+    if ( stru_50B700._screen_space_y[v6] >= v7 )
     {
-      if ( v9 > v8 )
+      if ( stru_50B700._screen_space_y[v6] > v8 )
         v8 = stru_50B700._screen_space_y[v6];
     }
     else
@@ -2326,152 +2331,136 @@
       v65 = v6;
       v7 = stru_50B700._screen_space_y[v6];
     }
-    ++v6;
   }
-  while ( v6 < v4 );
   v73 = v8;
   if ( v8 == v7 )
-    return 0;
+    return false;
   v10 = v65;
-  v68 = 0;
-  v5->_viewport_space_y = v7;
-  v5->_viewport_space_w = v8;
+  a2->_viewport_space_y = v7;
+  a2->_viewport_space_w = v8;
   v55 = v65;
-  if ( v4 > 0 )
+  if ( pNumVertices > 0 )
   {
     v11 = v65;
-    do
+    for ( v68 = 0; v68 < pNumVertices; ++v68 )
     {
       v10 += v64;
-      if ( v10 < v74 )
+      if ( v10 < pNumVertices )
       {
         if ( v10 < 0 )
-          v10 += v74;
+          v10 += pNumVertices;
       }
       else
       {
-        v10 -= v74;
+        v10 -= pNumVertices;
       }
-      v12 = stru_50B700._screen_space_y[v10];
-      if ( v12 <= stru_50B700._screen_space_y[v11] )
+      if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v11] )
       {
         v55 = v10;
         v11 = v10;
       }
-      if ( v12 == v73 )
+      if ( stru_50B700._screen_space_y[v10] == v73 )
         break;
-      ++v68;
     }
-    while ( v68 < v74 );
   }
   v13 = v55 + v64;
   v67 = v55 + v64;
-  if ( v55 + v64 < v74 )
+  if ( v55 + v64 < pNumVertices )
   {
     if ( v13 >= 0 )
       goto LABEL_27;
-    v13 += v74;
+    v13 += pNumVertices;
   }
   else
   {
-    v13 -= v74;
+    v13 -= pNumVertices;
   }
   v67 = v13;
 LABEL_27:
   if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] )
   {
-    v14 = stru_50B700._screen_space_x[v55];
-    v62 = v14 << 16;
-    v54 = ((stru_50B700._screen_space_x[v13] - v14) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]);
-    v5->array_18[v7] = LOWORD(stru_50B700._screen_space_x[v55]);
+    v62 = stru_50B700._screen_space_x[v55] << 16;
+    v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]);
+    a2->array_18[v7] = LOWORD(stru_50B700._screen_space_x[v55]);
   }
   v15 = v65;
-  v69 = 0;
   v61 = v65;
-  if ( v74 > 0 )
+  if ( pNumVertices > 0 )
   {
     v16 = v65;
-    do
+    for ( v69 = 0; v69 < pNumVertices; ++v69 )
     {
       v15 += v63;
-      if ( v15 < v74 )
+      if ( v15 < pNumVertices )
       {
         if ( v15 < 0 )
-          v15 += v74;
+          v15 += pNumVertices;
       }
       else
       {
-        v15 -= v74;
+        v15 -= pNumVertices;
       }
-      v17 = stru_50B700._screen_space_y[v15];
-      if ( v17 <= stru_50B700._screen_space_y[v16] )
+      if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v16] )
       {
         v61 = v15;
         v16 = v15;
       }
-      if ( v17 == v73 )
+      if ( stru_50B700._screen_space_y[v15] == v73 )
         break;
-      ++v69;
     }
-    while ( v69 < v74 );
   }
   v18 = v63 + v61;
   v66 = v63 + v61;
-  if ( v63 + v61 < v74 )
+  if ( v63 + v61 < pNumVertices )
   {
     if ( v18 >= 0 )
       goto LABEL_44;
-    v18 += v74;
+    v18 += pNumVertices;
   }
   else
   {
-    v18 -= v74;
+    v18 -= pNumVertices;
   }
   v66 = v18;
 LABEL_44:
   v19 = v18;
   v20 = v61;
-  v53 = stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v61];
   if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] )
   {
-    v21 = stru_50B700._screen_space_x[v20];
-    v5 = v60;
-    v61 = v21 << 16;
-    v53 = ((stru_50B700._screen_space_x[v19] - v21) << 16) / v53;
-    v60->array_3D8[v73] = LOWORD(stru_50B700._screen_space_x[v20]);
+    v61 = stru_50B700._screen_space_x[v20] << 16;
+    v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20];
+    a2->array_3D8[v73] = LOWORD(stru_50B700._screen_space_x[v20]);
   }
   v22 = v7;
-  v70 = v7;
   if ( v7 <= v73 )
   {
-    v56 = &v5->array_3D8[v7];
-    v23 = &v5->array_18[v7];
-    do
+    v56 = &a2->array_3D8[v7];
+    v23 = &a2->array_18[v7];
+    for ( v70 = v7; v70 <= v73; ++v70 )
     {
       v24 = v67;
       if ( v22 < stru_50B700._screen_space_y[v67] || v22 == v73 )
         goto LABEL_57;
       v25 = v64 + v67;
       v67 = v25;
-      if ( v25 < v74 )
+      if ( v25 < pNumVertices )
       {
         if ( v25 >= 0 )
           goto LABEL_55;
-        v25 += v74;
+        v25 += pNumVertices;
       }
       else
       {
-        v25 -= v74;
+        v25 -= pNumVertices;
       }
       v67 = v25;
 LABEL_55:
       v26 = v25;
-      v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
+      //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
       if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 )
       {
-        v28 = stru_50B700._screen_space_x[v24];
-        v54 = ((stru_50B700._screen_space_x[v26] - v28) << 16) / v27;
-        v62 = v28 << 16;
+        v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
+        v62 = stru_50B700._screen_space_x[v24] << 16;
       }
 LABEL_57:
       v29 = v66;
@@ -2479,27 +2468,26 @@
       {
         v30 = v63 + v66;
         v66 += v63;
-        if ( v66 >= v74 )
+        if ( v66 >= pNumVertices )
         {
-          v30 -= v74;
+          v30 -= pNumVertices;
           goto LABEL_63;
         }
         if ( v30 < 0 )
         {
-          v30 += v74;
+          v30 += pNumVertices;
 LABEL_63:
           v66 = v30;
         }
         v31 = v30;
-        v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
+        //v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
         if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 )
         {
-          v33 = stru_50B700._screen_space_x[v29];
-          v53 = ((stru_50B700._screen_space_x[v31] - v33) << 16) / v32;
-          v61 = v33 << 16;
+          v53 = ((stru_50B700._screen_space_x[v31] - stru_50B700._screen_space_x[v29]) << 16) / stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
+          v61 = stru_50B700._screen_space_x[v29] << 16;
         }
       }
-      *(__int16 *)((char *)v56 + (int)(char *)v5->array_18 - (char *)v5->array_3D8) = HIWORD(v62);
+      *(__int16 *)((char *)v56 + (int)(char *)a2->array_18 - (char *)a2->array_3D8) = HIWORD(v62);
       *v56 = HIWORD(v61);
       v34 = v23 + 480;
       v35 = v23[480];
@@ -2517,14 +2505,11 @@
       v22 = v70 + 1;
       v61 += v53;
       ++v23;
-      ++v70;
     }
-    while ( v70 <= v73 );
   }
-  v39 = a3;
   v40 = v73;
   if ( v73 < a3->_viewport_space_y || (v41 = a3->_viewport_space_w, v7 > v41) )
-    return 0;
+    return false;
   if ( v7 < a3->_viewport_space_y )
     v7 = a3->_viewport_space_y;
   if ( v73 > v41 )
@@ -2532,46 +2517,40 @@
     v40 = a3->_viewport_space_w;
     v73 = a3->_viewport_space_w;
   }
-  v71 = v7;
   if ( v7 <= v40 )
   {
-    a3a = (char *)v5 - (char *)a3;
-    v57 = &v5->array_18[v7];
-    v42 = &v39->array_3D8[v7];
-    do
+    a3a = (char *)a2 - (char *)a3;
+    v57 = &a2->array_18[v7];
+    v42 = &a3->array_3D8[v7];
+    for ( v71 = v7; v71 <= v40; ++v71 )
     {
-      if ( *(__int16 *)((char *)v42 + a3a) >= *(v42 - 480) && *v57 <= *v42 )
+      if ( *(__int16 *)((char *)v42 + a3a) >= *(v42 - 480) && a2->array_18[v71] <= a3->array_3D8[v71] )
         break;
       ++v57;
       ++v7;
-      ++v71;
       ++v42;
     }
-    while ( v71 <= v40 );
   }
-  v72 = v40;
   if ( v40 < v7 )
-    return 0;
-  v58 = &v5->array_18[v40];
-  v43 = &v39->array_3D8[v40];
-  do
+    return false;
+  v58 = &a2->array_18[v40];
+  v43 = &a3->array_3D8[v40];
+  for ( v72 = v40; v72 >= v7; --v72 )
   {
-    if ( *(__int16 *)((char *)v43 + (int)(char *)v5 - (char *)v39) >= *(v43 - 480) && *v58 <= *v43 )
+    if ( *(__int16 *)((char *)v43 + (int)(char *)a2 - (char *)a3) >= *(v43 - 480) && *v58 <= a3->array_3D8[v72] )
       break;
     --v58;
     --v40;
-    --v72;
     --v43;
     v73 = v40;
   }
-  while ( v72 >= v7 );
   if ( v7 >= v40 )
-    return 0;
-  a3b = (char *)v39 - (char *)v5;
-  v59 = &v39->array_3D8[v7];
-  v45 = &v5->array_18[v7];
-  v46 = v73 - v7 + 1;
-  do
+    return false;
+  a3b = (char *)a3 - (char *)a2;
+  v59 = &a3->array_3D8[v7];
+  v45 = &a2->array_18[v7];
+  
+  for ( v46 = v73 - v7 + 1; v46; --v46 )
   {
     v47 = *(__int16 *)((char *)v45 + a3b);
     if ( *v45 < v47 )
@@ -2580,40 +2559,35 @@
       v45[480] = *v59;
     ++v59;
     ++v45;
-    --v46;
   }
-  while ( v46 );
-  v5->_viewport_space_y = v7;
-  v5->_viewport_space_w = v73;
-  v5->field_8 = v5->array_18[v7];
-  v48 = v5->array_3D8[v7];
-  v5->field_10 = v7;
-  v5->field_14 = v7;
+  a2->_viewport_space_y = v7;
+  a2->_viewport_space_w = v73;
+  a2->field_8 = a2->array_18[v7];
+  v48 = a2->array_3D8[v7];
+  a2->field_10 = v7;
+  a2->field_14 = v7;
+  a2->field_C = v48;
   v49 = v7 + 1;
-  v5->field_C = v48;
   if ( v49 <= v73 )
   {
-    v50 = &v5->array_3D8[v49];
-    do
+    v50 = &a2->array_3D8[v49];
+    for ( v49; v49 <= v73; ++v49 )
     {
       v51 = *(v50 - 480);
-      if ( v51 < v5->field_8 )
+      if ( v51 < a2->field_8 )
       {
-        v5->field_8 = v51;
-        v5->field_10 = v49;
+        a2->field_8 = v51;
+        a2->field_10 = v49;
       }
-      v52 = *v50;
-      if ( v52 > v5->field_C )
+      if ( a2->array_3D8[v49] > a2->field_C )
       {
-        v5->field_C = v52;
-        v5->field_14 = v49;
+        a2->field_C = a2->array_3D8[v49];
+        a2->field_14 = v49;
       }
-      ++v49;
       ++v50;
     }
-    while ( v49 <= v73 );
   }
-  return 1;
+  return true;
 }
 // 50B700: using guessed type int stru_50B700.field_0;