changeset 2218:e8f9a06c7bcb

for video
author Ritor1
date Sun, 16 Feb 2014 21:49:39 +0600
parents 744ed51880ed
children e6771956e74a
files Mouse.cpp VideoPlayer.cpp
diffstat 2 files changed, 202 insertions(+), 221 deletions(-) [+]
line wrap: on
line diff
--- a/Mouse.cpp	Sat Feb 15 22:00:13 2014 +0600
+++ b/Mouse.cpp	Sun Feb 16 21:49:39 2014 +0600
@@ -61,7 +61,7 @@
   if ( _stricmp(this->pCurrentCursorName, pName) )
     strcpy(this->pCurrentCursorName, pName);
   ClearCursor();
-  if ( _strnicmp(pName, "MICON1", 5) )
+  if ( _strnicmp(pName, "MICON1", 5) )//если курсор не стрелка
   {
     this->uCursorTextureID = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE);
     this->uCursorTextureID_2 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE);
--- a/VideoPlayer.cpp	Sat Feb 15 22:00:13 2014 +0600
+++ b/VideoPlayer.cpp	Sun Feb 16 21:49:39 2014 +0600
@@ -65,24 +65,18 @@
 //----- (004BFE2D) --------------------------------------------------------
 _BINKBUF *VideoPlayer::CreateBinkBuffer(unsigned int uWidth, unsigned int uHeight, char a4)
 {
-  __int32 v4; // edi@3
   _BINKBUF *v5; // esi@3
   HRESULT v6; // eax@5
   IDirectDrawSurface *v7; // eax@6
   HRESULT v8; // eax@9
-  char v9; // al@11
   DDSURFACEDESC2 v11; // [sp+Ch] [bp-108h]@7
   DDSURFACEDESC Dst; // [sp+88h] [bp-8Ch]@3
-  unsigned int v13; // [sp+F4h] [bp-20h]@1
-  //struct tagRECT Rect; // [sp+F8h] [bp-1Ch]@11
   IDirectDrawSurface4 *v15; // [sp+108h] [bp-Ch]@7
   IDirectDrawSurface2 *a2; // [sp+10Ch] [bp-8h]@3
 
-  v13 = uWidth;
   //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
       //pVersion->pVersionInfo.dwMajorVersion >= 5u )
   {
-    v4 = 0;
     v15 = 0;
 
     if (uBinkVersion == 0x0001000500150000)
@@ -97,14 +91,14 @@
     }
     else __debugbreak();
 
-    memset(&v11, 0, 0x7Cu);
+    memset(&v11, 0, 0x7C);
     v11.dwSize = 124;
-    v11.dwWidth = v13;
-    v11.dwFlags = 0x1007u;                      // DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT
-    v11.ddsCaps.dwCaps = 0x4040u;               // DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY
+    v11.dwWidth = uWidth;
+    v11.dwFlags = 0x1007;                      // DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT
+    v11.ddsCaps.dwCaps = 0x4040;               // DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY
     v11.dwHeight = uHeight;
     *(_QWORD *)&v11.ddpfPixelFormat.dwSize = 0x400000020ui64;// DDPF_FOURCC
-    v11.ddpfPixelFormat.dwFourCC = 0x32595559u;
+    v11.ddpfPixelFormat.dwFourCC = 0x32595559;
     if (FAILED(pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0)))
     {
       memset(&v11.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT));
@@ -141,7 +135,7 @@
 
     memset(&Dst, 0, 0x6Cu);
     Dst.dwSize = 108;
-    Dst.dwWidth = v13;
+    Dst.dwWidth = uWidth;
     Dst.dwFlags = 4103;
     Dst.ddsCaps.dwCaps = 16448;
     Dst.dwHeight = uHeight;
@@ -166,11 +160,10 @@
   }*/
   v5->pTargetDDrawSurface = v7;
   v5->hWnd = window->GetApiHandle();
