diff mm7_2.cpp @ 1138:f947bedb2859

Слияние
author Ritor1
date Sat, 01 Jun 2013 10:32:31 +0600
parents 62c759bc49f7 d98415be04ca
children 3bc7bb4ab1a5
line wrap: on
line diff
--- a/mm7_2.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/mm7_2.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -2167,110 +2167,22 @@
                                             unsigned short *pDst, int dstWidth, int dstHeight, int dstPitch,
                                             int a10, int a11)
 {
-  int v11; // esi@1
   int result; // eax@1
-  int v13; // edi@8
   int v14; // ecx@10
-  double v15; // st7@11
-  double v16; // st6@11
   float v17; // ST3C_4@12
   float v18; // ST38_4@12
   unsigned int v19; // esi@12
-  int v20; // eax@16
   int v21; // eax@18
   unsigned int v22; // ecx@25
   unsigned int v23; // eax@29
-  unsigned __int16 *v24; // ecx@29
-  int v25; // edi@33
-  int v26; // ecx@35
-  double v27; // st7@36
-  double v28; // st6@36
-  float v29; // ST34_4@37
-  float v30; // ST30_4@37
-  unsigned int v31; // esi@37
-  int v32; // eax@41
-  int v33; // eax@43
-  unsigned int v34; // ecx@50
-  unsigned __int16 v35; // ax@54
-  unsigned __int16 *v36; // ecx@54
-  int v37; // edi@58
-  int v38; // ecx@60
-  double v39; // st7@61
-  double v40; // st6@61
-  float v41; // ST34_4@62
-  float v42; // ST30_4@62
-  unsigned int v43; // esi@62
-  int v44; // eax@66
-  int v45; // eax@68
-  unsigned int v46; // ecx@75
-  char v47; // al@79
-  unsigned __int16 *v48; // ecx@79
-  int v49; // edi@86
   int v50; // ecx@88
-  double v51; // st7@89
-  double v52; // st6@89
   float v53; // ST34_4@90
   float v54; // ST30_4@90
   unsigned int v55; // esi@90
-  int v56; // eax@94
   int v57; // eax@96
   unsigned int v58; // ecx@103
   unsigned int v59; // eax@107
-  unsigned __int16 *v60; // ecx@107
-  int v61; // edi@111
-  int v62; // ecx@113
-  double v63; // st7@114
-  double v64; // st6@114
-  float v65; // ST34_4@115
-  float v66; // ST30_4@115
-  unsigned int v67; // esi@115
-  int v68; // eax@119
-  int v69; // eax@121
-  unsigned int v70; // ecx@128
-  unsigned __int16 v71; // ax@132
-  unsigned __int16 *v72; // ecx@132
-  int v73; // edi@136
-  int v74; // ecx@138
-  double v75; // st7@139
-  double v76; // st6@139
-  float v77; // ST34_4@140
-  float v78; // ST30_4@140
-  unsigned int v79; // esi@140
-  int v80; // eax@144
-  int v81; // eax@146
-  unsigned int v82; // ecx@153
-  char v83; // al@157
-  unsigned __int16 *v84; // ecx@157
-  int v85; // edi@164
-  int v86; // ecx@166
-  double v87; // st7@167
-  double v88; // st6@167
-  float v89; // ST34_4@168
-  float v90; // ST30_4@168
-  unsigned int v91; // esi@168
-  signed int v92; // eax@170
-  int v93; // eax@171
-  int v94; // eax@173
-  unsigned int v95; // ecx@181
-  unsigned int v96; // eax@185
-  unsigned __int16 *v97; // ecx@185
-  int v98; // edi@189
-  int v99; // ecx@191
-  double v100; // st7@192
-  double v101; // st6@192
-  float v102; // ST34_4@193
-  float v103; // ST30_4@193
-  unsigned int v104; // esi@193
-  signed int v105; // eax@195
-  int v106; // eax@196
-  int v107; // eax@198
-  unsigned int v108; // ecx@206
-  unsigned __int16 v109; // ax@210
-  unsigned __int16 *v110; // ecx@210
-  int v111; // edi@214
   int v112; // ecx@216
-  double v113; // st7@217
-  double v114; // st6@217
   float v115; // ST34_4@218
   float v116; // ST30_4@218
   unsigned int v117; // esi@218
@@ -2279,855 +2191,275 @@
   int v120; // eax@223
   unsigned int v121; // ecx@231
   char v122; // al@235
-  unsigned __int16 *v123; // ecx@235
   double v124; // [sp+Ch] [bp-7Ch]@12
-  double v125; // [sp+Ch] [bp-7Ch]@37
-  double v126; // [sp+Ch] [bp-7Ch]@62
-  double v127; // [sp+Ch] [bp-7Ch]@90
-  //double v128; // [sp+Ch] [bp-7Ch]@115
-  uint _v128;
-  double v129; // [sp+Ch] [bp-7Ch]@140
-  double v130; // [sp+Ch] [bp-7Ch]@168
-  double v131; // [sp+Ch] [bp-7Ch]@193
+  unsigned int v127; // [sp+Ch] [bp-7Ch]@90
   double v132; // [sp+Ch] [bp-7Ch]@218
   double v133; // [sp+14h] [bp-74h]@12
-  double v134; // [sp+14h] [bp-74h]@37
-  double v135; // [sp+14h] [bp-74h]@62
-  double v136; // [sp+14h] [bp-74h]@90
-  //double v137; // [sp+14h] [bp-74h]@115
-  uint _v137;
-  double v138; // [sp+14h] [bp-74h]@140
-  double v139; // [sp+14h] [bp-74h]@168
-  double v140; // [sp+14h] [bp-74h]@193
+  unsigned int v136; // [sp+14h] [bp-74h]@90
   double v141; // [sp+14h] [bp-74h]@218
   double v142; // [sp+1Ch] [bp-6Ch]@12
-  double v143; // [sp+1Ch] [bp-6Ch]@37
-  double v144; // [sp+1Ch] [bp-6Ch]@62
-  double v145; // [sp+1Ch] [bp-6Ch]@90
-  //double v146; // [sp+1Ch] [bp-6Ch]@115
-  uint _v146;
-  double v147; // [sp+1Ch] [bp-6Ch]@140
-  double v148; // [sp+1Ch] [bp-6Ch]@168
-  double v149; // [sp+1Ch] [bp-6Ch]@193
+  unsigned int v145; // [sp+1Ch] [bp-6Ch]@90
   double v150; // [sp+1Ch] [bp-6Ch]@218
   double v151; // [sp+24h] [bp-64h]@12
-  double v152; // [sp+24h] [bp-64h]@37
-  double v153; // [sp+24h] [bp-64h]@62
-  double v154; // [sp+24h] [bp-64h]@90
-  //double v155; // [sp+24h] [bp-64h]@115
-  uint _v155;
-  double v156; // [sp+24h] [bp-64h]@140
-  double v157; // [sp+24h] [bp-64h]@168
-  double v158; // [sp+24h] [bp-64h]@193
+  unsigned int v154; // [sp+24h] [bp-64h]@90
   double v159; // [sp+24h] [bp-64h]@218
   int v160; // [sp+3Ch] [bp-4Ch]@13
   int v161; // [sp+40h] [bp-48h]@15
-  int v162; // [sp+44h] [bp-44h]@40
-  int v163; // [sp+44h] [bp-44h]@65
   int v164; // [sp+44h] [bp-44h]@93
-  int v165; // [sp+44h] [bp-44h]@118
-  int v166; // [sp+44h] [bp-44h]@143
-  int v167; // [sp+44h] [bp-44h]@169
-  int v168; // [sp+44h] [bp-44h]@194
   int v169; // [sp+44h] [bp-44h]@219
-  int v170; // [sp+48h] [bp-40h]@38
-  int v171; // [sp+48h] [bp-40h]@63
   int v172; // [sp+48h] [bp-40h]@91
-  int v173; // [sp+48h] [bp-40h]@116
-  int v174; // [sp+48h] [bp-40h]@141
   unsigned __int16 *v175; // [sp+4Ch] [bp-3Ch]@13
   int *v176; // [sp+50h] [bp-38h]@15
-  int *v177; // [sp+50h] [bp-38h]@40
-  int *v178; // [sp+50h] [bp-38h]@65
   int *v179; // [sp+50h] [bp-38h]@93
-  int *v180; // [sp+50h] [bp-38h]@118
-  int *v181; // [sp+50h] [bp-38h]@143
-  char *v182; // [sp+50h] [bp-38h]@169
-  char *v183; // [sp+50h] [bp-38h]@194
   char *v184; // [sp+50h] [bp-38h]@219
-  unsigned __int16 *v185; // [sp+54h] [bp-34h]@38
-  unsigned __int16 *v186; // [sp+54h] [bp-34h]@63
   unsigned __int16 *v187; // [sp+54h] [bp-34h]@91
-  unsigned __int16 *v188; // [sp+54h] [bp-34h]@116
-  unsigned __int16 *v189; // [sp+54h] [bp-34h]@141
-  signed int v190; // [sp+54h] [bp-34h]@170
-  signed int v191; // [sp+54h] [bp-34h]@195
-  signed int v192; // [sp+54h] [bp-34h]@220
   unsigned __int16 *v193; // [sp+5Ch] [bp-2Ch]@7
-  unsigned __int16 *v194; // [sp+5Ch] [bp-2Ch]@32
-  unsigned __int16 *v195; // [sp+5Ch] [bp-2Ch]@57
   unsigned __int16 *v196; // [sp+5Ch] [bp-2Ch]@85
-  unsigned __int16 *v197; // [sp+5Ch] [bp-2Ch]@110
-  unsigned __int16 *v198; // [sp+5Ch] [bp-2Ch]@135
-  unsigned __int16 *v199; // [sp+5Ch] [bp-2Ch]@163
-  unsigned __int16 *v200; // [sp+5Ch] [bp-2Ch]@188
   unsigned __int16 *v201; // [sp+5Ch] [bp-2Ch]@213
-  //stru350 *v202; // [sp+60h] [bp-28h]@1
-  int v203; // [sp+64h] [bp-24h]@12
-  int v204; // [sp+64h] [bp-24h]@37
-  int v205; // [sp+64h] [bp-24h]@62
-  int v206; // [sp+64h] [bp-24h]@90
-  int v207; // [sp+64h] [bp-24h]@115
-  int v208; // [sp+64h] [bp-24h]@140
-  int v209; // [sp+64h] [bp-24h]@168
-  int v210; // [sp+64h] [bp-24h]@193
-  int v211; // [sp+64h] [bp-24h]@218
-  float v212; // [sp+6Ch] [bp-1Ch]@11
-  float v213; // [sp+6Ch] [bp-1Ch]@36
-  float v214; // [sp+6Ch] [bp-1Ch]@61
-  float v215; // [sp+6Ch] [bp-1Ch]@89
-  float v216; // [sp+6Ch] [bp-1Ch]@114
-  float v217; // [sp+6Ch] [bp-1Ch]@139
-  float v218; // [sp+6Ch] [bp-1Ch]@167
-  float v219; // [sp+6Ch] [bp-1Ch]@192
-  float v220; // [sp+6Ch] [bp-1Ch]@217
-  float v221; // [sp+70h] [bp-18h]@11
-  float v222; // [sp+70h] [bp-18h]@36
-  float v223; // [sp+70h] [bp-18h]@61
-  float v224; // [sp+70h] [bp-18h]@89
-  float v225; // [sp+70h] [bp-18h]@114
-  float v226; // [sp+70h] [bp-18h]@139
-  float v227; // [sp+70h] [bp-18h]@167
-  float v228; // [sp+70h] [bp-18h]@192
-  float v229; // [sp+70h] [bp-18h]@217
-  signed int v230; // [sp+74h] [bp-14h]@1
   signed int v231; // [sp+78h] [bp-10h]@7
-  signed int v232; // [sp+78h] [bp-10h]@32
-  signed int v233; // [sp+78h] [bp-10h]@57
   signed int v234; // [sp+78h] [bp-10h]@85
-  signed int v235; // [sp+78h] [bp-10h]@110
-  signed int v236; // [sp+78h] [bp-10h]@135
-  signed int v237; // [sp+78h] [bp-10h]@163
-  signed int v238; // [sp+78h] [bp-10h]@188
   signed int v239; // [sp+78h] [bp-10h]@213
   __int64 v240; // [sp+7Ch] [bp-Ch]@12
-  __int64 v241; // [sp+7Ch] [bp-Ch]@37
-  __int64 v242; // [sp+7Ch] [bp-Ch]@62
   __int64 v243; // [sp+7Ch] [bp-Ch]@90
-  __int64 v244; // [sp+7Ch] [bp-Ch]@115
-  __int64 v245; // [sp+7Ch] [bp-Ch]@140
-  unsigned int v246; // [sp+7Ch] [bp-Ch]@168
-  unsigned int v247; // [sp+7Ch] [bp-Ch]@193
   unsigned int v248; // [sp+7Ch] [bp-Ch]@218
-  unsigned int v249; // [sp+80h] [bp-8h]@168
-  unsigned int v250; // [sp+80h] [bp-8h]@193
   unsigned int v251; // [sp+80h] [bp-8h]@218
   unsigned int v252; // [sp+84h] [bp-4h]@12
-  unsigned int v253; // [sp+84h] [bp-4h]@37
-  unsigned int v254; // [sp+84h] [bp-4h]@62
   unsigned int v255; // [sp+84h] [bp-4h]@90
-  unsigned int v256; // [sp+84h] [bp-4h]@115
-  unsigned int v257; // [sp+84h] [bp-4h]@140
-  unsigned int v258; // [sp+84h] [bp-4h]@168
-  unsigned int v259; // [sp+84h] [bp-4h]@193
   unsigned int v260; // [sp+84h] [bp-4h]@218
-  signed int a6a; // [sp+A0h] [bp+18h]@10
   float a6s; // [sp+A0h] [bp+18h]@12
   float a6t; // [sp+A0h] [bp+18h]@12
   unsigned int a6b; // [sp+A0h] [bp+18h]@12
-  signed int a6c; // [sp+A0h] [bp+18h]@35
-  float a6u; // [sp+A0h] [bp+18h]@37
-  float a6v; // [sp+A0h] [bp+18h]@37
-  unsigned int a6d; // [sp+A0h] [bp+18h]@37
-  signed int a6e; // [sp+A0h] [bp+18h]@60
-  float a6w; // [sp+A0h] [bp+18h]@62
-  float a6x; // [sp+A0h] [bp+18h]@62
-  unsigned int a6f; // [sp+A0h] [bp+18h]@62
-  signed int a6g; // [sp+A0h] [bp+18h]@88
   float a6y; // [sp+A0h] [bp+18h]@90
   float a6z; // [sp+A0h] [bp+18h]@90
   unsigned int a6h; // [sp+A0h] [bp+18h]@90
-  signed int a6i; // [sp+A0h] [bp+18h]@113
-  float a6ba; // [sp+A0h] [bp+18h]@115
-  float a6bb; // [sp+A0h] [bp+18h]@115
-  unsigned int a6j; // [sp+A0h] [bp+18h]@115
-  signed int a6k; // [sp+A0h] [bp+18h]@138
-  float a6bc; // [sp+A0h] [bp+18h]@140
-  float a6bd; // [sp+A0h] [bp+18h]@140
-  unsigned int a6l; // [sp+A0h] [bp+18h]@140
-  signed int a6m; // [sp+A0h] [bp+18h]@166
-  float a6be; // [sp+A0h] [bp+18h]@168
-  float a6bf; // [sp+A0h] [bp+18h]@168
-  unsigned int a6n; // [sp+A0h] [bp+18h]@168
-  signed int a6o; // [sp+A0h] [bp+18h]@191
-  float a6bg; // [sp+A0h] [bp+18h]@193
-  float a6bh; // [sp+A0h] [bp+18h]@193
-  unsigned int a6p; // [sp+A0h] [bp+18h]@193
-  signed int a6q; // [sp+A0h] [bp+18h]@216
   float a6bi; // [sp+A0h] [bp+18h]@218
   float a6bj; // [sp+A0h] [bp+18h]@218
   unsigned int a6r; // [sp+A0h] [bp+18h]@218
-  int a9a; // [sp+ACh] [bp+24h]@8
-  int a9b; // [sp+ACh] [bp+24h]@33
-  int a9c; // [sp+ACh] [bp+24h]@86
-  int a9d; // [sp+ACh] [bp+24h]@111
-  int a9e; // [sp+ACh] [bp+24h]@164
-  int a9f; // [sp+ACh] [bp+24h]@189
-
-  v11 = 0;
+  int dstdiffmult;
+
+  using namespace rounding;
+
+  int probablyBitDepth = this->field_20.field_C;
+  switch(probablyBitDepth)
+  {
+  case 8: dstdiffmult = dstPitch - dstWidth;
+    break;
+  case 16: dstdiffmult = 2 * (dstPitch - dstWidth);
+    break;
+  case 32: dstdiffmult = 4 * (dstPitch - dstWidth);
+    break;
+  default:
+    return probablyBitDepth;
+  }
+
+
+
   result = this->field_0.field_C;
-  //v202 = this;
-  v230 = 0;
-  if ( result != 8 )
-  {
-    if ( result != 16 )
-    {
-      if ( result != 32 )
-        return result;
-      result = this->field_20.field_C;
-      if ( result != 8 )
-      {
-        if ( result != 16 )
-        {
-          if ( result != 32 || (result = (int)pDst, v193 = pDst, v231 = 0, dstHeight <= 0) )
-            return result;
-          v13 = dstWidth;
-          a9a = 4 * (dstPitch - dstWidth);
-          while ( 1 )
-          {
-            v14 = 0;
-            a6a = 0;
-            if ( dstWidth > v11 )
-              break;
-LABEL_30:
-            v193 = (unsigned __int16 *)((char *)v193 + a9a);
-            ++v231;
-            result = v231;
-            if ( v231 >= dstHeight )
-              return result;
-            v11 = 0;
-          }
-          v221 = (double)dstWidth;
-          v212 = (double)srcWidth;
-          v15 = (double)dstHeight;
-          v16 = (double)srcHeight;
-          while ( 1 )
-          {
-            a6s = (double)a6a / v221 * v212;
-            v151 = floorf(a6s + 0.5f);//a6s + 6.7553994e15;
-            v203 = v14 + 1;
-            a6t = (double)(v14 + 1) / v221 * v212;
-            v142 = floorf(a6t + 0.5f);//a6t + 6.7553994e15;
-            v17 = (double)v231 / v15 * v16;
-            v133 = floorf(v17 + 0.5f);//v17 + 6.7553994e15;
-            v18 = (double)(v231 + 1) / v15 * v16;
-            v124 = floorf(v18 + 0.5f);//v18 + 6.7553994e15;
-            v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151));
-            v252 = 0;
-            a6b = 0;
-            v240 = 0i64;
-            if ( SLODWORD(v133) < SLODWORD(v124) )
-              break;
-LABEL_25:
-            v22 = (unsigned int)v240 / ((LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151)));
-            if ( v19 )
-            {
-              a6b /= v19;
-              v252 /= v19;
-              HIDWORD(v240) /= v19;
-            }
-            if ( v22 != 255 )
-              v22 &= 0x7FFFFFFFu;
-            v23 = _450F55(HIDWORD(v240) | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
-            v24 = v193;
-            v193 += 2;
-            *(_DWORD *)v24 = v23;
-            v14 = v203;
-            a6a = v203;
-            if ( v203 >= dstWidth )
-              goto LABEL_30;
-          }
-          v160 = LODWORD(v124) - LODWORD(v133);
-          v175 = &pSrc[2 * (LODWORD(v151) + srcPitch * LODWORD(v133))];
-          while ( SLODWORD(v151) >= SLODWORD(v142) )
-          {
-LABEL_24:
-            v175 += 2 * srcPitch;
-            --v160;
-            if ( !v160 )
-              goto LABEL_25;
-          }
-          v176 = (int *)v175;
-          v161 = LODWORD(v142) - LODWORD(v151);
-          while ( 1 )
-          {
-            v20 = *v176;
-            if ( a10 )
-            {
-              v230 = 1;
-              v13 = v20 != a11 ? 0xFF : 0;
-            }
-            v21 = _450FB1(v20);
-            if ( !v230 )
-              break;
-            LODWORD(v240) = v13 + v240;
-            v230 = 0;
-            if ( v13 )
-              goto LABEL_22;
-            --v19;
-LABEL_23:
-            ++v176;
-            --v161;
-            if ( !v161 )
-              goto LABEL_24;
-          }
-          LODWORD(v240) = ((unsigned int)v21 >> 24) + v240;
-LABEL_22:
-          a6b += BYTE2(v21);
-          v252 += BYTE1(v21);
-          HIDWORD(v240) += (unsigned __int8)v21;
-          goto LABEL_23;
-        }
-        result = (int)pDst;
-        v194 = pDst;
-        v232 = 0;
-        if ( dstHeight <= 0 )
-          return result;
-        v25 = dstWidth;
-        a9b = 2 * (dstPitch - dstWidth);
-        while ( 1 )
-        {
-          v26 = 0;
-          a6c = 0;
-          if ( dstWidth > v11 )
-            break;
-LABEL_55:
-          v194 = (unsigned __int16 *)((char *)v194 + a9b);
-          ++v232;
-          result = v232;
-          if ( v232 >= dstHeight )
-            return result;
-          v11 = 0;
-        }
-        v222 = (double)dstWidth;
-        v213 = (double)srcWidth;
-        v27 = (double)dstHeight;
-        v28 = (double)srcHeight;
-        while ( 1 )
-        {
-          a6u = (double)a6c / v222 * v213;
-          v125 = a6u + 6.7553994e15;
-          v204 = v26 + 1;
-          a6v = (double)(v26 + 1) / v222 * v213;
-          v134 = a6v + 6.7553994e15;
-          v29 = (double)v232 / v27 * v28;
-          v143 = v29 + 6.7553994e15;
-          v30 = (double)(v232 + 1) / v27 * v28;
-          v152 = v30 + 6.7553994e15;
-          v31 = (LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125));
-          v253 = 0;
-          a6d = 0;
-          v241 = 0i64;
-          if ( SLODWORD(v143) < SLODWORD(v152) )
-            break;
-LABEL_50:
-          v34 = (unsigned int)v241 / ((LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125)));
-          if ( v31 )
-          {
-            a6d /= v31;
-            v253 /= v31;
-            HIDWORD(v241) /= v31;
-          }
-          if ( v34 != 255 )
-            v34 &= 0x7FFFFFFFu;
-          v35 = _450F55(HIDWORD(v241) | ((v253 | ((a6d | (v34 << 8)) << 8)) << 8));
-          v36 = v194;
-          ++v194;
-          *v36 = v35;
-          v26 = v204;
-          a6c = v204;
-          if ( v204 >= dstWidth )
-            goto LABEL_55;
-        }
-        v170 = LODWORD(v152) - LODWORD(v143);
-        v185 = &pSrc[2 * (LODWORD(v125) + srcPitch * LODWORD(v143))];
-        while ( SLODWORD(v125) >= SLODWORD(v134) )
-        {
-LABEL_49:
-          v185 += 2 * srcPitch;
-          --v170;
-          if ( !v170 )
-            goto LABEL_50;
-        }
-        v177 = (int *)v185;
-        v162 = LODWORD(v134) - LODWORD(v125);
-        while ( 1 )
-        {
-          v32 = *v177;
-          if ( a10 )
-          {
-            v230 = 1;
-            v25 = v32 != a11 ? 0xFF : 0;
-          }
-          v33 = _450FB1(v32);
-          if ( !v230 )
-            break;
-          LODWORD(v241) = v25 + v241;
-          v230 = 0;
-          if ( v25 )
-            goto LABEL_47;
-          --v31;
-LABEL_48:
-          ++v177;
-          --v162;
-          if ( !v162 )
-            goto LABEL_49;
-        }
-        LODWORD(v241) = ((unsigned int)v33 >> 24) + v241;
-LABEL_47:
-        a6d += BYTE2(v33);
-        v253 += BYTE1(v33);
-        HIDWORD(v241) += (unsigned __int8)v33;
-        goto LABEL_48;
-      }
-      result = (int)pDst;
-      v195 = pDst;
-      v233 = 0;
-      if ( dstHeight <= 0 )
-        return result;
-      v37 = dstWidth;
-      while ( 1 )
-      {
-        v38 = 0;
-        a6e = 0;
-        if ( dstWidth > v11 )
-          break;
-LABEL_80:
-        v195 = (unsigned __int16 *)((char *)v195 + dstPitch - dstWidth);
-        ++v233;
-        result = v233;
-        if ( v233 >= dstHeight )
-          return result;
-        v11 = 0;
-      }
-      v223 = (double)dstWidth;
-      v214 = (double)srcWidth;
-      v39 = (double)dstHeight;
-      v40 = (double)srcHeight;
-      while ( 1 )
-      {
-        a6w = (double)a6e / v223 * v214;
-        v126 = a6w + 6.7553994e15;
-        v205 = v38 + 1;
-        a6x = (double)(v38 + 1) / v223 * v214;
-        v135 = a6x + 6.7553994e15;
-        v41 = (double)v233 / v39 * v40;
-        v144 = v41 + 6.7553994e15;
-        v42 = (double)(v233 + 1) / v39 * v40;
-        v153 = v42 + 6.7553994e15;
-        v43 = (LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126));
-        v254 = 0;
-        a6f = 0;
-        v242 = 0i64;
-        if ( SLODWORD(v144) < SLODWORD(v153) )
-          break;
-LABEL_75:
-        v46 = (unsigned int)v242 / ((LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126)));
-        if ( v43 )
-        {
-          a6f /= v43;
-          v254 /= v43;
-          HIDWORD(v242) /= v43;
-        }
-        if ( v46 != 255 )
-          v46 &= 0x7FFFFFFFu;
-        v47 = _450F55(HIDWORD(v242) | ((v254 | ((a6f | (v46 << 8)) << 8)) << 8));
-        v48 = v195;
-        v195 = (unsigned __int16 *)((char *)v195 + 1);
-        *(_BYTE *)v48 = v47;
-        v38 = v205;
-        a6e = v205;
-        if ( v205 >= dstWidth )
-          goto LABEL_80;
-      }
-      v171 = LODWORD(v153) - LODWORD(v144);
-      v186 = &pSrc[2 * (LODWORD(v126) + srcPitch * LODWORD(v144))];
-      while ( SLODWORD(v126) >= SLODWORD(v135) )
-      {
-LABEL_74:
-        v186 += 2 * srcPitch;
-        --v171;
-        if ( !v171 )
-          goto LABEL_75;
-      }
-      v178 = (int *)v186;
-      v163 = LODWORD(v135) - LODWORD(v126);
-      while ( 1 )
-      {
-        v44 = *v178;
-        if ( a10 )
-        {
-          v230 = 1;
-          v37 = v44 != a11 ? 0xFF : 0;
-        }
-        v45 = _450FB1(v44);
-        if ( !v230 )
-          break;
-        LODWORD(v242) = v37 + v242;
-        v230 = 0;
-        if ( v37 )
-          goto LABEL_72;
-        --v43;
-LABEL_73:
-        ++v178;
-        --v163;
-        if ( !v163 )
-          goto LABEL_74;
-      }
-      LODWORD(v242) = ((unsigned int)v45 >> 24) + v242;
-LABEL_72:
-      a6f += BYTE2(v45);
-      v254 += BYTE1(v45);
-      HIDWORD(v242) += (unsigned __int8)v45;
-      goto LABEL_73;
-    }
-    result = this->field_20.field_C;
-    if ( result != 8 )
-    {
-      if ( result != 16 )
-      {
-        if ( result != 32 || (result = (int)pDst, v196 = pDst, v234 = 0, dstHeight <= 0) )
-          return result;
-        v49 = dstWidth;
-        a9c = 4 * (dstPitch - dstWidth);
-        while ( 1 )
-        {
-          v50 = 0;
-          a6g = 0;
-          if ( dstWidth > v11 )
-            break;
-LABEL_108:
-          v196 = (unsigned __int16 *)((char *)v196 + a9c);
-          ++v234;
-          result = v234;
-          if ( v234 >= dstHeight )
-            return result;
-          v11 = 0;
-        }
-        v224 = (double)dstWidth;
-        v215 = (double)srcWidth;
-        v51 = (double)dstHeight;
-        v52 = (double)srcHeight;
-        while ( 1 )
-        {
-          a6y = (double)a6g / v224 * v215;
-          v127 = a6y + 6.7553994e15;
-          v206 = v50 + 1;
-          a6z = (double)(v50 + 1) / v224 * v215;
-          v136 = a6z + 6.7553994e15;
-          v53 = (double)v234 / v51 * v52;
-          v145 = v53 + 6.7553994e15;
-          v54 = (double)(v234 + 1) / v51 * v52;
-          v154 = v54 + 6.7553994e15;
-          v55 = (LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(v127));
-          v255 = 0;
-          a6h = 0;
-          v243 = 0i64;
-          if ( SLODWORD(v145) < SLODWORD(v154) )
-            break;
-LABEL_103:
-          v58 = (unsigned int)v243 / ((LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(v127)));
-          if ( v55 )
-          {
-            a6h /= v55;
-            v255 /= v55;
-            HIDWORD(v243) /= v55;
-          }
-          if ( v58 != 255 )
-            v58 &= 0x7FFFFFFFu;
-          v59 = _450F55(HIDWORD(v243) | ((v255 | ((a6h | (v58 << 8)) << 8)) << 8));
-          v60 = v196;
-          v196 += 2;
-          *(_DWORD *)v60 = v59;
-          v50 = v206;
-          a6g = v206;
-          if ( v206 >= dstWidth )
-            goto LABEL_108;
-        }
-        v172 = LODWORD(v154) - LODWORD(v145);
-        v187 = &pSrc[LODWORD(v127) + srcPitch * LODWORD(v145)];
-        while ( SLODWORD(v127) >= SLODWORD(v136) )
-        {
-LABEL_102:
-          v187 += srcPitch;
-          --v172;
-          if ( !v172 )
-            goto LABEL_103;
-        }
-        v179 = (int *)v187;
-        v164 = LODWORD(v136) - LODWORD(v127);
-        while ( 1 )
-        {
-          v56 = *(_WORD *)v179;
-          if ( a10 )
-          {
-            v230 = 1;
-            v49 = v56 != a11 ? 0xFF : 0;
-          }
-          v57 = _450FB1(v56);
-          if ( !v230 )
-            break;
-          LODWORD(v243) = v49 + v243;
-          v230 = 0;
-          if ( v49 )
-            goto LABEL_100;
-          --v55;
-LABEL_101:
-          v179 = (int *)((char *)v179 + 2);
-          --v164;
-          if ( !v164 )
-            goto LABEL_102;
-        }
-        LODWORD(v243) = ((unsigned int)v57 >> 24) + v243;
-LABEL_100:
-        a6h += BYTE2(v57);
-        v255 += BYTE1(v57);
-        HIDWORD(v243) += (unsigned __int8)v57;
-        goto LABEL_101;
-      }
-      result = (int)pDst;
-      v197 = pDst;
-      v235 = 0;
-      if ( dstHeight <= 0 )
-        return result;
-      v61 = dstWidth;
-      a9d = 2 * (dstPitch - dstWidth);
-      while ( 1 )
-      {
-        v62 = 0;
-        a6i = 0;
-        if ( dstWidth > v11 )
-          break;
-LABEL_133:
-        v197 = (unsigned __int16 *)((char *)v197 + a9d);
-        ++v235;
-        result = v235;
-        if ( v235 >= dstHeight )
-          return result;
-        v11 = 0;
-      }
-      v225 = (double)dstWidth;
-      v216 = (double)srcWidth;
-      v63 = (double)dstHeight;
-      v64 = (double)srcHeight;
-      while ( 1 )
-      {
-        a6ba = (double)a6i / v225 * v216;
-        _v128 = floorf(a6ba + 0.5f);
-        //v128 = a6ba + 6.7553994e15;
-        v207 = v62 + 1;
-        a6bb = (double)(v62 + 1) / v225 * v216;
-        //v137 = a6bb + 6.7553994e15;
-        _v137 = floorf(a6bb + 0.5f);
-        v65 = (double)v235 / v63 * v64;
-        //v146 = v65 + 6.7553994e15;
-        _v146 = floorf(v65 + 0.5f);
-        v66 = (double)(v235 + 1) / v63 * v64;
-        //v155 = v66 + 6.7553994e15;
-        _v155 = floorf(v66 + 0.5f);
-        //v67 = (LODWORD(v155) - LODWORD(v146)) * (LODWORD(v137) - LODWORD(v128));
-        v67 = (_v155 - _v146) * (_v137 - _v128);
-        v256 = 0;
-        a6j = 0;
-        v244 = 0i64;
-        //if ( SLODWORD(v146) < SLODWORD(v155) )
-        if (_v146 < _v155)
-          break;
-LABEL_128:
-        //v70 = (unsigned int)v244 / ((LODWORD(v155) - LODWORD(v146)) * (LODWORD(v137) - LODWORD(v128)));
-        v70 = (unsigned int)v244 / ((_v155 - _v146) * (_v137 - _v128));
-        if ( v67 )
-        {
-          a6j /= v67;
-          v256 /= v67;
-          HIDWORD(v244) /= v67;
-        }
-        if ( v70 != 255 )
-          v70 &= 0x7FFFFFFFu;
-        v71 = _450F55(HIDWORD(v244) | ((v256 | ((a6j | (v70 << 8)) << 8)) << 8));
-        v72 = v197;
-        ++v197;
-        *v72 = v71;
-        v62 = v207;
-        a6i = v207;
-        if ( v207 >= dstWidth )
-          goto LABEL_133;
-      }
-      //v173 = LODWORD(v155) - LODWORD(v146);
-      v173 = _v155 - _v146;
-      //v188 = &pSrc[LODWORD(v128) + srcPitch * LODWORD(v146)];
-      v188 = &pSrc[_v128 + srcPitch * _v146];
-      //while ( SLODWORD(v128) >= SLODWORD(v137) )
-      while (_v128 >= _v137)
-      {
-LABEL_127:
-        v188 += srcPitch;
-        --v173;
-        if ( !v173 )
-          goto LABEL_128;
-      }
-      v180 = (int *)v188;
-      //v165 = LODWORD(v137) - LODWORD(v128);
-      v165 = _v137 - _v128;
-      while ( 1 )
-      {
-        v68 = *(_WORD *)v180;
-        if ( a10 )
-        {
-          v230 = 1;
-          v61 = v68 != a11 ? 0xFF : 0;
-        }
-        v69 = _450FB1(v68);
-        if ( !v230 )
-          break;
-        LODWORD(v244) = v61 + v244;
-        v230 = 0;
-        if ( v61 )
-          goto LABEL_125;
-        --v67;
-LABEL_126:
-        v180 = (int *)((char *)v180 + 2);
-        --v165;
-        if ( !v165 )
-          goto LABEL_127;
-      }
-      LODWORD(v244) = ((unsigned int)v69 >> 24) + v244;
-LABEL_125:
-      a6j += BYTE2(v69);
-      v256 += BYTE1(v69);
-      HIDWORD(v244) += (unsigned __int8)v69;
-      goto LABEL_126;
-    }
+  if ( result == 32 )
+  {
     result = (int)pDst;
-    v198 = pDst;
-    v236 = 0;
+    v193 = pDst;
+    v231 = 0;
     if ( dstHeight <= 0 )
       return result;
-    v73 = dstWidth;
     while ( 1 )
     {
-      v74 = 0;
-      a6k = 0;
-      if ( dstWidth > v11 )
+      v14 = 0;
+      if ( dstWidth > 0 )
         break;
-LABEL_158:
-      v198 = (unsigned __int16 *)((char *)v198 + dstPitch - dstWidth);
-      ++v236;
-      result = v236;
-      if ( v236 >= dstHeight )
+LABEL_30:
+      v193 = (unsigned __int16 *)((char *)v193 + dstdiffmult);
+      ++v231;
+      result = v231;
+      if ( v231 >= dstHeight )
         return result;
-      v11 = 0;
-    }
-    v226 = (double)dstWidth;
-    v217 = (double)srcWidth;
-    v75 = (double)dstHeight;
-    v76 = (double)srcHeight;
+    }
     while ( 1 )
     {
-      a6bc = (double)a6k / v226 * v217;
-      v129 = a6bc + 6.7553994e15;
-      v208 = v74 + 1;
-      a6bd = (double)(v74 + 1) / v226 * v217;
-      v138 = a6bd + 6.7553994e15;
-      v77 = (double)v236 / v75 * v76;
-      v147 = v77 + 6.7553994e15;
-      v78 = (double)(v236 + 1) / v75 * v76;
-      v156 = v78 + 6.7553994e15;
-      v257 = 0;
-      v79 = (LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129));
-      a6l = 0;
-      v245 = 0i64;
-      if ( SLODWORD(v147) < SLODWORD(v156) )
+      a6s = (double)v14 / (double)dstWidth * (double)srcWidth;
+      v151 = bankersRounding(a6s);//a6s + 6.7553994e15;
+      a6t = (double)(v14 + 1) / (double)dstWidth * (double)srcWidth;
+      v142 = bankersRounding(a6t);//a6t + 6.7553994e15;
+      v17 = (double)v231 / (double)dstHeight * (double)srcHeight;
+      v133 = bankersRounding(v17);//v17 + 6.7553994e15;
+      v18 = (double)(v231 + 1) / (double)dstHeight * (double)srcHeight;
+      v124 = bankersRounding(v18);//v18 + 6.7553994e15;
+      v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151));
+      v252 = 0;
+      a6b = 0;
+      v240 = 0i64;
+      if ( SLODWORD(v133) < SLODWORD(v124) )
+        break;
+LABEL_25:
+      v22 = (unsigned int)v240 / ((LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151)));
+      if ( v19 )
+      {
+        a6b /= v19;
+        v252 /= v19;
+        HIDWORD(v240) /= v19;
+      }
+      if ( v22 != 255 )
+        v22 &= 0x7FFFFFFFu;
+      v23 = _450F55(HIDWORD(v240) | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
+      *(_DWORD *)v193 = v23;
+      switch(probablyBitDepth)
+      {
+      case 8: v193 = (unsigned __int16 *)((char *)v193 + 1);
+        break;
+      case 16: ++v193;
+        break;
+      case 32: v193 += 2;
         break;
-LABEL_153:
-      v82 = (unsigned int)v245 / ((LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129)));
-      if ( v79 )
-      {
-        a6l /= v79;
-        v257 /= v79;
-        HIDWORD(v245) /= v79;
-      }
-      if ( v82 != 255 )
-        v82 &= 0x7FFFFFFFu;
-      v83 = _450F55(HIDWORD(v245) | ((v257 | ((a6l | (v82 << 8)) << 8)) << 8));
-      v84 = v198;
-      v198 = (unsigned __int16 *)((char *)v198 + 1);
-      *(_BYTE *)v84 = v83;
-      v74 = v208;
-      a6k = v208;
-      if ( v208 >= dstWidth )
-        goto LABEL_158;
-    }
-    v174 = LODWORD(v156) - LODWORD(v147);
-    v189 = &pSrc[LODWORD(v129) + srcPitch * LODWORD(v147)];
-    while ( SLODWORD(v129) >= SLODWORD(v138) )
-    {
-LABEL_152:
-      v189 += srcPitch;
-      --v174;
-      if ( !v174 )
-        goto LABEL_153;
-    }
-    v166 = LODWORD(v138) - LODWORD(v129);
-    v181 = (int *)v189;
+      default:
+        assert(false);
+        return result;
+      }
+      ++v14;
+      if ( v14 >= dstWidth )
+        goto LABEL_30;
+    }
+    v160 = LODWORD(v124) - LODWORD(v133);
+    v175 = &pSrc[2 * (LODWORD(v151) + srcPitch * LODWORD(v133))];
+    while ( SLODWORD(v151) >= SLODWORD(v142) )
+    {
+LABEL_24:
+      v175 += 2 * srcPitch;
+      --v160;
+      if ( !v160 )
+        goto LABEL_25;
+    }
+    v176 = (int *)v175;
+    v161 = LODWORD(v142) - LODWORD(v151);
+    while ( 1 )
+    {
+      v21 = _450FB1(*v176);
+      break;
+LABEL_23:
+      ++v176;
+      --v161;
+      if ( !v161 )
+        goto LABEL_24;
+    }
+    LODWORD(v240) = ((unsigned int)v21 >> 24) + v240;
+    a6b += BYTE2(v21);
+    v252 += BYTE1(v21);
+    HIDWORD(v240) += (unsigned __int8)v21;
+    goto LABEL_23;
+  }
+
+  else if ( result == 16 )
+  {
+    result = (int)pDst;
+    v196 = pDst;
+    v234 = 0;
+    if ( dstHeight <= 0 )
+      return result; 
+    while ( 1 )
+    {
+      v50 = 0;
+      if ( dstWidth > 0 )
+        break;
+  LABEL_108:
+      v196 = (unsigned __int16 *)((char *)v196 + dstdiffmult);
+      ++v234;
+      result = v234;
+      if ( v234 >= dstHeight )
+        return result;
+    }
     while ( 1 )
     {
-      v80 = *(_WORD *)v181;
-      if ( a10 )
-      {
-        v230 = 1;
-        v73 = v80 != a11 ? 0xFF : 0;
-      }
-      v81 = _450FB1(v80);
-      if ( !v230 )
+      a6y = (double)v50 / (double)dstWidth * (double)srcWidth;
+      v127 = ceilf(a6y - 0.5f);//a6y + 6.7553994e15;
+      a6z = (double)(v50 + 1) / (double)dstWidth * (double)srcWidth;
+      v136 = ceilf(a6z - 0.5f);//a6z + 6.7553994e15;
+      v53 = (double)v234 / (double)dstHeight * (double)srcHeight;
+      v145 = ceilf(v53 - 0.5f);//v53 + 6.7553994e15;
+      v54 = (double)(v234 + 1) / (double)dstHeight * (double)srcHeight;
+      v154 = ceilf(v54 - 0.5f);//v54 + 6.7553994e15;
+      v55 = (v154 - v145) * (v136 - v127);
+      v255 = 0;
+      a6h = 0;
+      v243 = 0i64;
+      if ( v145 < v154 )
+        break;
+  LABEL_103:
+      v58 = (unsigned int)v243 / ((v154 - v145) * (v136 - v127));
+      if ( v55 )
+      {
+        a6h /= v55;
+        v255 /= v55;
+        HIDWORD(v243) /= v55;
+      }
+      if ( v58 != 255 )
+        v58 &= 0x7FFFFFFFu;
+      v59 = _450F55(HIDWORD(v243) | ((v255 | ((a6h | (v58 << 8)) << 8)) << 8));
+      *(_DWORD *)v196 = v59;
+      switch(probablyBitDepth)
+      {
+      case 8: v196 = (unsigned __int16 *)((char *)v196 + 1);
+        break;
+      case 16: ++v196;
+        break;
+      case 32: v196 += 2;
         break;
-      LODWORD(v245) = v73 + v245;
-      v230 = 0;
-      if ( v73 )
-        goto LABEL_150;
-      --v79;
-LABEL_151:
-      v181 = (int *)((char *)v181 + 2);
-      --v166;
-      if ( !v166 )
-        goto LABEL_152;
-    }
-    LODWORD(v245) = ((unsigned int)v81 >> 24) + v245;
-LABEL_150:
-    a6l += BYTE2(v81);
-    v257 += BYTE1(v81);
-    HIDWORD(v245) += (unsigned __int8)v81;
-    goto LABEL_151;
-  }
-  result = this->field_20.field_C;
-  if ( result == 8 )
+      default:
+        assert(false);
+        return result;
+      }
+      ++v50;
+      if ( v50 >= dstWidth )
+        goto LABEL_108;
+    }
+    v172 = v154 - v145;
+    v187 = &pSrc[v127 + srcPitch * v145];
+    while ( v127 >= v136 )
+    {
+  LABEL_102:
+      v187 += srcPitch;
+      --v172;
+      if ( !v172 )
+        goto LABEL_103;
+    }
+    v179 = (int *)v187;
+    v164 = LODWORD(v136) - LODWORD(v127);
+    while ( 1 )
+    {
+      v57 = _450FB1(*(_WORD *)v179);
+      break;
+  LABEL_101:
+      v179 = (int *)((char *)v179 + 2);
+      --v164;
+      if ( !v164 )
+        goto LABEL_102;
+    }
+    LODWORD(v243) = ((unsigned int)v57 >> 24) + v243;
+    a6h += BYTE2(v57);
+    v255 += BYTE1(v57);
+    HIDWORD(v243) += (unsigned __int8)v57;
+    goto LABEL_101;
+  }
+
+  else if ( result == 8 )
   {
     result = (int)pDst;
     v201 = pDst;
     v239 = 0;
     if ( dstHeight <= 0 )
       return result;
-    v111 = dstWidth;
     while ( 1 )
     {
       v112 = 0;
-      a6q = 0;
-      if ( dstWidth <= v11 )
+      if ( dstWidth <= 0 )
         goto LABEL_236;
-      v229 = (double)dstWidth;
-      v220 = (double)srcWidth;
-      v113 = (double)dstHeight;
-      v114 = (double)srcHeight;
       do
       {
-        a6bi = (double)a6q / v229 * v220;
+        a6bi = (double)v112 / (double)dstWidth * (double)srcWidth;
         v132 = a6bi + 6.7553994e15;
-        v211 = v112 + 1;
-        a6bj = (double)(v112 + 1) / v229 * v220;
+        a6bj = (double)(v112 + 1) / (double)dstWidth * (double)srcWidth;
         v141 = a6bj + 6.7553994e15;
-        v115 = (double)v239 / v113 * v114;
+        v115 = (double)v239 / (double)dstHeight * (double)srcHeight;
         v150 = v115 + 6.7553994e15;
-        v116 = (double)(v239 + 1) / v113 * v114;
+        v116 = (double)(v239 + 1) / (double)dstHeight * (double)srcHeight;
         v159 = v116 + 6.7553994e15;
         v251 = 0;
         v117 = (LODWORD(v159) - LODWORD(v150)) * (LODWORD(v141) - LODWORD(v132));
@@ -3141,36 +2473,15 @@
         do
         {
           v118 = LODWORD(v132);
-          v192 = LODWORD(v132);
           while ( v118 < SLODWORD(v141) )
           {
-            v119 = (unsigned __int8)v184[v192];
-            if ( a10 )
-            {
-              v230 = 1;
-              v111 = v119 != a11 ? 0xFF : 0;
-            }
+            v119 = (unsigned __int8)v184[v118];
             v120 = _450FB1(v119);
-            if ( v230 )
-            {
-              v248 += v111;
-              v230 = 0;
-              if ( !v111 )
-              {
-                --v117;
-                goto LABEL_228;
-              }
-            }
-            else
-            {
-              v248 += (unsigned int)v120 >> 24;
-            }
+            v248 += (unsigned int)v120 >> 24;
             a6r += BYTE2(v120);
             v260 += BYTE1(v120);
             v251 += (unsigned __int8)v120;
-LABEL_228:
-            ++v192;
-            v118 = v192;
+            ++v118;
           }
           v184 += srcPitch;
           --v169;
@@ -3187,225 +2498,32 @@
         if ( v121 != 255 )
           v121 &= 0x7FFFFFFFu;
         v122 = _450F55(v251 | ((v260 | ((a6r | (v121 << 8)) << 8)) << 8));
-        v123 = v201;
-        v201 = (unsigned __int16 *)((char *)v201 + 1);
-        *(_BYTE *)v123 = v122;
-        v112 = v211;
-        a6q = v211;
-      }
-      while ( v211 < dstWidth );
+        *v201 = v122;
+        switch(probablyBitDepth)
+        {
+        case 8: v201 = (unsigned __int16 *)((char *)v201 + 1);
+          break;
+        case 16: ++v201;
+          break;
+        case 32: v201 += 2;
+          break;
+        default:
+          assert(false);
+          return result;
+        }
+        ++v112;
+      }
+      while ( v112 < dstWidth );
 LABEL_236:
-      v201 = (unsigned __int16 *)((char *)v201 + dstPitch - dstWidth);
+      v201 = (unsigned __int16 *)((char *)v201 + dstdiffmult);
       ++v239;
       result = v239;
       if ( v239 >= dstHeight )
         return result;
-      v11 = 0;
-    }
-  }
-  if ( result == 16 )
-  {
-    result = (int)pDst;
-    v200 = pDst;
-    v238 = 0;
-    if ( dstHeight <= 0 )
-      return result;
-    v98 = dstWidth;
-    a9f = 2 * (dstPitch - dstWidth);
-    while ( 1 )
-    {
-      v99 = 0;
-      a6o = 0;
-      if ( dstWidth <= v11 )
-        goto LABEL_211;
-      v228 = (double)dstWidth;
-      v219 = (double)srcWidth;
-      v100 = (double)dstHeight;
-      v101 = (double)srcHeight;
-      do
-      {
-        a6bg = (double)a6o / v228 * v219;
-        v131 = a6bg + 6.7553994e15;
-        v210 = v99 + 1;
-        a6bh = (double)(v99 + 1) / v228 * v219;
-        v140 = a6bh + 6.7553994e15;
-        v102 = (double)v238 / v100 * v101;
-        v149 = v102 + 6.7553994e15;
-        v103 = (double)(v238 + 1) / v100 * v101;
-        v158 = v103 + 6.7553994e15;
-        v250 = 0;
-        v104 = (LODWORD(v158) - LODWORD(v149)) * (LODWORD(v140) - LODWORD(v131));
-        v259 = 0;
-        a6p = 0;
-        v247 = 0;
-        if ( SLODWORD(v149) >= SLODWORD(v158) )
-          goto LABEL_206;
-        v168 = LODWORD(v158) - LODWORD(v149);
-        v183 = (char *)pSrc + srcPitch * LODWORD(v149);
-        do
-        {
-          v105 = LODWORD(v131);
-          v191 = LODWORD(v131);
-          while ( v105 < SLODWORD(v140) )
-          {
-            v106 = (unsigned __int8)v183[v191];
-            if ( a10 )
-            {
-              v230 = 1;
-              v98 = v106 != a11 ? 0xFF : 0;
-            }
-            v107 = _450FB1(v106);
-            if ( v230 )
-            {
-              v247 += v98;
-              v230 = 0;
-              if ( !v98 )
-              {
-                --v104;
-                goto LABEL_203;
-              }
-            }
-            else
-            {
-              v247 += (unsigned int)v107 >> 24;
-            }
-            a6p += BYTE2(v107);
-            v259 += BYTE1(v107);
-            v250 += (unsigned __int8)v107;
-LABEL_203:
-            ++v191;
-            v105 = v191;
-          }
-          v183 += srcPitch;
-          --v168;
-        }
-        while ( v168 );
-LABEL_206:
-        v108 = v247 / ((LODWORD(v158) - LODWORD(v149)) * (LODWORD(v140) - LODWORD(v131)));
-        if ( v104 )
-        {
-          a6p /= v104;
-          v259 /= v104;
-          v250 /= v104;
-        }
-        if ( v108 != 255 )
-          v108 &= 0x7FFFFFFFu;
-        v109 = _450F55(v250 | ((v259 | ((a6p | (v108 << 8)) << 8)) << 8));
-        v110 = v200;
-        ++v200;
-        *v110 = v109;
-        v99 = v210;
-        a6o = v210;
-      }
-      while ( v210 < dstWidth );
-LABEL_211:
-      v200 = (unsigned __int16 *)((char *)v200 + a9f);
-      ++v238;
-      result = v238;
-      if ( v238 >= dstHeight )
-        return result;
-      v11 = 0;
-    }
-  }
-  if ( result != 32 || (result = (int)pDst, v199 = pDst, v237 = 0, dstHeight <= 0) )
-    return result;
-  v85 = dstWidth;
-  a9e = 4 * (dstPitch - dstWidth);
-  while ( 2 )
-  {
-    v86 = 0;
-    a6m = 0;
-    if ( dstWidth <= v11 )
-      goto LABEL_186;
-    v227 = (double)dstWidth;
-    v218 = (double)srcWidth;
-    v87 = (double)dstHeight;
-    v88 = (double)srcHeight;
-    do
-    {
-      a6be = (double)a6m / v227 * v218;
-      v130 = a6be + 6.7553994e15;
-      v209 = v86 + 1;
-      a6bf = (double)(v86 + 1) / v227 * v218;
-      v139 = a6bf + 6.7553994e15;
-      v89 = (double)v237 / v87 * v88;
-      v148 = v89 + 6.7553994e15;
-      v90 = (double)(v237 + 1) / v87 * v88;
-      v157 = v90 + 6.7553994e15;
-      v249 = 0;
-      v91 = (LODWORD(v157) - LODWORD(v148)) * (LODWORD(v139) - LODWORD(v130));
-      v258 = 0;
-      a6n = 0;
-      v246 = 0;
-      if ( SLODWORD(v148) >= SLODWORD(v157) )
-        goto LABEL_181;
-      v167 = LODWORD(v157) - LODWORD(v148);
-      v182 = (char *)pSrc + srcPitch * LODWORD(v148);
-      do
-      {
-        v92 = LODWORD(v130);
-        v190 = LODWORD(v130);
-        while ( v92 < SLODWORD(v139) )
-        {
-          v93 = (unsigned __int8)v182[v190];
-          if ( a10 )
-          {
-            v230 = 1;
-            v85 = v93 != a11 ? 0xFF : 0;
-          }
-          v94 = _450FB1(v93);
-          if ( v230 )
-          {
-            v246 += v85;
-            v230 = 0;
-            if ( !v85 )
-            {
-              --v91;
-              goto LABEL_178;
-            }
-          }
-          else
-          {
-            v246 += (unsigned int)v94 >> 24;
-          }
-          a6n += BYTE2(v94);
-          v258 += BYTE1(v94);
-          v249 += (unsigned __int8)v94;
-LABEL_178:
-          ++v190;
-          v92 = v190;
-        }
-        v182 += srcPitch;
-        --v167;
-      }
-      while ( v167 );
-LABEL_181:
-      v95 = v246 / ((LODWORD(v157) - LODWORD(v148)) * (LODWORD(v139) - LODWORD(v130)));
-      if ( v91 )
-      {
-        a6n /= v91;
-        v258 /= v91;
-        v249 /= v91;
-      }
-      if ( v95 != 255 )
-        v95 &= 0x7FFFFFFFu;
-      v96 = _450F55(v249 | ((v258 | ((a6n | (v95 << 8)) << 8)) << 8));
-      v97 = v199;
-      v199 += 2;
-      *(_DWORD *)v97 = v96;
-      v86 = v209;
-      a6m = v209;
-    }
-    while ( v209 < dstWidth );
-LABEL_186:
-    v199 = (unsigned __int16 *)((char *)v199 + a9e);
-    ++v237;
-    result = v237;
-    if ( v237 < dstHeight )
-    {
-      v11 = 0;
-      continue;
-    }
+    }
+  }
+  else //( result != 8 && result != 16 && result != 32 )
+  {
     return result;
   }
 }
