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