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