changeset 2125:ba3de1337989

house animations working round renamed to round_to_int
author zipi
date Thu, 26 Dec 2013 22:46:49 +0000
parents 7f403ebf619f
children a2da7afb41b4
files Bink_Smacker.cpp Bink_Smacker.h DecalBuilder.cpp VideoPlayer.cpp mm7_3.cpp mm7_4.cpp mm7_data.h
diffstat 7 files changed, 117 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/Bink_Smacker.cpp	Fri Dec 27 01:28:48 2013 +0600
+++ b/Bink_Smacker.cpp	Thu Dec 26 22:46:49 2013 +0000
@@ -24,8 +24,8 @@
 int  (__stdcall *smackw32_SmackBlitClear)(HSMACKBLIT, unsigned short *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int) = 0;
 int  (__stdcall *smackw32_SmackGoto)(_SMACK *, long) = 0;
 int  (__stdcall *smackw32_SmackBufferOpen)(HWND a1, long a2, long a3, long a4, long a5, long a6) = nullptr;
-int  (__stdcall *smackw32_SmackBufferNewPalette)(long, long, long) = nullptr;
-int  (__stdcall *smackw32_SmackColorRemapWithTrans)(long, long, long, long, long) = nullptr;
+void(__stdcall *smackw32_SmackBufferNewPalette)(HSMACKBUF, void *, unsigned int) = nullptr;
+void(__stdcall *smackw32_SmackColorRemapWithTrans)(_SMACK *, void *, unsigned int, unsigned int, unsigned int) = nullptr;
 void SMACKW32_DLL_Initialize()
 {
   HMODULE pDll = LoadLibraryW(L"SmackW32.dll");
@@ -50,16 +50,17 @@
     smackw32_SmackBlitClear = (int (__stdcall *)(HSMACKBLIT, unsigned short *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int))GetProcAddress(pDll, "_SmackBlitClear@32");
     smackw32_SmackGoto = (int  (__stdcall *)(_SMACK *, long))GetProcAddress(pDll, "_SmackGoto@8");
     smackw32_SmackBufferOpen = (int  (__stdcall *)(HWND, long, long, long, long, long))GetProcAddress(pDll, "_SmackBufferOpen@24");
-
-    LOAD(SmackBufferNewPalette);
-    LOAD(SmackColorRemapWithTrans);
+	smackw32_SmackBufferNewPalette = (void(__stdcall *)(HSMACKBUF, void *, unsigned int))GetProcAddress(pDll, "_SmackBufferNewPalette@12");
+	smackw32_SmackColorRemapWithTrans = (void(__stdcall *)(_SMACK *, void *, unsigned int, unsigned int, unsigned int))GetProcAddress(pDll, "_SmackColorRemapWithTrans@20");
+    //LOAD(SmackBufferNewPalette);
+    //LOAD(SmackColorRemapWithTrans);
   }
 }
 
 
 
 
-int __stdcall SmackColorRemapWithTrans(long a1, long a2, long a3, long a4, long a5)
+void __stdcall SmackColorRemapWithTrans(_SMACK *a1, void *a2, unsigned int a3, unsigned int a4, unsigned int a5)
 {
   return (smackw32_SmackColorRemapWithTrans)(a1, a2, a3, a4, a5);
 }
@@ -163,9 +164,9 @@
 
 
 // sub_4D83D0: using guessed type int __stdcall SmackBufferNewPalette(_DWORD, _DWORD, _DWORD);
-int __stdcall SmackBufferNewPalette(long a1, long a2, long a3)
+void __stdcall SmackBufferNewPalette(HSMACKBUF a1, void *a2, unsigned int a3)
 {
-  return (smackw32_SmackBufferNewPalette)(a1, a2, a3);
+ (smackw32_SmackBufferNewPalette)(a1, a2, a3);
 }
 
 
--- a/Bink_Smacker.h	Fri Dec 27 01:28:48 2013 +0600
+++ b/Bink_Smacker.h	Thu Dec 26 22:46:49 2013 +0000
@@ -143,6 +143,35 @@
         int numrects;
         HDC lastdc;
 };