-  v9 = a4;
-  v5->field_4C = v4;
-  v5->field_68 = v4;
-  v5->field_5C = v4;
-  v5->field_74 = v9 & 0x1F;
+  v5->field_4C = 0;
+  v5->field_68 = 0;
+  v5->field_5C = 0;
+  v5->field_74 = a4 & 0x1F;
   v5->field_78 = 1;
   v5->target_width = GetSystemMetrics(SM_CXSCREEN);
   v5->target_height = GetSystemMetrics(SM_CYSCREEN);
@@ -182,8 +175,8 @@
   v5->field_C = window->GetHeight();
   v5->field_1C = Rect.left;
   v5->field_20 = Rect.top;
-  Rect.left = v4;
-  Rect.top = v4;
+  Rect.left = 0;
+  Rect.top = 0;
   ClientToScreen(window->GetApiHandle(), (POINT *)&Rect);
   v5->field_1C = Rect.left - v5->field_1C;
   v5->field_20 = Rect.top - v5->field_20;
@@ -192,7 +185,7 @@
   v5->field_34 = v5->field_C - Rect.bottom;
   v5->field_8 = v5->uWidth + v5->field_30;
   v5->field_C = v5->uHeight + v5->field_34;
-  BinkBufferSetOffset(v5, v4, v4);
+  BinkBufferSetOffset(v5, 0, 0);
   BinkBufferSetScale(v5, v5->uWidth, v5->uHeight);
   return v5;
 }
@@ -204,7 +197,6 @@
   IDirectDrawSurface *v2; // edi@5
   IDirectDrawSurface4 *v6; // edi@11
 
-  //v1 = _this;
   //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u )
   {
     DDSURFACEDESC2 v8; // [sp+Ch] [bp-7Ch]@4
@@ -219,9 +211,9 @@
           break;
         
         if (uBinkVersion < 0x0003000000000000)
-          BYTE3(_this->uBinkDDSurfaceType) |= 0x80u;
+          _this->uBinkDDSurfaceType |= 0x80000000;
         else
-          BYTE3(_this->uBinkDDSurfaceType) |= 0x04;
+          _this->uBinkDDSurfaceType |= 0x4000000;
 
         if ( v6->Restore() )
           return 0;
@@ -265,16 +257,14 @@
 //----- (004C01FB) --------------------------------------------------------
 void BinkUnlockBuffer(_BINKBUF *_this)
 {
-  _BINKBUF *v1; // esi@1
   IDirectDrawSurface *v2; // eax@1
 
-  v1 = _this;
   v2 = _this->pTargetDDrawSurface;
   if ( v2 )
   {
     v2->Unlock(0);
-    v1->uDDrawSurfacePitch = 0;
-    v1->pDDrawSurfaceData = 0;
+    _this->uDDrawSurfacePitch = 0;
+    _this->pDDrawSurfaceData = 0;
 
     if (uBinkVersion < 0x0003000000000000)
       BYTE3(_this->uBinkDDSurfaceType) &= 0x7F;
@@ -330,7 +320,7 @@
   {
     pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
     AIL_redbook_stop(pAudioPlayer->hAILRedbook);
-    AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &uTrackStartMS, &uTrackEndMS);
+    AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS);
     AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS);
   }
   bGameoverLoop = 0;
@@ -342,7 +332,7 @@
   int v4; // ebp@1
   const char *pName; // edi@1
   MSG Msg; // [sp+Ch] [bp-1Ch]@12
- 	  	  
+
   v4 = a2;
   pName = pMovieName;
   if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) )
@@ -352,7 +342,7 @@
     ShowCursor(0);
     OpenGlobalMovie(pName, 0, ScreenSizeFlag);
     bPlayingMovie = 1;
-	field_44 = v4;
+    field_44 = v4;
     //if ( pRenderer->pRenderD3D )
     {
       pRenderer->ClearTarget(0);
@@ -365,61 +355,61 @@
     }*/
     pCurrentScreen = SCREEN_VIDEO;
 
