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