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
|
481
|
16 #include "MM7.h"
|
0
|
17 #include "mm7_data.h"
|
|
18
|
|
19
|
|
20 VideoPlayer *pVideoPlayer = nullptr;
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28 #pragma comment(lib, "Version.lib")
|
|
29 bool GetDllVersion(const wchar_t *pDllName, uint *pMajor, uint *pMinor)
|
|
30 {
|
|
31 uint uVersionSize = GetFileVersionInfoSizeW(pDllName, nullptr);
|
|
32 void *pVersionData = HeapAlloc(GetProcessHeap(), 0, uVersionSize);
|
|
33 {
|
|
34 GetFileVersionInfoW(pDllName, 0, uVersionSize, pVersionData);
|
|
35
|
|
36 VS_FIXEDFILEINFO *pInfo = nullptr;
|
|
37 UINT uInfoSize = 0;
|
|
38 VerQueryValueW(pVersionData, L"\\", (void **)&pInfo, &uInfoSize);
|
|
39
|
|
40 if (!pMajor || !pMinor)
|
|
41 {
|
|
42 HeapFree(GetProcessHeap(), 0, pVersionData);
|
|
43 return false;
|
|
44 }
|
|
45 *pMajor = pInfo->dwFileVersionMS;
|
|
46 *pMinor = pInfo->dwFileVersionLS;
|
|
47 }
|
|
48 HeapFree(GetProcessHeap(), 0, pVersionData);
|
|
49 return true;
|
|
50 }
|
|
51
|
|
52
|
|
53 // 3.15.1.0:
|
|
54 // 3 15 1 0
|
|
55 // 0x0003000F00010000
|
|
56 unsigned __int64 uBinkVersion;
|
|
57
|
|
58
|
|
59
|
|
60
|
|
61
|
|
62
|
|
63 //----- (004BFE2D) --------------------------------------------------------
|
|
64 _BINKBUF *VideoPlayer::CreateBinkBuffer(HWND hWindow, unsigned int uWidth, unsigned int uHeight, char a4)
|
|
65 {
|
|
66 __int32 v4; // edi@3
|
|
67 _BINKBUF *v5; // esi@3
|
|
68 HRESULT v6; // eax@5
|
|
69 IDirectDrawSurface *v7; // eax@6
|
|
70 HRESULT v8; // eax@9
|
|
71 char v9; // al@11
|
|
72 DDSURFACEDESC2 v11; // [sp+Ch] [bp-108h]@7
|
|
73 DDSURFACEDESC Dst; // [sp+88h] [bp-8Ch]@3
|
|
74 unsigned int v13; // [sp+F4h] [bp-20h]@1
|
|
75 struct tagRECT Rect; // [sp+F8h] [bp-1Ch]@11
|
|
76 IDirectDrawSurface4 *v15; // [sp+108h] [bp-Ch]@7
|
|
77 IDirectDrawSurface2 *a2; // [sp+10Ch] [bp-8h]@3
|
|
78 HWND hWnd; // [sp+110h] [bp-4h]@1
|
|
79
|
|
80 v13 = uWidth;
|
|
81 hWnd = hWindow;
|
|
82 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u )
|
|
83 {
|
|
84 v4 = 0;
|
|
85 v15 = 0;
|
|
86
|
|
87 if (uBinkVersion == 0x0001000500150000)
|
|
88 {
|
|
89 v5 = new _BINKBUF_1_5_21_0;
|
|
90 memset(v5, 0, sizeof(_BINKBUF_1_5_21_0));
|
|
91 }
|
|
92 else if (uBinkVersion == 0x0003000000000000)
|
|
93 {
|
|
94 v5 = new _BINKBUF_3_0_0_0;
|
|
95 memset(v5, 0, sizeof(_BINKBUF_3_0_0_0));
|
|
96 }
|
|
97
|
|
98 memset(&v11, 0, 0x7Cu);
|
|
99 v11.dwSize = 124;
|
|
100 v11.dwWidth = v13;
|
|
101 v11.dwFlags = 0x1007u; // DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT
|
|
102 v11.ddsCaps.dwCaps = 0x4040u; // DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY
|
|
103 v11.dwHeight = uHeight;
|
|
104 *(_QWORD *)&v11.ddpfPixelFormat.dwSize = 0x400000020ui64;// DDPF_FOURCC
|
|
105 v11.ddpfPixelFormat.dwFourCC = 0x32595559u;
|
|
106 if ( dword_6BE384_2dacceloff || pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0) )
|
|
107 {
|
|
108 memset(&v11.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT));
|
|
109
|
|
110 v11.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
|
111 v11.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
|
|
112
|
|
113 auto hr = pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0);
|
|
114 ErrD3D(hr, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:1476");
|
|
115 }
|
|
116 v5->uWidth = v11.dwWidth;
|
|
117 v5->uHeight = v11.dwHeight;
|
|
118 v5->uBinkDDSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)v15);
|
|
119 v5->field_38 = 0;
|
|
120 v7 = (IDirectDrawSurface *)v15;
|
|
121 }
|
|
122 else
|
|
123 {
|
|
124 v4 = 0;
|
|
125 a2 = 0;
|
|
126
|
|
127
|
|
128 if (uBinkVersion == 0x0001000500150000)
|
|
129 {
|
|
130 v5 = new _BINKBUF_1_5_21_0;
|
|
131 memset(v5, 0, sizeof(_BINKBUF_1_5_21_0));
|
|
132 }
|
|
133 else if (uBinkVersion == 0x0003000000000000)
|
|
134 {
|
|
135 v5 = new _BINKBUF_3_0_0_0;
|
|
136 memset(v5, 0, sizeof(_BINKBUF_3_0_0_0));
|
|
137 }
|
|
138
|
|
139 memset(&Dst, 0, 0x6Cu);
|
|
140 Dst.dwSize = 108;
|
|
141 Dst.dwWidth = v13;
|
|
142 Dst.dwFlags = 4103;
|
|
143 Dst.ddsCaps.dwCaps = 16448;
|
|
144 Dst.dwHeight = uHeight;
|
|
145 Dst.ddpfPixelFormat.dwSize = 32;
|
|
146 Dst.ddpfPixelFormat.dwFlags = 4;
|
|
147 Dst.ddpfPixelFormat.dwFourCC = 844715353;
|
|
148 if ( dword_6BE384_2dacceloff
|
|
149 || pRenderer->pDirectDraw2->CreateSurface(&Dst, (LPDIRECTDRAWSURFACE *)&a2, 0) )
|
|
150 {
|
|
151 memset(&Dst.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT));
|
|
152
|
|
153 Dst.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
|
154 Dst.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
|
|
155
|
|
156 auto hr = pRenderer->pDirectDraw2->CreateSurface(&Dst, (LPDIRECTDRAWSURFACE *)&a2, 0);
|
|
157 ErrD3D(hr, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:1426");
|
|
158 }
|
|
159 v5->uWidth = Dst.dwWidth;
|
|
160 v5->uHeight = Dst.dwHeight;
|
|
161 v5->uBinkDDSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)a2);
|
|
162 v5->field_38 = 0;
|
|
163 v7 = (IDirectDrawSurface *)a2;
|
|
164 }
|
|
165 v5->pTargetDDrawSurface = v7;
|
|
166 v5->hWnd = hWnd;
|
|
167 v9 = a4;
|
|
168 v5->field_4C = v4;
|
|
169 v5->field_68 = v4;
|
|
170 v5->field_5C = v4;
|
|
171 v5->field_74 = v9 & 0x1F;
|
|
172 v5->field_78 = 1;
|
|
173 v5->field_24 = GetSystemMetrics(v4);
|
|
174 v5->field_28 = GetSystemMetrics(SM_CYSCREEN);
|
|
175 v5->field_2C = 16;
|
|
176 GetWindowRect(hWnd, &Rect);
|
|
177 v5->field_8 = Rect.right - Rect.left;
|
|
178 v5->field_C = Rect.bottom - Rect.top;
|
|
179 v5->field_1C = Rect.left;
|
|
180 v5->field_20 = Rect.top;
|
|
181 Rect.left = v4;
|
|
182 Rect.top = v4;
|
|
183 ClientToScreen(hWnd, (LPPOINT)&Rect);
|
|
184 v5->field_1C = Rect.left - v5->field_1C;
|
|
185 v5->field_20 = Rect.top - v5->field_20;
|
|
186 GetClientRect(hWnd, &Rect);
|
|
187 v5->field_30 = v5->field_8 - Rect.right;
|
|
188 v5->field_34 = v5->field_C - Rect.bottom;
|
|
189 v5->field_8 = v5->uWidth + v5->field_30;
|
|
190 v5->field_C = v5->uHeight + v5->field_34;
|
|
191 BinkBufferSetOffset(v5, v4, v4);
|
|
192 BinkBufferSetScale(v5, v5->uWidth, v5->uHeight);
|
|
193 return v5;
|
|
194 }
|
|
195
|
|
196
|
|
197 //----- (004C0133) --------------------------------------------------------
|
|
198 bool BinkLockBuffer(_BINKBUF *_this)
|
|
199 {
|
|
200 _BINKBUF *v1; // esi@1
|
|
201 IDirectDrawSurface *v2; // edi@5
|
|
202 DWORD v4; // eax@8
|
|
203 DWORD v5; // eax@8
|
|
204 IDirectDrawSurface4 *v6; // edi@11
|
|
205 LPVOID v7; // eax@14
|
|
206
|
|
207 v1 = _this;
|
|
208 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u )
|
|
209 {
|
|
210 DDSURFACEDESC2 v8; // [sp+Ch] [bp-7Ch]@4
|
|
211 if ( _this->pTargetDDrawSurface )
|
|
212 {
|
|
213 memset(&v8, 0, 0x7Cu);
|
|
214 v8.dwSize = 124;
|
|
215 while ( 1 )
|
|
216 {
|
|
217 v6 = (IDirectDrawSurface4 *)v1->pTargetDDrawSurface;
|
|
218 if ( !v6->Lock(0, &v8, 1u, 0) )
|
|
219 break;
|
|
220
|
|
221 if (uBinkVersion < 0x0003000000000000)
|
|
222 BYTE3(v1->uBinkDDSurfaceType) |= 0x80u;
|
|
223 else
|
|
224 BYTE3(v1->uBinkDDSurfaceType) |= 0x04;
|
|
225
|
|
226 if ( v6->Restore() )
|
|
227 return 0;
|
|
228 }
|
|
229 v7 = v8.lpSurface;
|
|
230 v1->pDDrawSurfaceData_ = v8.lpSurface;
|
|
231 v1->pDDrawSurfaceData = v7;
|
|
232 v5 = v8.lPitch;
|
|
233 goto LABEL_15;
|
|
234 }
|
|
235 }
|
|
236 else
|
|
237 {
|
|
238 DDSURFACEDESC v8; // [sp+Ch] [bp-7Ch]@4
|
|
239 if ( _this->pTargetDDrawSurface )
|
|
240 {
|
|
241 memset(&v8.lPitch, 0, 0x6Cu);
|
|
242 v8.lPitch = 108;
|
|
243 while ( 1 )
|
|
244 {
|
|
245 v2 = v1->pTargetDDrawSurface;
|
|
246 if ( !v2->Lock(0, (LPDDSURFACEDESC)&v8.lPitch, 1u, 0) )
|
|
247 break;
|
|
248
|
|
249 if (uBinkVersion < 0x0003000000000000)
|
|
250 __asm int 3;
|
|
251 else
|
|
252 BYTE3(v1->uBinkDDSurfaceType) |= 4u;
|
|
253
|
|
254 if ( v2->Restore() )
|
|
255 return 0;
|
|
256 }
|
|
257 v4 = (DWORD)v8.lpSurface;
|
|
258 v1->pDDrawSurfaceData_ = (void *)v8.lpSurface;
|
|
259 v1->pDDrawSurfaceData = (void *)v4;
|
|
260 v5 = v8.dwReserved;
|
|
261 LABEL_15:
|
|
262 v1->uDDrawSurfacePitch = v5;
|
|
263 return 1;
|
|
264 }
|
|
265 }
|
|
266 return 1;
|
|
267 }
|
|
268
|
|
269 //----- (004C01FB) --------------------------------------------------------
|
|
270 void BinkUnlockBuffer(_BINKBUF *_this)
|
|
271 {
|
|
272 _BINKBUF *v1; // esi@1
|
|
273 IDirectDrawSurface *v2; // eax@1
|
|
274
|
|
275 v1 = _this;
|
|
276 v2 = _this->pTargetDDrawSurface;
|
|
277 if ( v2 )
|
|
278 {
|
|
279 v2->Unlock(0);
|
|
280 v1->uDDrawSurfacePitch = 0;
|
|
281 v1->pDDrawSurfaceData = 0;
|
|
282
|
|
283 if (uBinkVersion < 0x0003000000000000)
|
|
284 BYTE3(_this->uBinkDDSurfaceType) &= 0x7F;
|
|
285 else
|
|
286 BYTE3(_this->uBinkDDSurfaceType) &= 0xFB;
|
|
287 }
|
|
288 }
|
|
289 //----- (004BF794) --------------------------------------------------------
|
|
290 void __cdecl ShowIntroVideo_and_LoadingScreen()
|
|
291 {
|
|
292 RGBTexture tex; // [sp+Ch] [bp-30h]@1
|
|
293 unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8
|
|
294 unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8
|
|
295
|
|
296 pVideoPlayer->bStopBeforeSchedule = false;
|
165
|
297 pVideoPlayer->pResetflag = 0;
|
0
|
298 bGameoverLoop = 1;
|
256
|
299 if (!bNoVideo)
|
0
|
300 {
|
|
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) --------------------------------------------------------
|
227
|
337 void __fastcall VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4)
|
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 }
|
227
|
421 if (a4 == 1)
|
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;
|
323
|
956 if ( LOBYTE(v3->field_104) == 1 )
|
0
|
957 {
|
|
958 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925";
|
|
959 v12 = "Unsupported Bink playback!";
|
|
960 LABEL_6:
|
|
961 MessageBoxA(nullptr, v12, v15, 0);
|
|
962 return;
|
|
963 }
|
|
964 sprintf(Str2, "%s.smk", pMovieName);
|
|
965 v5 = OpenSmack(Str2);
|
|
966 v3->pSmackerMovie = v5;
|
|
967 if ( !v5 )
|
|
968 {
|
|
969 v3->Unload();
|
|
970 sprintf(pTmpBuf, "Can't load %s", &Str2);
|
|
971 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937";
|
|
972 v12 = pTmpBuf;
|
|
973 goto LABEL_6;
|
|
974 }
|
|
975 v16 = (int)pMovieName;
|
|
976 v3->uMovieFormat = 1;
|
|
977 strcpy(v3->pCurrentMovieName, (const char *)v16);
|
|
978 v6 = v3->pSmackerMovie;
|
|
979 v3->dword_0000A0 = 1;
|
|
980 v7 = SmackBufferOpen(v3->hWindow, 4, LOWORD(v6->Width), LOWORD(v6->Height), LOWORD(v6->Width), LOWORD(v6->Height));
|
|
981 v3->pSmackerBuffer = (_SMACKBUF *)v7;
|
|
982 if ( v7 )
|
|
983 {
|
|
984 pRenderer->BeginScene();
|
|
985 v9 = pRenderer->uTargetSurfacePitch;
|
|
986 v20 = pRenderer->pTargetSurface;
|
|
987 v10 = SmackCheckSurfaceFromat();
|
|
988 SmackToBuffer(v3->pSmackerMovie, 8, 8, 2 * v9, pRenderer->field_14, v20, v10);
|
|
989 pRenderer->EndScene();
|
|
990 }
|
|
991 v16 = 32767;
|
|
992 v11 = (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0);
|
347
|
993 SmackVolumePan(v3->pSmackerMovie, 1040384, v11, 32767);
|
0
|
994 }
|
|
995 }
|
|
996
|
|
997 //----- (004BF3F9) --------------------------------------------------------
|
|
998 bool VideoPlayer::AnyMovieLoaded()
|
|
999 {
|
|
1000 return pSmackerMovie || pBinkMovie;
|
|
1001 }
|
|
1002
|
|
1003 //----- (004BF411) --------------------------------------------------------
|
|
1004 void VideoPlayer::OpenMovie(const char *pFilename, unsigned int bLoop, int a4)
|
|
1005 {
|
|
1006 VideoPlayer *pVideoPlayer; // esi@1
|
|
1007 _BINK *pVideoOpen; // eax@2
|
|
1008 _SMACK *v6; // eax@3
|
|
1009 _BINK *pBinkMovie; // eax@5
|
|
1010 _SMACK *v8; // eax@7
|
|
1011 char *v9; // eax@7
|
|
1012 unsigned int v10; // eax@11
|
|
1013 _SMACKBLIT *v11; // eax@14
|
|
1014 const char *v12; // [sp-4h] [bp-38h]@8
|
|
1015 char pVideoName[120]; // [sp+Ch] [bp-28h]@2
|
|
1016
|
|
1017 pVideoPlayer = this;
|
|
1018 if ( !this->field_54 )
|
|
1019 {
|
|
1020 Prepare();
|
|
1021 pVideoPlayer->bLoopPlaying = bLoop;
|
|
1022 sprintf(pVideoName, "%s.bik", pFilename);
|
|
1023 pVideoOpen = OpenBink(pVideoName);
|
|
1024 pVideoPlayer->pBinkMovie = pVideoOpen;
|
|
1025 if ( pVideoOpen )
|
|
1026 {
|
|
1027 pVideoPlayer->uMovieFormat = 2;
|
|
1028 strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
|
|
1029 pBinkMovie = pVideoPlayer->pBinkMovie;
|
|
1030 pVideoPlayer->dword_0000A0 = 1;
|
|
1031 if ( pBinkMovie )
|
|
1032 pVideoPlayer->pBinkBuffer = CreateBinkBuffer(pVideoPlayer->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0);
|
|
1033 }
|
|
1034 else
|
|
1035 {
|
|
1036 Unload();
|
|
1037 sprintf(pVideoName, "%s.smk", pFilename);
|
|
1038 v6 = OpenSmack(pVideoName);
|
|
1039 pVideoPlayer->pSmackerMovie = v6;
|
|
1040 if ( !v6 )
|
|
1041 {
|
|
1042 Unload();
|
|
1043 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename);
|
|
1044 MessageBoxA(0, pVideoName, "Smacker Error", 0);
|
|
1045 return;
|
|
1046 }
|
|
1047 pVideoPlayer->uMovieFormat = 1;
|
|
1048 strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
|
|
1049 v8 = pVideoPlayer->pSmackerMovie;
|
|
1050 pVideoPlayer->dword_0000A0 = 2;
|
|
1051 v9 = (char *)malloc(v8->Width * v8->Height);
|
|
1052 pVideoPlayer->pSomeSmackerBuffer = v9;
|
|
1053 if ( !v9 )
|
|
1054 {
|
|
1055 Unload();
|
|
1056 v12 = "Can't allocate memory for buffer";
|
|
1057 sprintf(pVideoName, v12);
|
|
1058 MessageBoxA(0, pVideoName, "Smacker Error", 0);
|
|
1059 return;
|
|
1060 }
|
|
1061 SmackToBuffer(pVideoPlayer->pSmackerMovie, 0, 0, pVideoPlayer->pSmackerMovie->Width, pVideoPlayer->pSmackerMovie->Height, v9, 0);
|
|
1062 if ( a4 )
|
|
1063 {
|
|
1064 if ( (unsigned int)uCPUSpeed < 165 )
|
|
1065 {
|
|
1066 v10 = SmackCheckSurfaceFromat() | 2;
|
|
1067 }
|
|
1068 else
|
|
1069 {
|
|
1070 v10 = SmackCheckSurfaceFromat();
|
|
1071 LOBYTE(v10) = v10 | 6;
|
|
1072 }
|
|
1073 }
|
|
1074 else
|
|
1075 {
|
|
1076 v10 = SmackCheckSurfaceFromat();
|
|
1077 }
|
|
1078 v11 = SmackBlitOpen(v10);
|
|
1079 pVideoPlayer->pSmackMovieBlit = v11;
|
|
1080 if ( !v11 )
|
|
1081 {
|
|
1082 Unload();
|
|
1083 v12 = "Failed to open Blit API";
|
|
1084 sprintf(pVideoName, v12);
|
|
1085 MessageBoxA(0, pVideoName, "Smacker Error", 0);
|
|
1086 return;
|
|
1087 }
|
|
1088 }
|
|
1089 }
|
|
1090 }
|
|
1091
|
|
1092
|
|
1093 //----- (004BF5B2) --------------------------------------------------------
|
|
1094 void VideoPlayer::_4BF5B2()
|
|
1095 {
|
|
1096 VideoPlayer *v1; // esi@1
|
|
1097 unsigned int v2; // eax@1
|
|
1098 _BINK **v3; // edi@2
|
|
1099
|
|
1100 v1 = this;
|
|
1101 v2 = this->uMovieFormat;
|
|
1102 if ( v2 == 2 )
|
|
1103 {
|
|
1104 v3 = &this->pBinkMovie;
|
|
1105 BinkGoto(pBinkMovie, 1, 0);
|
|
1106 BinkDoFrame(pBinkMovie);
|
|
1107 BinkNextFrame(pBinkMovie);
|
|
1108 }
|
|
1109 else
|
|
1110 {
|
|
1111 if ( v2 != 1 )
|
|
1112 return;
|
|
1113 SmackGoto(pSmackerMovie, 1);
|
|
1114 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
1115 {
|
|
1116 SmackDoFrame(pSmackerMovie);
|
|
1117 SmackNextFrame(pSmackerMovie);
|
|
1118 }
|
|
1119 }
|
|
1120 pMouse->_469E24();
|
336
|
1121 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !v1->pSmackerMovie )
|
0
|
1122 {
|
|
1123 bGameoverLoop = 1;
|
|
1124 sub_4BD8B5();
|
336
|
1125 window_SpeakInHouse->Release();
|
0
|
1126 pParty->uFlags &= 0xFFFFFFFDu;
|
481
|
1127 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) )
|
0
|
1128 {
|
388
|
1129 pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0);
|
336
|
1130 window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
|
|
1131 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
|
|
1132 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
|
|
1133 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
|
|
1134 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
|
0
|
1135 }
|
|
1136 bGameoverLoop = 0;
|
|
1137 }
|
|
1138 }
|
|
1139
|
|
1140 //----- (004BF73A) --------------------------------------------------------
|
|
1141 void VideoPlayer::_4BF73A()
|
|
1142 {
|
|
1143 VideoPlayer *v1; // esi@1
|
|
1144 int v2; // edi@1
|
|
1145 unsigned __int8 v3; // bl@1
|
|
1146 int v4; // edi@1
|
|
1147 char Source[32]; // [sp+Ch] [bp-40h]@1
|
|
1148
|
|
1149 v1 = this;
|
|
1150 v2 = this->dword_0000A0;
|
|
1151 v3 = LOBYTE(this->bLoopPlaying);
|
|
1152 strcpy(Source, this->pCurrentMovieName);
|
|
1153 Unload();
|
|
1154 v4 = v2 - 1;
|
|
1155 if ( v4 )
|
|
1156 {
|
|
1157 if ( v4 == 1 )
|
|
1158 OpenMovie(Source, v3, 1);
|
|
1159 }
|
|
1160 else
|
|
1161 {
|
|
1162 _4BF28F(Source, v3);
|
|
1163 }
|
|
1164 }
|
|
1165
|
|
1166 //----- (004BF8F6) --------------------------------------------------------
|
|
1167 void VideoPlayer::PlayDeathMovie()
|
|
1168 {
|
|
1169 bStopBeforeSchedule = 0;
|
165
|
1170 pResetflag = 0;
|
0
|
1171 pGame->pCShow->PlayMovie(MOVIE_Death, 1);
|
|
1172 } |