diff mm7_2.cpp @ 2331:9551756f46c4

Moving functions out of mm7_6.cpp into appropriate classes as static methods or free functions
author Grumpy7
date Wed, 02 Apr 2014 01:21:05 +0200
parents 8e9be4fa33a8
children ddb803517a48
line wrap: on
line diff
--- a/mm7_2.cpp	Tue Apr 01 23:44:27 2014 +0200
+++ b/mm7_2.cpp	Wed Apr 02 01:21:05 2014 +0200
@@ -75,31 +75,6 @@
 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive);
 bool __fastcall Initialize(HINSTANCE hInst, char *pCmdLine);
 
-//----- (004A1780) mm6_chinese---------------------------------------------
-__int64 fixpoint_div(int a1, int a2)
-{
-  return ((__int64)a1 << 16) / a2;
-}
-
-__int64 fixpoint_sub_unknown(int a1, int a2)
-{
-  return (((__int64)a1 << 16) * a2) >> 16;
-}
-
-//----- (0042EBBE) --------------------------------------------------------
-//----- (004453C0) mm6-----------------------------------------------------
-//----- (004A1760) mm6_chinese---------------------------------------------
-__int64 fixpoint_mul(int a1, int a2)
-{
-  return ((__int64)a1 * (__int64)a2) >> 16;
-}
-
-__int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2)
-{
-  return fixpoint_mul(x1, x2) +
-         fixpoint_mul(y1, y2) +
-         fixpoint_mul(z1, z2);
-}
 
 //----- (004BB756) --------------------------------------------------------
 int UseNPCSkill(NPCProf profession)
@@ -1909,139 +1884,6 @@
                                                                     + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00));
 }
 
-//----- (0045281E) --------------------------------------------------------
-//    Calculates atan2(y/x)
-// return value: angle in integer format (multiplier of Pi/1024)  
-unsigned int stru193_math::Atan2(int x, int y)
-{
-  signed int quadrant;
-  __int64 dividend;
-  int quotient;
-  int lowIdx;
-  int highIdx;
-  int angle;
-
-  int X = x;
-  int Y = y;
-
-  if ( abs(X) < 65536 )
-  {
-    if ( (abs(Y) >> 15) >= abs(X) )
-      X = 0;
-  }
-
-  if ( !X )
-  {
-    if ( Y > 0 )
-    {
-      return uIntegerHalfPi;   //Pi/2
-    }
-    else
-    {
-      return uIntegerHalfPi + uIntegerPi; //3*(Pi/2)
-    }
-  }
-
-  if ( Y )
-  {
-    if ( X < 0 )
-    {
-      X = -X;
-      if ( Y > 0 )
-      {
-        quadrant = 4;        
-      }
-      else
-      {
-        quadrant = 3;        
-      }      
-    }
-    else
-    {
-      if ( Y > 0 )
-      {
-        quadrant = 1;       
-      }
-      else
-      {
-        quadrant = 2;
-      }      
-    }
-
-    if ( Y < 0 )
-      Y = -Y;
-
-    LODWORD(dividend) = Y << 16;
-    HIDWORD(dividend) = Y >> 16;
-    quotient = dividend / X;        
-
-    //looks like binary search
-    {
-      int i;
-      highIdx = uIntegerHalfPi;
-      lowIdx = 0;
-
-      for (i = 0; i < 6; ++i)
-      {        
-        if (quotient <= pTanTable[(lowIdx + highIdx) / 2])      
-          highIdx = (lowIdx + highIdx) / 2;
-        else
-          lowIdx = (lowIdx + highIdx) / 2;    
-      }
-    }
-
-    angle = lowIdx + 1;
-    while ( angle < (highIdx - 1) && quotient >= pTanTable[angle] )
-      ++angle;
-
-    switch (quadrant)
-    {
-    case 1: //X > 0, Y > 0
-      return angle;        
-
-    case 2: //X > 0, Y < 0
-      return uIntegerDoublePi - angle;   //2*Pi - angle
-
-    case 3: //X > 0, Y < 0
-      return uIntegerPi + angle;        //Pi + angle 
-
-    case 4: //X < 0, Y > 0
-      return uIntegerPi - angle;        //Pi - angle  
-    }
-
-    //should newer get here
-    return 0;
-  }
-
-  if ( X < 0 )    //Y == 0, X < 0
-    return uIntegerPi;  
-
-  return 0;
-}
-
-//----- (00452969) --------------------------------------------------------
-stru193_math::stru193_math()
-{
-  double v3; // ST18_8@2
-
-  this->pTanTable[0] = 0;
-  this->pCosTable[0] = 65536;
-  this->pInvCosTable[0] = 65536;
-  for(int i = 1; i < (signed int)this->uIntegerHalfPi; i++)
-  {
-    v3 = (double)i * 3.141592653589793 / (double)uIntegerPi;
-    pTanTable[i] = (signed __int64)(tan(v3) * (double)this->pCosTable[0] + 0.5);
-    pCosTable[i] = (signed __int64)(cos(v3) * (double)this->pCosTable[0] + 0.5);
-    pInvCosTable[i] = (signed __int64)(1.0 / cos(v3) * (double)this->pCosTable[0] + 0.5);
-  }
-  for(int i = this->uIntegerHalfPi; i < 520; i++)
-  {
-    this->pTanTable[i] = 0xEFFFFFFFu;
-    this->pCosTable[i] = 0;
-    this->pInvCosTable[i] = 0xEFFFFFFFu;
-  }
-}
-
 //----- (00452A9E) --------------------------------------------------------
 int integer_sqrt(int val)
 {
@@ -2573,6 +2415,30 @@
 }
 // 6BE3A0: using guessed type float flt_6BE3A0;
 
+
+//----- (0042F3D6) --------------------------------------------------------
+void InitializeTurnBasedAnimations(void *_this)
+{
+  for (unsigned int i = 0; i < pIconIDs_Turn.size(); ++i)
+  {
+    char icon_name[32];
+    sprintf(icon_name, "turn%u", i);
+    pIconIDs_Turn[i] = pIconsFrameTable->FindIcon(icon_name);
+    pIconsFrameTable->InitializeAnimation(pIconIDs_Turn[i]);
+  }
+
+  uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop");
+  uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour");
+  uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart");
+  uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1");
+  uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11");
+
+  pIconsFrameTable->InitializeAnimation(uIconID_TurnHour);
+  pIconsFrameTable->InitializeAnimation(uIconID_TurnStop);
+  pIconsFrameTable->InitializeAnimation(uIconID_TurnStart);
+  pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame);
+}
+
 //----- (00464839) --------------------------------------------------------
 char Is_out15odm_underwater()
 {