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;
|
256
|
298 if (!bNoVideo)
|
0
|
299 {
|
|
300 pRenderer->PresentBlackScreen();
|
|
301 pGame->pCShow->PlayMovie(MOVIE_3DOLogo, 1);
|
|
302 if ( !pVideoPlayer->bStopBeforeSchedule )
|
|
303 {
|
|
304 pGame->pCShow->PlayMovie(MOVIE_NWCLogo, 1);
|
|
305 if ( !pVideoPlayer->bStopBeforeSchedule )
|
|
306 {
|
|
307 pGame->pCShow->PlayMovie(MOVIE_JVC, 1);
|
|
308 if ( !pVideoPlayer->bStopBeforeSchedule )
|
|
309 pGame->pCShow->PlayMovie(MOVIE_Intro, 1);
|
|
310 }
|
|
311 }
|
|
312 }
|
|
313 tex.Load("mm6title.pcx", 2);
|
|
314 pRenderer->BeginScene();
|
|
315 pRenderer->DrawTextureRGB(0, 0, &tex);
|
|
316 free(tex.pPixels);
|
|
317 tex.pPixels = 0;
|
|
318 MainMenuUI_LoadFontsAndSomeStuff();
|
|
319 DrawCopyrightWindow();
|
|
320 pRenderer->EndScene();
|
|
321 pRenderer->Present();
|
|
322 if (!bNoSound && pAudioPlayer->hAILRedbook )
|
|
323 {
|
|
324 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
|
|
325 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
|
|
326 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &uTrackStartMS, &uTrackEndMS);
|
|
327 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS);
|
|
328 }
|
|
329 bGameoverLoop = 0;
|
|
330 }
|
|
331
|
|
332
|
|
333
|
|
334
|
|
335 //----- (004BE70E) --------------------------------------------------------
|
227
|
336 void __fastcall VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4)
|
0
|
337 {
|
|
338 int v4; // ebp@1
|
|
339 const char *pName; // edi@1
|
|
340 MSG Msg; // [sp+Ch] [bp-1Ch]@12
|
|
341
|
|
342 v4 = a2;
|
|
343 pName = pMovieName;
|
|
344 if ( !(dword_6BE364_game_settings_1 & 0x44) )
|
|
345 {
|
|
346 if ( a2 == 2 )
|
|
347 v4 = 0;
|
|
348 ShowCursor(0);
|
|
349 pVideoPlayer->OpenMovie(pName, 0, ScreenSizeFlag);
|
|
350 pVideoPlayer->bPlayingMovie = 1;
|
|
351 pVideoPlayer->field_44 = v4;
|
|
352 if ( pRenderer->pRenderD3D )
|
|
353 {
|
|
354 pRenderer->ClearTarget(0);
|
|
355 }
|
|
356 else
|
|
357 {
|
|
358 pRenderer->BeginScene();
|
|
359 pRenderer->ClearTarget(0);
|
|
360 pRenderer->EndScene();
|
|
361 }
|
151
|
362 pCurrentScreen = SCREEN_VIDEO;
|
0
|
363 if ( pVideoPlayer->uMovieFormat == 2 )
|
|
364 {
|
|
365 if ( pVideoPlayer->pBinkMovie )
|
|
366 {
|
|
367 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
|
|
368 while ( pVideoPlayer->pBinkMovie )
|
|
369 {
|
|
370 if ( pVideoPlayer->bStopBeforeSchedule )
|
|
371 break;
|
|
372 while ( PeekMessageA(&Msg, 0, 0, 0, 1) )
|
|
373 {
|
|
374 if ( Msg.message == 18 )
|
|
375 Game_DeinitializeAndTerminate(0);
|
|
376 if ( Msg.message == 15 )
|
|
377 break;
|
|
378 TranslateMessage(&Msg);
|
|
379 DispatchMessageA(&Msg);
|
|
380 }
|
|
381 GUI_MainMenuMessageProc();
|
|
382 if ( !pVideoPlayer->pBinkMovie )
|
|
383 break;
|
|
384 if ( !BinkWait(pVideoPlayer->pBinkMovie) && !pVideoPlayer->bStopBeforeSchedule )
|
|
385 pVideoPlayer->BinkDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
|
|
386 }
|
|
387 }
|
|
388 if ( pVideoPlayer->bStopBeforeSchedule == 1 )
|
|
389 Sleep(0x3E8u);
|
|
390 }
|
|
391 else
|
|
392 {
|
|
393 if ( pVideoPlayer->uMovieFormat == 1 )
|
|
394 {
|
|
395 if ( pVideoPlayer->pSmackerMovie )
|
|
396 {
|
|
397 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
|
|
398 while ( pVideoPlayer->pSmackerMovie )
|
|
399 {
|
|
400 if ( pVideoPlayer->bStopBeforeSchedule )
|
|
401 break;
|
|
402 while ( PeekMessageW(&Msg, 0, 0, 0, 1) )
|
|
403 {
|
|
404 if (Msg.message == WM_QUIT)
|
|
405 Game_DeinitializeAndTerminate(0);
|
|
406 if (Msg.message == WM_PAINT)
|
|
407 break;
|
|
408 TranslateMessage(&Msg);
|
|
409 DispatchMessageW(&Msg);
|
|
410 }
|
4
|
411 GUI_MainMenuMessageProc();
|
0
|
412 if ( !pVideoPlayer->pSmackerMovie )
|
|
413 break;
|
|
414 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule )
|
|
415 pVideoPlayer->SmackDrawFrame(pVideoPlayer->hWindow, v4, ScreenSizeFlag);
|
|
416 }
|
|
417 }
|
|
418 }
|
|
419 }
|
227
|
420 if (a4 == 1)
|
151
|
421 pCurrentScreen = SCREEN_GAME;
|
0
|
422 pVideoPlayer->bPlayingMovie = 0;
|
|
423 ShowCursor(1);
|
151
|
424 if ( pCurrentScreen == SCREEN_VIDEO )
|
|
425 pCurrentScreen = SCREEN_GAME;
|
0
|
426 }
|
|
427 }
|
|
428
|
|
429
|
|
430
|
|
431
|
|
432 //----- (004BE95A) --------------------------------------------------------
|
|
433 unsigned int VideoPlayer::SmackCheckSurfaceFromat()
|
|
434 {
|
|
435 DDPIXELFORMAT a2; // [sp+0h] [bp-20h]@1
|
|
436
|
|
437 a2.dwSize = 32;
|
|
438 a2.dwFlags = 64;
|
|
439 pRenderer->GetTargetPixelFormat(&a2);
|
|
440 if ( a2.dwRGBBitCount != 8 )
|
|
441 {
|
|
442 if ( a2.dwRBitMask == 0xF800 )
|
|
443 {
|
|
444 if ( a2.dwGBitMask == 0x7E0 && a2.dwBBitMask == 0x1F )
|
|
445 return 0xC0000000u;
|
|
446 }
|
|
447 else
|
|
448 {
|
|
449 if ( a2.dwRBitMask == 0x7C00
|
|
450 && a2.dwGBitMask == 0x3E0
|
|
451 && a2.dwBBitMask == 0x1F )
|
|
452 return 0x80000000u;
|
|
453 }
|
|
454 MessageBoxA(0, "Unsupported pixel format.", "Smacker Error", 0);
|
|
455 }
|
|
456 return 0;
|
|
457 }
|
|
458
|
|
459 //----- (004BE9D8) --------------------------------------------------------
|
|
460 void VideoPlayer::Initialize()
|
|
461 {
|
|
462 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9
|
|
463
|
|
464 uint uBinkVersionMajor = -1,
|
|
465 uBinkVersionMinor = -1;
|
|
466 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor);
|
|
467 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor;
|
|
468
|
|
469 strcpy(pTmpBuf, "anims\\might7.vid");
|
|
470 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
|
|
471 if ( hMightVid == INVALID_HANDLE_VALUE )
|
|
472 {
|
|
473 sprintf(pTmpBuf2, "Can't open file - anims\\%s.smk", pTmpBuf);
|
|
474 MessageBoxA(0, pTmpBuf2, "Video File Error", 0);
|
|
475 return;
|
|
476 }
|
|
477 strcpy(pTmpBuf, "anims\\magic7.vid");
|
|
478 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
|
|
479 if ( hMagicVid == INVALID_HANDLE_VALUE )
|
|
480 {
|
|
481 if ( !bCanLoadFromCD )
|
|
482 {
|
|
483 sprintf(pTmpBuf2, "Can't open file - anims\\%s.smk", pTmpBuf);
|
|
484 MessageBoxA(0, pTmpBuf2, "Video File Error", 0);
|
|
485 return;
|
|
486 }
|
|
487 sprintf(pTmpBuf2, "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf);
|
|
488 hMagicVid = CreateFileA(pTmpBuf2, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
|
|
489 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE )
|
|
490 {
|
|
491 sprintf(pTmpBuf2, "Can't open file - %s", pTmpBuf);
|
|
492 MessageBoxA(0, pTmpBuf2, "Video File Error", 0);
|
|
493 return;
|
|
494 }
|
|
495 }
|
|
496 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0);
|
|
497 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0);
|
|
498 pMagicVideoHeaders = 0;
|
|
499 pMightVideoHeaders = 0;
|
|
500 pMightVideoHeaders = (MovieHeader *)pAllocator->AllocNamedChunk(0, 44 * uNumMightVideoHeaders + 2, 0);
|
|
501 pMagicVideoHeaders = (MovieHeader *)pAllocator->AllocNamedChunk(pMagicVideoHeaders, 44 * uNumMagicVideoHeaders + 2, 0);
|
|
502 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0);
|
|
503 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0);
|
|
504 }
|
|
505
|
|
506 //----- (004BEB41) --------------------------------------------------------
|
|
507 void VideoPlayer::Prepare()
|
|
508 {
|
|
509 VideoPlayer *pVideoPlayer; // esi@1
|
|
510 IDirectDrawSurface *v2; // [sp-4h] [bp-Ch]@5
|
|
511
|
|
512 pVideoPlayer = this;
|
|
513 pEventTimer->Pause();
|
|
514 pVideoPlayer->bStopBeforeSchedule = 0;
|
|
515 if ( pAudioPlayer->hAILRedbook )
|
|
516 AIL_redbook_pause(pAudioPlayer->hAILRedbook);
|
|
517 pVideoPlayer->field_54 = 1;
|
|
518 pVideoPlayer->hWindow = hWnd;
|
|
519 pVideoPlayer->pSmackerMovie = 0;
|
|
520 pVideoPlayer->pSmackerBuffer = 0;
|
|
521 pVideoPlayer->pBinkMovie = 0;
|
|
522 pVideoPlayer->pBinkBuffer = 0;
|
|
523 pVideoPlayer->bPlayingMovie = 0;
|
|
524 pVideoPlayer->bFirstFrame = 0;
|
|
525 pVideoPlayer->bUsingSmackerMMX = SmackUseMMX(1);
|
|
526 BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver);
|
|
527 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5 )
|
|
528 v2 = (IDirectDrawSurface*)pRenderer->pBackBuffer4;
|
|
529 else
|
|
530 v2 = (IDirectDrawSurface*)pRenderer->pBackBuffer2;
|
|
531 pVideoPlayer->uBinkDirectDrawSurfaceType = BinkDDSurfaceType(v2);
|
|
532 _flushall();
|
|
533 }
|
|
534
|
|
535
|
|
536 //----- (004BEBD7) --------------------------------------------------------
|
|
537 void VideoPlayer::Unload()
|
|
538 {
|
|
539 VideoPlayer *pVideoPlayer; // esi@1
|
|
540 _BINK *pBinkMovie; // eax@1
|
|
541 _BINKBUF *pBinkBuffer; // eax@3
|
|
542 _SMACK *pSmackerMovie; // eax@5
|
|
543
|
|
544 pVideoPlayer = this;
|
|
545 pBinkMovie = this->pBinkMovie;
|
|
546 if ( pBinkMovie )
|
|
547 {
|
|
548 BinkPause(pBinkMovie, 1);
|
|
549 Sleep(300);
|
|
550 BinkClose(pVideoPlayer->pBinkMovie);
|
|
551 pVideoPlayer->pBinkMovie = 0;
|
|
552 }
|
|
553 pBinkBuffer = pVideoPlayer->pBinkBuffer;
|
|
554 if ( pBinkBuffer )
|
|
555 {
|
|
556 pBinkBuffer->pTargetDDrawSurface->Release();
|
|
557 pVideoPlayer->pBinkBuffer->pTargetDDrawSurface = 0;
|
|
558 free(pVideoPlayer->pBinkBuffer);
|
|
559 pVideoPlayer->pBinkBuffer = 0;
|
|
560 }
|
|
561 pSmackerMovie = pVideoPlayer->pSmackerMovie;
|
|
562 if ( pSmackerMovie )
|
|
563 {
|
|
564 SmackSoundOnOff(pSmackerMovie, 0);
|
|
565 SmackClose(pVideoPlayer->pSmackerMovie);
|
|
566 pVideoPlayer->pSmackerMovie = 0;
|
|
567 }
|
|
568 if ( pVideoPlayer->pSmackerBuffer )
|
|
569 {
|
|
570 SmackBufferClose(pVideoPlayer->pSmackerBuffer);
|
|
571 pVideoPlayer->pSmackerBuffer = 0;
|
|
572 }
|
|
573 if ( pVideoPlayer->pSmackMovieBlit )
|
|
574 {
|
|
575 SmackBlitClose(pVideoPlayer->pSmackMovieBlit);
|
|
576 pVideoPlayer->pSmackMovieBlit = 0;
|
|
577 }
|
|
578 pVideoPlayer->field_54 = 0;
|
|
579 pVideoPlayer->uMovieFormat = 0;
|
|
580 pVideoPlayer->dword_0000A0 = 0;
|
|
581 memset(pVideoPlayer->pCurrentMovieName, 0, 0x40);
|
|
582 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop )
|
|
583 AIL_redbook_resume(pAudioPlayer->hAILRedbook);
|
|
584 pEventTimer->Resume();
|
|
585 }
|
|
586
|
|
587 //----- (004BECD5) --------------------------------------------------------
|
|
588 void VideoPlayer::FastForwardToFrame(unsigned int uDstFrameNum)
|
|
589 {
|
|
590 VideoPlayer *v2; // esi@1
|
|
591 unsigned int v3; // eax@1
|
|
592
|
|
593 v2 = this;
|
|
594 v3 = this->uMovieFormat;
|
|
595 if ( v3 == 2 )
|
|
596 {
|
|
597 if (uDstFrameNum)
|
|
598 {
|
|
599 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame :
|
|
600 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame :
|
|
601 nullptr;
|
|
602 while (*pCurrentFrame < uDstFrameNum)
|
|
603 {
|
|
604 BinkDoFrame(pBinkMovie);
|
|
605 BinkNextFrame(pBinkMovie);
|
|
606 }
|
|
607 }
|
|
608 }
|
|
609 else
|
|
610 {
|
|
611 if ( v3 != 1 )
|
|
612 return;
|
|
613 SmackSoundOnOff(this->pSmackerMovie, 0);
|
|
614 if (uDstFrameNum)
|
|
615 {
|
|
616 while ( v2->pSmackerMovie->FrameNum < uDstFrameNum)
|
|
617 {
|
|
618 SmackDoFrame(v2->pSmackerMovie);
|
|
619 SmackNextFrame(v2->pSmackerMovie);
|
|
620 }
|
|
621 }
|
|
622 }
|
|
623 Unload();
|
|
624 }
|
|
625
|
|
626
|
|
627 //----- (004BED4F) --------------------------------------------------------
|
|
628 void VideoPlayer::BinkDrawFrame(HWND hWnd, int a3, int a4)
|
|
629 {
|
|
630 //VideoPlayer *v4; // esi@1
|
|
631 _BINKBUF *v5; // eax@5
|
|
632 LONG v6; // edx@6
|
|
633 int v7; // ecx@6
|
|
634 LONG v8; // edx@6
|
|
635 struct tagRECT a3a; // [sp+8h] [bp-20h]@10
|
|
636 struct tagRECT a1; // [sp+18h] [bp-10h]@6
|
|
637
|
|
638 //v4 = this;
|
|
639 if ( this->pBinkMovie && this->pBinkBuffer )
|
|
640 {
|
|
641 BinkDoFrame(pBinkMovie);
|
|
642 BinkGetRects(pBinkMovie, pBinkBuffer->uBinkDDSurfaceType);
|
|
643 if ( BinkLockBuffer(pBinkBuffer) )
|
|
644 {
|
|
645 BinkCopyToBuffer(pBinkMovie, pBinkBuffer->pDDrawSurfaceData, pBinkBuffer->uDDrawSurfacePitch, pBinkBuffer->uHeight,
|
|
646 0, 0, pBinkBuffer->uBinkDDSurfaceType);
|
|
647 BinkUnlockBuffer(pBinkBuffer);
|
|
648 }
|
|
649 v5 = pBinkBuffer;
|
|
650 if ( pRenderer->bWindowMode )
|
|
651 {
|
|
652 v6 = v5->uRectX;
|
|
653 a1.left = v6;
|
|
654 a1.top = v5->uRectY;
|
|
655 v7 = v6 + v5->uWidth;
|
|
656 a1.right = v6 + v5->uWidth;
|
|
657 v8 = a1.top + v5->uHeight;
|
|
658 }
|
|
659 else
|
|
660 {
|
|
661 a1.left = 0;
|
|
662 a1.top = 0;
|
|
663 v7 = v5->uWidth;
|
|
664 a1.right = v5->uWidth;
|
|
665 v8 = v5->uHeight;
|
|
666 }
|
|
667 a1.bottom = v8;
|
|
668 if ( a4 )
|
|
669 {
|
|
670 a1.right = v5->uWidth + v7;
|
|
671 a1.bottom = v5->uHeight + v8;
|
|
672 }
|
|
673 a3a.left = 0;
|
|
674 a3a.top = 0;
|
|
675 a3a.right = v5->uWidth;
|
|
676 a3a.bottom = v5->uHeight;
|
|
677 pRenderer->BltToFront(&a1, v5->pTargetDDrawSurface, &a3a, 0x1000000u);
|
|
678
|
|
679
|
|
680 int *pCurrentFrame = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uCurrentFrame :
|
|
681 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uCurrentFrame:
|
|
682 nullptr;
|
|
683 int *pNumFrames = uBinkVersion == 0x0001000500150000 ? &((_BINK_1_5_21_0 *)pBinkMovie)->uNumFrames :
|
|
684 uBinkVersion == 0x0003000000000000 ? &((_BINK_3_0_0_0 *)pBinkMovie)->uNumFrames :
|
|
685 nullptr;
|
|
686
|
|
687 if (*pCurrentFrame != *pNumFrames - 1 || bLoopPlaying)
|
|
688 BinkNextFrame(pBinkMovie);
|
|
689 else
|
|
690 Unload();
|
|
691 }
|
|
692 }
|
|
693
|
|
694
|
|
695
|
|
696 //----- (004BEE6B) --------------------------------------------------------
|
|
697 void VideoPlayer::SmackDrawFrame(HWND hWnd, int a3, int a4)
|
|
698 {
|
|
699 VideoPlayer *v4; // esi@1
|
|
700 _SMACK *v5; // eax@3
|
|
701 unsigned int v6; // eax@5
|
|
702 char v7; // zf@5
|
|
703 int v8; // eax@11
|
|
704 _SMACK *v9; // eax@13
|
|
705 _SMACK *v10; // eax@16
|
|
706 _SMACK *v11; // eax@20
|
|
707 unsigned int v12; // [sp-1Ch] [bp-34h]@7
|
|
708 LONG v13; // [sp-18h] [bp-30h]@7
|
|
709 LONG v14; // [sp-14h] [bp-2Ch]@7
|
|
710 signed int v15; // [sp-10h] [bp-28h]@7
|
|
711 signed int v16; // [sp-Ch] [bp-24h]@7
|
|
712 signed int v17; // [sp-8h] [bp-20h]@7
|
|
713 struct tagPOINT Point; // [sp+8h] [bp-10h]@7
|
|
714 unsigned short *pOutSurface; // [sp+10h] [bp-8h]@5
|
|
715 unsigned int uPixelsPerRow; // [sp+14h] [bp-4h]@5
|
|
716
|
|
717 v4 = this;
|
|
718 if ( !pRenderer->bWindowMode || GetFocus() == hWnd )
|
|
719 {
|
|
720 v5 = v4->pSmackerMovie;
|
|
721 if ( v5->NewPalette )
|
|
722 SmackBlitSetPalette(v4->pSmackMovieBlit, v5->Palette, v5->PalType);
|
|
723 SmackDoFrame(v4->pSmackerMovie);
|
|
724 pRenderer->LockFrontBuffer((void **)&pOutSurface, &uPixelsPerRow);
|
|
725 v6 = 2 * uPixelsPerRow;
|
|
726 v7 = v4->bFirstFrame == 0;
|
|
727 uPixelsPerRow *= 2;
|
|
728 if ( !v7 )
|
|
729 {
|
|
730 if ( pRenderer->bWindowMode )
|
|
731 {
|
|
732 Point.y = 0;
|
|
733 Point.x = 0;
|
|
734 ClientToScreen(hWnd, &Point);
|
|
735 v17 = -1;
|
|
736 v16 = 480;
|
|
737 v15 = 640;
|
|
738 v14 = Point.y;
|
|
739 v13 = Point.x;
|
|
740 v12 = uPixelsPerRow;
|
|
741 }
|
|
742 else
|
|
743 {
|
|
744 v17 = -1;
|
|
745 v16 = 480;
|
|
746 v15 = 640;
|
|
747 v14 = 0;
|
|
748 v13 = 0;
|
|
749 v12 = v6;
|
|
750 }
|
|
751 SmackBlitClear(v4->pSmackMovieBlit, pOutSurface, v12, v13, v14, v15, v16, v17);
|
|
752 v4->bFirstFrame = 0;
|
|
753 }
|
|
754 pRenderer->RestoreFrontBuffer();
|
|
755 if ( pRenderer->bWindowMode )
|
|
756 {
|
|
757 Point.y = 0;
|
|
758 Point.x = 0;
|
|
759 ClientToScreen(hWnd, &Point);
|
|
760 v8 = SmackToBufferRect(v4->pSmackerMovie, 0);
|
|
761 if ( a4 )
|
|
762 {
|
|
763 while ( v8 )
|
|
764 {
|
|
765 v9 = v4->pSmackerMovie;
|
|
766 SmackBlit(
|
|
767 v4->pSmackMovieBlit,
|
|
768 pOutSurface,
|
|
769 uPixelsPerRow,
|
|
770 v9->LastRectx + Point.x / 2,
|
|
771 a3 + v9->LastRecty + Point.y / 2,
|
|
772 v4->pSomeSmackerBuffer,
|
|
773 v9->Width,
|
|
774 v9->LastRectx,
|
|
775 v9->LastRecty,
|
|
776 v9->LastRectw,
|
|
777 v9->LastRecth);
|
|
778 v8 = SmackToBufferRect(v4->pSmackerMovie, 0);
|
|
779 }
|
|
780 }
|
|
781 else
|
|
782 {
|
|
783 while ( v8 )
|
|
784 {
|
|
785 v10 = v4->pSmackerMovie;
|
|
786 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, Point.x + v10->LastRectx, a3 + Point.y + v10->LastRecty,
|
|
787 v4->pSomeSmackerBuffer, v10->Width, v10->LastRectx, v10->LastRecty, v10->LastRectw, v10->LastRecth);
|
|
788 v8 = SmackToBufferRect(v4->pSmackerMovie, 0);
|
|
789 }
|
|
790 }
|
|
791 }
|
|
792 else
|
|
793 {
|
|
794 while ( SmackToBufferRect(v4->pSmackerMovie, 0) )
|
|
795 {
|
|
796 v11 = v4->pSmackerMovie;
|
|
797 SmackBlit(v4->pSmackMovieBlit, pOutSurface, uPixelsPerRow, v11->LastRectx, a3 + v11->LastRecty, v4->pSomeSmackerBuffer,
|
|
798 v11->Width, v11->LastRectx, v11->LastRecty, v11->LastRectw, v11->LastRecth);
|
|
799 }
|
|
800 }
|
|
801 pRenderer->UnlockFrontBuffer();
|
|
802 if ( v4->pSmackerMovie->FrameNum != v4->pSmackerMovie->Frames - 1 || v4->bLoopPlaying )
|
|
803 SmackNextFrame(v4->pSmackerMovie);
|
|
804 else
|
|
805 Unload();
|
|
806 }
|
|
807 }
|
|
808 // 4D83D8: using guessed type int __stdcall SmackBlitSetPalette(int, int, int);
|
|
809 // 4D83DC: using guessed type int __stdcall SmackBlitClear(int, int, int, int, int, int, int, int);
|
|
810 // 4D83E0: using guessed type int __stdcall SmackToBufferRect(int, int);
|
|
811 // 4D83E4: using guessed type int __stdcall SmackDoFrame(int);
|
|
812 // 4D83E8: using guessed type int __stdcall SmackNextFrame(int);
|
|
813 // 4D8404: using guessed type int __stdcall SmackBlit(int, int, int, int, int, int, int, int, int, int, int);
|
|
814
|
|
815 //----- (004BF08B) --------------------------------------------------------
|
|
816 void VideoPlayer::SmackUpdatePalette(HWND hWnd)
|
|
817 {
|
|
818 VideoPlayer *v2; // esi@1
|
|
819 unsigned __int16 *v3; // ebx@1
|
|
820 unsigned int v4; // edi@1
|
|
821 unsigned int v5; // eax@1
|
|
822 _SMACK *v6; // eax@1
|
|
823
|
|
824 v2 = this;
|
|
825 pRenderer->BeginScene();
|
|
826 v3 = pRenderer->pTargetSurface;
|
|
827 v4 = pRenderer->uTargetSurfacePitch;
|
|
828 v5 = SmackCheckSurfaceFromat();
|
|
829 SmackToBuffer(v2->pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5);
|
|
830 v6 = v2->pSmackerMovie;
|
|
831 if ( v6->NewPalette )
|
|
832 {
|
|
833 SmackBufferNewPalette((long)pSmackerBuffer, (long)v6->Palette, LOWORD(v6->PalType));
|
|
834 SmackColorRemapWithTrans(
|
|
835 (long)pSmackerMovie,
|
|
836 (long)pSmackerBuffer->Palette,
|
|
837 (long)pSmackerBuffer->MaxPalColors,
|
|
838 (long)pSmackerBuffer->PalType,
|
|
839 1000);
|
|
840 }
|
|
841 SmackDoFrame(v2->pSmackerMovie);
|
|
842 if ( v2->pSmackerMovie->FrameNum != v2->pSmackerMovie->Frames - 1 || v2->bLoopPlaying )
|
|
843 SmackNextFrame(v2->pSmackerMovie);
|
|
844 else
|
|
845 Unload();
|
|
846 pRenderer->EndScene();
|
|
847 }
|
|
848
|
|
849
|
|
850
|
|
851
|
|
852
|
|
853 //----- (004BF141) --------------------------------------------------------
|
|
854 _BINK *VideoPlayer::OpenBink(const char *pName)
|
|
855 {
|
|
856 //VideoPlayer *v2; // esi@1
|
|
857 signed int v3; // edi@1
|
|
858 int v4; // ebx@2
|
|
859 signed int v5; // edi@5
|
|
860 int v6; // ebx@6
|
|
861 HANDLE v8; // [sp-8h] [bp-18h]@10
|
|
862 unsigned int v9; // [sp-4h] [bp-14h]@10
|
|
863
|
|
864 for (uint i = 0; i < uNumMightVideoHeaders; ++i)
|
|
865 if (!strcmpi(pName, pMightVideoHeaders[i].pVideoName))
|
|
866 {
|
|
867 SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN);
|
|
868
|
|
869 if (uBinkVersion < 0x0003000000000000)
|
|
870 return BinkOpen(hMightVid, 0x8800000);
|
|
871 else
|
|
872 return BinkOpen(hMightVid, 0x82000000);
|
|
873 }
|
|
874
|
|
875 for (uint i = 0; i < uNumMagicVideoHeaders; ++i)
|
|
876 if (!strcmpi(pName, pMagicVideoHeaders[i].pVideoName))
|
|
877 {
|
|
878 SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN);
|
|
879
|
|
880 if (uBinkVersion < 0x0003000000000000)
|
|
881 return BinkOpen(hMagicVid, 0x8800000);
|
|
882 else
|
|
883 return BinkOpen(hMagicVid, 0x82000000);
|
|
884 }
|
|
885
|
|
886 return nullptr;
|
|
887 }
|
|
888 //----- (004BF1E6) --------------------------------------------------------
|
|
889 _SMACK *VideoPlayer::OpenSmack(const char *pFilename)
|
|
890 {
|
|
891 VideoPlayer *pVideoPlayer; // esi@1
|
|
892 signed int v3; // edi@1
|
|
893 int v4; // ebx@2
|
|
894 signed int v5; // edi@5
|
|
895 //int v6; // ebx@6
|
|
896 //HANDLE v8; // [sp-Ch] [bp-1Ch]@10
|
|
897 //unsigned int v9; // [sp-8h] [bp-18h]@10
|
|
898 //signed int v10; // [sp-4h] [bp-14h]@10
|
|
899
|
|
900 pVideoPlayer = this;
|
|
901 if ( (signed int)this->uNumMightVideoHeaders > 0 )
|
|
902 {
|
|
903 for ( v3 = 0; v3 < (signed int)pVideoPlayer->uNumMightVideoHeaders; ++v3)
|
|
904 {
|
|
905 v4 = _strcmpi(pVideoPlayer->pMightVideoHeaders[v3].pVideoName, pFilename);
|
|
906 if ( !v4 )
|
|
907 {
|
|
908 SetFilePointer(pVideoPlayer->hMightVid, pVideoPlayer->pMightVideoHeaders[v3].uFileOffset, 0, 0);
|
|
909 return SmackOpen(pVideoPlayer->hMightVid, 0x7140, -1);
|
|
910 }
|
|
911 }
|
|
912 }
|
|
913 v5 = 0;
|
|
914 if ( (signed int)pVideoPlayer->uNumMagicVideoHeaders > 0 )
|
|
915 {
|
|
916 while ( _strcmpi(pVideoPlayer->pMagicVideoHeaders[v5].pVideoName, pFilename) )
|
|
917 {
|
|
918 ++v5;
|
|
919 if ( v5 >= (signed int)pVideoPlayer->uNumMagicVideoHeaders )
|
|
920 return 0;
|
|
921 }
|
|
922 SetFilePointer(pVideoPlayer->hMagicVid, pVideoPlayer->pMagicVideoHeaders[v5].uFileOffset, 0, 0);
|
|
923 return SmackOpen(pVideoPlayer->hMagicVid, 0x7140, -1);
|
|
924 }
|
|
925 return 0;
|
|
926 }
|
|
927
|
|
928 //----- (004BF28F) --------------------------------------------------------
|
|
929 void VideoPlayer::_4BF28F(const char *pMovieName, unsigned int a3_1)
|
|
930 {
|
|
931 VideoPlayer *v3; // esi@1
|
|
932 std::string *v4; // ecx@3
|
|
933 _SMACK *v5; // eax@4
|
|
934 _SMACK *v6; // eax@7
|
|
935 int v7; // eax@7
|
|
936 int v8; // ecx@7
|
|
937 unsigned int v9; // ebx@8
|
|
938 unsigned int v10; // eax@8
|
|
939 signed __int64 v11; // qax@9
|
|
940 char *v12; // [sp-20h] [bp-54h]@3
|
|
941 int v13; // [sp-1Ch] [bp-50h]@3
|
|
942 std::string v14; // [sp-18h] [bp-4Ch]@3
|
|
943 const char *v15; // [sp-8h] [bp-3Ch]@3
|
|
944 int v16; // [sp-4h] [bp-38h]@3
|
|
945 char Str2[0x30]; // [sp+Ch] [bp-28h]@4
|
|
946 std::string *v18; // [sp+3Ch] [bp+8h]@3
|
|
947 std::string *v19; // [sp+3Ch] [bp+8h]@5
|
|
948 unsigned __int16 *v20; // [sp+3Ch] [bp+8h]@8
|
|
949
|
|
950 v3 = this;
|
|
951 if ( !this->field_54 )
|
|
952 {
|
|
953 Prepare();
|
|
954 v3->bLoopPlaying = a3_1;
|
323
|
955 if ( LOBYTE(v3->field_104) == 1 )
|
0
|
956 {
|
|
957 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925";
|
|
958 v12 = "Unsupported Bink playback!";
|
|
959 LABEL_6:
|
|
960 MessageBoxA(nullptr, v12, v15, 0);
|
|
961 return;
|
|
962 }
|
|
963 sprintf(Str2, "%s.smk", pMovieName);
|
|
964 v5 = OpenSmack(Str2);
|
|
965 v3->pSmackerMovie = v5;
|
|
966 if ( !v5 )
|
|
967 {
|
|
968 v3->Unload();
|
|
969 sprintf(pTmpBuf, "Can't load %s", &Str2);
|
|
970 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937";
|
|
971 v12 = pTmpBuf;
|
|
972 goto LABEL_6;
|
|
973 }
|
|
974 v16 = (int)pMovieName;
|
|
975 v3->uMovieFormat = 1;
|
|
976 strcpy(v3->pCurrentMovieName, (const char *)v16);
|
|
977 v6 = v3->pSmackerMovie;
|
|
978 v3->dword_0000A0 = 1;
|
|
979 v7 = SmackBufferOpen(v3->hWindow, 4, LOWORD(v6->Width), LOWORD(v6->Height), LOWORD(v6->Width), LOWORD(v6->Height));
|
|
980 v3->pSmackerBuffer = (_SMACKBUF *)v7;
|
|
981 if ( v7 )
|
|
982 {
|
|
983 pRenderer->BeginScene();
|
|
984 v9 = pRenderer->uTargetSurfacePitch;
|
|
985 v20 = pRenderer->pTargetSurface;
|
|
986 v10 = SmackCheckSurfaceFromat();
|
|
987 SmackToBuffer(v3->pSmackerMovie, 8, 8, 2 * v9, pRenderer->field_14, v20, v10);
|
|
988 pRenderer->EndScene();
|
|
989 }
|
|
990 v16 = 32767;
|
|
991 v11 = (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0);
|
347
|
992 SmackVolumePan(v3->pSmackerMovie, 1040384, v11, 32767);
|
0
|
993 }
|
|
994 }
|
|
995
|
|
996 //----- (004BF3F9) --------------------------------------------------------
|
|
997 bool VideoPlayer::AnyMovieLoaded()
|
|
998 {
|
|
999 return pSmackerMovie || pBinkMovie;
|
|
1000 }
|
|
1001
|
|
1002 //----- (004BF411) --------------------------------------------------------
|
|
1003 void VideoPlayer::OpenMovie(const char *pFilename, unsigned int bLoop, int a4)
|
|
1004 {
|
|
1005 VideoPlayer *pVideoPlayer; // esi@1
|
|
1006 _BINK *pVideoOpen; // eax@2
|
|
1007 _SMACK *v6; // eax@3
|
|
1008 _BINK *pBinkMovie; // eax@5
|
|
1009 _SMACK *v8; // eax@7
|
|
1010 char *v9; // eax@7
|
|
1011 unsigned int v10; // eax@11
|
|
1012 _SMACKBLIT *v11; // eax@14
|
|
1013 const char *v12; // [sp-4h] [bp-38h]@8
|
|
1014 char pVideoName[120]; // [sp+Ch] [bp-28h]@2
|
|
1015
|
|
1016 pVideoPlayer = this;
|
|
1017 if ( !this->field_54 )
|
|
1018 {
|
|
1019 Prepare();
|
|
1020 pVideoPlayer->bLoopPlaying = bLoop;
|
|
1021 sprintf(pVideoName, "%s.bik", pFilename);
|
|
1022 pVideoOpen = OpenBink(pVideoName);
|
|
1023 pVideoPlayer->pBinkMovie = pVideoOpen;
|
|
1024 if ( pVideoOpen )
|
|
1025 {
|
|
1026 pVideoPlayer->uMovieFormat = 2;
|
|
1027 strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
|
|
1028 pBinkMovie = pVideoPlayer->pBinkMovie;
|
|
1029 pVideoPlayer->dword_0000A0 = 1;
|
|
1030 if ( pBinkMovie )
|
|
1031 pVideoPlayer->pBinkBuffer = CreateBinkBuffer(pVideoPlayer->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0);
|
|
1032 }
|
|
1033 else
|
|
1034 {
|
|
1035 Unload();
|
|
1036 sprintf(pVideoName, "%s.smk", pFilename);
|
|
1037 v6 = OpenSmack(pVideoName);
|
|
1038 pVideoPlayer->pSmackerMovie = v6;
|
|
1039 if ( !v6 )
|
|
1040 {
|
|
1041 Unload();
|
|
1042 sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename);
|
|
1043 MessageBoxA(0, pVideoName, "Smacker Error", 0);
|
|
1044 return;
|
|
1045 }
|
|
1046 pVideoPlayer->uMovieFormat = 1;
|
|
1047 strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
|
|
1048 v8 = pVideoPlayer->pSmackerMovie;
|
|
1049 pVideoPlayer->dword_0000A0 = 2;
|
|
1050 v9 = (char *)malloc(v8->Width * v8->Height);
|
|
1051 pVideoPlayer->pSomeSmackerBuffer = v9;
|
|
1052 if ( !v9 )
|
|
1053 {
|
|
1054 Unload();
|
|
1055 v12 = "Can't allocate memory for buffer";
|
|
1056 sprintf(pVideoName, v12);
|
|
1057 MessageBoxA(0, pVideoName, "Smacker Error", 0);
|
|
1058 return;
|
|
1059 }
|
|
1060 SmackToBuffer(pVideoPlayer->pSmackerMovie, 0, 0, pVideoPlayer->pSmackerMovie->Width, pVideoPlayer->pSmackerMovie->Height, v9, 0);
|
|
1061 if ( a4 )
|
|
1062 {
|
|
1063 if ( (unsigned int)uCPUSpeed < 165 )
|
|
1064 {
|
|
1065 v10 = SmackCheckSurfaceFromat() | 2;
|
|
1066 }
|
|
1067 else
|
|
1068 {
|
|
1069 v10 = SmackCheckSurfaceFromat();
|
|
1070 LOBYTE(v10) = v10 | 6;
|
|
1071 }
|
|
1072 }
|
|
1073 else
|
|
1074 {
|
|
1075 v10 = SmackCheckSurfaceFromat();
|
|
1076 }
|
|
1077 v11 = SmackBlitOpen(v10);
|
|
1078 pVideoPlayer->pSmackMovieBlit = v11;
|
|
1079 if ( !v11 )
|
|
1080 {
|
|
1081 Unload();
|
|
1082 v12 = "Failed to open Blit API";
|
|
1083 sprintf(pVideoName, v12);
|
|
1084 MessageBoxA(0, pVideoName, "Smacker Error", 0);
|
|
1085 return;
|
|
1086 }
|
|
1087 }
|
|
1088 }
|
|
1089 }
|
|
1090
|
|
1091
|
|
1092 //----- (004BF5B2) --------------------------------------------------------
|
|
1093 void VideoPlayer::_4BF5B2()
|
|
1094 {
|
|
1095 VideoPlayer *v1; // esi@1
|
|
1096 unsigned int v2; // eax@1
|
|
1097 _BINK **v3; // edi@2
|
|
1098
|
|
1099 v1 = this;
|
|
1100 v2 = this->uMovieFormat;
|
|
1101 if ( v2 == 2 )
|
|
1102 {
|
|
1103 v3 = &this->pBinkMovie;
|
|
1104 BinkGoto(pBinkMovie, 1, 0);
|
|
1105 BinkDoFrame(pBinkMovie);
|
|
1106 BinkNextFrame(pBinkMovie);
|
|
1107 }
|
|
1108 else
|
|
1109 {
|
|
1110 if ( v2 != 1 )
|
|
1111 return;
|
|
1112 SmackGoto(pSmackerMovie, 1);
|
|
1113 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
1114 {
|
|
1115 SmackDoFrame(pSmackerMovie);
|
|
1116 SmackNextFrame(pSmackerMovie);
|
|
1117 }
|
|
1118 }
|
|
1119 pMouse->_469E24();
|
336
|
1120 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !v1->pSmackerMovie )
|
0
|
1121 {
|
|
1122 bGameoverLoop = 1;
|
|
1123 sub_4BD8B5();
|
336
|
1124 window_SpeakInHouse->Release();
|
0
|
1125 pParty->uFlags &= 0xFFFFFFFDu;
|
|
1126 if ( EnterHouse((enum HOUSE_TYPE)165) )
|
|
1127 {
|
388
|
1128 pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0);
|
336
|
1129 window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
|
|
1130 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
|
|
1131 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
|
|
1132 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
|
|
1133 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
|
0
|
1134 }
|
|
1135 bGameoverLoop = 0;
|
|
1136 }
|
|
1137 }
|
|
1138
|
|
1139 //----- (004BF73A) --------------------------------------------------------
|
|
1140 void VideoPlayer::_4BF73A()
|
|
1141 {
|
|
1142 VideoPlayer *v1; // esi@1
|
|
1143 int v2; // edi@1
|
|
1144 unsigned __int8 v3; // bl@1
|
|
1145 int v4; // edi@1
|
|
1146 char Source[32]; // [sp+Ch] [bp-40h]@1
|
|
1147
|
|
1148 v1 = this;
|
|
1149 v2 = this->dword_0000A0;
|
|
1150 v3 = LOBYTE(this->bLoopPlaying);
|
|
1151 strcpy(Source, this->pCurrentMovieName);
|
|
1152 Unload();
|
|
1153 v4 = v2 - 1;
|
|
1154 if ( v4 )
|
|
1155 {
|
|
1156 if ( v4 == 1 )
|
|
1157 OpenMovie(Source, v3, 1);
|
|
1158 }
|
|
1159 else
|
|
1160 {
|
|
1161 _4BF28F(Source, v3);
|
|
1162 }
|
|
1163 }
|
|
1164
|
|
1165 //----- (004BF8F6) --------------------------------------------------------
|
|
1166 void VideoPlayer::PlayDeathMovie()
|
|
1167 {
|
|
1168 bStopBeforeSchedule = 0;
|
165
|
1169 pResetflag = 0;
|
0
|
1170 pGame->pCShow->PlayMovie(MOVIE_Death, 1);
|
|
1171 } |