+#define BINKFRAMERATE            0x00001000L // Override fr (call BinkFrameRate first)
+#define BINKPRELOADALL            0x00002000L // Preload the entire animation
+#define BINKSNDTRACK            0x00004000L // Set the track number to play
+#define BINKOLDFRAMEFORMAT        0x00008000L // using the old Bink frame format (internal use only)
+#define BINKRBINVERT            0x00010000L // use reversed R and B planes (internal use only)
+#define BINKGRAYSCALE            0x00020000L // Force Bink to use grayscale
+#define BINKNOMMX                0x00040000L // Don't use MMX
+#define BINKNOSKIP                0x00080000L // Don't skip frames if falling behind
+#define BINKALPHA                0x00100000L // Decompress alpha plane (if present)
+#define BINKNOFILLIOBUF            0x00200000L // Fill the IO buffer in SmackOpen
+#define BINKSIMULATE            0x00400000L // Simulate the speed (call BinkSim first)
+#define BINKFILEHANDLE            0x00800000L // Use when passing in a file handle
+#define BINKIOSIZE                0x01000000L // Set an io size (call BinkIOSize first)
+#define BINKIOPROCESSOR            0x02000000L // Set an io processor (call BinkIO first)
+#define BINKFROMMEMORY            0x04000000L // Use when passing in a pointer to the file
+#define BINKNOTHREADEDIO        0x08000000L // Don't use a background thread for IO
+
+#define BINKSURFACEFAST            0x00000000L
+#define BINKSURFACESLOW            0x08000000L
+#define BINKSURFACEDIRECT        0x04000000L
+
+#define BINKCOPYALL                0x80000000L // copy all pixels (not just changed)
+#define BINKCOPY2XH                0x10000000L // Force doubling height scaling
+#define BINKCOPY2XHI            0x20000000L // Force interleaving height scaling
+#define BINKCOPY2XW                0x30000000L // copy the width zoomed by two
+#define BINKCOPY2XWH            0x40000000L // copy the width and height zoomed by two
+#define BINKCOPY2XWHI            0x50000000L // copy the width and height zoomed by two
+#define BINKCOPY1XI                0x60000000L // copy the width and height zoomed by two
+#define BINKCOPYNOSCALING        0x70000000L // Force scaling off
 
 #define SMACKNEEDPAN    0x00020L // Will be setting the pan
 #define SMACKNEEDVOLUME 0x00040L // Will be setting the volume
@@ -197,10 +226,10 @@
 int __stdcall SmackGoto(_SMACK *a1, long a2);
 
 // sub_4D83D0: using guessed type int __stdcall SmackBufferNewPalette(_DWORD, _DWORD, _DWORD);
-int __stdcall SmackBufferNewPalette(long a1, long a2, long a3);
+void __stdcall SmackBufferNewPalette(HSMACKBUF a1, void *a2, unsigned int a3);
 
 // sub_4D83D4: using guessed type int __stdcall SmackColorRemapWithTrans(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
-int __stdcall SmackColorRemapWithTrans(long a1, long a2, long a3, long a4, long a5);
+void __stdcall SmackColorRemapWithTrans(_SMACK *a1, void *a2, unsigned int a3, unsigned int a4, unsigned int a5);
 
 
 