-	auto hwnd = pVideoPlayer->window->GetApiHandle();
-	RECT rc_client;
-	GetClientRect(hwnd, &rc_client);
-	int client_width = rc_client.right - rc_client.left,
-		client_height = rc_client.bottom - rc_client.top;
+    auto hwnd = pVideoPlayer->window->GetApiHandle();
+    RECT rc_client;
+    GetClientRect(hwnd, &rc_client);
+    int client_width = rc_client.right - rc_client.left,
+        client_height = rc_client.bottom - rc_client.top;
 
-	HDC     dc = GetDC(hwnd);
-	HDC     back_dc = CreateCompatibleDC(dc);
-	HBITMAP back_bmp;
-	SelectObject(back_dc, back_bmp = CreateCompatibleBitmap(dc, client_width, client_height));
+    HDC     dc = GetDC(hwnd);
+    HDC     back_dc = CreateCompatibleDC(dc);
+    HBITMAP back_bmp;
+    SelectObject(back_dc, back_bmp = CreateCompatibleBitmap(dc, client_width, client_height));
 
-	while (true)
-	{
-		if ( pVideoPlayer->bStopBeforeSchedule )
-			break;
-		while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE))
-		{
-			if (Msg.message == 18)
-				Game_DeinitializeAndTerminate(0);
-			if (Msg.message == 15)
-				break;
-			TranslateMessage(&Msg);
-			DispatchMessageA(&Msg);
-		}
-		GUI_MainMenuMessageProc();
+    while (true)
+    {
+      if ( pVideoPlayer->bStopBeforeSchedule )
+        break;
+      while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE))
+      {
+        if (Msg.message == 18)
+          Game_DeinitializeAndTerminate(0);
+        if (Msg.message == 15)
+          break;
+        TranslateMessage(&Msg);
+        DispatchMessageA(&Msg);
+      }
+      GUI_MainMenuMessageProc();
 
-		if (pMovie->Stopped())
-		  break;
-		auto image = pPlayer->DoFrame();
-		if (image)
-		{
-			// draw to hwnd
-			BITMAPINFO bmi;
-			bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-			bmi.bmiHeader.biWidth = client_width;
-			bmi.bmiHeader.biHeight = -client_height;
-			bmi.bmiHeader.biPlanes = 1;
-			bmi.bmiHeader.biBitCount = 32;
-			bmi.bmiHeader.biCompression = BI_RGB;
-			bmi.bmiHeader.biSizeImage = 0;
-			bmi.bmiHeader.biXPelsPerMeter = 0;
-			bmi.bmiHeader.biYPelsPerMeter = 0;
-			bmi.bmiHeader.biClrUsed = 0;
-			bmi.bmiHeader.biClrImportant = 0;
-			GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS);
-			SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS);
-			BitBlt(dc, 0, 0, client_width, client_height, back_dc, 0, 0, SRCCOPY);
+      if (pMovie->Stopped())
+        break;
+      char *image = pPlayer->DoFrame();
+      if (image)
+      {
+        // draw to hwnd
+        BITMAPINFO bmi;
+        bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+        bmi.bmiHeader.biWidth = client_width;
+        bmi.bmiHeader.biHeight = -client_height;
+        bmi.bmiHeader.biPlanes = 1;
+        bmi.bmiHeader.biBitCount = 32;
+        bmi.bmiHeader.biCompression = BI_RGB;
+        bmi.bmiHeader.biSizeImage = 0;
+        bmi.bmiHeader.biXPelsPerMeter = 0;
+        bmi.bmiHeader.biYPelsPerMeter = 0;
+        bmi.bmiHeader.biClrUsed = 0;
+        bmi.bmiHeader.biClrImportant = 0;
+        GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS);
+        SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS);
+        BitBlt(dc, 0, 0, client_width, client_height, back_dc, 0, 0, SRCCOPY);
 