@@ -3484,7 +2602,7 @@
       v9 = 2;
       for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 )
       {
-        if ( !_strcmpi((&Str1)[4 * v9], "New") )
+        if ( !_stricmp((&Str1)[4 * v9], "New") )
         {
           v10 = (int)&v2->pTextures[v2->sNumTextures].uFlags;
           *(char *)v10 |= 2u;
@@ -5736,25 +4854,25 @@
         for ( j = 0; j < v41.uPropCount; ++j )
         {
           v27 = v41.pProperties[j];
-          if ( _strcmpi(v41.pProperties[j], "NBM") )
-          {
-            if ( _strcmpi(v27, "Invisible") )
+          if ( _stricmp(v41.pProperties[j], "NBM") )
+          {
+            if ( _stricmp(v27, "Invisible") )
             {
-              if ( _strcmpi(v27, "FS") )
+              if ( _stricmp(v27, "FS") )
               {
-                if ( _strcmpi(v27, "FM") )
+                if ( _stricmp(v27, "FM") )
                 {
-                  if ( _strcmpi(v27, "FF") )
+                  if ( _stricmp(v27, "FF") )
                   {
-                    if ( _strcmpi(v27, "Marker") )
+                    if ( _stricmp(v27, "Marker") )
                     {
-                      if ( _strcmpi(v27, "LoopSlow") )
+                      if ( _stricmp(v27, "LoopSlow") )
                       {
-                        if ( _strcmpi(v27, "EmitFire") )
+                        if ( _stricmp(v27, "EmitFire") )
                         {
-                          if ( _strcmpi(v27, "Dawn") )
+                          if ( _stricmp(v27, "Dawn") )
                           {
-                            if ( !_strcmpi(v27, "Dusk") )
+                            if ( !_stricmp(v27, "Dusk") )
                               HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 2u;
                           }
                           else
@@ -5966,17 +5084,17 @@
         {
           v21 = Argsb;
           v22 = v44.pProperties[Argsb];
-          if ( !_strcmpi(v44.pProperties[Argsb], "NoDraw") )
+          if ( !_stricmp(v44.pProperties[Argsb], "NoDraw") )
           {
             v23 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v23 |= 1u;
           }
-          if ( !_strcmpi(v22, "Lifetime") )
+          if ( !_stricmp(v22, "Lifetime") )
           {
             v24 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v24 |= 4u;
           }
-          if ( !_strcmpi(v22, "FTLifetime") )
+          if ( !_stricmp(v22, "FTLifetime") )
           {
             v25 = (int)&v2->pObjects[v2->uNumObjects];
             *(short *)(v25 + 42) = 8 * pSpriteFrameTable->pSpriteSFrames[*(short *)(v25 + 40)].uAnimLength;
@@ -5985,32 +5103,32 @@
             v27 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v27 |= 4u;
           }
-          if ( !_strcmpi(v22, "NoPickup") )
+          if ( !_stricmp(v22, "NoPickup") )
           {
             v28 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v28 |= 0x10u;
           }
-          if ( !_strcmpi(v22, "NoGravity") )
+          if ( !_stricmp(v22, "NoGravity") )
           {
             v29 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v29 |= 0x20u;
           }
-          if ( !_strcmpi(v22, "FlagOnIntercept") )
+          if ( !_stricmp(v22, "FlagOnIntercept") )
           {
             v30 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v30 |= 0x40u;
           }
-          if ( !_strcmpi(v22, "Bounce") )
+          if ( !_stricmp(v22, "Bounce") )
           {
             v31 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v31 |= 0x80u;
           }
           v32 = v45.pProperties[v21];
-          if ( !_strcmpi(v45.pProperties[v21], "Fire") )
+          if ( !_stricmp(v45.pProperties[v21], "Fire") )
             HIBYTE(v2->pObjects[v2->uNumObjects].uFlags) |= 2u;
-          if ( !_strcmpi(v32, "Lines") )
+          if ( !_stricmp(v32, "Lines") )
             HIBYTE(v2->pObjects[v2->uNumObjects].uFlags) |= 4u;
-          if ( !_strcmpi(v44.pProperties[v21], "bits") )
+          if ( !_stricmp(v44.pProperties[v21], "bits") )
           {
             v33 = v44.pProperties[v21 + 1];
             v34 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
@@ -7053,7 +6171,7 @@
         v29 = 0;
         //goto LABEL_262;
         v30 = 1;
-        ArcomageGame::OnMouseClick(v30, v29);
+        ArcomageGame::OnMouseClick(v30, v29 != 0);
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
 
       case WM_LBUTTONDBLCLK:
@@ -7129,7 +6247,7 @@
           ArcomageGame::OnMouseMove((POINT *)pXY);
           ArcomageGame::OnMouseClick(0, wParam & 1);
           v29 = (wParam >> 1) & 1;
-          ArcomageGame::OnMouseClick(1, v29);
+          ArcomageGame::OnMouseClick(1, v29 != 0);
         }
         else
         {
@@ -7967,7 +7085,7 @@
 //----- (00464839) --------------------------------------------------------
 char __cdecl Is_out15odm_underwater()
 {
-  return _strcmpi(pCurrentMapName, "out15.odm") == 0;
+  return _stricmp(pCurrentMapName, "out15.odm") == 0;
 }
 
 //----- (00464851) --------------------------------------------------------
@@ -8011,19 +7129,19 @@
   bUnderwater = 0;
   uLevelMapStatsID = v5;
   pGame->uFlags2 &= 0xFFFFFFF7u;
-  if ( !_strcmpi(pCurrentMapName, "out15.odm") )
+  if ( !_stricmp(pCurrentMapName, "out15.odm") )
   {
     bUnderwater = 1;
     pGame->uFlags2 |= 8u;
   }
   pParty->floor_face_pid = 0;
-  if ( _strcmpi(Str1, "blv") )
+  if ( _stricmp(Str1, "blv") )
     PrepareToLoadODM(v9, 0);
   else
     PrepareToLoadBLV(v9);
   pAudioPlayer->SetMapEAX();
   sub_461103();
-  if ( !_strcmpi(pCurrentMapName, "d11.blv") || !_strcmpi(pCurrentMapName, "d10.blv") )
+  if ( !_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv") )
   {
     //spawning grounds & good analogue - no loot & exp from monsters
 
@@ -11068,7 +10186,7 @@
 }
 
 //----- (0046BEF1) --------------------------------------------------------
-void SpriteObject::_46BEF1_apply_spells()
+void SpriteObject::_46BEF1_apply_spells_aoe()
 {
   SpriteObject *v1; // edi@1
   Actor *v2; // esi@2
@@ -11077,6 +10195,8 @@
   unsigned __int8 v5; // c3@4
   signed int v6; // [sp+8h] [bp-4h]@1
 
+  int v7,v8,v9,v10,v11;
+
   v6 = 0;
   v1 = this;
   if ( (signed int)uNumActors > 0 )
@@ -11087,7 +10207,79 @@
       if ( v2->CanAct() )
       {
         //UNDEF(v3);
-        if ( !(v4 | v5) )
+		//.text:0046BF26                 movsx   eax, word ptr [esi-2]
+		//.text:0046BF2A                 sub     eax, [edi+4]
+		//.text:0046BF31                 mov     [ebp+var_8], eax
+		//.text:0046BF37                 fild    [ebp+var_8]
+		// v7 pushed to stack
+		v7 = v2->vPosition.x - this->vPosition.x;
+
+		//.text:0046BF2D                 movsx   ecx, word ptr [esi+2]
+		v8 = v2->vPosition.z;
+
+		//.text:0046BF34                 movsx   eax, word ptr [esi]
+		//.text:0046BF3A                 sub     eax, [edi+8]
+		//.text:0046BF3D                 mov     [ebp+var_8], eax
+		//.text:0046BF44                 fild    [ebp+var_8]
+		// v9 pushed to stack
+		v9 = v2->vPosition.y - this->vPosition.y;
+
+		//.text:0046BF40                 movsx   eax, word ptr [esi-6]
+		//.text:0046BF47                 sar     eax, 1
+		//.text:0046BF49                 add     eax, ecx
+		//.text:0046BF4B                 sub     eax, [edi+0Ch]
+		//.text:0046BF4E                 mov     [ebp+var_8], eax
+		//.text:0046BF51                 fild    [ebp+var_8]
+		//.text:0046BF58                 fld     st
+		// v10 pushed to stack, two times
+		v10 = v2->uActorHeight / 2 + v8 - this->vVelocity.y;
+
+		//.text:0046BF54                 movsx   eax, word ptr [esi-8]
+		//.text:0046BF5A                 add     eax, 100h
+		//.text:0046BF63                 mov     ecx, eax
+		v11 = this->vVelocity.x;
+
+		//.text:0046BF5F                 fmul    st, st(1)
+		// stack: v10*v10, v10, v9, v7
+		//.text:0046BF61                 fld     st(2)
+		// stack: v7, v10*v10, v10, v9, v7
+		
+
+		//.text:0046BF65                 fmul    st, st(3)
+		// stack: v7*v9, v10*v10, v10, v9, v7
+		
+		//.text:0046BF67                 imul    ecx, eax
+		v11 = v11 * v11;
+
+		//.text:0046BF6A                 faddp   st(1), st
+		// stack: v10*v10+v7*v9, v10, v9, v7
+		//.text:0046BF6C                 fld     st(3)
+		// stack: v7, v10*v10+v7*v9, v10, v9, v7
+		//.text:0046BF6E                 fmul    st, st(4)
+		// stack: v7*v7, v10*v10+v7*v9, v10, v9, v7
+		//.text:0046BF70                 faddp   st(1), st
+		// stack: v10*v10+v7*v9+v7*v7, v10, v9, v7
+		
+		//.text:0046BF72                 mov     [ebp+var_8], ecx
+		//.text:0046BF75                 fild    [ebp+var_8]
+		// v11 pushed to stack
+
+		//.text:0046BF78                 fcompp
+		// if ( v11 > v10*v10+v7*v9+v7*v7 )
+		// stack: v10, v9, v7
+
+		//.text:0046BF7A                 fstp    st
+		// stack: v9, v7
+
+		//.text:0046BF7C                 fnstsw  ax
+		//.text:0046BF7E                 fstp    st
+		// stack: v7
+
+		//.text:0046BF80                 test    ah, 41h
+		//.text:0046BF83                 fstp    st
+		//.text:0046BF85                 jnz     short loc_46BFDD
+
+		if ( v11 >= v10*v10+v7*v9+v7*v7 )
         {
           if ( stru_50C198.GetMagicalResistance(v2, 0xAu) )
           {
@@ -11348,7 +10540,7 @@
         {
           if ( v6 != 9030 || v2->spell_skill != 4 )
             goto LABEL_246;
-          v2->_46BEF1_apply_spells();
+          v2->_46BEF1_apply_spells_aoe();
 LABEL_233:
           if ( !v138 )
           {
@@ -11457,7 +10649,7 @@
               }
               else
               {
-                v2->_46BEF1_apply_spells();
+                v2->_46BEF1_apply_spells_aoe();
               }
               v2->spell_level = 0;
               v2->spell_skill = 0;