--- a/DecalBuilder.cpp	Fri Dec 27 01:28:48 2013 +0600
+++ b/DecalBuilder.cpp	Thu Dec 26 22:46:49 2013 +0000
@@ -506,9 +506,9 @@
 				(double)pFace->pBoundingBox.z2 + pBloodsplat->radius > pBloodsplat->z )
 			{
 				v8 = (double)((pFace->pFacePlane.dist
-							+ round(pBloodsplat->x) * pFace->pFacePlane.vNormal.x
-							+ round(pBloodsplat->y) * pFace->pFacePlane.vNormal.y
-							+ round(pBloodsplat->z) * pFace->pFacePlane.vNormal.z) >> 16);
+							+ round_to_int(pBloodsplat->x) * pFace->pFacePlane.vNormal.x
+							+ round_to_int(pBloodsplat->y) * pFace->pFacePlane.vNormal.y
+							+ round_to_int(pBloodsplat->z) * pFace->pFacePlane.vNormal.z) >> 16);
 				if ( v8 <= pBloodsplat->radius )
 				{
 					pBloodsplat->dot_dist = v8;
--- a/VideoPlayer.cpp	Fri Dec 27 01:28:48 2013 +0600
+++ b/VideoPlayer.cpp	Thu Dec 26 22:46:49 2013 +0000
@@ -309,7 +309,7 @@
   if (!bNoVideo)
   {
     pRenderer->PresentBlackScreen();
-    PlayFullscreenMovie(MOVIE_3DOLogo, true);
+    //PlayFullscreenMovie(MOVIE_3DOLogo, true);
     //pGame->pCShow->PlayMovie(MOVIE_3DOLogo, 1);
     if ( !pVideoPlayer->bStopBeforeSchedule )
     {
@@ -841,6 +841,7 @@
         pRenderer->EndScene();
       }
 }
+auto pixels = new unsigned short[640 * 480];
 
 //----- (004BF08B) --------------------------------------------------------
 void VideoPlayer::SmackUpdatePalette()
@@ -852,11 +853,10 @@
   //_SMACK *v6; // eax@1
 
   Log::Warning(L"smacker");
-  return;
+  //return;
 
   pRenderer->BeginScene();
 
-  auto pixels = new unsigned short[640 * 480];
   v3 = pixels;//pRenderer->pTargetSurface;
   v4 = 640;//pRenderer->uTargetSurfacePitch;
   v5 = SmackCheckSurfaceFromat();
@@ -869,17 +869,17 @@
     {
       pRenderer->WritePixel16(x, y, pixels[x + y * 640]);
     }
-  delete [] pixels;
+  //delete [] pixels;
 
   //v6 = pSmackerMovie;
-  if (false&& pSmackerMovie->NewPalette )
+  if ( pSmackerMovie->NewPalette )
   {
-    SmackBufferNewPalette((long)pSmackerBuffer, (long)pSmackerMovie->Palette, LOWORD(pSmackerMovie->PalType));
+    SmackBufferNewPalette(pSmackerBuffer, pSmackerMovie->Palette, (pSmackerMovie->PalType));
     SmackColorRemapWithTrans(
-      (long)pSmackerMovie,
-      (long)pSmackerBuffer->Palette,
-      (long)pSmackerBuffer->MaxPalColors,
-      (long)pSmackerBuffer->PalType,
+      pSmackerMovie,
+      pSmackerBuffer->Palette,
+	  pSmackerBuffer->MaxPalColors,
+      pSmackerBuffer->PalType,
       1000);
   }
   SmackDoFrame(pSmackerMovie);
@@ -921,10 +921,10 @@
     {
       SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN);
 
-      if (uBinkVersion < 0x0003000000000000)
-        return BinkOpen(hMagicVid, 0x8800000);
-      else
-        return BinkOpen(hMagicVid, 0x82000000);
+	  if (uBinkVersion < 0x0003000000000000)
+		  return BinkOpen(hMagicVid, BINKNOTHREADEDIO | BINKFILEHANDLE);//0x8800000);
+	  else
+		  return BinkOpen(hMagicVid, BINKIOPROCESSOR | BINKCOPYALL);//0x82000000);
     }
 
   return nullptr;
--- a/mm7_3.cpp	Fri Dec 27 01:28:48 2013 +0600
+++ b/mm7_3.cpp	Thu Dec 26 22:46:49 2013 +0000
@@ -2067,11 +2067,11 @@
       v6 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789 / this->field_B4[i*4];
       if ( pRenderer->pRenderD3D )
       {
-        pGame->pIndoorCameraD3D->Project(round(this->field_B4[i*4]), round(this->field_B4[i*4+1]), round(this->field_B4[i*4+2]),
+        pGame->pIndoorCameraD3D->Project(round_to_int(this->field_B4[i*4]), round_to_int(this->field_B4[i*4+1]), round_to_int(this->field_B4[i*4+2]),
            &a5, &a6);
         this->field_B4[i*4+16] = (double)a5;
         this->field_B4[i*4+17] = (double)a6;
-        this->field_B4[i*4+18] = round(this->field_B4[i*4]);
+        this->field_B4[i*4+18] = round_to_int(this->field_B4[i*4]);
       }
       else
       {
@@ -3295,9 +3295,9 @@
   }
   else
   {
-    v_18.x = round((double)this->v_18.x / len * 65536.0);
-    v_18.y = round((double)this->v_18.y / len * 65536.0);
-    v_18.y = round((double)this->v_18.z / len * 65536.0);
+    v_18.x = round_to_int((double)this->v_18.x / len * 65536.0);
+    v_18.y = round_to_int((double)this->v_18.y / len * 65536.0);
+    v_18.y = round_to_int((double)this->v_18.z / len * 65536.0);
   }
 }
 
@@ -3994,63 +3994,58 @@
 
   v1 = pParty->uCurrentMonth + 1;
   v2 = pParty->uDaysPlayed + 1;
