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