-			delete[] image;
-		}
-		if (pVideoPlayer->bStopBeforeSchedule == 1)
-			Sleep(0x3E8u);
-	}
-	pVideoPlayer->Unload();
-	/*
+        delete[] image;
+      }
+      if (pVideoPlayer->bStopBeforeSchedule == 1)
+      Sleep(1000);
+    }
+    pVideoPlayer->Unload();
+    /*
     if ( pVideoPlayer->uMovieFormat == 2 )
     {
       if ( pVideoPlayer->pBinkMovie )
@@ -468,9 +458,6 @@
   }
 }
 
-
-
-
 //----- (004BE95A) --------------------------------------------------------
 unsigned int VideoPlayer::SmackCheckSurfaceFromat()
 {
@@ -513,7 +500,7 @@
   uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor;
 
   strcpy(pTmpBuf.data(), "anims\\might7.vid");
-  hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
+  hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0);
   if ( hMightVid == INVALID_HANDLE_VALUE )
   {
     sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data());
@@ -521,20 +508,20 @@
     return;
   }
   strcpy(pTmpBuf.data(), "anims\\magic7.vid");
-  hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
+  hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0);
   if ( hMagicVid == INVALID_HANDLE_VALUE )
   {
     if ( !bCanLoadFromCD )
-      {
+    {
        sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data());
        MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0);
        return;
-	  }
+    }
     sprintf(pTmpBuf2.data(), "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf.data());
-    hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
+    hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0);
     if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE )
     {
-	  sprintf(pTmpBuf2.data(), "Can't open file - %s", pTmpBuf.data());
+      sprintf(pTmpBuf2.data(), "Can't open file - %s", pTmpBuf.data());
       MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0);
       return;
     }
@@ -571,7 +558,6 @@
   uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer4);
 }
 
-
 //----- (004BEBD7) --------------------------------------------------------
 void VideoPlayer::Unload()
 {
@@ -883,39 +869,37 @@
 
 void VideoPlayer::UpdatePalette()
 {
-	//VideoPlayer *v2; // esi@1
-	unsigned __int16 *v3; // ebx@1
-	unsigned int v4; // edi@1
-	unsigned int v5; // eax@1
-	//_SMACK *v6; // eax@1
+  unsigned __int16 *v3; // ebx@1
+  unsigned int v4; // edi@1
+  unsigned int v5; // eax@1
 
-	Log::Warning(L"smacker");
+  Log::Warning(L"smacker");
+
+  pRenderer->BeginScene();
 
-	pRenderer->BeginScene();
+  if (pMovie->Stopped())//видео завершено/перезагрузка
+  {
+    int width = pMovie->GetWidth();
+    int height = pMovie->GetHeight();
+    delete pMovie;
 
-	if (pMovie->Stopped())
-	{
-		int width = pMovie->GetWidth();
-		int height = pMovie->GetHeight();
-		delete pMovie;
+    SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN);
 
-		SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN);
+    pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height);
+  }
+  else
+  {
 
-		pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height);
-	}
-	else
-	{
-
-		auto image = pPlayer->DoFrame();
+    auto image = pPlayer->DoFrame();
 
-		if (image)
-		{
-			memcpy(pRenderer->pTargetSurface, image, 480 * 480 * 4);
-			delete[] image;
-		}
-	}
+    if (image)
+    {
+      memcpy(pRenderer->pTargetSurface, image, 480 * 480 * 4);//запись кадра на экран
+      delete[] image;
+    }
+  }
 
-	pRenderer->EndScene();
+  pRenderer->EndScene();
 }
 /*
 //----- (004BF08B) --------------------------------------------------------
@@ -1040,21 +1024,21 @@
   if (!this->bBufferLoaded)
   {
     //Prepare();
-	  pEventTimer->Pause();
-	  if (pAudioPlayer->hAILRedbook)
-		  AIL_redbook_pause(pAudioPlayer->hAILRedbook);
+    pEventTimer->Pause();
+    if (pAudioPlayer->hAILRedbook)
+      AIL_redbook_pause(pAudioPlayer->hAILRedbook);
 
-	  bStopBeforeSchedule = false;
-	  bBufferLoaded = 1;
-	  /*
-	  pSmackerMovie = 0;
-	  pSmackerBuffer = 0;
-	  pBinkMovie = 0;
-	  pBinkBuffer = 0;
-	  */
-	  bPlayingMovie = false;
-	  bFirstFrame = false;
-	  bUsingSmackerMMX = SmackUseMMX(1);
+    bStopBeforeSchedule = false;
+    bBufferLoaded = 1;
+    /*
+    pSmackerMovie = 0;
+    pSmackerBuffer = 0;
+    pBinkMovie = 0;
+    pBinkBuffer = 0;
+    */
+    bPlayingMovie = false;
+    bFirstFrame = false;
+    bUsingSmackerMMX = SmackUseMMX(1);
 
     this->bLoopPlaying = a3_1;
     if ( LOBYTE(this->field_104) == 1 )
