Mercurial > might-and-magic-trilogy
annotate VideoPlayer.cpp @ 191:d625cbdf34f0
25.12.12(byte_4ED3D8)
author | Ritor1 |
---|---|
date | Tue, 25 Dec 2012 22:24:33 +0600 |
parents | 27bdff4ed3e6 |
children | af624eaf2fc5 |
rev | line source |
---|---|
0 | 1 #include "OSAPI.h" |
2 | |
3 #include "Bink_Smacker.h" | |
4 | |
5 #include "OSInfo.h" | |
6 #include "VideoPlayer.h" | |
7 #include "AudioPlayer.h" | |
8 #include "Game.h" | |
9 #include "Render.h" | |
10 #include "Party.h" | |
11 #include "GUIWindow.h" | |
12 #include "Allocator.h" | |
13 #include "Time.h" | |
14 #include "Log.h" | |
15 | |
16 #include "mm7_data.h" | |
17 | |
18 | |
19 VideoPlayer *pVideoPlayer = nullptr; | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
21 | 27 #pragma comment(lib, "Version.lib") |
28 bool GetDllVersion(const wchar_t *pDllName, uint *pMajor, uint *pMinor) | |
29 { | |
30 uint uVersionSize = GetFileVersionInfoSizeW(pDllName, nullptr); | |
31 void *pVersionData = HeapAlloc(GetProcessHeap(), 0, uVersionSize); | |
32 { | |
33 GetFileVersionInfoW(pDllName, 0, uVersionSize, pVersionData); | |
34 | |
35 VS_FIXEDFILEINFO *pInfo = nullptr; | |
36 UINT uInfoSize = 0; | |
37 VerQueryValueW(pVersionData, L"\\", (void **)&pInfo, &uInfoSize); | |
38 | |
39 if (!pMajor || !pMinor) | |
40 { | |
41 HeapFree(GetProcessHeap(), 0, pVersionData); | |
42 return false; | |
43 } | |
44 *pMajor = pInfo->dwFileVersionMS; | |
45 *pMinor = pInfo->dwFileVersionLS; | |
46 } | |
47 HeapFree(GetProcessHeap(), 0, pVersionData); | |
48 return true; | |
49 } | |
50 | |
51 | |
52 // 3.15.1.0: | |
53 // 3 15 1 0 | |
54 // 0x0003000F00010000 | |
55 unsigned __int64 uBinkVersion; | |
56 | |
57 | |
58 | |
59 | |
60 | |
0 | 61 |
62 //----- (004BFE2D) -------------------------------------------------------- | |
13
17150bdf321e
исправлено неполное воспроизведение роликов, бинков
Серик@ПончиК
parents:
3
diff
changeset
|
63 _BINKBUF *VideoPlayer::CreateBinkBuffer(HWND hWindow, unsigned int uWidth, unsigned int uHeight, char a4) |
0 | 64 { |
65 __int32 v4; // edi@3 | |
66 _BINKBUF *v5; // esi@3 | |
67 HRESULT v6; // eax@5 | |
68 IDirectDrawSurface *v7; // eax@6 | |
69 HRESULT v8; // eax@9 | |
70 char v9; // al@11 | |
71 DDSURFACEDESC2 v11; // [sp+Ch] [bp-108h]@7 | |
72 DDSURFACEDESC Dst; // [sp+88h] [bp-8Ch]@3 | |
73 unsigned int v13; // [sp+F4h] [bp-20h]@1 | |
74 struct tagRECT Rect; // [sp+F8h] [bp-1Ch]@11 | |
75 IDirectDrawSurface4 *v15; // [sp+108h] [bp-Ch]@7 | |
76 IDirectDrawSurface2 *a2; // [sp+10Ch] [bp-8h]@3 | |
77 HWND hWnd; // [sp+110h] [bp-4h]@1 | |
78 | |
79 v13 = uWidth; | |
13
17150bdf321e
исправлено неполное воспроизведение роликов, бинков
Серик@ПончиК
parents:
3
diff
changeset
|
80 hWnd = hWindow; |
17150bdf321e
исправлено неполное воспроизведение роликов, бинков
Серик@ПончиК
parents:
3
diff
changeset
|
81 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) |
0 | 82 { |
83 v4 = 0; | |
84 v15 = 0; | |
21 | 85 |
86 if (uBinkVersion == 0x0001000500150000) | |
87 { | |
88 v5 = new _BINKBUF_1_5_21_0; | |
89 memset(v5, 0, sizeof(_BINKBUF_1_5_21_0)); | |
90 } | |
91 else if (uBinkVersion == 0x0003000000000000) | |
92 { | |
93 v5 = new _BINKBUF_3_0_0_0; | |
94 memset(v5, 0, sizeof(_BINKBUF_3_0_0_0)); | |
95 } | |
96 | |
0 | 97 memset(&v11, 0, 0x7Cu); |
98 v11.dwSize = 124; | |
99 v11.dwWidth = v13; | |
100 v11.dwFlags = 0x1007u; // DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | |
101 v11.ddsCaps.dwCaps = 0x4040u; // DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | |
102 v11.dwHeight = uHeight; | |
103 *(_QWORD *)&v11.ddpfPixelFormat.dwSize = 0x400000020ui64;// DDPF_FOURCC | |
104 v11.ddpfPixelFormat.dwFourCC = 0x32595559u; | |
105 if ( dword_6BE384_2dacceloff || pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0) ) | |
106 { | |
107 memset(&v11.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT)); | |
108 | |
109 v11.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
110 v11.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; | |
111 | |
112 auto hr = pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0); | |
113 ErrD3D(hr, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:1476"); | |
114 } | |
115 v5->uWidth = v11.dwWidth; | |
116 v5->uHeight = v11.dwHeight; | |
117 v5->uBinkDDSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)v15); | |
118 v5->field_38 = 0; | |
119 v7 = (IDirectDrawSurface *)v15; | |
120 } | |
121 else | |
122 { | |
123 v4 = 0; | |
124 a2 = 0; | |
21 | 125 |
126 | |
127 if (uBinkVersion == 0x0001000500150000) | |
128 { | |
129 v5 = new _BINKBUF_1_5_21_0; | |
130 memset(v5, 0, sizeof(_BINKBUF_1_5_21_0)); | |
131 } | |
132 else if (uBinkVersion == 0x0003000000000000) | |
133 { | |
134 v5 = new _BINKBUF_3_0_0_0; | |
135 memset(v5, 0, sizeof(_BINKBUF_3_0_0_0)); | |
136 } | |
137 | |
0 | 138 memset(&Dst, 0, 0x6Cu); |
139 Dst.dwSize = 108; | |
140 Dst.dwWidth = v13; | |
141 Dst.dwFlags = 4103; | |
142 Dst.ddsCaps.dwCaps = 16448; | |
143 Dst.dwHeight = uHeight; | |
144 Dst.ddpfPixelFormat.dwSize = 32; | |
145 Dst.ddpfPixelFormat.dwFlags = 4; | |
146 Dst.ddpfPixelFormat.dwFourCC = 844715353; | |
147 if ( dword_6BE384_2dacceloff | |
148 || pRenderer->pDirectDraw2->CreateSurface(&Dst, (LPDIRECTDRAWSURFACE *)&a2, 0) ) | |
149 { | |
150 memset(&Dst.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT)); | |
151 | |
152 Dst.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
153 Dst.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; | |
154 | |
155 auto hr = pRenderer->pDirectDraw2->CreateSurface(&Dst, (LPDIRECTDRAWSURFACE *)&a2, 0); | |
156 ErrD3D(hr, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:1426"); | |
157 } | |
158 v5->uWidth = Dst.dwWidth; | |
159 v5->uHeight = Dst.dwHeight; | |
160 v5->uBinkDDSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)a2); | |
161 v5->field_38 = 0; | |
162 v7 = (IDirectDrawSurface *)a2; | |
163 } | |
164 v5->pTargetDDrawSurface = v7; | |
165 v5->hWnd = hWnd; | |
166 v9 = a4; | |
167 v5->field_4C = v4; | |
168 v5->field_68 = v4; | |
169 v5->field_5C = v4; | |
170 v5->field_74 = v9 & 0x1F; | |
171 v5->field_78 = 1; | |
172 v5->field_24 = GetSystemMetrics(v4); | |
173 v5->field_28 = GetSystemMetrics(SM_CYSCREEN); | |
174 v5->field_2C = 16; | |
175 GetWindowRect(hWnd, &Rect); | |
176 v5->field_8 = Rect.right - Rect.left; | |
177 v5->field_C = Rect.bottom - Rect.top; | |
178 v5->field_1C = Rect.left; | |
179 v5->field_20 = Rect.top; | |
180 Rect.left = v4; | |
181 Rect.top = v4; | |
182 ClientToScreen(hWnd, (LPPOINT)&Rect); | |
183 v5->field_1C = Rect.left - v5->field_1C; | |
184 v5->field_20 = Rect.top - v5->field_20; | |
185 GetClientRect(hWnd, &Rect); | |
186 v5->field_30 = v5->field_8 - Rect.right; | |
187 v5->field_34 = v5->field_C - Rect.bottom; | |
188 v5->field_8 = v5->uWidth + v5->field_30; | |
189 v5->field_C = v5->uHeight + v5->field_34; | |
190 BinkBufferSetOffset(v5, v4, v4); | |
191 BinkBufferSetScale(v5, v5->uWidth, v5->uHeight); | |
192 return v5; | |
193 } | |
21 | 194 |
0 | 195 |
196 //----- (004C0133) -------------------------------------------------------- | |
197 bool BinkLockBuffer(_BINKBUF *_this) | |
198 { | |
199 _BINKBUF *v1; // esi@1 | |
200 IDirectDrawSurface *v2; // edi@5 | |
201 DWORD v4; // eax@8 | |
202 DWORD v5; // eax@8 | |
203 IDirectDrawSurface4 *v6; // edi@11 | |
204 LPVOID v7; // eax@14 | |
205 | |
206 v1 = _this; | |
13
17150bdf321e
исправлено неполное воспроизведение роликов, бинков
Серик@ПончиК
parents:
3
diff
changeset
|
207 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) |
0 | 208 { |
209 DDSURFACEDESC2 v8; // [sp+Ch] [bp-7Ch]@4 | |
210 if ( _this->pTargetDDrawSurface ) | |
211 { | |
212 memset(&v8, 0, 0x7Cu); | |
213 v8.dwSize = 124; | |
214 while ( 1 ) | |
215 { | |
216 v6 = (IDirectDrawSurface4 *)v1->pTargetDDrawSurface; | |
217 if ( !v6->Lock(0, &v8, 1u, 0) ) | |
218 break; | |
21 | 219 |
220 if (uBinkVersion < 0x0003000000000000) | |
221 BYTE3(v1->uBinkDDSurfaceType) |= 0x80u; | |
222 else | |
223 BYTE3(v1->uBinkDDSurfaceType) |= 0x04; | |
224 | |
0 | 225 if ( v6->Restore() ) |
226 return 0; | |
227 } | |
228 v7 = v8.lpSurface; | |
229 v1->pDDrawSurfaceData_ = v8.lpSurface; | |
230 v1->pDDrawSurfaceData = v7; | |
231 v5 = v8.lPitch; | |
232 goto LABEL_15; | |
233 } | |
234 } | |
235 else | |
236 { | |
237 DDSURFACEDESC v8; // [sp+Ch] [bp-7Ch]@4 | |
238 if ( _this->pTargetDDrawSurface ) | |
239 { | |
240 memset(&v8.lPitch, 0, 0x6Cu); | |
241 v8.lPitch = 108; | |
242 while ( 1 ) | |
243 { | |
244 v2 = v1->pTargetDDrawSurface; | |
245 if ( !v2->Lock(0, (LPDDSURFACEDESC)&v8.lPitch, 1u, 0) ) | |
246 break; | |
21 | 247 |
248 if (uBinkVersion < 0x0003000000000000) | |
249 __asm int 3; | |
250 else | |
251 BYTE3(v1->uBinkDDSurfaceType) |= 4u; | |
252 | |
0 | 253 if ( v2->Restore() ) |
254 return 0; | |
255 } | |
256 v4 = (DWORD)v8.lpSurface; | |
257 v1->pDDrawSurfaceData_ = (void *)v8.lpSurface; | |
258 v1->pDDrawSurfaceData = (void *)v4; | |
259 v5 = v8.dwReserved; | |
260 LABEL_15: | |
261 v1->uDDrawSurfacePitch = v5; | |
262 return 1; | |
263 } | |
264 } | |
265 return 1; | |
266 } | |
267 | |
268 //----- (004C01FB) -------------------------------------------------------- | |
269 void BinkUnlockBuffer(_BINKBUF *_this) | |
270 { | |
271 _BINKBUF *v1; // esi@1 | |
272 IDirectDrawSurface *v2; // eax@1 | |
273 | |
274 v1 = _this; | |
275 v2 = _this->pTargetDDrawSurface; | |
276 if ( v2 ) | |
277 { | |
278 v2->Unlock(0); | |
279 v1->uDDrawSurfacePitch = 0; | |
280 v1->pDDrawSurfaceData = 0; | |
21 | 281 |
282 if (uBinkVersion < 0x0003000000000000) | |
283 BYTE3(_this->uBinkDDSurfaceType) &= 0x7F; | |
284 else | |
285 BYTE3(_this->uBinkDDSurfaceType) &= 0xFB; | |
0 | 286 } |
287 } | |
288 //----- (004BF794) -------------------------------------------------------- | |
289 void __cdecl ShowIntroVideo_and_LoadingScreen() | |
290 { | |
291 RGBTexture tex; // [sp+Ch] [bp-30h]@1 | |
292 unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8 | |
293 unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8 | |
294 | |
295 pVideoPlayer->bStopBeforeSchedule = false; | |
296 pVideoPlayer->field_40 = 0; | |
297 bGameoverLoop = 1; | |
298 if ( !bNoVideo ) | |
299 { | |
300 bNoVideo = 0; | |
301 pRenderer->PresentBlackScreen(); | |
302 pGame->pCShow->PlayMovie(MOVIE_3DOLogo, 1); | |
303 if ( !pVideoPlayer->bStopBeforeSchedule ) | |
304 { | |
305 pGame->pCShow->PlayMovie(MOVIE_NWCLogo, 1); | |
306 if ( !pVideoPlayer->bStopBeforeSchedule ) | |
307 { | |
308 pGame->pCShow->PlayMovie(MOVIE_JVC, 1); | |
309 if ( !pVideoPlayer->bStopBeforeSchedule ) | |
13
17150bdf321e
исправлено неполное воспроизведение роликов, бинков
Серик@ПончиК
parents:
3
diff
changeset
|
310 pGame->pCShow->PlayMovie(MOVIE_Intro, 1); |
0 | 311 } |
312 } | |
313 } | |
314 tex.Load("mm6title.pcx", 2); | |
315 pRenderer->BeginScene(); | |
316 pRenderer->DrawTextureRGB(0, 0, &tex); | |
317 free(tex.pPixels); | |
318 tex.pPixels = 0; | |
319 MainMenuUI_LoadFontsAndSomeStuff(); | |
320 DrawCopyrightWindow(); | |
321 pRenderer->EndScene(); | |
322 pRenderer->Present(); | |
3 | 323 if (!bNoSound && pAudioPlayer->hAILRedbook ) |
0 | 324 { |
325 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); | |
326 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
180 | 327 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &uTrackStartMS, &uTrackEndMS); |
0 | 328 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); |
329 } | |
330 bGameoverLoop = 0; | |
331 } | |
332 | |
333 | |
334 | |
335 | |
336 //----- (004BE70E) -------------------------------------------------------- | |
180 | 337 void __fastcall VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) |
0 | 338 { |
339 int v4; // ebp@1 | |
180 | 340 const char *pName; // edi@1 |
0 | 341 MSG Msg; // [sp+Ch] [bp-1Ch]@12 |
342 | |
343 v4 = a2; | |
180 | 344 pName = pMovieName; |
0 | 345 if ( !(dword_6BE364_game_settings_1 & 0x44) ) |
346 { | |
347 if ( a2 == 2 ) | |
348 v4 = 0; | |
349 ShowCursor(0); | |
180 | 350 pVideoPlayer->OpenMovie(pName, 0, ScreenSizeFlag); |
0 | 351 pVideoPlayer->bPlayingMovie = 1; |
352 pVideoPlayer->field_44 = v4; | |
353 if ( pRenderer->pRenderD3D ) | |
354 { | |
355 pRenderer->ClearTarget(0); | |
356 } | |
357 else | |
358 { | |
359 pRenderer->BeginScene(); | |
360 pRenderer->ClearTarget(0); | |
361 pRenderer->EndScene(); | |
362 } | |
186 | 363 pCurrentScreen = 16; // |
0 | 364 if ( pVideoPlayer->uMovieFormat == 2 ) |
365 { | |
366 if ( pVideoPlayer->pBinkMovie ) | |
367 { | |
180 | 368 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag); |
0 | 369 while ( pVideoPlayer->pBinkMovie ) |
370 { | |
371 if ( pVideoPlayer->bStopBeforeSchedule ) | |
372 break; | |
180 | 373 while ( PeekMessageA(&Msg, 0, 0, 0, 1) ) |
0 | 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(); | |
383 if ( !pVideoPlayer->pBinkMovie ) | |
384 break; | |
385 if ( !BinkWait(pVideoPlayer->pBinkMovie) && !pVideoPlayer->bStopBeforeSchedule ) | |
180 | 386 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag); |
0 | 387 } |
388 } | |
389 if ( pVideoPlayer->bStopBeforeSchedule == 1 ) | |
390 Sleep(0x3E8u); | |
391 } | |
392 else | |
393 { | |
394 if ( pVideoPlayer->uMovieFormat == 1 ) | |
395 { | |
396 if ( pVideoPlayer->pSmackerMovie ) | |
397 { | |
180 | 398 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag); |
0 | 399 while ( pVideoPlayer->pSmackerMovie ) |
400 { | |
401 if ( pVideoPlayer->bStopBeforeSchedule ) | |
402 break; | |
180 | 403 while ( PeekMessageW(&Msg, 0, 0, 0, 1) ) |
0 | 404 { |
405 if (Msg.message == WM_QUIT) | |
406 Game_DeinitializeAndTerminate(0); | |
407 if (Msg.message == WM_PAINT) | |
408 break; | |
409 TranslateMessage(&Msg); | |
410 DispatchMessageW(&Msg); | |
411 } | |
412 GUI_MainMenuMessageProc(); | |
413 if ( !pVideoPlayer->pSmackerMovie ) | |
414 break; | |
415 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule ) | |
180 | 416 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag); |
0 | 417 } |
418 } | |
419 } | |
420 } | |
421 if ( a4 == 1 ) | |
44 | 422 pCurrentScreen = 0; |
0 | 423 pVideoPlayer->bPlayingMovie = 0; |
424 ShowCursor(1); | |
186 | 425 if ( pCurrentScreen == 16 )// |
44 | 426 pCurrentScreen = 0; |
0 | 427 } |
428 } | |
21 | 429 |
0 | 430 |
431 | |
432 | |
433 //----- (004BE95A) -------------------------------------------------------- | |
434 unsigned int VideoPlayer::SmackCheckSurfaceFromat() | |
435 { | |
436 DDPIXELFORMAT a2; // [sp+0h] [bp-20h]@1 | |
437 | |
438 a2.dwSize = 32; | |
439 a2.dwFlags = 64; | |
440 pRenderer->GetTargetPixelFormat(&a2); | |
441 if ( a2.dwRGBBitCount != 8 ) | |
442 { | |
443 if ( a2.dwRBitMask == 0xF800 ) | |
444 { | |
445 if ( a2.dwGBitMask == 0x7E0 && a2.dwBBitMask == 0x1F ) | |
446 return 0xC0000000u; | |
447 } | |
448 else | |
449 { | |
450 if ( a2.dwRBitMask == 0x7C00 | |
451 && a2.dwGBitMask == 0x3E0 | |
452 && a2.dwBBitMask == 0x1F ) | |
453 return 0x80000000u; | |
454 } | |
455 MessageBoxA(0, "Unsupported pixel format.", "Smacker Error", 0); | |
456 } | |
457 return 0; | |
458 } | |
459 | |
460 //----- (004BE9D8) -------------------------------------------------------- | |
461 void VideoPlayer::Initialize() | |
462 { | |
463 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9 | |
183 | 464 |
21 | 465 uint uBinkVersionMajor = -1, |
466 uBinkVersionMinor = -1; | |
467 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor); | |
468 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor; | |
469 | |
0 | 470 strcpy(pTmpBuf, "anims\\might7.vid"); |
183 | 471 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0); |
472 if ( hMightVid == INVALID_HANDLE_VALUE ) | |
0 | 473 { |
183 | 474 sprintf(pTmpBuf2, "Can't open file - anims\\%s.smk", pTmpBuf); |
475 MessageBoxA(0, pTmpBuf2, "Video File Error", 0); | |
0 | 476 return; |
477 } | |
478 strcpy(pTmpBuf, "anims\\magic7.vid"); | |
183 | 479 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0); |
480 if ( hMagicVid == INVALID_HANDLE_VALUE ) | |
0 | 481 { |
482 if ( !bCanLoadFromCD ) | |
183 | 483 { |
484 sprintf(pTmpBuf2, "Can't open file - anims\\%s.smk", pTmpBuf); | |
485 MessageBoxA(0, pTmpBuf2, "Video File Error", 0); | |
486 return; | |
487 } | |
90 | 488 sprintf(pTmpBuf2, "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf); |
183 | 489 hMagicVid = CreateFileA(pTmpBuf2, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0); |
490 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE ) | |
0 | 491 { |
183 | 492 sprintf(pTmpBuf2, "Can't open file - %s", pTmpBuf); |
493 MessageBoxA(0, pTmpBuf2, "Video File Error", 0); | |
494 return; | |
0 | 495 } |
496 } | |
183 | 497 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0); |
498 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); | |
0 | 499 pMagicVideoHeaders = 0; |
500 pMightVideoHeaders = 0; | |
183 | 501 pMightVideoHeaders = (MovieHeader *)pAllocator->AllocNamedChunk(0, 44 * uNumMightVideoHeaders + 2, 0); |
502 pMagicVideoHeaders = (MovieHeader *)pAllocator->AllocNamedChunk(pMagicVideoHeaders, 44 * uNumMagicVideoHeaders + 2, 0); | |
0 | 503 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); |
504 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0); | |
505 } | |
506 | |
507 //----- (004BEB41) -------------------------------------------------------- | |
508 void VideoPlayer::Prepare() | |
509 { | |
186 | 510 VideoPlayer *pVideoPlayer; // esi@1 |
0 | 511 IDirectDrawSurface *v2; // [sp-4h] [bp-Ch]@5 |
512 | |
186 | 513 pVideoPlayer = this; |
0 | 514 pEventTimer->Pause(); |
186 | 515 pVideoPlayer->bStopBeforeSchedule = 0; |
0 | 516 if ( pAudioPlayer->hAILRedbook ) |
517 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
186 | 518 pVideoPlayer->field_54 = 1; |
519 pVideoPlayer->hWindow = hWnd; | |
520 pVideoPlayer->pSmackerMovie = 0; | |
521 pVideoPlayer->pSmackerBuffer = 0; | |
522 pVideoPlayer->pBinkMovie = 0; | |
523 pVideoPlayer->pBinkBuffer = 0; | |
524 pVideoPlayer->bPlayingMovie = 0; | |
525 pVideoPlayer->bFirstFrame = 0; | |
526 pVideoPlayer->bUsingSmackerMMX = SmackUseMMX(1); | |
0 | 527 BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver); |
183 | 528 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5 ) |
0 | 529 v2 = (IDirectDrawSurface*)pRenderer->pBackBuffer4; |
530 else | |
531 v2 = (IDirectDrawSurface*)pRenderer->pBackBuffer2; | |
186 | 532 pVideoPlayer->uBinkDirectDrawSurfaceType = BinkDDSurfaceType(v2); |
0 | 533 _flushall(); |
534 } | |
535 | |
536 | |
537 //----- (004BEBD7) -------------------------------------------------------- | |
538 void VideoPlayer::Unload() | |
539 { | |
180 | 540 VideoPlayer *pVideoPlayer; // esi@1 |
541 _BINK *pBinkMovie; // eax@1 | |
542 _BINKBUF *pBinkBuffer; // eax@3 | |
543 _SMACK *pSmackerMovie; // eax@5 | |
0 | 544 |
180 | 545 pVideoPlayer = this; |
546 pBinkMovie = this->pBinkMovie; | |
547 if ( pBinkMovie ) | |
0 | 548 { |
180 | 549 BinkPause(pBinkMovie, 1); |
550 Sleep(300); | |
551 BinkClose(pVideoPlayer->pBinkMovie); | |
552 pVideoPlayer->pBinkMovie = 0; | |
0 | 553 } |
180 | 554 pBinkBuffer = pVideoPlayer->pBinkBuffer; |
555 if ( pBinkBuffer ) | |
0 | 556 { |
180 | 557 pBinkBuffer->pTargetDDrawSurface->Release(); |
558 pVideoPlayer->pBinkBuffer->pTargetDDrawSurface = 0; | |
559 free(pVideoPlayer->pBinkBuffer); | |
560 pVideoPlayer->pBinkBuffer = 0; | |
0 | 561 } |
180 | 562 pSmackerMovie = pVideoPlayer->pSmackerMovie; |
563 if ( pSmackerMovie ) | |
0 | 564 { |
180 | 565 SmackSoundOnOff(pSmackerMovie, 0); |
566 SmackClose(pVideoPlayer->pSmackerMovie); | |
567 pVideoPlayer->pSmackerMovie = 0; | |
0 | 568 } |
180 | 569 if ( pVideoPlayer->pSmackerBuffer ) |
0 | 570 { |
180 | 571 SmackBufferClose(pVideoPlayer->pSmackerBuffer); |
572 pVideoPlayer->pSmackerBuffer = 0; | |
0 | 573 } |
180 | 574 if ( pVideoPlayer->pSmackMovieBlit ) |
0 | 575 { |
180 | 576 SmackBlitClose(pVideoPlayer->pSmackMovieBlit); |
577 pVideoPlayer->pSmackMovieBlit = 0; | |
0 | 578 } |
180 | 579 pVideoPlayer->field_54 = 0; |
580 pVideoPlayer->uMovieFormat = 0; | |
581 pVideoPlayer->dword_0000A0 = 0; | |
582 memset(pVideoPlayer->pCurrentMovieName, 0, 0x40); | |
0 | 583 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) |
584 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | |
585 pEventTimer->Resume(); | |
586 } | |
587 | |
588 //----- (004BECD5) -------------------------------------------------------- | |
21 | 589 void VideoPlayer::FastForwardToFrame(unsigned int uDstFrameNum) |
0 | 590 { |
591 VideoPlayer *v2; // esi@1 | |
592 unsigned int v3; // eax@1 | |
593 | |
594 v2 = this; | |
595 v3 = this->uMovieFormat; | |
596 if ( v3 == 2 ) | |
597 { | |
21 | 598 if (uDstFrameNum) |
0 | 599 { |
21 | 600 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : |
601 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame : | |
602 nullptr; | |
603 while (*pCurrentFrame < uDstFrameNum) | |
0 | 604 { |
21 | 605 BinkDoFrame(pBinkMovie); |
606 BinkNextFrame(pBinkMovie); | |
0 | 607 } |
608 } | |
609 } | |
610 else | |
611 { | |
612 if ( v3 != 1 ) | |
613 return; | |
614 SmackSoundOnOff(this->pSmackerMovie, 0); | |
21 | 615 if (uDstFrameNum) |
0 | 616 { |
21 | 617 while ( v2->pSmackerMovie->FrameNum < uDstFrameNum) |
0 | 618 { |
619 SmackDoFrame(v2->pSmackerMovie); | |
620 SmackNextFrame(v2->pSmackerMovie); | |
621 } | |
622 } | |
623 } | |
624 Unload(); | |
625 } | |
21 | 626 |
0 | 627 |
628 //----- (004BED4F) -------------------------------------------------------- | |
629 void VideoPlayer::BinkDrawFrame(HWND hWnd, int a3, int a4) | |
630 { | |
21 | 631 //VideoPlayer *v4; // esi@1 |
0 | 632 _BINKBUF *v5; // eax@5 |
633 LONG v6; // edx@6 | |
634 int v7; // ecx@6 | |
635 LONG v8; // edx@6 | |
636 struct tagRECT a3a; // [sp+8h] [bp-20h]@10 | |
637 struct tagRECT a1; // [sp+18h] [bp-10h]@6 | |
638 | |
21 | 639 //v4 = this; |
0 | 640 if ( this->pBinkMovie && this->pBinkBuffer ) |
641 { | |
21 | 642 BinkDoFrame(pBinkMovie); |
643 BinkGetRects(pBinkMovie, pBinkBuffer->uBinkDDSurfaceType); | |
644 if ( BinkLockBuffer(pBinkBuffer) ) | |
0 | 645 { |
183 | 646 BinkCopyToBuffer(pBinkMovie, pBinkBuffer->pDDrawSurfaceData, pBinkBuffer->uDDrawSurfacePitch, pBinkBuffer->uHeight, |
647 0, 0, pBinkBuffer->uBinkDDSurfaceType); | |
21 | 648 BinkUnlockBuffer(pBinkBuffer); |
0 | 649 } |
21 | 650 v5 = pBinkBuffer; |
0 | 651 if ( pRenderer->bWindowMode ) |
652 { | |
653 v6 = v5->uRectX; | |
654 a1.left = v6; | |
655 a1.top = v5->uRectY; | |
656 v7 = v6 + v5->uWidth; | |
657 a1.right = v6 + v5->uWidth; | |
658 v8 = a1.top + v5->uHeight; | |
659 } | |
660 else | |
661 { | |
662 a1.left = 0; | |
663 a1.top = 0; | |
664 v7 = v5->uWidth; | |
665 a1.right = v5->uWidth; | |
666 v8 = v5->uHeight; | |
667 } | |
668 a1.bottom = v8; | |
669 if ( a4 ) | |
670 { | |
671 a1.right = v5->uWidth + v7; | |
672 a1.bottom = v5->uHeight + v8; | |
673 } | |
674 a3a.left = 0; | |
675 a3a.top = 0; | |
676 a3a.right = v5->uWidth; | |
677 a3a.bottom = v5->uHeight; | |
678 pRenderer->BltToFront(&a1, v5->pTargetDDrawSurface, &a3a, 0x1000000u); | |
21 | 679 |
680 | |
681 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame : | |
682 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame: | |
683 nullptr; | |
684 int *pNumFrames = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uNumFrames : | |
685 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uNumFrames : | |
686 nullptr; | |
687 | |
688 if (*pCurrentFrame != *pNumFrames - 1 || bLoopPlaying) | |
689 BinkNextFrame(pBinkMovie); | |
0 | 690 else |
691 Unload(); | |
692 } | |
693 } | |
21 | 694 |
695 | |
0 | 696 |
697 //----- (004BEE6B) -------------------------------------------------------- | |
698 void VideoPlayer::SmackDrawFrame(HWND hWnd, int a3, int a4) | |
699 { | |
700 VideoPlayer *v4; // esi@1 | |
701 _SMACK *v5; // eax@3 | |
702 unsigned int v6; // eax@5 | |
703 char v7; // zf@5 | |
704 int v8; // eax@11 | |
705 _SMACK *v9; // eax@13 | |
706 _SMACK *v10; // eax@16 | |
707 _SMACK *v11; // eax@20 | |
708 unsigned int v12; // [sp-1Ch] [bp-34h]@7 | |
709 LONG v13; // [sp-18h] [bp-30h]@7 | |
710 LONG v14; // [sp-14h] [bp-2Ch]@7 | |
711 signed int v15; // [sp-10h] [bp-28h]@7 | |
712 signed int v16; // [sp-Ch] [bp-24h]@7 | |
713 signed int v17; // [sp-8h] [bp-20h]@7 | |
714 struct tagPOINT Point; // [sp+8h] [bp-10h]@7 | |
715 unsigned short *pOutSurface; // [sp+10h] [bp-8h]@5 | |
716 unsigned int uPixelsPerRow; // [sp+14h] [bp-4h]@5 | |
717 | |
718 v4 = this; | |
719 if ( !pRenderer->bWindowMode || GetFocus() == hWnd ) | |
720 { | |
721 v5 = v4->pSmackerMovie; | |
722 if ( v5->NewPalette ) | |
723 SmackBlitSetPalette(v4->pSmackMovieBlit, v5->Palette, v5->PalType); | |
724 SmackDoFrame(v4->pSmackerMovie); | |
725 pRenderer->LockFrontBuffer((void **)&pOutSurface, &uPixelsPerRow); | |
726 v6 = 2 * uPixelsPerRow; | |
727 v7 = v4->bFirstFrame == 0; | |
728 uPixelsPerRow *= 2; | |
729 if ( !v7 ) | |
730 { | |
731 if ( pRenderer->bWindowMode ) | |
732 { | |
733 Point.y = 0; | |
734 Point.x = 0; | |
735 ClientToScreen(hWnd, &Point); | |
736 v17 = -1; | |
737 v16 = 480; | |
738 v15 = 640; | |
739 v14 = Point.y; | |
740 v13 = Point.x; | |
741 v12 = uPixelsPerRow; | |
742 } | |
743 else | |
744 { | |
745 v17 = -1; | |
746 v16 = 480; | |
747 v15 = 640; | |
748 v14 = 0; | |
749 v13 = 0; | |
750 v12 = v6; | |
751 } | |
752 SmackBlitClear(v4->pSmackMovieBlit, pOutSurface, v12, v13, v14, v15, v16, v17); | |
753 v4->bFirstFrame = 0; | |
754 } | |
755 pRenderer->RestoreFrontBuffer(); | |
756 if ( pRenderer->bWindowMode ) | |
757 { | |
758 Point.y = 0; | |
759 Point.x = 0; | |
760 ClientToScreen(hWnd, &Point); | |
761 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
762 if ( a4 ) | |
763 { | |
764 while ( v8 ) | |
765 { | |
766 v9 = v4->pSmackerMovie; | |
767 SmackBlit( | |
768 v4->pSmackMovieBlit, | |
769 pOutSurface, | |
770 uPixelsPerRow, | |
771 v9->LastRectx + Point.x / 2, | |
772 a3 + v9->LastRecty + Point.y / 2, | |
773 v4->pSomeSmackerBuffer, | |
774 v9->Width, | |
775 v9->LastRectx, | |
776 v9->LastRecty, | |
777 v9->LastRectw, | |
778 v9->LastRecth); | |
779 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); | |
780 } | |
781 } | |
782 else | |
783 { | |
784 while ( v8 ) | |
785 { | |
786 v10 = v4->pSmackerMovie; | |
183 | 787 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, Point.x + v10->LastRectx, a3 + Point.y + v10->LastRecty, |
788 v4->pSomeSmackerBuffer, v10->Width, v10->LastRectx, v10->LastRecty, v10->LastRectw, v10->LastRecth); | |
0 | 789 v8 = SmackToBufferRect(v4->pSmackerMovie, 0); |
790 } | |
791 } | |
792 } | |
793 else | |
794 { | |
795 while ( SmackToBufferRect(v4->pSmackerMovie, 0) ) | |
796 { | |
797 v11 = v4->pSmackerMovie; | |
183 | 798 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, v11->LastRectx, a3 + v11->LastRecty, v4->pSomeSmackerBuffer, |
799 v11->Width, v11->LastRectx, v11->LastRecty, v11->LastRectw, v11->LastRecth); | |
0 | 800 } |
801 } | |
802 pRenderer->UnlockFrontBuffer(); | |
803 if ( v4->pSmackerMovie->FrameNum != v4->pSmackerMovie->Frames - 1 || v4->bLoopPlaying ) | |
804 SmackNextFrame(v4->pSmackerMovie); | |
805 else | |
806 Unload(); | |
807 } | |
808 } | |
809 // 4D83D8: using guessed type int __stdcall SmackBlitSetPalette(int, int, int); | |
810 // 4D83DC: using guessed type int __stdcall SmackBlitClear(int, int, int, int, int, int, int, int); | |
811 // 4D83E0: using guessed type int __stdcall SmackToBufferRect(int, int); | |
812 // 4D83E4: using guessed type int __stdcall SmackDoFrame(int); | |
813 // 4D83E8: using guessed type int __stdcall SmackNextFrame(int); | |
814 // 4D8404: using guessed type int __stdcall SmackBlit(int, int, int, int, int, int, int, int, int, int, int); | |
815 | |
816 //----- (004BF08B) -------------------------------------------------------- | |
817 void VideoPlayer::SmackUpdatePalette(HWND hWnd) | |
818 { | |
819 VideoPlayer *v2; // esi@1 | |
820 unsigned __int16 *v3; // ebx@1 | |
821 unsigned int v4; // edi@1 | |
822 unsigned int v5; // eax@1 | |
823 _SMACK *v6; // eax@1 | |
824 | |
825 v2 = this; | |
826 pRenderer->BeginScene(); | |
827 v3 = pRenderer->pTargetSurface; | |
828 v4 = pRenderer->uTargetSurfacePitch; | |
829 v5 = SmackCheckSurfaceFromat(); | |
830 SmackToBuffer(v2->pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5); | |
831 v6 = v2->pSmackerMovie; | |
832 if ( v6->NewPalette ) | |
833 { | |
834 SmackBufferNewPalette((long)pSmackerBuffer, (long)v6->Palette, LOWORD(v6->PalType)); | |
835 SmackColorRemapWithTrans( | |
836 (long)pSmackerMovie, | |
837 (long)pSmackerBuffer->Palette, | |
838 (long)pSmackerBuffer->MaxPalColors, | |
839 (long)pSmackerBuffer->PalType, | |
840 1000); | |
841 } | |
842 SmackDoFrame(v2->pSmackerMovie); | |
843 if ( v2->pSmackerMovie->FrameNum != v2->pSmackerMovie->Frames - 1 || v2->bLoopPlaying ) | |
844 SmackNextFrame(v2->pSmackerMovie); | |
845 else | |
846 Unload(); | |
847 pRenderer->EndScene(); | |
848 } | |
3 | 849 |
0 | 850 |
21 | 851 |
852 | |
853 | |
0 | 854 //----- (004BF141) -------------------------------------------------------- |
855 _BINK *VideoPlayer::OpenBink(const char *pName) | |
856 { | |
21 | 857 //VideoPlayer *v2; // esi@1 |
0 | 858 signed int v3; // edi@1 |
859 int v4; // ebx@2 | |
860 signed int v5; // edi@5 | |
861 int v6; // ebx@6 | |
862 HANDLE v8; // [sp-8h] [bp-18h]@10 | |
863 unsigned int v9; // [sp-4h] [bp-14h]@10 | |
864 | |
21 | 865 for (uint i = 0; i < uNumMightVideoHeaders; ++i) |
866 if (!strcmpi(pName, pMightVideoHeaders[i].pVideoName)) | |
0 | 867 { |
21 | 868 SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); |
869 | |
870 if (uBinkVersion < 0x0003000000000000) | |
80 | 871 return BinkOpen(hMightVid, 0x8800000); |
21 | 872 else |
873 return BinkOpen(hMightVid, 0x82000000); | |
0 | 874 } |
21 | 875 |
876 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
877 if (!strcmpi(pName, pMagicVideoHeaders[i].pVideoName)) | |
0 | 878 { |
21 | 879 SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); |
880 | |
881 if (uBinkVersion < 0x0003000000000000) | |
80 | 882 return BinkOpen(hMagicVid, 0x8800000); |
21 | 883 else |
884 return BinkOpen(hMagicVid, 0x82000000); | |
0 | 885 } |
21 | 886 |
887 return nullptr; | |
0 | 888 } |
889 //----- (004BF1E6) -------------------------------------------------------- | |
890 _SMACK *VideoPlayer::OpenSmack(const char *pFilename) | |
891 { | |
180 | 892 VideoPlayer *pVideoPlayer; // esi@1 |
0 | 893 signed int v3; // edi@1 |
894 int v4; // ebx@2 | |
895 signed int v5; // edi@5 | |
183 | 896 //int v6; // ebx@6 |
897 //HANDLE v8; // [sp-Ch] [bp-1Ch]@10 | |
898 //unsigned int v9; // [sp-8h] [bp-18h]@10 | |
899 //signed int v10; // [sp-4h] [bp-14h]@10 | |
0 | 900 |
180 | 901 pVideoPlayer = this; |
0 | 902 if ( (signed int)this->uNumMightVideoHeaders > 0 ) |
903 { | |
183 | 904 for ( v3 = 0; v3 < (signed int)pVideoPlayer->uNumMightVideoHeaders; ++v3) |
0 | 905 { |
183 | 906 v4 = _strcmpi(pVideoPlayer->pMightVideoHeaders[v3].pVideoName, pFilename); |
907 if ( !v4 ) | |
908 { | |
909 SetFilePointer(pVideoPlayer->hMightVid, pVideoPlayer->pMightVideoHeaders[v3].uFileOffset, 0, 0); | |
910 return SmackOpen(pVideoPlayer->hMightVid, 0x7140, -1); | |
911 } | |
0 | 912 } |
913 } | |
914 v5 = 0; | |
180 | 915 if ( (signed int)pVideoPlayer->uNumMagicVideoHeaders > 0 ) |
0 | 916 { |
183 | 917 while ( _strcmpi(pVideoPlayer->pMagicVideoHeaders[v5].pVideoName, pFilename) ) |
0 | 918 { |
919 ++v5; | |
180 | 920 if ( v5 >= (signed int)pVideoPlayer->uNumMagicVideoHeaders ) |
0 | 921 return 0; |
922 } | |
180 | 923 SetFilePointer(pVideoPlayer->hMagicVid, pVideoPlayer->pMagicVideoHeaders[v5].uFileOffset, 0, 0); |
183 | 924 return SmackOpen(pVideoPlayer->hMagicVid, 0x7140, -1); |
0 | 925 } |
926 return 0; | |
927 } | |
928 | |
929 //----- (004BF28F) -------------------------------------------------------- | |
930 void VideoPlayer::_4BF28F(const char *pMovieName, unsigned int a3_1) | |
931 { | |
932 VideoPlayer *v3; // esi@1 | |
933 std::string *v4; // ecx@3 | |
934 _SMACK *v5; // eax@4 | |
935 _SMACK *v6; // eax@7 | |
936 int v7; // eax@7 | |
937 int v8; // ecx@7 | |
938 unsigned int v9; // ebx@8 | |
939 unsigned int v10; // eax@8 | |
940 signed __int64 v11; // qax@9 | |
941 char *v12; // [sp-20h] [bp-54h]@3 | |
942 int v13; // [sp-1Ch] [bp-50h]@3 | |
943 std::string v14; // [sp-18h] [bp-4Ch]@3 | |
944 const char *v15; // [sp-8h] [bp-3Ch]@3 | |
945 int v16; // [sp-4h] [bp-38h]@3 | |
946 char Str2[0x30]; // [sp+Ch] [bp-28h]@4 | |
947 std::string *v18; // [sp+3Ch] [bp+8h]@3 | |
948 std::string *v19; // [sp+3Ch] [bp+8h]@5 | |
949 unsigned __int16 *v20; // [sp+3Ch] [bp+8h]@8 | |
950 | |
951 v3 = this; | |
952 if ( !this->field_54 ) | |
953 { | |
954 Prepare(); | |
955 v3->bLoopPlaying = a3_1; | |
956 __debugbreak(); // VideoPlayer is larger than this | |
957 if ( v3[1].pVideoFrame.pName[0] == 1 ) | |
958 { | |
959 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925"; | |
960 v12 = "Unsupported Bink playback!"; | |
961 LABEL_6: | |
962 MessageBoxA(nullptr, v12, v15, 0); | |
963 return; | |
964 } | |
96 | 965 sprintf(Str2, "%s.smk", pMovieName); |
0 | 966 v5 = OpenSmack(Str2); |
967 v3->pSmackerMovie = v5; | |
968 if ( !v5 ) | |
969 { | |
970 v3->Unload(); | |
96 | 971 sprintf(pTmpBuf, "Can't load %s", &Str2); |
0 | 972 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937"; |
973 v12 = pTmpBuf; | |
974 goto LABEL_6; | |
975 } | |
976 v16 = (int)pMovieName; | |
977 v3->uMovieFormat = 1; | |
978 strcpy(v3->pCurrentMovieName, (const char *)v16); | |
979 v6 = v3->pSmackerMovie; | |
980 v3->dword_0000A0 = 1; | |
981 v7 = SmackBufferOpen(v3->hWindow, 4, LOWORD(v6->Width), LOWORD(v6->Height), LOWORD(v6->Width), LOWORD(v6->Height)); | |
982 v3->pSmackerBuffer = (_SMACKBUF *)v7; | |
983 if ( v7 ) | |
984 { | |
985 pRenderer->BeginScene(); | |
986 v9 = pRenderer->uTargetSurfacePitch; | |
987 v20 = pRenderer->pTargetSurface; | |
988 v10 = SmackCheckSurfaceFromat(); | |
989 SmackToBuffer(v3->pSmackerMovie, 8, 8, 2 * v9, pRenderer->field_14, v20, v10); | |
990 pRenderer->EndScene(); | |
991 } | |
992 v16 = 32767; | |
993 v11 = (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0); | |
994 SmackVolumePan(v8, HIDWORD(v11), v3->pSmackerMovie, 1040384, v11, 32767); | |
995 } | |
996 } | |
997 | |
998 //----- (004BF3F9) -------------------------------------------------------- | |
999 bool VideoPlayer::AnyMovieLoaded() | |
1000 { | |
1001 return pSmackerMovie || pBinkMovie; | |
1002 } | |
1003 | |
1004 //----- (004BF411) -------------------------------------------------------- | |
1005 void VideoPlayer::OpenMovie(const char *pFilename, unsigned int bLoop, int a4) | |
1006 { | |
180 | 1007 VideoPlayer *pVideoPlayer; // esi@1 |
1008 _BINK *pVideoOpen; // eax@2 | |
0 | 1009 _SMACK *v6; // eax@3 |
13
17150bdf321e
исправлено неполное воспроизведение роликов, бинков
Серик@ПончиК
parents:
3
diff
changeset
|
1010 _BINK *pBinkMovie; // eax@5 |
0 | 1011 _SMACK *v8; // eax@7 |
1012 char *v9; // eax@7 | |
1013 unsigned int v10; // eax@11 | |
1014 _SMACKBLIT *v11; // eax@14 | |
1015 const char *v12; // [sp-4h] [bp-38h]@8 | |
1016 char pVideoName[120]; // [sp+Ch] [bp-28h]@2 | |
1017 | |
180 | 1018 pVideoPlayer = this; |
0 | 1019 if ( !this->field_54 ) |
1020 { | |
1021 Prepare(); | |
180 | 1022 pVideoPlayer->bLoopPlaying = bLoop; |
0 | 1023 sprintf(pVideoName, "%s.bik", pFilename); |
180 | 1024 pVideoOpen = OpenBink(pVideoName); |
1025 pVideoPlayer->pBinkMovie = pVideoOpen; | |
1026 if ( pVideoOpen ) | |
0 | 1027 { |
180 | 1028 pVideoPlayer->uMovieFormat = 2; |
1029 strcpy(pVideoPlayer->pCurrentMovieName, pFilename); | |
1030 pBinkMovie = pVideoPlayer->pBinkMovie; | |
1031 pVideoPlayer->dword_0000A0 = 1; | |
13
17150bdf321e
исправлено неполное воспроизведение роликов, бинков
Серик@ПончиК
parents:
3
diff
changeset
|
1032 if ( pBinkMovie ) |
180 | 1033 pVideoPlayer->pBinkBuffer = CreateBinkBuffer(pVideoPlayer->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0); |
0 | 1034 } |
1035 else | |
1036 { | |
1037 Unload(); | |
1038 sprintf(pVideoName, "%s.smk", pFilename); | |
1039 v6 = OpenSmack(pVideoName); | |
180 | 1040 pVideoPlayer->pSmackerMovie = v6; |
0 | 1041 if ( !v6 ) |
1042 { | |
1043 Unload(); | |
96 | 1044 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); |
0 | 1045 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1046 return; | |
1047 } | |
180 | 1048 pVideoPlayer->uMovieFormat = 1; |
1049 strcpy(pVideoPlayer->pCurrentMovieName, pFilename); | |
1050 v8 = pVideoPlayer->pSmackerMovie; | |
1051 pVideoPlayer->dword_0000A0 = 2; | |
0 | 1052 v9 = (char *)malloc(v8->Width * v8->Height); |
180 | 1053 pVideoPlayer->pSomeSmackerBuffer = v9; |
0 | 1054 if ( !v9 ) |
1055 { | |
1056 Unload(); | |
1057 v12 = "Can't allocate memory for buffer"; | |
96 | 1058 sprintf(pVideoName, v12); |
180 | 1059 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1060 return; | |
0 | 1061 } |
180 | 1062 SmackToBuffer(pVideoPlayer->pSmackerMovie, 0, 0, pVideoPlayer->pSmackerMovie->Width, pVideoPlayer->pSmackerMovie->Height, v9, 0); |
0 | 1063 if ( a4 ) |
1064 { | |
1065 if ( (unsigned int)uCPUSpeed < 165 ) | |
1066 { | |
1067 v10 = SmackCheckSurfaceFromat() | 2; | |
1068 } | |
1069 else | |
1070 { | |
1071 v10 = SmackCheckSurfaceFromat(); | |
1072 LOBYTE(v10) = v10 | 6; | |
1073 } | |
1074 } | |
1075 else | |
1076 { | |
1077 v10 = SmackCheckSurfaceFromat(); | |
1078 } | |
1079 v11 = SmackBlitOpen(v10); | |
180 | 1080 pVideoPlayer->pSmackMovieBlit = v11; |
0 | 1081 if ( !v11 ) |
1082 { | |
1083 Unload(); | |
1084 v12 = "Failed to open Blit API"; | |
180 | 1085 sprintf(pVideoName, v12); |
1086 MessageBoxA(0, pVideoName, "Smacker Error", 0); | |
1087 return; | |
0 | 1088 } |
1089 } | |
1090 } | |
1091 } | |
21 | 1092 |
0 | 1093 |
1094 //----- (004BF5B2) -------------------------------------------------------- | |
1095 void VideoPlayer::_4BF5B2() | |
1096 { | |
1097 VideoPlayer *v1; // esi@1 | |
1098 unsigned int v2; // eax@1 | |
1099 _BINK **v3; // edi@2 | |
1100 | |
1101 v1 = this; | |
1102 v2 = this->uMovieFormat; | |
1103 if ( v2 == 2 ) | |
1104 { | |
1105 v3 = &this->pBinkMovie; | |
1106 BinkGoto(pBinkMovie, 1, 0); | |
1107 BinkDoFrame(pBinkMovie); | |
1108 BinkNextFrame(pBinkMovie); | |
1109 } | |
1110 else | |
1111 { | |
1112 if ( v2 != 1 ) | |
1113 return; | |
1114 SmackGoto(pSmackerMovie, 1); | |
1115 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1116 { | |
1117 SmackDoFrame(pSmackerMovie); | |
1118 SmackNextFrame(pSmackerMovie); | |
1119 } | |
1120 } | |
1121 pMouse->_469E24(); | |
1122 if ( ptr_507BC0 && ptr_507BC0->ptr_1C == (void *)165 && !v1->pSmackerMovie ) | |
1123 { | |
1124 bGameoverLoop = 1; | |
1125 sub_4BD8B5(); | |
1126 ptr_507BC0->Release(); | |
1127 pParty->uFlags &= 0xFFFFFFFDu; | |
1128 if ( EnterHouse((enum HOUSE_TYPE)165) ) | |
1129 { | |
1130 pAudioPlayer->PlaySound(SOUND_0, 0, 0, -1, 0, 0, 0, 0); | |
2 | 1131 ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0); |
59 | 1132 ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0); |
1133 ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0); | |
1134 ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0); | |
1135 ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0); | |
0 | 1136 } |
1137 bGameoverLoop = 0; | |
1138 } | |
1139 } | |
1140 | |
1141 //----- (004BF73A) -------------------------------------------------------- | |
1142 void VideoPlayer::_4BF73A() | |
1143 { | |
1144 VideoPlayer *v1; // esi@1 | |
1145 int v2; // edi@1 | |
1146 unsigned __int8 v3; // bl@1 | |
1147 int v4; // edi@1 | |
1148 char Source[32]; // [sp+Ch] [bp-40h]@1 | |
1149 | |
1150 v1 = this; | |
1151 v2 = this->dword_0000A0; | |
1152 v3 = LOBYTE(this->bLoopPlaying); | |
1153 strcpy(Source, this->pCurrentMovieName); | |
1154 Unload(); | |
1155 v4 = v2 - 1; | |
1156 if ( v4 ) | |
1157 { | |
1158 if ( v4 == 1 ) | |
1159 OpenMovie(Source, v3, 1); | |
1160 } | |
1161 else | |
1162 { | |
1163 _4BF28F(Source, v3); | |
1164 } | |
1165 } | |
1166 | |
1167 //----- (004BF8F6) -------------------------------------------------------- | |
1168 void VideoPlayer::PlayDeathMovie() | |
1169 { | |
1170 bStopBeforeSchedule = 0; | |
1171 field_40 = 0; | |
1172 pGame->pCShow->PlayMovie(MOVIE_Death, 1); | |
1173 } |