-  if ( a1 )
+  if ((v1 == (a1 + 1) * 3 && v2 >= 21) || v1 == (a1 + 1) % 4 * 3 + 1 || v1 == (a1 + 1) % 4 * 3 + 2 || (v1 == (a1 + 2) % 4 * 3 && v2 < 21))
+	  return true;
+  return false;
+
+  switch (a1)
   {
-    v3 = a1 - 1;
-    if ( a1 - 1 )
-    {
-      v4 = v3 - 1;
-      if ( v3 - 1 )
-      {
-        if ( v4 != 1 )
-          return false;
-        if ( v1 != 12 )
-        {
-          if ( (signed int)v1 >= 1 && (signed int)v1 <= 2 )
-            return true;
-          v6 = v1 == 3;
-          if ( !v6 || (signed int)v2 >= 21 )
-            return false;
-          return true;
-        }
-      }
-      else
-      {
-        if ( v1 != 9 )
-        {
-          if ( (signed int)v1 >= 10 && (signed int)v1 <= 11 )
-            return true;
-          v6 = v1 == 12;
-          if ( !v6 || (signed int)v2 >= 21 )
-            return false;
-          return true;
-        }
-      }
-    }
-    else
-    {
-      if ( v1 != 6 )
-      {
-        if ( (signed int)v1 >= 7 && (signed int)v1 <= 8 )
-          return true;
-        v6 = v1 == 9;
-        if ( !v6 || (signed int)v2 >= 21 )
-          return false;
-        return true;
-      }
-    }
-  }
-  else
-  {
-    if ( v1 != 3 )
-    {
-      if ( (signed int)v1 >= 4 && (signed int)v1 <= 5 )
-        return true;
-      v6 = v1 == 6;
-      if ( !v6 || (signed int)v2 >= 21 )
-        return false;
-      return true;
-    }
+	case 3:
+		if (v1 != 12)//12.21 -> 3.20
+		{
+			if ((signed int)v1 >= 1 && (signed int)v1 <= 2)
+				return true;
+			v6 = v1 == 3;
+			if (!v6 || (signed int)v2 >= 21)
+				return false;
+			return true;
+		}
+		break;
+	case 2:
+		if (v1 != 9)//9.21 -> 12.20
+		{
+			if ((signed int)v1 >= 10 && (signed int)v1 <= 11)
+				return true;
+			v6 = v1 == 12;
+			if (!v6 || (signed int)v2 >= 21)
+				return false;
+			return true;
+		}
+		break;
+	case 1:
+		if (v1 != 6)//6.21 -> 9.20
+		{
+			if ((signed int)v1 >= 7 && (signed int)v1 <= 8)
+				return true;
+			v6 = v1 == 9;
+			if (!v6 || (signed int)v2 >= 21)
+				return false;
+			return true;
+		}
+		break;
+	case 0:
+		if (v1 != 3)//3.21 -> 9.20
+		{
+			if ((signed int)v1 >= 4 && (signed int)v1 <= 5)
+				return true;
+			v6 = v1 == 6;
+			if (!v6 || (signed int)v2 >= 21)
+				return false;
+			return true;
+		}
+		break;
+	default:
+		return false;
   }
   if ( (signed int)v2 >= 21 )
     return true;
--- a/mm7_4.cpp	Fri Dec 27 01:28:48 2013 +0600
+++ b/mm7_4.cpp	Thu Dec 26 22:46:49 2013 +0000
@@ -172,9 +172,9 @@
     v = v_replace;
   HSV2RGB(&r, &g, &b, h, s, v);
 
-  return (((uint)round(r * 255.0f) & 0xFF) << 16) |
-         (((uint)round(g * 255.0f) & 0xFF) << 8) |
-         (((uint)round(b * 255.0f) & 0xFF));
+  return (((uint)round_to_int(r * 255.0f) & 0xFF) << 16) |
+         (((uint)round_to_int(g * 255.0f) & 0xFF) << 8) |
+         (((uint)round_to_int(b * 255.0f) & 0xFF));
 }
 
 //----- (0048B561) --------------------------------------------------------
--- a/mm7_data.h	Fri Dec 27 01:28:48 2013 +0600
+++ b/mm7_data.h	Thu Dec 26 22:46:49 2013 +0000
@@ -1352,7 +1352,7 @@
 int __fastcall MakeColorMaskFromBitDepth(int a1);
 void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels);
 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb
-inline int round(float x) { return (int)floor(x + 0.5f); }
+inline int round_to_int(float x) { return (int)floor(x + 0.5f); }
 inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count)
 {
   unsigned __int32* p = (unsigned __int32 *)ptr;