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