Mercurial > mm7
annotate VideoPlayer.cpp @ 2244:66c509997062
TE monster attack
author | Ritor1 |
---|---|
date | Mon, 24 Feb 2014 16:54:21 +0600 |
parents | 17bc3a1eb037 |
children | aff7a7b072b7 |
rev | line source |
---|---|
0 | 1 |
2 #include "Bink_Smacker.h" | |
3 | |
1262 | 4 #include "mm7_data.h" |
1016 | 5 #include "CShow.h" |
6 #include "Mouse.h" | |
7 | |
0 | 8 #include "VideoPlayer.h" |
9 #include "AudioPlayer.h" | |
10 #include "Game.h" | |
11 #include "Render.h" | |
12 #include "Party.h" | |
13 #include "GUIWindow.h" | |
2044 | 14 #include "Timer.h" |
0 | 15 #include "Log.h" |
1253 | 16 #include "texts.h" |
1299 | 17 #include "UI\UIHouses.h" |
0 | 18 |
19 | |
20 VideoPlayer *pVideoPlayer = nullptr; | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 #pragma comment(lib, "Version.lib") | |
29 bool GetDllVersion(const wchar_t *pDllName, uint *pMajor, uint *pMinor) | |
30 { | |
31 uint uVersionSize = GetFileVersionInfoSizeW(pDllName, nullptr); | |
32 void *pVersionData = HeapAlloc(GetProcessHeap(), 0, uVersionSize); | |
33 { | |
34 GetFileVersionInfoW(pDllName, 0, uVersionSize, pVersionData); | |
35 | |
36 VS_FIXEDFILEINFO *pInfo = nullptr; | |
37 UINT uInfoSize = 0; | |
38 VerQueryValueW(pVersionData, L"\\", (void **)&pInfo, &uInfoSize); | |
39 | |
40 if (!pMajor || !pMinor) | |
41 { | |
42 HeapFree(GetProcessHeap(), 0, pVersionData); | |
43 return false; | |
44 } | |
45 *pMajor = pInfo->dwFileVersionMS; | |
46 *pMinor = pInfo->dwFileVersionLS; | |
47 } | |
48 HeapFree(GetProcessHeap(), 0, pVersionData); | |
49 return true; | |
50 } | |
51 | |
52 | |
53 // 3.15.1.0: | |
54 // 3 15 1 0 | |
55 // 0x0003000F00010000 | |
56 unsigned __int64 uBinkVersion; | |
57 | |
58 | |
59 | |
60 | |
61 | |
1459 | 62 bool BinkLockBuffer(struct _BINKBUF *_this); |
63 void BinkUnlockBuffer(struct _BINKBUF *_this); | |
0 | 64 |
65 //----- (004BFE2D) -------------------------------------------------------- | |
1802 | 66 _BINKBUF *VideoPlayer::CreateBinkBuffer(unsigned int uWidth, unsigned int uHeight, char a4) |
0 | 67 { |
68 _BINKBUF *v5; // esi@3 | |
69 HRESULT v6; // eax@5 | |
70 IDirectDrawSurface *v7; // eax@6 | |
71 HRESULT v8; // eax@9 | |
72 DDSURFACEDESC2 v11; // [sp+Ch] [bp-108h]@7 | |
73 DDSURFACEDESC Dst; // [sp+88h] [bp-8Ch]@3 | |
74 IDirectDrawSurface4 *v15; // [sp+108h] [bp-Ch]@7 | |
75 IDirectDrawSurface2 *a2; // [sp+10Ch] [bp-8h]@3 | |
76 | |
2152 | 77 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
78 //pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
0 | 79 { |
80 v15 = 0; | |
81 | |
82 if (uBinkVersion == 0x0001000500150000) | |
83 { | |
84 v5 = new _BINKBUF_1_5_21_0; | |
85 memset(v5, 0, sizeof(_BINKBUF_1_5_21_0)); | |
86 } | |
87 else if (uBinkVersion == 0x0003000000000000) | |
88 { | |
89 v5 = new _BINKBUF_3_0_0_0; | |
90 memset(v5, 0, sizeof(_BINKBUF_3_0_0_0)); | |
91 } | |
1802 | 92 else __debugbreak(); |
0 | 93 |
2218 | 94 memset(&v11, 0, 0x7C); |
0 | 95 v11.dwSize = 124; |
2218 | 96 v11.dwWidth = uWidth; |
97 v11.dwFlags = 0x1007; // DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | |
98 v11.ddsCaps.dwCaps = 0x4040; // DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | |
0 | 99 v11.dwHeight = uHeight; |
100 *(_QWORD *)&v11.ddpfPixelFormat.dwSize = 0x400000020ui64;// DDPF_FOURCC | |
2218 | 101 v11.ddpfPixelFormat.dwFourCC = 0x32595559; |
2151 | 102 if (FAILED(pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0))) |
0 | 103 { |
104 memset(&v11.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT)); | |
105 | |
106 v11.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
107 v11.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; | |
108 | |
1980 | 109 long hr = pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0); |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
110 ErrD3D(hr); |
0 | 111 } |
112 v5->uWidth = v11.dwWidth; | |
113 v5->uHeight = v11.dwHeight; | |
114 v5->uBinkDDSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)v15); | |
115 v5->field_38 = 0; | |
116 v7 = (IDirectDrawSurface *)v15; | |
117 } | |
2152 | 118 /*else |
0 | 119 { |
120 v4 = 0; | |
121 a2 = 0; | |
122 | |
123 | |
124 if (uBinkVersion == 0x0001000500150000) | |
125 { | |
126 v5 = new _BINKBUF_1_5_21_0; | |
127 memset(v5, 0, sizeof(_BINKBUF_1_5_21_0)); | |
128 } | |
129 else if (uBinkVersion == 0x0003000000000000) | |
130 { | |
131 v5 = new _BINKBUF_3_0_0_0; | |
132 memset(v5, 0, sizeof(_BINKBUF_3_0_0_0)); | |
133 } | |
1802 | 134 else __debugbreak(); |
0 | 135 |
136 memset(&Dst, 0, 0x6Cu); | |
137 Dst.dwSize = 108; | |
2218 | 138 Dst.dwWidth = uWidth; |
0 | 139 Dst.dwFlags = 4103; |
140 Dst.ddsCaps.dwCaps = 16448; | |
141 Dst.dwHeight = uHeight; | |
142 Dst.ddpfPixelFormat.dwSize = 32; | |
143 Dst.ddpfPixelFormat.dwFlags = 4; | |
144 Dst.ddpfPixelFormat.dwFourCC = 844715353; | |
2151 | 145 if (FAILED(pRenderer->pDirectDraw2->CreateSurface(&Dst, (LPDIRECTDRAWSURFACE *)&a2, 0))) |
0 | 146 { |
147 memset(&Dst.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT)); | |
148 | |
149 Dst.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
150 Dst.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; | |
151 | |
1980 | 152 long hr = pRenderer->pDirectDraw2->CreateSurface(&Dst, (LPDIRECTDRAWSURFACE *)&a2, 0); |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
153 ErrD3D(hr); |
0 | 154 } |
155 v5->uWidth = Dst.dwWidth; | |
156 v5->uHeight = Dst.dwHeight; | |
157 v5->uBinkDDSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)a2); | |
158 v5->field_38 = 0; | |
159 v7 = (IDirectDrawSurface *)a2; | |
2152 | 160 }*/ |
0 | 161 v5->pTargetDDrawSurface = v7; |
1802 | 162 v5->hWnd = window->GetApiHandle(); |
2218 | 163 v5->field_4C = 0; |
164 v5->field_68 = 0; | |
165 v5->field_5C = 0; | |
166 v5->field_74 = a4 & 0x1F; | |
0 | 167 v5->field_78 = 1; |
1802 | 168 v5->target_width = GetSystemMetrics(SM_CXSCREEN); |
169 v5->target_height = GetSystemMetrics(SM_CYSCREEN); | |
0 | 170 v5->field_2C = 16; |
1802 | 171 |
172 RECT Rect; | |
173 GetWindowRect(window->GetApiHandle(), &Rect); | |
174 v5->field_8 = window->GetWidth(); | |
175 v5->field_C = window->GetHeight(); | |
0 | 176 v5->field_1C = Rect.left; |
177 v5->field_20 = Rect.top; | |
2218 | 178 Rect.left = 0; |
179 Rect.top = 0; | |
1802 | 180 ClientToScreen(window->GetApiHandle(), (POINT *)&Rect); |
0 | 181 v5->field_1C = Rect.left - v5->field_1C; |
182 v5->field_20 = Rect.top - v5->field_20; | |
1802 | 183 GetClientRect(window->GetApiHandle(), &Rect); |
0 | 184 v5->field_30 = v5->field_8 - Rect.right; |
185 v5->field_34 = v5->field_C - Rect.bottom; | |
186 v5->field_8 = v5->uWidth + v5->field_30; | |
187 v5->field_C = v5->uHeight + v5->field_34; | |
2218 | 188 BinkBufferSetOffset(v5, 0, 0); |
0 | 189 BinkBufferSetScale(v5, v5->uWidth, v5->uHeight); |
190 return v5; | |
191 } | |
192 | |
193 | |
194 //----- (004C0133) -------------------------------------------------------- | |
195 bool BinkLockBuffer(_BINKBUF *_this) | |
196 { | |
197 IDirectDrawSurface *v2; // edi@5 | |
198 IDirectDrawSurface4 *v6; // edi@11 | |
199 | |
2152 | 200 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) |
0 | 201 { |
2132 | 202 DDSURFACEDESC2 v8; // [sp+Ch] [bp-7Ch]@4 |
0 | 203 if ( _this->pTargetDDrawSurface ) |
204 { | |
2132 | 205 memset(&v8, 0, 0x7C); |
0 | 206 v8.dwSize = 124; |
207 while ( 1 ) | |
208 { | |
2132 | 209 v6 = (IDirectDrawSurface4 *)_this->pTargetDDrawSurface; |
210 if ( !v6->Lock(0, &v8, 1, 0) ) | |
0 | 211 break; |
212 | |
213 if (uBinkVersion < 0x0003000000000000) | |
2218 | 214 _this->uBinkDDSurfaceType |= 0x80000000; |
0 | 215 else |
2218 | 216 _this->uBinkDDSurfaceType |= 0x4000000; |
0 | 217 |
218 if ( v6->Restore() ) | |
219 return 0; | |
220 } | |
2132 | 221 _this->pDDrawSurfaceData_ = v8.lpSurface; |
222 _this->pDDrawSurfaceData = v8.lpSurface; | |
223 _this->uDDrawSurfacePitch = v8.lPitch; | |
224 return 1; | |
0 | 225 } |
226 } | |
2152 | 227 /*else |
0 | 228 { |
2132 | 229 DDSURFACEDESC v8; // [sp+Ch] [bp-7Ch]@4 |
0 | 230 if ( _this->pTargetDDrawSurface ) |
231 { | |
232 memset(&v8.lPitch, 0, 0x6Cu); | |
233 v8.lPitch = 108; | |
234 while ( 1 ) | |
235 { | |
2132 | 236 v2 = _this->pTargetDDrawSurface; |
237 if ( !v2->Lock(0, (LPDDSURFACEDESC)&v8.lPitch, 1, 0) ) | |
0 | 238 break; |
239 | |
240 if (uBinkVersion < 0x0003000000000000) | |
241 __asm int 3; | |
242 else | |
2132 | 243 BYTE3(_this->uBinkDDSurfaceType) |= 4u; |
0 | 244 |
245 if ( v2->Restore() ) | |
246 return 0; | |
247 } | |
2132 | 248 _this->pDDrawSurfaceData_ = v8.lpSurface; |
249 _this->pDDrawSurfaceData = v8.lpSurface; | |
250 _this->uDDrawSurfacePitch = v8.dwReserved; | |
0 | 251 return 1; |
252 } | |
2152 | 253 }*/ |
0 | 254 return 1; |
255 } | |
256 | |
257 //----- (004C01FB) -------------------------------------------------------- | |
258 void BinkUnlockBuffer(_BINKBUF *_this) | |
259 { | |
260 IDirectDrawSurface *v2; // eax@1 | |
261 | |
262 v2 = _this->pTargetDDrawSurface; | |
263 if ( v2 ) | |
264 { | |
265 v2->Unlock(0); | |
2218 | 266 _this->uDDrawSurfacePitch = 0; |
267 _this->pDDrawSurfaceData = 0; | |
0 | 268 |
269 if (uBinkVersion < 0x0003000000000000) | |
270 BYTE3(_this->uBinkDDSurfaceType) &= 0x7F; | |
271 else | |
272 BYTE3(_this->uBinkDDSurfaceType) &= 0xFB; | |
273 } | |
274 } | |
275 //----- (004BF794) -------------------------------------------------------- | |
1458 | 276 void ShowIntroVideo_and_LoadingScreen() |
0 | 277 { |
278 RGBTexture tex; // [sp+Ch] [bp-30h]@1 | |
279 unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8 | |
280 unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8 | |
281 | |
282 pVideoPlayer->bStopBeforeSchedule = false; | |
165 | 283 pVideoPlayer->pResetflag = 0; |
0 | 284 bGameoverLoop = 1; |
256 | 285 if (!bNoVideo) |
0 | 286 { |
287 pRenderer->PresentBlackScreen(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
288 PlayFullscreenMovie(MOVIE_3DOLogo, true); |
1397 | 289 //pGame->pCShow->PlayMovie(MOVIE_3DOLogo, 1); |
0 | 290 if ( !pVideoPlayer->bStopBeforeSchedule ) |
291 { | |
1397 | 292 PlayFullscreenMovie(MOVIE_NWCLogo, true); |
293 //pGame->pCShow->PlayMovie(MOVIE_NWCLogo, 1); | |
0 | 294 if ( !pVideoPlayer->bStopBeforeSchedule ) |
295 { | |
1397 | 296 PlayFullscreenMovie(MOVIE_JVC, true); |
297 //pGame->pCShow->PlayMovie(MOVIE_JVC, 1); | |
0 | 298 if ( !pVideoPlayer->bStopBeforeSchedule ) |
1397 | 299 PlayFullscreenMovie(MOVIE_Intro, true); |
300 //pGame->pCShow->PlayMovie(MOVIE_Intro, 1); | |
0 | 301 } |
302 } | |
303 } | |
304 tex.Load("mm6title.pcx", 2); | |
305 pRenderer->BeginScene(); | |
306 pRenderer->DrawTextureRGB(0, 0, &tex); | |
307 free(tex.pPixels); | |
308 tex.pPixels = 0; | |
762 | 309 |
310 LoadFonts_and_DrawCopyrightWindow(); | |
311 | |
0 | 312 pRenderer->EndScene(); |
313 pRenderer->Present(); | |
1004 | 314 |
315 #ifndef _DEBUG | |
316 Sleep(1500); // let the copyright window stay for a while | |
317 #endif | |
318 | |
0 | 319 if (!bNoSound && pAudioPlayer->hAILRedbook ) |
320 { | |
321 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); | |
322 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
2218 | 323 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS); |
0 | 324 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); |
325 } | |
326 bGameoverLoop = 0; | |
327 } | |
328 | |
329 //----- (004BE70E) -------------------------------------------------------- | |
1802 | 330 void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) |
0 | 331 { |
332 int v4; // ebp@1 | |
333 const char *pName; // edi@1 | |
334 MSG Msg; // [sp+Ch] [bp-1Ch]@12 | |
2218 | 335 |
0 | 336 v4 = a2; |
337 pName = pMovieName; | |
2061 | 338 if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) ) |
0 | 339 { |
340 if ( a2 == 2 ) | |
341 v4 = 0; | |
342 ShowCursor(0); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
343 OpenGlobalMovie(pName, 0, ScreenSizeFlag); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
344 bPlayingMovie = 1; |
2218 | 345 field_44 = v4; |
2154 | 346 //if ( pRenderer->pRenderD3D ) |
0 | 347 { |
348 pRenderer->ClearTarget(0); | |
349 } | |
2154 | 350 /* else |
0 | 351 { |
352 pRenderer->BeginScene(); | |
353 pRenderer->ClearTarget(0); | |
354 pRenderer->EndScene(); | |
2154 | 355 }*/ |
151 | 356 pCurrentScreen = SCREEN_VIDEO; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
357 |
2218 | 358 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
359 RECT rc_client; | |
360 GetClientRect(hwnd, &rc_client); | |
361 int client_width = rc_client.right - rc_client.left, | |
362 client_height = rc_client.bottom - rc_client.top; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
363 |
2218 | 364 HDC dc = GetDC(hwnd); |
365 HDC back_dc = CreateCompatibleDC(dc); | |
366 HBITMAP back_bmp; | |
367 SelectObject(back_dc, back_bmp = CreateCompatibleBitmap(dc, client_width, client_height)); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
368 |
2218 | 369 while (true) |
370 { | |
371 if ( pVideoPlayer->bStopBeforeSchedule ) | |
372 break; | |
373 while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE)) | |
374 { | |
375 if (Msg.message == 18) | |
376 Game_DeinitializeAndTerminate(0); | |
377 if (Msg.message == 15) | |
378 break; | |
379 TranslateMessage(&Msg); | |
380 DispatchMessageA(&Msg); | |
381 } | |
382 GUI_MainMenuMessageProc(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
383 |
2218 | 384 if (pMovie->Stopped()) |
385 break; | |
386 char *image = pPlayer->DoFrame(); | |
387 if (image) | |
388 { | |
389 // draw to hwnd | |
390 BITMAPINFO bmi; | |
391 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
392 bmi.bmiHeader.biWidth = client_width; | |
393 bmi.bmiHeader.biHeight = -client_height; | |
394 bmi.bmiHeader.biPlanes = 1; | |
395 bmi.bmiHeader.biBitCount = 32; | |
396 bmi.bmiHeader.biCompression = BI_RGB; | |
397 bmi.bmiHeader.biSizeImage = 0; | |
398 bmi.bmiHeader.biXPelsPerMeter = 0; | |
399 bmi.bmiHeader.biYPelsPerMeter = 0; | |
400 bmi.bmiHeader.biClrUsed = 0; | |
401 bmi.bmiHeader.biClrImportant = 0; | |
402 GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS); | |
403 SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS); | |
404 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
|
405 |
2218 | 406 delete[] image; |
407 } | |
408 if (pVideoPlayer->bStopBeforeSchedule == 1) | |
409 Sleep(1000); | |
410 } | |
411 pVideoPlayer->Unload(); | |
412 /* | |
0 | 413 if ( pVideoPlayer->uMovieFormat == 2 ) |
414 { | |
415 if ( pVideoPlayer->pBinkMovie ) | |
416 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
417 //pVideoPlayer->BinkDrawFrame(v4, ScreenSizeFlag); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
418 |
0 | 419 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
420 } |
0 | 421 if ( pVideoPlayer->bStopBeforeSchedule == 1 ) |
422 Sleep(0x3E8u); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
423 }*/ |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
424 /* |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
425 if ( pVideoPlayer->uMovieFormat == 1 ) |
0 | 426 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
427 if ( pVideoPlayer->pSmackerMovie ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
428 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
429 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
430 while ( pVideoPlayer->pSmackerMovie ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
431 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
432 if ( pVideoPlayer->bStopBeforeSchedule ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
433 break; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
434 while ( PeekMessageW(&Msg, 0, 0, 0, 1) ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
435 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
436 if (Msg.message == WM_QUIT) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
437 Game_DeinitializeAndTerminate(0); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
438 if (Msg.message == WM_PAINT) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
439 break; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
440 TranslateMessage(&Msg); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
441 DispatchMessageW(&Msg); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
442 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
443 GUI_MainMenuMessageProc(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
444 if ( !pVideoPlayer->pSmackerMovie ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
445 break; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
446 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule ) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
447 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
448 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
449 } |
0 | 450 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
451 */ |
227 | 452 if (a4 == 1) |
151 | 453 pCurrentScreen = SCREEN_GAME; |
0 | 454 pVideoPlayer->bPlayingMovie = 0; |
455 ShowCursor(1); | |
151 | 456 if ( pCurrentScreen == SCREEN_VIDEO ) |
457 pCurrentScreen = SCREEN_GAME; | |
0 | 458 } |
459 } | |
460 | |
461 //----- (004BE95A) -------------------------------------------------------- | |
462 unsigned int VideoPlayer::SmackCheckSurfaceFromat() | |
463 { | |
464 DDPIXELFORMAT a2; // [sp+0h] [bp-20h]@1 | |
465 | |
466 a2.dwSize = 32; | |
467 a2.dwFlags = 64; | |
468 pRenderer->GetTargetPixelFormat(&a2); | |
2070 | 469 if (a2.dwRGBBitCount == 32) |
470 return SMACKBUFFER565; | |
0 | 471 if ( a2.dwRGBBitCount != 8 ) |
472 { | |
473 if ( a2.dwRBitMask == 0xF800 ) | |
474 { | |
475 if ( a2.dwGBitMask == 0x7E0 && a2.dwBBitMask == 0x1F ) | |
1035 | 476 return SMACKBUFFER565; |
0 | 477 } |
478 else | |
479 { | |
480 if ( a2.dwRBitMask == 0x7C00 | |
481 && a2.dwGBitMask == 0x3E0 | |
482 && a2.dwBBitMask == 0x1F ) | |
1035 | 483 return SMACKBUFFER555; |
0 | 484 } |
485 MessageBoxA(0, "Unsupported pixel format.", "Smacker Error", 0); | |
486 } | |
487 return 0; | |
488 } | |
489 | |
490 //----- (004BE9D8) -------------------------------------------------------- | |
1802 | 491 void VideoPlayer::Initialize(OSWindow *target_window) |
0 | 492 { |
493 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9 | |
494 | |
1802 | 495 window = target_window; |
496 | |
0 | 497 uint uBinkVersionMajor = -1, |
498 uBinkVersionMinor = -1; | |
499 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor); | |
500 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor; | |
501 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
502 strcpy(pTmpBuf.data(), "anims\\might7.vid"); |
2218 | 503 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 504 if ( hMightVid == INVALID_HANDLE_VALUE ) |
505 { | |
1217 | 506 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
|
507 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 508 return; |
509 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
510 strcpy(pTmpBuf.data(), "anims\\magic7.vid"); |
2218 | 511 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 512 if ( hMagicVid == INVALID_HANDLE_VALUE ) |
513 { | |
514 if ( !bCanLoadFromCD ) | |
2218 | 515 { |
1217 | 516 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
|
517 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 518 return; |
2218 | 519 } |
1217 | 520 sprintf(pTmpBuf2.data(), "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf.data()); |
2218 | 521 hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 522 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE ) |
523 { | |
2218 | 524 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
|
525 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 526 return; |
527 } | |
528 } | |
529 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0); | |
530 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); | |
531 pMagicVideoHeaders = 0; | |
532 pMightVideoHeaders = 0; | |
1583 | 533 pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2); |
534 pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2); | |
0 | 535 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); |
536 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0); | |
537 } | |
538 | |
539 //----- (004BEB41) -------------------------------------------------------- | |
540 void VideoPlayer::Prepare() | |
541 { | |
542 pEventTimer->Pause(); | |
543 if ( pAudioPlayer->hAILRedbook ) | |
544 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
1802 | 545 |
546 bStopBeforeSchedule = false; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
547 bBufferLoaded = 1; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
548 /* |
1802 | 549 pSmackerMovie = 0; |
550 pSmackerBuffer = 0; | |
551 pBinkMovie = 0; | |
552 pBinkBuffer = 0; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
553 */ |
1802 | 554 bPlayingMovie = false; |
555 bFirstFrame = false; | |
556 bUsingSmackerMMX = SmackUseMMX(1); | |
0 | 557 BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver); |
2152 | 558 uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer4); |
0 | 559 } |
560 | |
561 //----- (004BEBD7) -------------------------------------------------------- | |
562 void VideoPlayer::Unload() | |
563 { | |
1802 | 564 //_BINK *pBinkMovie; // eax@1 |
565 //_BINKBUF *pBinkBuffer; // eax@3 | |
566 //_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
|
567 /* |
0 | 568 if ( pBinkMovie ) |
569 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
570 //BinkPause(pBinkMovie, 1); |
0 | 571 Sleep(300); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
572 //BinkClose(pBinkMovie); |
1802 | 573 pBinkMovie = 0; |
0 | 574 } |
1802 | 575 |
0 | 576 if ( pBinkBuffer ) |
577 { | |
578 pBinkBuffer->pTargetDDrawSurface->Release(); | |
1802 | 579 pBinkBuffer->pTargetDDrawSurface = 0; |
580 free(pBinkBuffer); | |
581 pBinkBuffer = 0; | |
0 | 582 } |
1802 | 583 |
0 | 584 if ( pSmackerMovie ) |
585 { | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
586 //SmackSoundOnOff(pSmackerMovie, 0); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
587 //SmackClose(pSmackerMovie); |
1802 | 588 pSmackerMovie = 0; |
0 | 589 } |
1802 | 590 if ( pSmackerBuffer ) |
0 | 591 { |
1802 | 592 SmackBufferClose(pSmackerBuffer); |
593 pSmackerBuffer = 0; | |
0 | 594 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
595 */ |
1802 | 596 if ( pSmackMovieBlit ) |
0 | 597 { |
1802 | 598 SmackBlitClose(pSmackMovieBlit); |
599 pSmackMovieBlit = 0; | |
0 | 600 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
601 bBufferLoaded = 0; |
1802 | 602 uMovieFormat = 0; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
603 uMovieFormatSwapped = 0; |
1802 | 604 memset(pCurrentMovieName, 0, 0x40); |
0 | 605 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) |
606 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | |
607 pEventTimer->Resume(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
608 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
609 if (pMovie) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
610 { |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
611 delete pMovie; |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
612 pMovie = nullptr; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
613 } |
0 | 614 } |
615 | |
616 //----- (004BECD5) -------------------------------------------------------- | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
617 /* |
0 | 618 void VideoPlayer::FastForwardToFrame(unsigned int uDstFrameNum) |
619 { | |
620 VideoPlayer *v2; // esi@1 | |
621 unsigned int v3; // eax@1 | |
622 | |
623 v2 = this; | |
624 v3 = this->uMovieFormat; | |
625 if ( v3 == 2 ) | |
626 { | |
627 if (uDstFrameNum) | |
628 { | |
629 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : | |
630 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame : | |
631 nullptr; | |
632 while (*pCurrentFrame < uDstFrameNum) | |
633 { | |
634 BinkDoFrame(pBinkMovie); | |
635 BinkNextFrame(pBinkMovie); | |
636 } | |
637 } | |
638 } | |
639 else | |
640 { | |
641 if ( v3 != 1 ) | |
642 return; | |
643 SmackSoundOnOff(this->pSmackerMovie, 0); | |
644 if (uDstFrameNum) | |
645 { | |
646 while ( v2->pSmackerMovie->FrameNum < uDstFrameNum) | |
647 { | |
648 SmackDoFrame(v2->pSmackerMovie); | |
649 SmackNextFrame(v2->pSmackerMovie); | |
650 } | |
651 } | |
652 } | |
653 Unload(); | |
654 } | |
655 | |
656 | |
657 //----- (004BED4F) -------------------------------------------------------- | |
1802 | 658 void VideoPlayer::BinkDrawFrame(int a3, int a4) |
0 | 659 { |
660 //VideoPlayer *v4; // esi@1 | |
661 _BINKBUF *v5; // eax@5 | |
662 LONG v6; // edx@6 | |
663 int v7; // ecx@6 | |
664 LONG v8; // edx@6 | |
665 struct tagRECT a3a; // [sp+8h] [bp-20h]@10 | |
666 struct tagRECT a1; // [sp+18h] [bp-10h]@6 | |
667 | |
668 //v4 = this; | |
669 if ( this->pBinkMovie && this->pBinkBuffer ) | |
670 { | |
671 BinkDoFrame(pBinkMovie); | |
672 BinkGetRects(pBinkMovie, pBinkBuffer->uBinkDDSurfaceType); | |
673 if ( BinkLockBuffer(pBinkBuffer) ) | |
674 { | |
675 BinkCopyToBuffer(pBinkMovie, pBinkBuffer->pDDrawSurfaceData, pBinkBuffer->uDDrawSurfacePitch, pBinkBuffer->uHeight, | |
676 0, 0, pBinkBuffer->uBinkDDSurfaceType); | |
677 BinkUnlockBuffer(pBinkBuffer); | |
678 } | |
679 v5 = pBinkBuffer; | |
680 if ( pRenderer->bWindowMode ) | |
681 { | |
682 v6 = v5->uRectX; | |
683 a1.left = v6; | |
684 a1.top = v5->uRectY; | |
685 v7 = v6 + v5->uWidth; | |
686 a1.right = v6 + v5->uWidth; | |
687 v8 = a1.top + v5->uHeight; | |
688 } | |
689 else | |
690 { | |
691 a1.left = 0; | |
692 a1.top = 0; | |
693 v7 = v5->uWidth; | |
694 a1.right = v5->uWidth; | |
695 v8 = v5->uHeight; | |
696 } | |
697 a1.bottom = v8; | |
698 if ( a4 ) | |
699 { | |
700 a1.right = v5->uWidth + v7; | |
701 a1.bottom = v5->uHeight + v8; | |
702 } | |
703 a3a.left = 0; | |
704 a3a.top = 0; | |
705 a3a.right = v5->uWidth; | |
706 a3a.bottom = v5->uHeight; | |
707 pRenderer->BltToFront(&a1, v5->pTargetDDrawSurface, &a3a, 0x1000000u); | |
708 | |
709 | |
710 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : | |
711 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame: | |
712 nullptr; | |
713 int *pNumFrames = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uNumFrames : | |
714 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uNumFrames : | |
715 nullptr; | |
716 | |
717 if (*pCurrentFrame != *pNumFrames - 1 || bLoopPlaying) | |
718 BinkNextFrame(pBinkMovie); | |
719 else | |
720 Unload(); | |
721 } | |
722 } | |
723 | |
724 | |
725 | |
726 //----- (004BEE6B) -------------------------------------------------------- | |
1802 | 727 void VideoPlayer::SmackDrawFrame(int a3, int a4) |
0 | 728 { |
729 VideoPlayer *v4; // esi@1 | |
730 _SMACK *v5; // eax@3 | |
731 unsigned int v6; // eax@5 | |
732 char v7; // zf@5 | |
733 int v8; // eax@11 | |
734 _SMACK *v9; // eax@13 | |
735 _SMACK *v10; // eax@16 | |
736 _SMACK *v11; // eax@20 | |
737 unsigned int v12; // [sp-1Ch] [bp-34h]@7 | |
738 LONG v13; // [sp-18h] [bp-30h]@7 | |
739 LONG v14; // [sp-14h] [bp-2Ch]@7 | |
740 signed int v15; // [sp-10h] [bp-28h]@7 | |
741 signed int v16; // [sp-Ch] [bp-24h]@7 | |
742 signed int v17; // [sp-8h] [bp-20h]@7 | |
743 struct tagPOINT Point; // [sp+8h] [bp-10h]@7 | |
744 unsigned short *pOutSurface; // [sp+10h] [bp-8h]@5 | |
745 unsigned int uPixelsPerRow; // [sp+14h] [bp-4h]@5 | |
746 | |
747 v4 = this; | |
1802 | 748 if ( !pRenderer->bWindowMode || window->Focused()) |
0 | 749 { |
750 v5 = v4->pSmackerMovie; | |
751 if ( v5->NewPalette ) | |
752 SmackBlitSetPalette(v4->pSmackMovieBlit, v5->Palette, v5->PalType); | |
753 SmackDoFrame(v4->pSmackerMovie); | |
754 pRenderer->LockFrontBuffer((void **)&pOutSurface, &uPixelsPerRow); | |
755 v6 = 2 * uPixelsPerRow; | |
756 v7 = v4->bFirstFrame == 0; | |
757 uPixelsPerRow *= 2; | |
758 if ( !v7 ) | |
759 { | |
760 if ( pRenderer->bWindowMode ) | |
761 { | |
762 Point.y = 0; | |
763 Point.x = 0; | |
1802 | 764 ClientToScreen(window->GetApiHandle(), &Point); |
0 | 765 v17 = -1; |
766 v16 = 480; | |
767 v15 = 640; | |
768 v14 = Point.y; | |
769 v13 = Point.x; | |
770 v12 = uPixelsPerRow; | |
771 } | |
772 else | |
773 { | |
774 v17 = -1; | |
775 v16 = 480; | |
776 v15 = 640; | |
777 v14 = 0; | |
778 v13 = 0; | |
779 v12 = v6; | |
780 } | |
781 SmackBlitClear(v4->pSmackMovieBlit, pOutSurface, v12, v13, v14, v15, v16, v17); | |
782 v4->bFirstFrame = 0; | |
783 } | |
784 pRenderer->RestoreFrontBuffer(); | |
785 if ( pRenderer->bWindowMode ) | |
786 { | |
787 Point.y = 0; | |
788 Point.x = 0; | |
1802 | 789 ClientToScreen(window->GetApiHandle(), &Point); |
0 | 790 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); |
791 if ( a4 ) | |
792 { | |
793 while ( v8 ) | |
794 { | |
795 v9 = v4->pSmackerMovie; | |
796 SmackBlit( | |
797 v4->pSmackMovieBlit, | |
798 pOutSurface, | |
799 uPixelsPerRow, | |
800 v9->LastRectx + Point.x / 2, | |
801 a3 + v9->LastRecty + Point.y / 2, | |
802 v4->pSomeSmackerBuffer, | |
803 v9->Width, | |
804 v9->LastRectx, | |
805 v9->LastRecty, | |
806 v9->LastRectw, | |
807 v9->LastRecth); | |
808 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
809 } | |
810 } | |
811 else | |
812 { | |
813 while ( v8 ) | |
814 { | |
815 v10 = v4->pSmackerMovie; | |
816 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, Point.x + v10->LastRectx, a3 + Point.y + v10->LastRecty, | |
817 v4->pSomeSmackerBuffer, v10->Width, v10->LastRectx, v10->LastRecty, v10->LastRectw, v10->LastRecth); | |
818 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
819 } | |
820 } | |
821 } | |
822 else | |
823 { | |
824 while ( SmackToBufferRect(v4->pSmackerMovie, 0) ) | |
825 { | |
826 v11 = v4->pSmackerMovie; | |
827 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, v11->LastRectx, a3 + v11->LastRecty, v4->pSomeSmackerBuffer, | |
828 v11->Width, v11->LastRectx, v11->LastRecty, v11->LastRectw, v11->LastRecth); | |
829 } | |
830 } | |
831 pRenderer->UnlockFrontBuffer(); | |
832 if ( v4->pSmackerMovie->FrameNum != v4->pSmackerMovie->Frames - 1 || v4->bLoopPlaying ) | |
833 SmackNextFrame(v4->pSmackerMovie); | |
834 else | |
835 Unload(); | |
836 } | |
837 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
838 */ |
1802 | 839 void VideoPlayer::_inlined_in_463149() |
840 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
841 /* |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
842 if ( pSmackMovie && !SmackWait(pSmackerMovie) ) |
1802 | 843 { |
844 pRenderer->BeginScene(); | |
845 pMouse->DrawCursorToTarget(); | |
846 SmackUpdatePalette(); | |
2216 | 847 pMouse->ReadCursorWithItem(); |
1802 | 848 pRenderer->EndScene(); |
849 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
850 else if ( pBinkMovie && !BinkWait(pBinkMovie) ) |
1802 | 851 { |
852 pRenderer->BeginScene(); | |
853 pMouse->DrawCursorToTarget(); | |
854 BinkUpdatePalette(); | |
2216 | 855 pMouse->ReadCursorWithItem(); |
1802 | 856 pRenderer->EndScene(); |
857 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
858 */ |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
859 if (pMovie) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
860 { |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
861 pRenderer->BeginScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
862 pMouse->DrawCursorToTarget(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
863 UpdatePalette(); |
2216 | 864 pMouse->ReadCursorWithItem(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
865 pRenderer->EndScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
866 } |
1802 | 867 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
868 //auto pixels = new unsigned short[640 * 480]; |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
869 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
870 void VideoPlayer::UpdatePalette() |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
871 { |
2218 | 872 Log::Warning(L"smacker"); |
873 | |
874 pRenderer->BeginScene(); | |
875 if (pMovie->Stopped())//âèäåî çàâåðøåíî/ïåðåçàãðóçêà | |
876 { | |
2222 | 877 int width = game_viewport_width; |
878 int height = game_viewport_height; | |
2218 | 879 delete pMovie; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
880 |
2218 | 881 SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN); |
0 | 882 |
2218 | 883 pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height); |
884 } | |
885 else | |
886 { | |
2221 | 887 char *image = pPlayer->DoFrame(); |
2222 | 888 int image_array[460 * 344];//game_viewport_width * game_viewport_height |
2218 | 889 if (image) |
890 { | |
2222 | 891 memcpy(image_array, image, sizeof (image_array)); |
2223 | 892 for (unsigned int y = 8; y < 8 + game_viewport_height; ++y)//êîîðäèíàòû ìåñòîïîëîæåíèÿ âèäåîðîëèêà |
2221 | 893 { |
894 for (unsigned int x = 8; x < 8 + game_viewport_width; ++x) | |
895 { | |
2222 | 896 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + x + y * pRenderer->uTargetSurfacePitch; |
897 *p = image_array[((x - 8) + ((y - 8)*game_viewport_width))]; | |
2221 | 898 } |
899 } | |
2218 | 900 delete[] image; |
901 } | |
902 } | |
903 pRenderer->EndScene(); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
904 } |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
905 /* |
0 | 906 //----- (004BF08B) -------------------------------------------------------- |
1802 | 907 void VideoPlayer::SmackUpdatePalette() |
0 | 908 { |
2069 | 909 //VideoPlayer *v2; // esi@1 |
0 | 910 unsigned __int16 *v3; // ebx@1 |
911 unsigned int v4; // edi@1 | |
912 unsigned int v5; // eax@1 | |
2069 | 913 //_SMACK *v6; // eax@1 |
0 | 914 |
2070 | 915 Log::Warning(L"smacker"); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
916 |
0 | 917 pRenderer->BeginScene(); |
2069 | 918 |
919 v3 = pixels;//pRenderer->pTargetSurface; | |
920 v4 = 640;//pRenderer->uTargetSurfacePitch; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
921 v5 = SmackCheckSurfaceFromat(); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
922 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
923 SmackToBuffer(pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5); |
2069 | 924 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
925 |
2070 | 926 for (unsigned int y = 8; y < 8 + pSmackerMovie->Height; ++y) |
2069 | 927 for (unsigned int x = 8; x < 8 + pSmackerMovie->Width; ++x) |
928 { | |
929 pRenderer->WritePixel16(x, y, pixels[x + y * 640]); | |
930 } | |
2125 | 931 //delete [] pixels; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
932 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
933 //v6 = pSmackerMovie; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
934 while (true) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
935 { |
2125 | 936 if ( pSmackerMovie->NewPalette ) |
0 | 937 { |
2125 | 938 SmackBufferNewPalette(pSmackerBuffer, pSmackerMovie->Palette, (pSmackerMovie->PalType)); |
0 | 939 SmackColorRemapWithTrans( |
2125 | 940 pSmackerMovie, |
941 pSmackerBuffer->Palette, | |
942 pSmackerBuffer->MaxPalColors, | |
943 pSmackerBuffer->PalType, | |
0 | 944 1000); |
945 } | |
2069 | 946 SmackDoFrame(pSmackerMovie); |
947 if ( pSmackerMovie->FrameNum != pSmackerMovie->Frames - 1 || bLoopPlaying ) | |
948 SmackNextFrame(pSmackerMovie); | |
0 | 949 else |
950 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
951 |
0 | 952 pRenderer->EndScene(); |
953 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
954 */ |
0 | 955 |
956 | |
957 | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
958 /* |
0 | 959 //----- (004BF141) -------------------------------------------------------- |
960 _BINK *VideoPlayer::OpenBink(const char *pName) | |
961 { | |
962 //VideoPlayer *v2; // esi@1 | |
963 signed int v3; // edi@1 | |
964 int v4; // ebx@2 | |
965 signed int v5; // edi@5 | |
966 int v6; // ebx@6 | |
967 HANDLE v8; // [sp-8h] [bp-18h]@10 | |
968 unsigned int v9; // [sp-4h] [bp-14h]@10 | |
969 | |
970 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
971 if (!_stricmp(pName, pMightVideoHeaders[i].pVideoName)) |
0 | 972 { |
973 SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
974 | |
975 if (uBinkVersion < 0x0003000000000000) | |
976 return BinkOpen(hMightVid, 0x8800000); | |
977 else | |
978 return BinkOpen(hMightVid, 0x82000000); | |
979 } | |
980 | |
981 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
982 if (!_stricmp(pName, pMagicVideoHeaders[i].pVideoName)) |
0 | 983 { |
984 SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
985 | |
2125 | 986 if (uBinkVersion < 0x0003000000000000) |
987 return BinkOpen(hMagicVid, BINKNOTHREADEDIO | BINKFILEHANDLE);//0x8800000); | |
988 else | |
989 return BinkOpen(hMagicVid, BINKIOPROCESSOR | BINKCOPYALL);//0x82000000); | |
0 | 990 } |
991 | |
992 return nullptr; | |
993 } | |
994 //----- (004BF1E6) -------------------------------------------------------- | |
995 _SMACK *VideoPlayer::OpenSmack(const char *pFilename) | |
996 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
997 if ( this->uNumMightVideoHeaders ) |
0 | 998 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
999 for ( uint i = 0; i < (signed int)this->uNumMightVideoHeaders; ++i) |
0 | 1000 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1001 if ( !_stricmp(this->pMightVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1002 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1003 SetFilePointer(this->hMightVid, this->pMightVideoHeaders[i].uFileOffset, 0, 0); |
2082 | 1004 return SmackOpen(this->hMightVid, SMACKTRACK2|SMACKTRACK1|SMACKFILEHANDLE|SMACKLOADEXTRA|SMACKNEEDVOLUME, -1);//0x7140, |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1005 } |
0 | 1006 } |
1007 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1008 if ( this->uNumMagicVideoHeaders ) |
0 | 1009 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1010 for ( uint i = 0; i < (signed int)this->uNumMagicVideoHeaders; ++i ) |
0 | 1011 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1012 if ( !_stricmp(this->pMagicVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1013 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1014 SetFilePointer(this->hMagicVid, this->pMagicVideoHeaders[i].uFileOffset, 0, 0); |
2079 | 1015 return SmackOpen(this->hMagicVid, SMACKTRACK2|SMACKTRACK1|SMACKFILEHANDLE|SMACKLOADEXTRA|SMACKNEEDVOLUME, -1); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1016 } |
0 | 1017 } |
1018 } | |
1019 return 0; | |
1020 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1021 */ |
0 | 1022 //----- (004BF28F) -------------------------------------------------------- |
898 | 1023 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
0 | 1024 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1025 if (!this->bBufferLoaded) |
0 | 1026 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1027 //Prepare(); |
2218 | 1028 pEventTimer->Pause(); |
1029 if (pAudioPlayer->hAILRedbook) | |
1030 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1031 |
2218 | 1032 bStopBeforeSchedule = false; |
1033 bBufferLoaded = 1; | |
1034 /* | |
1035 pSmackerMovie = 0; | |
1036 pSmackerBuffer = 0; | |
1037 pBinkMovie = 0; | |
1038 pBinkBuffer = 0; | |
1039 */ | |
1040 bPlayingMovie = false; | |
1041 bFirstFrame = false; | |
1042 bUsingSmackerMMX = SmackUseMMX(1); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1043 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1044 this->bLoopPlaying = a3_1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1045 if ( LOBYTE(this->field_104) == 1 ) |
0 | 1046 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1047 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
0 | 1048 return; |
1049 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1050 |
2218 | 1051 LoadMovie(pMovieName); |
1052 /* | |
1053 this->pSmackerMovie = OpenSmack(Str2); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1054 if ( !this->pSmackerMovie ) |
0 | 1055 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1056 this->Unload(); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1057 sprintf(pTmpBuf.data(), "Can't load %s", &Str2); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1058 MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0); |
898 | 1059 return; |
0 | 1060 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1061 */ |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1062 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1063 /* |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1064 this->pSmackerBuffer = (_SMACKBUF *)SmackBufferOpen(window->GetApiHandle(), 4, LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height), LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height)); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1065 if ( this->pSmackerBuffer ) |
0 | 1066 { |
1067 pRenderer->BeginScene(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1068 SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat()); |
0 | 1069 pRenderer->EndScene(); |
1070 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1071 SmackVolumePan(this->pSmackerMovie, 1040384, (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0), 32767); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1072 */ |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1073 |
0 | 1074 } |
1075 } | |
1076 | |
1077 //----- (004BF3F9) -------------------------------------------------------- | |
1078 bool VideoPlayer::AnyMovieLoaded() | |
1079 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1080 return pMovie;// pSmackerMovie || pBinkMovie; |
0 | 1081 } |
1082 | |
1083 //----- (004BF411) -------------------------------------------------------- | |
898 | 1084 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
0 | 1085 { |
1086 unsigned int v10; // eax@11 | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1087 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1088 if (!this->bBufferLoaded) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1089 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1090 //Prepare(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1091 pEventTimer->Pause(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1092 if (pAudioPlayer->hAILRedbook) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1093 AIL_redbook_pause(pAudioPlayer->hAILRedbook); |
0 | 1094 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1095 bStopBeforeSchedule = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1096 bBufferLoaded = 1; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1097 /* |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1098 pSmackerMovie = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1099 pSmackerBuffer = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1100 pBinkMovie = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1101 pBinkBuffer = 0; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1102 */ |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1103 bPlayingMovie = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1104 bFirstFrame = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1105 bUsingSmackerMMX = SmackUseMMX(1); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1106 this->bLoopPlaying = bLoop; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1107 LoadMovie(pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1108 return; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1109 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1110 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1111 /* |
0 | 1112 sprintf(pVideoName, "%s.bik", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1113 this->pBinkMovie = OpenBink(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1114 if ( this->pBinkMovie ) |
0 | 1115 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1116 this->uMovieFormat = 2; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1117 strcpy(this->pCurrentMovieName, pFilename); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1118 pBinkMovie = this->pBinkMovie; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1119 this->uMovieFormatSwapped = 1; |
0 | 1120 if ( pBinkMovie ) |
1802 | 1121 this->pBinkBuffer = CreateBinkBuffer(pBinkMovie->uWidth, pBinkMovie->uHeight, 0); |
0 | 1122 } |
1123 else | |
1124 { | |
1125 Unload(); | |
898 | 1126 sprintfex(pVideoName, "%s.smk", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1127 this->pSmackerMovie = OpenSmack(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1128 if ( !this->pSmackerMovie ) |
0 | 1129 { |
1130 Unload(); | |
1131 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); | |
1132 MessageBoxA(0, pVideoName, "Smacker Error", 0); | |
1133 return; | |
1134 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1135 this->uMovieFormat = 1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1136 strcpy(this->pCurrentMovieName, pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1137 this->uMovieFormatSwapped = 2; |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1138 this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1139 if ( !this->pSomeSmackerBuffer ) |
0 | 1140 { |
1141 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1142 sprintf(pVideoName, "Can't allocate memory for buffer"); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1143 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
0 | 1144 return; |
1145 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1146 SmackToBuffer(this->pSmackerMovie, 0, 0, this->pSmackerMovie->Width, this->pSmackerMovie->Height, this->pSomeSmackerBuffer, 0); |
1035 | 1147 |
1148 v10 = SmackCheckSurfaceFromat(); | |
0 | 1149 if ( a4 ) |
1150 { | |
1035 | 1151 v10 |= SMACKBLIT2X; |
1152 | |
1153 if (uCPUSpeed >= 165 ) | |
1154 v10 |= SMACKBLIT2XSMOOTHING; | |
0 | 1155 else |
1035 | 1156 Log::Warning(L"Smacker seems to use lower resolution because it thinks CPU is slow"); |
0 | 1157 } |
1035 | 1158 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1159 this->pSmackMovieBlit = SmackBlitOpen(v10); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1160 if ( !this->pSmackMovieBlit ) |
0 | 1161 { |
1162 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1163 sprintf(pVideoName, "Failed to open Blit API"); |
0 | 1164 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1165 return; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1166 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1167 }*/ |
0 | 1168 } |
1169 } | |
1170 | |
1171 | |
1172 //----- (004BF5B2) -------------------------------------------------------- | |
1173 void VideoPlayer::_4BF5B2() | |
1174 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1175 //__debugbreak(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1176 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1177 /*if ( this->uMovieFormat == 2 ) |
0 | 1178 { |
1179 BinkGoto(pBinkMovie, 1, 0); | |
1180 BinkDoFrame(pBinkMovie); | |
1181 BinkNextFrame(pBinkMovie); | |
1182 } | |
1183 else | |
1184 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1185 if ( this->uMovieFormat != 1 ) |
0 | 1186 return; |
1187 SmackGoto(pSmackerMovie, 1); | |
1188 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1189 { | |
1190 SmackDoFrame(pSmackerMovie); | |
1191 SmackNextFrame(pSmackerMovie); | |
1192 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1193 }*/ |
0 | 1194 pMouse->_469E24(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1195 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pMovie)//!this->pSmackerMovie ) |
0 | 1196 { |
2218 | 1197 bGameoverLoop = true; |
1919 | 1198 HouseDialogPressCloseBtn(); |
336 | 1199 window_SpeakInHouse->Release(); |
2218 | 1200 pParty->uFlags &= 0xFFFFFFFD; |
481 | 1201 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) |
0 | 1202 { |
388 | 1203 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
|
1204 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); |
2218 | 1205 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, 0x31, "", 0); |
1206 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, 0x32, "", 0); | |
1207 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, 0x33, "", 0); | |
1208 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, 0x34, "", 0); | |
0 | 1209 } |
1210 bGameoverLoop = 0; | |
1211 } | |
1212 } | |
1213 | |
1214 //----- (004BF73A) -------------------------------------------------------- | |
898 | 1215 void VideoPlayer::SelectMovieType() |
0 | 1216 { |
1217 char Source[32]; // [sp+Ch] [bp-40h]@1 | |
1218 | |
1219 strcpy(Source, this->pCurrentMovieName); | |
1220 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1221 if ( this->uMovieFormatSwapped == 1 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1222 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1223 else if ( this->uMovieFormatSwapped == 2 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1224 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
0 | 1225 else |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1226 __debugbreak(); |
0 | 1227 } |
1228 | |
1229 //----- (004BF8F6) -------------------------------------------------------- | |
1230 void VideoPlayer::PlayDeathMovie() | |
1231 { | |
1232 bStopBeforeSchedule = 0; | |
165 | 1233 pResetflag = 0; |
1397 | 1234 PlayFullscreenMovie(MOVIE_Death, true); |
1235 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); | |
1262 | 1236 } |
1237 | |
1238 //----- (004BE6F5) -------------------------------------------------------- | |
1239 VideoPlayer::VideoPlayer() : | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1240 bBufferLoaded(0), |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1241 //pBinkMovie(nullptr), pBinkBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1242 //pSmackerMovie(nullptr), pSmackerBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1243 pSmackMovieBlit(nullptr) |
1262 | 1244 { |
1245 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); | |
1246 bStopBeforeSchedule = false; | |
1247 pResetflag = 0; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1248 pPlayer = new MultimediaPlayer(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1249 pPlayer->Initialize(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1250 pMovie = nullptr; |
1262 | 1251 //pBinkMovie = nullptr; |
1252 } | |
2134 | 1253 |
1254 bool MultimediaPlayer::libavcodec_initialized = false; | |
1255 | |
1256 void MultimediaPlayer::Logger(void *, int, const char *format, va_list args) | |
1257 { | |
2218 | 1258 char msg[1024]; |
1259 vsprintf(msg, format, args); | |
2134 | 1260 |
2218 | 1261 DWORD w; |
1262 WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, lstrlenA(msg), &w, nullptr); | |
2134 | 1263 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1264 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1265 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
|
1266 { |
2218 | 1267 HANDLE stream = (HANDLE)opaque; |
1268 //int numBytes = stream->read((char*)buf, buf_size); | |
1269 int numBytes; | |
1270 ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL); | |
1271 return numBytes; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1272 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1273 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1274 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
|
1275 { |
2218 | 1276 if (whence == AVSEEK_SIZE) |
1277 return pVideoPlayer->uSize; | |
1278 HANDLE h = (HANDLE)opaque; | |
1279 LARGE_INTEGER li; | |
1280 li.QuadPart = offset; | |
1281 | |
1282 if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN)) | |
1283 return -1; | |
1284 return li.QuadPart; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1285 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1286 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1287 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
|
1288 { |
2218 | 1289 char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2 |
1290 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
|
1291 |
2218 | 1292 sprintf(pVideoNameBik, "%s.bik", pFilename); |
1293 sprintf(pVideoNameSmk, "%s.smk", pFilename); | |
1294 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1295 { | |
1296 //no BIK in MightVid | |
1297 /* | |
1298 if (!_stricmp(pVideoNameBik, pMightVideoHeaders[i].pVideoName)) | |
1299 { | |
1300 hVidFile = hMightVid; | |
1301 uOffset = pMightVideoHeaders[i].uFileOffset; | |
1302 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
1303 this->uMovieFormat = 2; | |
1304 this->uMovieFormatSwapped = 1; | |
1305 } | |
1306 */ | |
1307 if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName)) | |
1308 { | |
1309 hVidFile = hMightVid; | |
1310 uOffset = pMightVideoHeaders[i].uFileOffset; | |
1311 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
1312 this->uMovieFormat = 1; | |
1313 this->uMovieFormatSwapped = 2; | |
1314 } | |
1315 } | |
1316 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1317 { | |
1318 if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName)) | |
1319 { | |
1320 hVidFile = hMagicVid; | |
1321 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
1322 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
1323 this->uMovieFormat = 2; | |
1324 this->uMovieFormatSwapped = 1; | |
1325 } | |
1326 if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName)) | |
1327 { | |
1328 hVidFile = hMagicVid; | |
1329 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
1330 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
1331 this->uMovieFormat = 1; | |
1332 this->uMovieFormatSwapped = 2; | |
1333 } | |
1334 } | |
1335 if (!hVidFile) | |
1336 { | |
1337 Unload(); | |
1338 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0); | |
1339 return; | |
1340 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1341 |
2218 | 1342 SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN); |
1343 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
|
1344 |
2218 | 1345 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
1346 RECT rc_client; | |
1347 GetClientRect(hwnd, &rc_client); | |
1348 int client_width = rc_client.right - rc_client.left, | |
1349 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
|
1350 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1351 |
2218 | 1352 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
|
1353 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1354 } |