@@ -1063,9 +1047,9 @@
       return;
     }
 
-	LoadMovie(pMovieName);
-	/*
-	this->pSmackerMovie = OpenSmack(Str2);
+    LoadMovie(pMovieName);
+    /*
+    this->pSmackerMovie = OpenSmack(Str2);
     if ( !this->pSmackerMovie )
     {
       this->Unload();
@@ -1074,8 +1058,6 @@
       return;
     }
     */
- 
-
 
 	/*
 	this->pSmackerBuffer = (_SMACKBUF *)SmackBufferOpen(window->GetApiHandle(), 4, LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height), LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height));
@@ -1211,22 +1193,21 @@
   pMouse->_469E24();
   if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pMovie)//!this->pSmackerMovie )
   {
-    bGameoverLoop = 1;
+    bGameoverLoop = true;
     HouseDialogPressCloseBtn();
     window_SpeakInHouse->Release();
-    pParty->uFlags &= 0xFFFFFFFDu;
+    pParty->uFlags &= 0xFFFFFFFD;
     if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) )
     {
       pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0);
       window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0);
-      window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-      window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-      window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-      window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
+      window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, 0x31, "", 0);
+      window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, 0x32, "", 0);
+      window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, 0x33, "", 0);
+      window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, 0x34, "", 0);
     }
     bGameoverLoop = 0;
   }
-  
 }
 
 //----- (004BF73A) --------------------------------------------------------
@@ -1273,100 +1254,100 @@
 
 void MultimediaPlayer::Logger(void *, int, const char *format, va_list args)
 {
-	char msg[1024];
-	vsprintf(msg, format, args);
+  char msg[1024];
+  vsprintf(msg, format, args);
 
-	DWORD w;
-	WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, lstrlenA(msg), &w, nullptr);
+  DWORD w;
+  WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, lstrlenA(msg), &w, nullptr);
 }
 
 int VideoPlayer::readFunction(void* opaque, uint8_t* buf, int buf_size)
 {
-	HANDLE stream = (HANDLE)opaque;
-	//int numBytes = stream->read((char*)buf, buf_size);
-	int numBytes;
-	ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL);
-	return numBytes;
+  HANDLE stream = (HANDLE)opaque;
+  //int numBytes = stream->read((char*)buf, buf_size);
+  int numBytes;
+  ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL);
+  return numBytes;
 }
 
 int64_t VideoPlayer::seekFunction(void* opaque, int64_t offset, int whence)
 {
-	if (whence == AVSEEK_SIZE)
-		return pVideoPlayer->uSize;
-	HANDLE h = (HANDLE)opaque;
-	LARGE_INTEGER li;
-	li.QuadPart = offset;
-	
-	if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN))
-		return -1;
-	return li.QuadPart;
+  if (whence == AVSEEK_SIZE)
+    return pVideoPlayer->uSize;
+  HANDLE h = (HANDLE)opaque;
+  LARGE_INTEGER li;
+  li.QuadPart = offset;
+
+  if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN))
+    return -1;
+  return li.QuadPart;
 }
 
 void VideoPlayer::LoadMovie(const char * pFilename)
 {
-	char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2
-	char pVideoNameSmk[120]; // [sp+Ch] [bp-28h]@2
+  char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2
+  char pVideoNameSmk[120]; // [sp+Ch] [bp-28h]@2
 
-	sprintf(pVideoNameBik, "%s.bik", pFilename);
-	sprintf(pVideoNameSmk, "%s.smk", pFilename);
-	for (uint i = 0; i < uNumMightVideoHeaders; ++i)
-	{
-		//no BIK in MightVid
-		/*
-		if (!_stricmp(pVideoNameBik, pMightVideoHeaders[i].pVideoName))
-		{
-			hVidFile = hMightVid;
-			uOffset = pMightVideoHeaders[i].uFileOffset;
-			uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset;
-			this->uMovieFormat = 2;
-			this->uMovieFormatSwapped = 1;
-		}
-		*/
-		if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName))
-		{
-			hVidFile = hMightVid;
-			uOffset = pMightVideoHeaders[i].uFileOffset;
-			uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset;
-			this->uMovieFormat = 1;
-			this->uMovieFormatSwapped = 2;
-		}
-	}
-	for (uint i = 0; i < uNumMagicVideoHeaders; ++i)
-	{
-		if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName))
-		{
-			hVidFile = hMagicVid;
-			uOffset = pMagicVideoHeaders[i].uFileOffset;
-			uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset;
-			this->uMovieFormat = 2;
-			this->uMovieFormatSwapped = 1;
-		}
-		if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName))
-		{
-			hVidFile = hMagicVid;
-			uOffset = pMagicVideoHeaders[i].uFileOffset;
-			uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset;
-			this->uMovieFormat = 1;
-			this->uMovieFormatSwapped = 2;
-		}
-	}
-	if (!hVidFile)
-	{
-		Unload();
-		MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0);
-		return;
-	}
+  sprintf(pVideoNameBik, "%s.bik", pFilename);
+  sprintf(pVideoNameSmk, "%s.smk", pFilename);
+  for (uint i = 0; i < uNumMightVideoHeaders; ++i)
+  {
+    //no BIK in MightVid
+    /*
+    if (!_stricmp(pVideoNameBik, pMightVideoHeaders[i].pVideoName))
+    {
+      hVidFile = hMightVid;
+      uOffset = pMightVideoHeaders[i].uFileOffset;
+      uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset;
+      this->uMovieFormat = 2;
+      this->uMovieFormatSwapped = 1;
+    }
+    */
+    if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName))
+    {
+      hVidFile = hMightVid;
+      uOffset = pMightVideoHeaders[i].uFileOffset;
+      uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset;
+      this->uMovieFormat = 1;
+      this->uMovieFormatSwapped = 2;
+    }
+  }
+  for (uint i = 0; i < uNumMagicVideoHeaders; ++i)
+  {
+    if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName))
+    {
+      hVidFile = hMagicVid;
+      uOffset = pMagicVideoHeaders[i].uFileOffset;
+      uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset;
+      this->uMovieFormat = 2;
+      this->uMovieFormatSwapped = 1;
+    }
+    if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName))
+    {
+      hVidFile = hMagicVid;
+      uOffset = pMagicVideoHeaders[i].uFileOffset;
+      uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset;
+      this->uMovieFormat = 1;
+      this->uMovieFormatSwapped = 2;
+    }
+  }
+  if (!hVidFile)
+  {
+    Unload();
+    MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0);
+    return;
+  }
 
-	SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN);
-	strcpy(this->pCurrentMovieName, pFilename);
+  SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN);
+  strcpy(this->pCurrentMovieName, pFilename);
 
-	auto hwnd = pVideoPlayer->window->GetApiHandle();
-	RECT rc_client;
-	GetClientRect(hwnd, &rc_client);
-	int client_width = rc_client.right - rc_client.left,
-		client_height = rc_client.bottom - rc_client.top;
+  auto hwnd = pVideoPlayer->window->GetApiHandle();
+  RECT rc_client;
+  GetClientRect(hwnd, &rc_client);
+  int client_width = rc_client.right - rc_client.left,
+      client_height = rc_client.bottom - rc_client.top;
 
 
-	pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, client_width, client_height);
+  pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, client_width, client_height);
 
 }
\ No newline at end of file