Mercurial > mm7
annotate VideoPlayer.cpp @ 2352:8a49cf25fb88
Moving zlib wrappers to separate headers
author | Grumpy7 |
---|---|
date | Wed, 09 Apr 2014 21:51:06 +0200 |
parents | d57505d3c70c |
children | 08c4f1799ca1 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2223
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
0 | 2 |
2336 | 3 #include "mm7_unsorted_subs.h" |
0 | 4 #include "Bink_Smacker.h" |
5 | |
1262 | 6 #include "mm7_data.h" |
1016 | 7 #include "CShow.h" |
8 #include "Mouse.h" | |
9 | |
0 | 10 #include "VideoPlayer.h" |
2345 | 11 #include "MediaPlayer.h" |
0 | 12 #include "AudioPlayer.h" |
13 #include "Game.h" | |
14 #include "Render.h" | |
15 #include "Party.h" | |
16 #include "GUIWindow.h" | |
2044 | 17 #include "Timer.h" |
0 | 18 #include "Log.h" |
1253 | 19 #include "texts.h" |
1299 | 20 #include "UI\UIHouses.h" |
0 | 21 |
22 VideoPlayer *pVideoPlayer = nullptr; | |
23 | |
2347 | 24 #pragma comment(lib, "Version.lib") |
0 | 25 bool GetDllVersion(const wchar_t *pDllName, uint *pMajor, uint *pMinor) |
26 { | |
27 uint uVersionSize = GetFileVersionInfoSizeW(pDllName, nullptr); | |
28 void *pVersionData = HeapAlloc(GetProcessHeap(), 0, uVersionSize); | |
29 { | |
30 GetFileVersionInfoW(pDllName, 0, uVersionSize, pVersionData); | |
31 | |
32 VS_FIXEDFILEINFO *pInfo = nullptr; | |
33 UINT uInfoSize = 0; | |
34 VerQueryValueW(pVersionData, L"\\", (void **)&pInfo, &uInfoSize); | |
35 | |
36 if (!pMajor || !pMinor) | |
37 { | |
38 HeapFree(GetProcessHeap(), 0, pVersionData); | |
39 return false; | |
40 } | |
41 *pMajor = pInfo->dwFileVersionMS; | |
42 *pMinor = pInfo->dwFileVersionLS; | |
43 } | |
44 HeapFree(GetProcessHeap(), 0, pVersionData); | |
45 return true; | |
46 } | |
47 | |
48 unsigned __int64 uBinkVersion; | |
49 | |
50 //----- (004BF794) -------------------------------------------------------- | |
2290 | 51 void ShowMM7IntroVideo_and_LoadingScreen() |
0 | 52 { |
53 RGBTexture tex; // [sp+Ch] [bp-30h]@1 | |
2290 | 54 unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8 |
55 unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8 | |
0 | 56 |
57 pVideoPlayer->bStopBeforeSchedule = false; | |
165 | 58 pVideoPlayer->pResetflag = 0; |
2290 | 59 bGameoverLoop = true; |
256 | 60 if (!bNoVideo) |
0 | 61 { |
62 pRenderer->PresentBlackScreen(); | |
63 if ( !pVideoPlayer->bStopBeforeSchedule ) | |
2290 | 64 PlayFullscreenMovie(MOVIE_Intro, true); |
0 | 65 } |
2334 | 66 // char pContainerName[64]; |
2278 | 67 |
2290 | 68 tex.Load("mm6title.pcx", 2); |
0 | 69 pRenderer->BeginScene(); |
70 pRenderer->DrawTextureRGB(0, 0, &tex); | |
71 free(tex.pPixels); | |
72 tex.pPixels = 0; | |
762 | 73 |
2290 | 74 //LoadFonts_and_DrawCopyrightWindow(); |
75 DrawMM7CopyrightWindow(); | |
762 | 76 |
0 | 77 pRenderer->EndScene(); |
78 pRenderer->Present(); | |
1004 | 79 |
80 #ifndef _DEBUG | |
81 Sleep(1500); // let the copyright window stay for a while | |
82 #endif | |
83 | |
2290 | 84 if (!bNoSound && pAudioPlayer->hAILRedbook ) |
0 | 85 { |
86 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); | |
87 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
2218 | 88 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS); |
0 | 89 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); |
2290 | 90 } |
91 bGameoverLoop = false; | |
0 | 92 } |
93 | |
94 //----- (004BE70E) -------------------------------------------------------- | |
1802 | 95 void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) |
0 | 96 { |
97 int v4; // ebp@1 | |
98 MSG Msg; // [sp+Ch] [bp-1Ch]@12 | |
2218 | 99 |
0 | 100 v4 = a2; |
2061 | 101 if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) ) |
0 | 102 { |
103 if ( a2 == 2 ) | |
104 v4 = 0; | |
2347 | 105 ShowCursor(0);//Убрать курсор |
106 OpenGlobalMovie(pMovieName, 0, ScreenSizeFlag); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
107 bPlayingMovie = 1; |
2218 | 108 field_44 = v4; |
2347 | 109 pRenderer->ClearTarget(0); |
151 | 110 pCurrentScreen = SCREEN_VIDEO; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
111 |
2218 | 112 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
113 RECT rc_client; | |
114 GetClientRect(hwnd, &rc_client); | |
115 int client_width = rc_client.right - rc_client.left, | |
116 client_height = rc_client.bottom - rc_client.top; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
117 |
2218 | 118 HDC dc = GetDC(hwnd); |
119 HDC back_dc = CreateCompatibleDC(dc); | |
120 HBITMAP back_bmp; | |
121 SelectObject(back_dc, back_bmp = CreateCompatibleBitmap(dc, client_width, client_height)); | |
2347 | 122 |
123 DWORD t = GetTickCount();//текущее время от запуска ОС | |
124 | |
125 end_current_file = false;//установить флаг конца видеоролика | |
126 | |
127 while (true) //Цикл воспроизведения видеоролика | |
2218 | 128 { |
129 if ( pVideoPlayer->bStopBeforeSchedule ) | |
130 break; | |
131 while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE)) | |
132 { | |
133 if (Msg.message == 18) | |
134 Game_DeinitializeAndTerminate(0); | |
135 if (Msg.message == 15) | |
136 break; | |
137 TranslateMessage(&Msg); | |
138 DispatchMessageA(&Msg); | |
139 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
140 |
2347 | 141 double dt = (GetTickCount() - t) / 1000.0; //изменение времени |
2345 | 142 //dt = 1.0/15.0; |
143 t = GetTickCount(); | |
144 | |
145 //log("dt=%.5f\n", dt); | |
146 | |
147 auto image = new char[client_width * client_height * 4]; | |
148 | |
2347 | 149 pMovie->GetNextFrame(dt, image); //получить следующий кадр |
150 | |
151 if (end_current_file)//достигнут ли конец видео? | |
2218 | 152 break; |
2347 | 153 |
2218 | 154 if (image) |
155 { | |
156 // draw to hwnd | |
157 BITMAPINFO bmi; | |
158 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
159 bmi.bmiHeader.biWidth = client_width; | |
160 bmi.bmiHeader.biHeight = -client_height; | |
161 bmi.bmiHeader.biPlanes = 1; | |
162 bmi.bmiHeader.biBitCount = 32; | |
163 bmi.bmiHeader.biCompression = BI_RGB; | |
164 bmi.bmiHeader.biSizeImage = 0; | |
165 bmi.bmiHeader.biXPelsPerMeter = 0; | |
166 bmi.bmiHeader.biYPelsPerMeter = 0; | |
167 bmi.bmiHeader.biClrUsed = 0; | |
168 bmi.bmiHeader.biClrImportant = 0; | |
169 GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS); | |
170 SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS); | |
171 BitBlt(dc, 0, 0, client_width, client_height, back_dc, 0, 0, SRCCOPY); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
172 |
2347 | 173 delete[] image;//удалить кадр |
2218 | 174 } |
2347 | 175 |
176 GUI_MainMenuMessageProc(); //после отрисовки, т.к. иначе вылетает dt = 0.03, image - ??? | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
177 |
2347 | 178 if (pVideoPlayer->bStopBeforeSchedule == 1)//остановка видео |
179 Sleep(1000); //пауза после видеоролика | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
180 } |
2347 | 181 |
182 pVideoPlayer->Unload(); | |
183 | |
227 | 184 if (a4 == 1) |
151 | 185 pCurrentScreen = SCREEN_GAME; |
2347 | 186 |
0 | 187 pVideoPlayer->bPlayingMovie = 0; |
2347 | 188 |
189 ShowCursor(1);//вернуть курсор | |
190 | |
151 | 191 if ( pCurrentScreen == SCREEN_VIDEO ) |
192 pCurrentScreen = SCREEN_GAME; | |
0 | 193 } |
194 } | |
195 | |
196 //----- (004BE9D8) -------------------------------------------------------- | |
1802 | 197 void VideoPlayer::Initialize(OSWindow *target_window) |
0 | 198 { |
199 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9 | |
200 | |
1802 | 201 window = target_window; |
202 | |
0 | 203 uint uBinkVersionMajor = -1, |
204 uBinkVersionMinor = -1; | |
205 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor); | |
206 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor; | |
207 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
208 strcpy(pTmpBuf.data(), "anims\\might7.vid"); |
2218 | 209 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 210 if ( hMightVid == INVALID_HANDLE_VALUE ) |
211 { | |
1217 | 212 sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data()); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
213 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 214 return; |
215 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
216 strcpy(pTmpBuf.data(), "anims\\magic7.vid"); |
2218 | 217 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 218 if ( hMagicVid == INVALID_HANDLE_VALUE ) |
219 { | |
220 if ( !bCanLoadFromCD ) | |
2218 | 221 { |
1217 | 222 sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data()); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
223 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 224 return; |
2218 | 225 } |
1217 | 226 sprintf(pTmpBuf2.data(), "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf.data()); |
2218 | 227 hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 228 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE ) |
229 { | |
2218 | 230 sprintf(pTmpBuf2.data(), "Can't open file - %s", pTmpBuf.data()); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
231 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 232 return; |
233 } | |
234 } | |
235 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0); | |
236 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); | |
237 pMagicVideoHeaders = 0; | |
238 pMightVideoHeaders = 0; | |
1583 | 239 pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2); |
240 pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2); | |
0 | 241 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); |
242 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0); | |
243 } | |
244 | |
245 //----- (004BEBD7) -------------------------------------------------------- | |
246 void VideoPlayer::Unload() | |
247 { | |
1802 | 248 //_BINK *pBinkMovie; // eax@1 |
249 //_BINKBUF *pBinkBuffer; // eax@3 | |
250 //_SMACK *pSmackerMovie; // eax@5 | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
251 /* |
0 | 252 if ( pBinkMovie ) |
253 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
254 //BinkPause(pBinkMovie, 1); |
0 | 255 Sleep(300); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
256 //BinkClose(pBinkMovie); |
1802 | 257 pBinkMovie = 0; |
0 | 258 } |
1802 | 259 |
0 | 260 if ( pBinkBuffer ) |
261 { | |
262 pBinkBuffer->pTargetDDrawSurface->Release(); | |
1802 | 263 pBinkBuffer->pTargetDDrawSurface = 0; |
264 free(pBinkBuffer); | |
265 pBinkBuffer = 0; | |
0 | 266 } |
1802 | 267 |
0 | 268 if ( pSmackerMovie ) |
269 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
270 //SmackSoundOnOff(pSmackerMovie, 0); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
271 //SmackClose(pSmackerMovie); |
1802 | 272 pSmackerMovie = 0; |
0 | 273 } |
1802 | 274 if ( pSmackerBuffer ) |
0 | 275 { |
1802 | 276 SmackBufferClose(pSmackerBuffer); |
277 pSmackerBuffer = 0; | |
0 | 278 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
279 */ |
1802 | 280 if ( pSmackMovieBlit ) |
0 | 281 { |
1802 | 282 SmackBlitClose(pSmackMovieBlit); |
283 pSmackMovieBlit = 0; | |
0 | 284 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
285 bBufferLoaded = 0; |
1802 | 286 uMovieFormat = 0; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
287 uMovieFormatSwapped = 0; |
1802 | 288 memset(pCurrentMovieName, 0, 0x40); |
0 | 289 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) |
290 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | |
291 pEventTimer->Resume(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
292 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
293 if (pMovie) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
294 { |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
295 delete pMovie; |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
296 pMovie = nullptr; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
297 } |
0 | 298 } |
299 | |
1802 | 300 void VideoPlayer::_inlined_in_463149() |
301 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
302 if (pMovie) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
303 { |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
304 pRenderer->BeginScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
305 pMouse->DrawCursorToTarget(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
306 UpdatePalette(); |
2216 | 307 pMouse->ReadCursorWithItem(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
308 pRenderer->EndScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
309 } |
1802 | 310 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
311 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
312 void VideoPlayer::UpdatePalette() |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
313 { |
2218 | 314 Log::Warning(L"smacker"); |
2345 | 315 loop_current_file = true; |
2218 | 316 pRenderer->BeginScene(); |
2345 | 317 /*if (pMovie->Stopped())//видео завершено/перезагрузка |
2218 | 318 { |
2222 | 319 int width = game_viewport_width; |
320 int height = game_viewport_height; | |
2218 | 321 delete pMovie; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
322 |
2218 | 323 SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN); |
0 | 324 |
2345 | 325 //pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height); |
2218 | 326 } |
2345 | 327 else */ |
2218 | 328 { |
2345 | 329 double dt = (GetTickCount() - time_video_begin) / 1000.0; |
330 //dt = 1.0/15.0; | |
331 time_video_begin = GetTickCount(); | |
332 | |
333 //log("dt=%.5f\n", dt); | |
334 | |
335 auto image = new char[current_movie_width * current_movie_height * 4]; | |
336 | |
337 pMovie->GetNextFrame(dt, image); | |
338 Sleep(70); //Ritor1:it's my include | |
339 | |
2222 | 340 int image_array[460 * 344];//game_viewport_width * game_viewport_height |
2218 | 341 if (image) |
342 { | |
2222 | 343 memcpy(image_array, image, sizeof (image_array)); |
2223 | 344 for (unsigned int y = 8; y < 8 + game_viewport_height; ++y)//координаты местоположения видеоролика |
2221 | 345 { |
346 for (unsigned int x = 8; x < 8 + game_viewport_width; ++x) | |
347 { | |
2222 | 348 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + x + y * pRenderer->uTargetSurfacePitch; |
349 *p = image_array[((x - 8) + ((y - 8)*game_viewport_width))]; | |
2221 | 350 } |
351 } | |
2218 | 352 delete[] image; |
353 } | |
354 } | |
355 pRenderer->EndScene(); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
356 } |
0 | 357 |
358 //----- (004BF28F) -------------------------------------------------------- | |
898 | 359 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
0 | 360 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
361 if (!this->bBufferLoaded) |
0 | 362 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
363 //Prepare(); |
2218 | 364 pEventTimer->Pause(); |
365 if (pAudioPlayer->hAILRedbook) | |
366 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
367 |
2218 | 368 bStopBeforeSchedule = false; |
369 bBufferLoaded = 1; | |
370 bPlayingMovie = false; | |
371 bFirstFrame = false; | |
372 bUsingSmackerMMX = SmackUseMMX(1); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
373 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
374 this->bLoopPlaying = a3_1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
375 if ( LOBYTE(this->field_104) == 1 ) |
0 | 376 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
377 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
0 | 378 return; |
379 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
380 |
2218 | 381 LoadMovie(pMovieName); |
2345 | 382 time_video_begin = GetTickCount(); |
0 | 383 } |
384 } | |
385 | |
386 //----- (004BF3F9) -------------------------------------------------------- | |
387 bool VideoPlayer::AnyMovieLoaded() | |
388 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
389 return pMovie;// pSmackerMovie || pBinkMovie; |
0 | 390 } |
391 | |
392 //----- (004BF411) -------------------------------------------------------- | |
898 | 393 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
0 | 394 { |
2334 | 395 // unsigned int v10; // eax@11 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
396 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
397 if (!this->bBufferLoaded) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
398 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
399 pEventTimer->Pause(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
400 if (pAudioPlayer->hAILRedbook) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
401 AIL_redbook_pause(pAudioPlayer->hAILRedbook); |
0 | 402 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
403 bStopBeforeSchedule = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
404 bBufferLoaded = 1; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
405 bPlayingMovie = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
406 bFirstFrame = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
407 bUsingSmackerMMX = SmackUseMMX(1); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
408 this->bLoopPlaying = bLoop; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
409 LoadMovie(pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
410 return; |
0 | 411 } |
412 } | |
413 | |
2347 | 414 //----- (004BF5B2) -------------------------------------------------------- |
0 | 415 void VideoPlayer::_4BF5B2() |
416 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
417 //__debugbreak(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
418 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
419 /*if ( this->uMovieFormat == 2 ) |
0 | 420 { |
421 BinkGoto(pBinkMovie, 1, 0); | |
422 BinkDoFrame(pBinkMovie); | |
423 BinkNextFrame(pBinkMovie); | |
424 } | |
425 else | |
426 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
427 if ( this->uMovieFormat != 1 ) |
0 | 428 return; |
429 SmackGoto(pSmackerMovie, 1); | |
430 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
431 { | |
432 SmackDoFrame(pSmackerMovie); | |
433 SmackNextFrame(pSmackerMovie); | |
434 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
435 }*/ |
0 | 436 pMouse->_469E24(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
437 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pMovie)//!this->pSmackerMovie ) |
0 | 438 { |
2218 | 439 bGameoverLoop = true; |
1919 | 440 HouseDialogPressCloseBtn(); |
336 | 441 window_SpeakInHouse->Release(); |
2218 | 442 pParty->uFlags &= 0xFFFFFFFD; |
481 | 443 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) |
0 | 444 { |
388 | 445 pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2154
diff
changeset
|
446 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); |
2218 | 447 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, 0x31, "", 0); |
448 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, 0x32, "", 0); | |
449 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, 0x33, "", 0); | |
450 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, 0x34, "", 0); | |
0 | 451 } |
452 bGameoverLoop = 0; | |
453 } | |
454 } | |
455 | |
456 //----- (004BF73A) -------------------------------------------------------- | |
898 | 457 void VideoPlayer::SelectMovieType() |
0 | 458 { |
459 char Source[32]; // [sp+Ch] [bp-40h]@1 | |
460 | |
461 strcpy(Source, this->pCurrentMovieName); | |
462 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
463 if ( this->uMovieFormatSwapped == 1 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
464 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
465 else if ( this->uMovieFormatSwapped == 2 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
466 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
0 | 467 else |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
468 __debugbreak(); |
0 | 469 } |
470 | |
471 //----- (004BF8F6) -------------------------------------------------------- | |
472 void VideoPlayer::PlayDeathMovie() | |
473 { | |
474 bStopBeforeSchedule = 0; | |
165 | 475 pResetflag = 0; |
1397 | 476 PlayFullscreenMovie(MOVIE_Death, true); |
477 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); | |
1262 | 478 } |
479 | |
480 //----- (004BE6F5) -------------------------------------------------------- | |
481 VideoPlayer::VideoPlayer() : | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
482 bBufferLoaded(0), |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
483 //pBinkMovie(nullptr), pBinkBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
484 //pSmackerMovie(nullptr), pSmackerBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
485 pSmackMovieBlit(nullptr) |
1262 | 486 { |
487 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); | |
488 bStopBeforeSchedule = false; | |
489 pResetflag = 0; | |
2345 | 490 //pPlayer = new MultimediaPlayer(); |
491 //pPlayer->Initialize(); | |
492 pPlayer = new Media::Player;//создаётся плеер | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
493 pMovie = nullptr; |
1262 | 494 //pBinkMovie = nullptr; |
495 } | |
2134 | 496 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
497 int VideoPlayer::readFunction(void* opaque, uint8_t* buf, int buf_size) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
498 { |
2218 | 499 HANDLE stream = (HANDLE)opaque; |
500 //int numBytes = stream->read((char*)buf, buf_size); | |
501 int numBytes; | |
502 ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL); | |
503 return numBytes; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
504 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
505 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
506 int64_t VideoPlayer::seekFunction(void* opaque, int64_t offset, int whence) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
507 { |
2218 | 508 if (whence == AVSEEK_SIZE) |
509 return pVideoPlayer->uSize; | |
510 HANDLE h = (HANDLE)opaque; | |
511 LARGE_INTEGER li; | |
512 li.QuadPart = offset; | |
513 | |
514 if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN)) | |
515 return -1; | |
516 return li.QuadPart; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
517 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
518 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
519 void VideoPlayer::LoadMovie(const char * pFilename) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
520 { |
2218 | 521 char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2 |
522 char pVideoNameSmk[120]; // [sp+Ch] [bp-28h]@2 | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
523 |
2218 | 524 sprintf(pVideoNameBik, "%s.bik", pFilename); |
525 sprintf(pVideoNameSmk, "%s.smk", pFilename); | |
526 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
527 { | |
528 //no BIK in MightVid | |
529 /* | |
530 if (!_stricmp(pVideoNameBik, pMightVideoHeaders[i].pVideoName)) | |
531 { | |
532 hVidFile = hMightVid; | |
533 uOffset = pMightVideoHeaders[i].uFileOffset; | |
534 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
535 this->uMovieFormat = 2; | |
536 this->uMovieFormatSwapped = 1; | |
537 } | |
538 */ | |
539 if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName)) | |
540 { | |
541 hVidFile = hMightVid; | |
542 uOffset = pMightVideoHeaders[i].uFileOffset; | |
543 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
544 this->uMovieFormat = 1; | |
545 this->uMovieFormatSwapped = 2; | |
546 } | |
547 } | |
548 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
549 { | |
550 if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName)) | |
551 { | |
552 hVidFile = hMagicVid; | |
553 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
554 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
555 this->uMovieFormat = 2; | |
556 this->uMovieFormatSwapped = 1; | |
557 } | |
558 if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName)) | |
559 { | |
560 hVidFile = hMagicVid; | |
561 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
562 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
563 this->uMovieFormat = 1; | |
564 this->uMovieFormatSwapped = 2; | |
565 } | |
566 } | |
567 if (!hVidFile) | |
568 { | |
569 Unload(); | |
570 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0); | |
571 return; | |
572 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
573 |
2218 | 574 SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN); |
575 strcpy(this->pCurrentMovieName, pFilename); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
576 |
2218 | 577 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
578 RECT rc_client; | |
579 GetClientRect(hwnd, &rc_client); | |
580 int client_width = rc_client.right - rc_client.left, | |
581 client_height = rc_client.bottom - rc_client.top; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
582 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
583 |
2218 | 584 pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, client_width, client_height); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
585 |
2345 | 586 } |
587 void VideoPlayer::PlayAudio(const wchar_t * pFilename) | |
588 { | |
589 Media::ITrack *track = pPlayer->LoadTrack(pFilename); | |
590 track->Play(); | |
591 } | |
592 void VideoPlayer::PlayMovie(const wchar_t * pFilename) | |
593 { | |
594 Media::IMovie *track = pPlayer->LoadMovie(pFilename, 640, 480, 0); | |
595 track->Play(); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
596 } |