diff mm7_4.cpp @ 737:225d92620998

004A19D8 refactored
author Nomad
date Fri, 22 Mar 2013 20:40:23 +0200
parents 6daaa2f18d0d
children 852ec78d9548
line wrap: on
line diff
--- a/mm7_4.cpp	Fri Mar 22 20:07:55 2013 +0200
+++ b/mm7_4.cpp	Fri Mar 22 20:40:23 2013 +0200
@@ -4932,9 +4932,9 @@
 
 
 //----- (004A19D8) --------------------------------------------------------
-int __fastcall sub_4A19D8(unsigned int a1, unsigned int a2)
+unsigned int BlendColors(unsigned int a1, unsigned int a2)
 {
-  signed __int64 v2; // ST10_8@1
+  /*signed __int64 v2; // ST10_8@1
   double v3; // st7@1
   float v4; // ST24_4@1
   double v5; // ST10_8@1
@@ -4945,22 +4945,32 @@
   float v10; // ST24_4@1
   double v11; // ST10_8@1
   float v12; // ST24_4@1
-  double v13; // ST08_8@1
-
-  v2 = a1 >> 24;
-  v3 = (double)v2 * 0.0039215689;
+  double v13; // ST08_8@1*/
+
+  uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f *
+                                   (a2 >> 24) / 255.0f * 255.0f),
+       red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f *
+                                 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f),
+       green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f *
+                                   ((a2 >> 8) & 0xFF) / 255.0f * 255.0f),
+       blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f *
+                                   ((a2 >> 0) & 0xFF) / 255.0f * 255.0f);
+  return (alpha << 24) | (red << 16) | (green << 8) | blue;
+  /*v2 = a1 >> 24;
+  v3 = (double)v2 / 255.0f;
+  HIDWORD(v2) = 0;
   LODWORD(v2) = a2 >> 24;
-  v4 = v3 * (double)v2 * 0.0039215689 * 255.0;
+  v4 = v3 * (double)v2 / 255.0f * 255.0;
   v5 = v4 + 6.7553994e15;
   v6 = LODWORD(v5);
-  v7 = (double)((a1 >> 16) & 0xFFi64) * 0.0039215689 * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0;
+  v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0;
   v8 = v7 + 6.7553994e15;
   v9 = LOBYTE(v8);
-  v10 = (double)((unsigned __int16)a1 >> 8) * 0.0039215689 * (double)((unsigned __int16)a2 >> 8) * 0.0039215689 * 255.0;
+  v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0;
   v11 = v10 + 6.7553994e15;
-  v12 = (double)(a1 & 0xFFi64) * 0.0039215689 * (double)(unsigned __int8)a2 * 0.0039215689 * 255.0;
+  v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0;
   v13 = v12 + 6.7553994e15;
-  return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);
+  return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/
 }