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