Mercurial > mm7
annotate VideoPlayer.cpp @ 2219:e6771956e74a
for mouse
author | Ritor1 |
---|---|
date | Mon, 17 Feb 2014 17:28:06 +0600 |
parents | e8f9a06c7bcb |
children | c69013c186c7 |
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 unsigned __int16 *v3; // ebx@1 |
873 unsigned int v4; // edi@1 | |
874 unsigned int v5; // eax@1 | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
875 |
2218 | 876 Log::Warning(L"smacker"); |
877 | |
878 pRenderer->BeginScene(); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
879 |
2218 | 880 if (pMovie->Stopped())//âèäåî çàâåðøåíî/ïåðåçàãðóçêà |
881 { | |
882 int width = pMovie->GetWidth(); | |
883 int height = pMovie->GetHeight(); | |
884 delete pMovie; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
885 |
2218 | 886 SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN); |
0 | 887 |
2218 | 888 pMovie = pPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height); |
889 } | |
890 else | |
891 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
892 |
2218 | 893 auto image = pPlayer->DoFrame(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
894 |
2218 | 895 if (image) |
896 { | |
897 memcpy(pRenderer->pTargetSurface, image, 480 * 480 * 4);//çàïèñü êàäðà íà ýêðàí | |
898 delete[] image; | |
899 } | |
900 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
901 |
2218 | 902 pRenderer->EndScene(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
903 } |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
904 /* |
0 | 905 //----- (004BF08B) -------------------------------------------------------- |
1802 | 906 void VideoPlayer::SmackUpdatePalette() |
0 | 907 { |
2069 | 908 //VideoPlayer *v2; // esi@1 |
0 | 909 unsigned __int16 *v3; // ebx@1 |
910 unsigned int v4; // edi@1 | |
911 unsigned int v5; // eax@1 | |
2069 | 912 //_SMACK *v6; // eax@1 |
0 | 913 |
2070 | 914 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
|
915 |
0 | 916 pRenderer->BeginScene(); |
2069 | 917 |
918 v3 = pixels;//pRenderer->pTargetSurface; | |
919 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
|
920 v5 = SmackCheckSurfaceFromat(); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
921 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
922 SmackToBuffer(pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5); |
2069 | 923 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
924 |
2070 | 925 for (unsigned int y = 8; y < 8 + pSmackerMovie->Height; ++y) |
2069 | 926 for (unsigned int x = 8; x < 8 + pSmackerMovie->Width; ++x) |
927 { | |
928 pRenderer->WritePixel16(x, y, pixels[x + y * 640]); | |
929 } | |
2125 | 930 //delete [] pixels; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
931 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
932 //v6 = pSmackerMovie; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
933 while (true) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
934 { |
2125 | 935 if ( pSmackerMovie->NewPalette ) |
0 | 936 { |
2125 | 937 SmackBufferNewPalette(pSmackerBuffer, pSmackerMovie->Palette, (pSmackerMovie->PalType)); |
0 | 938 SmackColorRemapWithTrans( |
2125 | 939 pSmackerMovie, |
940 pSmackerBuffer->Palette, | |
941 pSmackerBuffer->MaxPalColors, | |
942 pSmackerBuffer->PalType, | |
0 | 943 1000); |
944 } | |
2069 | 945 SmackDoFrame(pSmackerMovie); |
946 if ( pSmackerMovie->FrameNum != pSmackerMovie->Frames - 1 || bLoopPlaying ) | |
947 SmackNextFrame(pSmackerMovie); | |
0 | 948 else |
949 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
950 |
0 | 951 pRenderer->EndScene(); |
952 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
953 */ |
0 | 954 |
955 | |
956 | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
957 /* |
0 | 958 //----- (004BF141) -------------------------------------------------------- |
959 _BINK *VideoPlayer::OpenBink(const char *pName) | |
960 { | |
961 //VideoPlayer *v2; // esi@1 | |
962 signed int v3; // edi@1 | |
963 int v4; // ebx@2 | |
964 signed int v5; // edi@5 | |
965 int v6; // ebx@6 | |
966 HANDLE v8; // [sp-8h] [bp-18h]@10 | |
967 unsigned int v9; // [sp-4h] [bp-14h]@10 | |
968 | |
969 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
970 if (!_stricmp(pName, pMightVideoHeaders[i].pVideoName)) |
0 | 971 { |
972 SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
973 | |
974 if (uBinkVersion < 0x0003000000000000) | |
975 return BinkOpen(hMightVid, 0x8800000); | |
976 else | |
977 return BinkOpen(hMightVid, 0x82000000); | |
978 } | |
979 | |
980 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
981 if (!_stricmp(pName, pMagicVideoHeaders[i].pVideoName)) |
0 | 982 { |
983 SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); | |
984 | |
2125 | 985 if (uBinkVersion < 0x0003000000000000) |
986 return BinkOpen(hMagicVid, BINKNOTHREADEDIO | BINKFILEHANDLE);//0x8800000); | |
987 else | |
988 return BinkOpen(hMagicVid, BINKIOPROCESSOR | BINKCOPYALL);//0x82000000); | |
0 | 989 } |
990 | |
991 return nullptr; | |
992 } | |
993 //----- (004BF1E6) -------------------------------------------------------- | |
994 _SMACK *VideoPlayer::OpenSmack(const char *pFilename) | |
995 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
996 if ( this->uNumMightVideoHeaders ) |
0 | 997 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
998 for ( uint i = 0; i < (signed int)this->uNumMightVideoHeaders; ++i) |
0 | 999 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1000 if ( !_stricmp(this->pMightVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1001 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1002 SetFilePointer(this->hMightVid, this->pMightVideoHeaders[i].uFileOffset, 0, 0); |
2082 | 1003 return SmackOpen(this->hMightVid, SMACKTRACK2|SMACKTRACK1|SMACKFILEHANDLE|SMACKLOADEXTRA|SMACKNEEDVOLUME, -1);//0x7140, |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1004 } |
0 | 1005 } |
1006 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1007 if ( this->uNumMagicVideoHeaders ) |
0 | 1008 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1009 for ( uint i = 0; i < (signed int)this->uNumMagicVideoHeaders; ++i ) |
0 | 1010 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1011 if ( !_stricmp(this->pMagicVideoHeaders[i].pVideoName, pFilename) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1012 { |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1013 SetFilePointer(this->hMagicVid, this->pMagicVideoHeaders[i].uFileOffset, 0, 0); |
2079 | 1014 return SmackOpen(this->hMagicVid, SMACKTRACK2|SMACKTRACK1|SMACKFILEHANDLE|SMACKLOADEXTRA|SMACKNEEDVOLUME, -1); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1015 } |
0 | 1016 } |
1017 } | |
1018 return 0; | |
1019 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1020 */ |
0 | 1021 //----- (004BF28F) -------------------------------------------------------- |
898 | 1022 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
0 | 1023 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1024 if (!this->bBufferLoaded) |
0 | 1025 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1026 //Prepare(); |
2218 | 1027 pEventTimer->Pause(); |
1028 if (pAudioPlayer->hAILRedbook) | |
1029 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1030 |
2218 | 1031 bStopBeforeSchedule = false; |
1032 bBufferLoaded = 1; | |
1033 /* | |
1034 pSmackerMovie = 0; | |
1035 pSmackerBuffer = 0; | |
1036 pBinkMovie = 0; | |
1037 pBinkBuffer = 0; | |
1038 */ | |
1039 bPlayingMovie = false; | |
1040 bFirstFrame = false; | |
1041 bUsingSmackerMMX = SmackUseMMX(1); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1042 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1043 this->bLoopPlaying = a3_1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1044 if ( LOBYTE(this->field_104) == 1 ) |
0 | 1045 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1046 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
0 | 1047 return; |
1048 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1049 |
2218 | 1050 LoadMovie(pMovieName); |
1051 /* | |
1052 this->pSmackerMovie = OpenSmack(Str2); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1053 if ( !this->pSmackerMovie ) |
0 | 1054 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1055 this->Unload(); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1056 sprintf(pTmpBuf.data(), "Can't load %s", &Str2); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1057 MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0); |
898 | 1058 return; |
0 | 1059 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1060 */ |
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 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
|
1064 if ( this->pSmackerBuffer ) |
0 | 1065 { |
1066 pRenderer->BeginScene(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1067 SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat()); |
0 | 1068 pRenderer->EndScene(); |
1069 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1070 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
|
1071 */ |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1072 |
0 | 1073 } |
1074 } | |
1075 | |
1076 //----- (004BF3F9) -------------------------------------------------------- | |
1077 bool VideoPlayer::AnyMovieLoaded() | |
1078 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1079 return pMovie;// pSmackerMovie || pBinkMovie; |
0 | 1080 } |
1081 | |
1082 //----- (004BF411) -------------------------------------------------------- | |
898 | 1083 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
0 | 1084 { |
1085 unsigned int v10; // eax@11 | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1086 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1087 if (!this->bBufferLoaded) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1088 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1089 //Prepare(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1090 pEventTimer->Pause(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1091 if (pAudioPlayer->hAILRedbook) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1092 AIL_redbook_pause(pAudioPlayer->hAILRedbook); |
0 | 1093 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1094 bStopBeforeSchedule = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1095 bBufferLoaded = 1; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1096 /* |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1097 pSmackerMovie = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1098 pSmackerBuffer = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1099 pBinkMovie = 0; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1100 pBinkBuffer = 0; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1101 */ |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1102 bPlayingMovie = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1103 bFirstFrame = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1104 bUsingSmackerMMX = SmackUseMMX(1); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1105 this->bLoopPlaying = bLoop; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1106 LoadMovie(pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1107 return; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1108 |
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 /* |
0 | 1111 sprintf(pVideoName, "%s.bik", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1112 this->pBinkMovie = OpenBink(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1113 if ( this->pBinkMovie ) |
0 | 1114 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1115 this->uMovieFormat = 2; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1116 strcpy(this->pCurrentMovieName, pFilename); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1117 pBinkMovie = this->pBinkMovie; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1118 this->uMovieFormatSwapped = 1; |
0 | 1119 if ( pBinkMovie ) |
1802 | 1120 this->pBinkBuffer = CreateBinkBuffer(pBinkMovie->uWidth, pBinkMovie->uHeight, 0); |
0 | 1121 } |
1122 else | |
1123 { | |
1124 Unload(); | |
898 | 1125 sprintfex(pVideoName, "%s.smk", pFilename); |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1126 this->pSmackerMovie = OpenSmack(pVideoName); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1127 if ( !this->pSmackerMovie ) |
0 | 1128 { |
1129 Unload(); | |
1130 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); | |
1131 MessageBoxA(0, pVideoName, "Smacker Error", 0); | |
1132 return; | |
1133 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1134 this->uMovieFormat = 1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1135 strcpy(this->pCurrentMovieName, pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1136 this->uMovieFormatSwapped = 2; |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1137 this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1138 if ( !this->pSomeSmackerBuffer ) |
0 | 1139 { |
1140 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1141 sprintf(pVideoName, "Can't allocate memory for buffer"); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1142 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
0 | 1143 return; |
1144 } | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1145 SmackToBuffer(this->pSmackerMovie, 0, 0, this->pSmackerMovie->Width, this->pSmackerMovie->Height, this->pSomeSmackerBuffer, 0); |
1035 | 1146 |
1147 v10 = SmackCheckSurfaceFromat(); | |
0 | 1148 if ( a4 ) |
1149 { | |
1035 | 1150 v10 |= SMACKBLIT2X; |
1151 | |
1152 if (uCPUSpeed >= 165 ) | |
1153 v10 |= SMACKBLIT2XSMOOTHING; | |
0 | 1154 else |
1035 | 1155 Log::Warning(L"Smacker seems to use lower resolution because it thinks CPU is slow"); |
0 | 1156 } |
1035 | 1157 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1158 this->pSmackMovieBlit = SmackBlitOpen(v10); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1159 if ( !this->pSmackMovieBlit ) |
0 | 1160 { |
1161 Unload(); | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1162 sprintf(pVideoName, "Failed to open Blit API"); |
0 | 1163 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1164 return; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1165 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1166 }*/ |
0 | 1167 } |
1168 } | |
1169 | |
1170 | |
1171 //----- (004BF5B2) -------------------------------------------------------- | |
1172 void VideoPlayer::_4BF5B2() | |
1173 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1174 //__debugbreak(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1175 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1176 /*if ( this->uMovieFormat == 2 ) |
0 | 1177 { |
1178 BinkGoto(pBinkMovie, 1, 0); | |
1179 BinkDoFrame(pBinkMovie); | |
1180 BinkNextFrame(pBinkMovie); | |
1181 } | |
1182 else | |
1183 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1184 if ( this->uMovieFormat != 1 ) |
0 | 1185 return; |
1186 SmackGoto(pSmackerMovie, 1); | |
1187 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1188 { | |
1189 SmackDoFrame(pSmackerMovie); | |
1190 SmackNextFrame(pSmackerMovie); | |
1191 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1192 }*/ |
0 | 1193 pMouse->_469E24(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1194 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pMovie)//!this->pSmackerMovie ) |
0 | 1195 { |
2218 | 1196 bGameoverLoop = true; |
1919 | 1197 HouseDialogPressCloseBtn(); |
336 | 1198 window_SpeakInHouse->Release(); |
2218 | 1199 pParty->uFlags &= 0xFFFFFFFD; |
481 | 1200 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) |
0 | 1201 { |
388 | 1202 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
|
1203 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); |
2218 | 1204 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, 0x31, "", 0); |
1205 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, 0x32, "", 0); | |
1206 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, 0x33, "", 0); | |
1207 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, 0x34, "", 0); | |
0 | 1208 } |
1209 bGameoverLoop = 0; | |
1210 } | |
1211 } | |
1212 | |
1213 //----- (004BF73A) -------------------------------------------------------- | |
898 | 1214 void VideoPlayer::SelectMovieType() |
0 | 1215 { |
1216 char Source[32]; // [sp+Ch] [bp-40h]@1 | |
1217 | |
1218 strcpy(Source, this->pCurrentMovieName); | |
1219 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1220 if ( this->uMovieFormatSwapped == 1 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1221 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1222 else if ( this->uMovieFormatSwapped == 2 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1223 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
0 | 1224 else |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
1225 __debugbreak(); |
0 | 1226 } |
1227 | |
1228 //----- (004BF8F6) -------------------------------------------------------- | |
1229 void VideoPlayer::PlayDeathMovie() | |
1230 { | |
1231 bStopBeforeSchedule = 0; | |
165 | 1232 pResetflag = 0; |
1397 | 1233 PlayFullscreenMovie(MOVIE_Death, true); |
1234 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); | |
1262 | 1235 } |
1236 | |
1237 //----- (004BE6F5) -------------------------------------------------------- | |
1238 VideoPlayer::VideoPlayer() : | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1239 bBufferLoaded(0), |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1240 //pBinkMovie(nullptr), pBinkBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1241 //pSmackerMovie(nullptr), pSmackerBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1242 pSmackMovieBlit(nullptr) |
1262 | 1243 { |
1244 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); | |
1245 bStopBeforeSchedule = false; | |
1246 pResetflag = 0; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1247 pPlayer = new MultimediaPlayer(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1248 pPlayer->Initialize(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1249 pMovie = nullptr; |
1262 | 1250 //pBinkMovie = nullptr; |
1251 } | |
2134 | 1252 |
1253 bool MultimediaPlayer::libavcodec_initialized = false; | |
1254 | |
1255 void MultimediaPlayer::Logger(void *, int, const char *format, va_list args) | |
1256 { | |
2218 | 1257 char msg[1024]; |
1258 vsprintf(msg, format, args); | |
2134 | 1259 |
2218 | 1260 DWORD w; |
1261 WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, lstrlenA(msg), &w, nullptr); | |
2134 | 1262 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1263 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1264 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
|
1265 { |
2218 | 1266 HANDLE stream = (HANDLE)opaque; |
1267 //int numBytes = stream->read((char*)buf, buf_size); | |
1268 int numBytes; | |
1269 ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL); | |
1270 return numBytes; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1271 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1272 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1273 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
|
1274 { |
2218 | 1275 if (whence == AVSEEK_SIZE) |
1276 return pVideoPlayer->uSize; | |
1277 HANDLE h = (HANDLE)opaque; | |
1278 LARGE_INTEGER li; | |
1279 li.QuadPart = offset; | |
1280 | |
1281 if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN)) | |
1282 return -1; | |
1283 return li.QuadPart; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
1284 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1285 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1286 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
|
1287 { |
2218 | 1288 char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2 |
1289 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
|
1290 |
2218 | 1291 sprintf(pVideoNameBik, "%s.bik", pFilename); |
1292 sprintf(pVideoNameSmk, "%s.smk", pFilename); | |
1293 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1294 { | |
1295 //no BIK in MightVid | |
1296 /* | |
1297 if (!_stricmp(pVideoNameBik, pMightVideoHeaders[i].pVideoName)) | |
1298 { | |
1299 hVidFile = hMightVid; | |
1300 uOffset = pMightVideoHeaders[i].uFileOffset; | |
1301 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
1302 this->uMovieFormat = 2; | |
1303 this->uMovieFormatSwapped = 1; | |
1304 } | |
1305 */ | |
1306 if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName)) | |
1307 { | |
1308 hVidFile = hMightVid; | |
1309 uOffset = pMightVideoHeaders[i].uFileOffset; | |
1310 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
1311 this->uMovieFormat = 1; | |
1312 this->uMovieFormatSwapped = 2; | |
1313 } | |
1314 } | |
1315 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1316 { | |
1317 if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName)) | |
1318 { | |
1319 hVidFile = hMagicVid; | |
1320 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
1321 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
1322 this->uMovieFormat = 2; | |
1323 this->uMovieFormatSwapped = 1; | |
1324 } | |
1325 if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName)) | |
1326 { | |
1327 hVidFile = hMagicVid; | |
1328 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
1329 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
1330 this->uMovieFormat = 1; | |
1331 this->uMovieFormatSwapped = 2; | |
1332 } | |
1333 } | |
1334 if (!hVidFile) | |
1335 { | |
1336 Unload(); | |
1337 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0); | |
1338 return; | |
1339 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1340 |
2218 | 1341 SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN); |
1342 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
|
1343 |
2218 | 1344 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
1345 RECT rc_client; | |
1346 GetClientRect(hwnd, &rc_client); | |
1347 int client_width = rc_client.right - rc_client.left, | |
1348 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
|
1349 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1350 |
2218 | 1351 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
|
1352 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
1353 } |