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
|
|
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
|
|
61
|
|
62 //----- (004BFE2D) --------------------------------------------------------
|
|
63 _BINKBUF *VideoPlayer::CreateBinkBuffer(HWND hWindow, unsigned int uWidth, unsigned int uHeight, char a4)
|
|
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;
|
|
80 hWnd = hWindow;
|
|
81 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u )
|
|
82 {
|
|
83 v4 = 0;
|
|
84 v15 = 0;
|
|
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
|
|
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;
|
|
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
|
|
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 }
|
|
194
|
|
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;
|
|
207 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u )
|
|
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;
|
|
219
|
|
220 if (uBinkVersion < 0x0003000000000000)
|
|
221 BYTE3(v1->uBinkDDSurfaceType) |= 0x80u;
|
|
222 else
|
|
223 BYTE3(v1->uBinkDDSurfaceType) |= 0x04;
|
|
224
|
|
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;
|
|
247
|
|
248 if (uBinkVersion < 0x0003000000000000)
|
|
249 __asm int 3;
|
|
250 else
|
|
251 BYTE3(v1->uBinkDDSurfaceType) |= 4u;
|
|
252
|
|
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;
|
|
281
|
|
282 if (uBinkVersion < 0x0003000000000000)
|
|
283 BYTE3(_this->uBinkDDSurfaceType) &= 0x7F;
|
|
284 else
|
|
285 BYTE3(_this->uBinkDDSurfaceType) &= 0xFB;
|
|
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;
|
165
|
296 pVideoPlayer->pResetflag = 0;
|
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 )
|
|
310 pGame->pCShow->PlayMovie(MOVIE_Intro, 1);
|
|
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();
|
|
323 if (!bNoSound && pAudioPlayer->hAILRedbook )
|
|
324 {
|
|
325 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
|
|
326 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
|
|
327 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &uTrackStartMS, &uTrackEndMS);
|
|
328 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS);
|
|
329 }
|
|
330 bGameoverLoop = 0;
|
|
331 }
|
|
332
|
|
333
|
|
334
|
|
335
|
|
336 //----- (004BE70E) --------------------------------------------------------
|
3
|
337 void __fastcall VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int uGameState)
|
0
|
338 {
|
|
339 int v4; // ebp@1
|
|
340 const char *pName; // edi@1
|
|
341 MSG Msg; // [sp+Ch] [bp-1Ch]@12
|
|
342
|
|
343 v4 = a2;
|
|
344 pName = pMovieName;
|
|
345 if ( !(dword_6BE364_game_settings_1 & 0x44) )
|
|
346 {
|
|
347 if ( a2 == 2 )
|
|
348 v4 = 0;
|
|
349 ShowCursor(0);
|
|
350 pVideoPlayer->OpenMovie(pName, 0, ScreenSizeFlag);
|
|
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 }
|
151
|
363 pCurrentScreen = SCREEN_VIDEO;
|
0
|
364 if ( pVideoPlayer->uMovieFormat == 2 )
|
|
365 {
|
|
366 if ( pVideoPlayer->pBinkMovie )
|
|
367 {
|
|
368 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
|
|
369 while ( pVideoPlayer->pBinkMovie )
|
|
370 {
|
|
371 if ( pVideoPlayer->bStopBeforeSchedule )
|
|
372 break;
|
|
373 while ( PeekMessageA(&Msg, 0, 0, 0, 1) )
|
|
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 )
|
|
386 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
|
|
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 {
|
|
398 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
|
|
399 while ( pVideoPlayer->pSmackerMovie )
|
|
400 {
|
|
401 if ( pVideoPlayer->bStopBeforeSchedule )
|
|
402 break;
|
|
403 while ( PeekMessageW(&Msg, 0, 0, 0, 1) )
|
|
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 }
|
4
|
412 GUI_MainMenuMessageProc();
|
0
|
413 if ( !pVideoPlayer->pSmackerMovie )
|
|
414 break;
|
|
415 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule )
|
|
416 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
|
|
417 }
|
|
418 }
|
|
419 }
|
|
420 }
|
3
|
421 if ( uGameState == GAME_FINISHED )
|
151
|
422 pCurrentScreen = SCREEN_GAME;
|
0
|
423 pVideoPlayer->bPlayingMovie = 0;
|
|
424 ShowCursor(1);
|
151
|
425 if ( pCurrentScreen == SCREEN_VIDEO )
|
|
426 pCurrentScreen = SCREEN_GAME;
|
0
|
427 }
|
|
428 }
|
|
429
|
|
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
|
|
464
|
|
465 uint uBinkVersionMajor = -1,
|
|
466 uBinkVersionMinor = -1;
|
|
467 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor);
|
|
468 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor;
|
|
469
|
|
470 strcpy(pTmpBuf, "anims\\might7.vid");
|
|
471 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
|
|
472 if ( hMightVid == INVALID_HANDLE_VALUE )
|
|
473 {
|
|
474 sprintf(pTmpBuf2, "Can't open file - anims\\%s.smk", pTmpBuf);
|
|
475 MessageBoxA(0, pTmpBuf2, "Video File Error", 0);
|
|
476 return;
|
|
477 }
|
|
478 strcpy(pTmpBuf, "anims\\magic7.vid");
|
|
479 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
|
|
480 if ( hMagicVid == INVALID_HANDLE_VALUE )
|
|
481 {
|
|
482 if ( !bCanLoadFromCD )
|
|
483 {
|
|
484 sprintf(pTmpBuf2, "Can't open file - anims\\%s.smk", pTmpBuf);
|
|
485 MessageBoxA(0, pTmpBuf2, "Video File Error", 0);
|
|
486 return;
|
|
487 }
|
|
488 sprintf(pTmpBuf2, "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf);
|
|
489 hMagicVid = CreateFileA(pTmpBuf2, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
|
|
490 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE )
|
|
491 {
|
|
492 sprintf(pTmpBuf2, "Can't open file - %s", pTmpBuf);
|
|
493 MessageBoxA(0, pTmpBuf2, "Video File Error", 0);
|
|
494 return;
|
|
495 }
|
|
496 }
|
|
497 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0);
|
|
498 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0);
|
|
499 pMagicVideoHeaders = 0;
|
|
500 pMightVideoHeaders = 0;
|
|
501 pMightVideoHeaders = (MovieHeader *)pAllocator->AllocNamedChunk(0, 44 * uNumMightVideoHeaders + 2, 0);
|
|
502 pMagicVideoHeaders = (MovieHeader *)pAllocator->AllocNamedChunk(pMagicVideoHeaders, 44 * uNumMagicVideoHeaders + 2, 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 {
|
|
510 VideoPlayer *pVideoPlayer; // esi@1
|
|
511 IDirectDrawSurface *v2; // [sp-4h] [bp-Ch]@5
|
|
512
|
|
513 pVideoPlayer = this;
|
|
514 pEventTimer->Pause();
|
|
515 pVideoPlayer->bStopBeforeSchedule = 0;
|
|
516 if ( pAudioPlayer->hAILRedbook )
|
|
517 AIL_redbook_pause(pAudioPlayer->hAILRedbook);
|
|
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);
|
|
527 BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver);
|
|
528 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5 )
|
|
529 v2 = (IDirectDrawSurface*)pRenderer->pBackBuffer4;
|
|
530 else
|
|
531 v2 = (IDirectDrawSurface*)pRenderer->pBackBuffer2;
|
|
532 pVideoPlayer->uBinkDirectDrawSurfaceType = BinkDDSurfaceType(v2);
|
|
533 _flushall();
|
|
534 }
|
|
535
|
|
536
|
|
537 //----- (004BEBD7) --------------------------------------------------------
|
|
538 void VideoPlayer::Unload()
|
|
539 {
|
|
540 VideoPlayer *pVideoPlayer; // esi@1
|
|
541 _BINK *pBinkMovie; // eax@1
|
|
542 _BINKBUF *pBinkBuffer; // eax@3
|
|
543 _SMACK *pSmackerMovie; // eax@5
|
|
544
|
|
545 pVideoPlayer = this;
|
|
546 pBinkMovie = this->pBinkMovie;
|
|
547 if ( pBinkMovie )
|
|
548 {
|
|
549 BinkPause(pBinkMovie, 1);
|
|
550 Sleep(300);
|
|
551 BinkClose(pVideoPlayer->pBinkMovie);
|
|
552 pVideoPlayer->pBinkMovie = 0;
|
|
553 }
|
|
554 pBinkBuffer = pVideoPlayer->pBinkBuffer;
|
|
555 if ( pBinkBuffer )
|
|
556 {
|
|
557 pBinkBuffer->pTargetDDrawSurface->Release();
|
|
558 pVideoPlayer->pBinkBuffer->pTargetDDrawSurface = 0;
|
|
559 free(pVideoPlayer->pBinkBuffer);
|
|
560 pVideoPlayer->pBinkBuffer = 0;
|
|
561 }
|
|
562 pSmackerMovie = pVideoPlayer->pSmackerMovie;
|
|
563 if ( pSmackerMovie )
|
|
564 {
|
|
565 SmackSoundOnOff(pSmackerMovie, 0);
|
|
566 SmackClose(pVideoPlayer->pSmackerMovie);
|
|
567 pVideoPlayer->pSmackerMovie = 0;
|
|
568 }
|
|
569 if ( pVideoPlayer->pSmackerBuffer )
|
|
570 {
|
|
571 SmackBufferClose(pVideoPlayer->pSmackerBuffer);
|
|
572 pVideoPlayer->pSmackerBuffer = 0;
|
|
573 }
|
|
574 if ( pVideoPlayer->pSmackMovieBlit )
|
|
575 {
|
|
576 SmackBlitClose(pVideoPlayer->pSmackMovieBlit);
|
|
577 pVideoPlayer->pSmackMovieBlit = 0;
|
|
578 }
|
|
579 pVideoPlayer->field_54 = 0;
|
|
580 pVideoPlayer->uMovieFormat = 0;
|
|
581 pVideoPlayer->dword_0000A0 = 0;
|
|
582 memset(pVideoPlayer->pCurrentMovieName, 0, 0x40);
|
|
583 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop )
|
|
584 AIL_redbook_resume(pAudioPlayer->hAILRedbook);
|
|
585 pEventTimer->Resume();
|
|
586 }
|
|
587
|
|
588 //----- (004BECD5) --------------------------------------------------------
|
|
589 void VideoPlayer::FastForwardToFrame(unsigned int uDstFrameNum)
|
|
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 {
|
|
598 if (uDstFrameNum)
|
|
599 {
|
|
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)
|
|
604 {
|
|
605 BinkDoFrame(pBinkMovie);
|
|
606 BinkNextFrame(pBinkMovie);
|
|
607 }
|
|
608 }
|
|
609 }
|
|
610 else
|
|
611 {
|
|
612 if ( v3 != 1 )
|
|
613 return;
|
|
614 SmackSoundOnOff(this->pSmackerMovie, 0);
|
|
615 if (uDstFrameNum)
|
|
616 {
|
|
617 while ( v2->pSmackerMovie->FrameNum < uDstFrameNum)
|
|
618 {
|
|
619 SmackDoFrame(v2->pSmackerMovie);
|
|
620 SmackNextFrame(v2->pSmackerMovie);
|
|
621 }
|
|
622 }
|
|
623 }
|
|
624 Unload();
|
|
625 }
|
|
626
|
|
627
|
|
628 //----- (004BED4F) --------------------------------------------------------
|
|
629 void VideoPlayer::BinkDrawFrame(HWND hWnd, int a3, int a4)
|
|
630 {
|
|
631 //VideoPlayer *v4; // esi@1
|
|
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
|
|
639 //v4 = this;
|
|
640 if ( this->pBinkMovie && this->pBinkBuffer )
|
|
641 {
|
|
642 BinkDoFrame(pBinkMovie);
|
|
643 BinkGetRects(pBinkMovie, pBinkBuffer->uBinkDDSurfaceType);
|
|
644 if ( BinkLockBuffer(pBinkBuffer) )
|
|
645 {
|
|
646 BinkCopyToBuffer(pBinkMovie, pBinkBuffer->pDDrawSurfaceData, pBinkBuffer->uDDrawSurfacePitch, pBinkBuffer->uHeight,
|
|
647 0, 0, pBinkBuffer->uBinkDDSurfaceType);
|
|
648 BinkUnlockBuffer(pBinkBuffer);
|
|
649 }
|
|
650 v5 = pBinkBuffer;
|
|
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);
|
|
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);
|
|
690 else
|
|
691 Unload();
|
|
692 }
|
|
693 }
|
|
694
|
|
695
|
|
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;
|
|
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);
|
|
789 v8 = SmackToBufferRect(v4->pSmackerMovie, 0);
|
|
790 }
|
|
791 }
|
|
792 }
|
|
793 else
|
|
794 {
|
|
795 while ( SmackToBufferRect(v4->pSmackerMovie, 0) )
|
|
796 {
|
|
797 v11 = v4->pSmackerMovie;
|
|
798 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, v11->LastRectx, a3 + v11->LastRecty, v4->pSomeSmackerBuffer,
|
|
799 v11->Width, v11->LastRectx, v11->LastRecty, v11->LastRectw, v11->LastRecth);
|
|
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 }
|
|
849
|
|
850
|
|
851
|
|
852
|
|
853
|
|
854 //----- (004BF141) --------------------------------------------------------
|
|
855 _BINK *VideoPlayer::OpenBink(const char *pName)
|
|
856 {
|
|
857 //VideoPlayer *v2; // esi@1
|
|
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
|
|
865 for (uint i = 0; i < uNumMightVideoHeaders; ++i)
|
|
866 if (!strcmpi(pName, pMightVideoHeaders[i].pVideoName))
|
|
867 {
|
|
868 SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN);
|
|
869
|
|
870 if (uBinkVersion < 0x0003000000000000)
|
|
871 return BinkOpen(hMightVid, 0x8800000);
|
|
872 else
|
|
873 return BinkOpen(hMightVid, 0x82000000);
|
|
874 }
|
|
875
|
|
876 for (uint i = 0; i < uNumMagicVideoHeaders; ++i)
|
|
877 if (!strcmpi(pName, pMagicVideoHeaders[i].pVideoName))
|
|
878 {
|
|
879 SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN);
|
|
880
|
|
881 if (uBinkVersion < 0x0003000000000000)
|
|
882 return BinkOpen(hMagicVid, 0x8800000);
|
|
883 else
|
|
884 return BinkOpen(hMagicVid, 0x82000000);
|
|
885 }
|
|
886
|
|
887 return nullptr;
|
|
888 }
|
|
889 //----- (004BF1E6) --------------------------------------------------------
|
|
890 _SMACK *VideoPlayer::OpenSmack(const char *pFilename)
|
|
891 {
|
|
892 VideoPlayer *pVideoPlayer; // esi@1
|
|
893 signed int v3; // edi@1
|
|
894 int v4; // ebx@2
|
|
895 signed int v5; // edi@5
|
|
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
|
|
900
|
|
901 pVideoPlayer = this;
|
|
902 if ( (signed int)this->uNumMightVideoHeaders > 0 )
|
|
903 {
|
|
904 for ( v3 = 0; v3 < (signed int)pVideoPlayer->uNumMightVideoHeaders; ++v3)
|
|
905 {
|
|
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 }
|
|
912 }
|
|
913 }
|
|
914 v5 = 0;
|
|
915 if ( (signed int)pVideoPlayer->uNumMagicVideoHeaders > 0 )
|
|
916 {
|
|
917 while ( _strcmpi(pVideoPlayer->pMagicVideoHeaders[v5].pVideoName, pFilename) )
|
|
918 {
|
|
919 ++v5;
|
|
920 if ( v5 >= (signed int)pVideoPlayer->uNumMagicVideoHeaders )
|
|
921 return 0;
|
|
922 }
|
|
923 SetFilePointer(pVideoPlayer->hMagicVid, pVideoPlayer->pMagicVideoHeaders[v5].uFileOffset, 0, 0);
|
|
924 return SmackOpen(pVideoPlayer->hMagicVid, 0x7140, -1);
|
|
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 }
|
|
965 sprintf(Str2, "%s.smk", pMovieName);
|
|
966 v5 = OpenSmack(Str2);
|
|
967 v3->pSmackerMovie = v5;
|
|
968 if ( !v5 )
|
|
969 {
|
|
970 v3->Unload();
|
|
971 sprintf(pTmpBuf, "Can't load %s", &Str2);
|
|
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 {
|
|
1007 VideoPlayer *pVideoPlayer; // esi@1
|
|
1008 _BINK *pVideoOpen; // eax@2
|
|
1009 _SMACK *v6; // eax@3
|
|
1010 _BINK *pBinkMovie; // eax@5
|
|
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
|
|
1018 pVideoPlayer = this;
|
|
1019 if ( !this->field_54 )
|
|
1020 {
|
|
1021 Prepare();
|
|
1022 pVideoPlayer->bLoopPlaying = bLoop;
|
|
1023 sprintf(pVideoName, "%s.bik", pFilename);
|
|
1024 pVideoOpen = OpenBink(pVideoName);
|
|
1025 pVideoPlayer->pBinkMovie = pVideoOpen;
|
|
1026 if ( pVideoOpen )
|
|
1027 {
|
|
1028 pVideoPlayer->uMovieFormat = 2;
|
|
1029 strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
|
|
1030 pBinkMovie = pVideoPlayer->pBinkMovie;
|
|
1031 pVideoPlayer->dword_0000A0 = 1;
|
|
1032 if ( pBinkMovie )
|
|
1033 pVideoPlayer->pBinkBuffer = CreateBinkBuffer(pVideoPlayer->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0);
|
|
1034 }
|
|
1035 else
|
|
1036 {
|
|
1037 Unload();
|
|
1038 sprintf(pVideoName, "%s.smk", pFilename);
|
|
1039 v6 = OpenSmack(pVideoName);
|
|
1040 pVideoPlayer->pSmackerMovie = v6;
|
|
1041 if ( !v6 )
|
|
1042 {
|
|
1043 Unload();
|
|
1044 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename);
|
|
1045 MessageBoxA(0, pVideoName, "Smacker Error", 0);
|
|
1046 return;
|
|
1047 }
|
|
1048 pVideoPlayer->uMovieFormat = 1;
|
|
1049 strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
|
|
1050 v8 = pVideoPlayer->pSmackerMovie;
|
|
1051 pVideoPlayer->dword_0000A0 = 2;
|
|
1052 v9 = (char *)malloc(v8->Width * v8->Height);
|
|
1053 pVideoPlayer->pSomeSmackerBuffer = v9;
|
|
1054 if ( !v9 )
|
|
1055 {
|
|
1056 Unload();
|
|
1057 v12 = "Can't allocate memory for buffer";
|
|
1058 sprintf(pVideoName, v12);
|
|
1059 MessageBoxA(0, pVideoName, "Smacker Error", 0);
|
|
1060 return;
|
|
1061 }
|
|
1062 SmackToBuffer(pVideoPlayer->pSmackerMovie, 0, 0, pVideoPlayer->pSmackerMovie->Width, pVideoPlayer->pSmackerMovie->Height, v9, 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);
|
|
1080 pVideoPlayer->pSmackMovieBlit = v11;
|
|
1081 if ( !v11 )
|
|
1082 {
|
|
1083 Unload();
|
|
1084 v12 = "Failed to open Blit API";
|
|
1085 sprintf(pVideoName, v12);
|
|
1086 MessageBoxA(0, pVideoName, "Smacker Error", 0);
|
|
1087 return;
|
|
1088 }
|
|
1089 }
|
|
1090 }
|
|
1091 }
|
|
1092
|
|
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);
|
|
1131 ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
|
|
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);
|
|
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;
|
165
|
1171 pResetflag = 0;
|
0
|
1172 pGame->pCShow->PlayMovie(MOVIE_Death, 1);
|
|
1173 } |